Index: trunk/gui/Makefile.in
===================================================================
--- trunk/gui/Makefile.in	(revision 6716)
+++ 	(revision )
@@ -1,60 +1,0 @@
-
-srcdir		= @srcdir@
-prefix		= @prefix@
-exec_prefix	= @exec_prefix@
-bindir		= @bindir@
-libdir		= @libdir@
-datadir		= @datadir@
-datarootdir	= @datarootdir@
-mandir		= @mandir@
-includedir	= @includedir@
-
-SHELL		= @SHELL@
-INSTALL		= @INSTALL@
-MKDIR_P		= @MKDIR_P@
-VPATH		= $(srcdir)
-TCLSH		= @TCLSH@
-
-PACKAGE_VERSION = @PACKAGE_VERSION@
-
-version 	= $(PACKAGE_VERSION)
-name 		= RapptureGUI$(version)
-
-destdir		= $(libdir)/$(name)
-
-FILES		= \
-		pkgIndex.tcl 
-
-SUBDIRS		= src scripts apps 
-
-.PHONY:	all install test clean distclean $(SUBDIRS)
-
-all:
-	for i in $(SUBDIRS) ; do \
-	  $(MAKE) -C $$i all || exit 1 ;\
-	done
-
-install: 
-	$(MKDIR_P) -m 0755 $(destdir)
-	for i in $(FILES); do \
-	    echo "Installing $$i" ; \
-	    $(INSTALL) -m 0444 $$i $(destdir) ; \
-	done 
-	for i in $(SUBDIRS) ; do \
-	  $(MAKE) -C $$i install || exit 1 ;\
-	done
-
-test: 
-	#$(TCLSH) `@CYGPATH@ $(srcdir)/tests/all.tcl` $(TESTFLAGS)
-
-clean:
-	for i in $(SUBDIRS) ; do \
-	  $(MAKE) -C $$i clean ;\
-	done
-
-distclean: 
-	for i in $(SUBDIRS) ; do \
-	  $(MAKE) -C $$i distclean ;\
-	done
-	$(RM) Makefile pkgIndex.tcl 
-	$(RM) -r config.cache config.log config.status autom4te.cache
Index: trunk/gui/aclocal.m4
===================================================================
--- trunk/gui/aclocal.m4	(revision 6716)
+++ 	(revision )
@@ -1,1 +1,0 @@
-builtin(include,./cf/tcl.m4)
Index: trunk/gui/apps/Makefile.in
===================================================================
--- trunk/gui/apps/Makefile.in	(revision 6716)
+++ 	(revision )
@@ -1,69 +1,0 @@
-
-SHELL		= @SHELL@
-TCLSH		= @TCLSH@
-srcdir		= @srcdir@
-prefix		= @prefix@
-exec_prefix	= @exec_prefix@
-bindir		= @bindir@
-libdir		= @libdir@
-datadir		= @datadir@
-datarootdir	= @datarootdir@
-mandir		= @mandir@
-includedir	= @includedir@
-
-pkgdatadir	= $(datadir)/$(PKG_DIR)
-pkglibdir	= $(libdir)/$(PKG_DIR)
-pkgincludedir	= $(includedir)/$(PKG_DIR)
-top_builddir	= .
-
-MKDIR_P		= @MKDIR_P@
-INSTALL		= @INSTALL@
-
-SCRIPTS	= \
-		about \
-		copy_rappture_examples \
-		encodedata \
-		$(srcdir)/execute.tcl \
-		$(srcdir)/launcher.tcl \
-		$(srcdir)/mapviewer-test \
-		$(srcdir)/grabdata \
-		$(srcdir)/nanovis-test \
-		$(srcdir)/vtkglyphs-test \
-		$(srcdir)/vtkheightmap-test \
-		$(srcdir)/vtkisosurface-test \
-		$(srcdir)/vtkstreamlines-test \
-		$(srcdir)/vtkviewer-test \
-		$(srcdir)/vtkvolume-test \
-		$(srcdir)/flowvis-test \
-		$(srcdir)/rpdiff \
-		$(srcdir)/rptimes \
-		rappture \
-		rappture.env \
-		rappture-csh.env \
-		rappture.use \
-		rerun \
-		simsim  \
-		xmldiff
-
-WINDOWS_SCRIPTS =  \
-		$(srcdir)/rappture.cmd \
-		$(srcdir)/driver.cmd \
-		$(srcdir)/rerun.cmd
-
-.PHONY: all install clean distclean
-
-all:
-
-install: all
-	$(MKDIR_P) -m 0755 $(bindir)
-	@for i in $(SCRIPTS); do \
-	    echo "Installing $$i" ; \
-	    $(INSTALL) -m 0555 $$i $(bindir) ; \
-	done
-
-clean:
-
-distclean: clean
-	$(RM) about copy_rappture_examples encodedata rappture.env rappture-csh.env rappture rappture.use rerun simsim xmldiff
-	$(RM) Makefile *~
-
Index: trunk/gui/apps/about.in
===================================================================
--- trunk/gui/apps/about.in	(revision 6716)
+++ 	(revision )
@@ -1,95 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  ABOUT PANEL
-#
-#  This little script lets developers create an "about" page for
-#  the first page of a nanoWhim application.  It's sort of like a
-#  web browser, but it shows only one page and handles the links
-#  so they pop things up on the user's desktop
-#
-#  RUN AS FOLLOWS:
-#    about <file.html>
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-dir=`dirname $0` ; \
-. $dir/rappture.env ; \
-exec wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-
-package require http
-package require Rappture
-package require RapptureGUI
-
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-18-*
-
-# install a better bug handler
-Rappture::bugreport::install
-
-proc escapeChars {info} {
-    regsub -all & $info \001 info
-    regsub -all \" $info {\&quot;} info
-    regsub -all < $info {\&lt;} info
-    regsub -all > $info {\&gt;} info
-    regsub -all \001 $info {\&amp;} info
-    return $info
-}
-
-#
-# Process command line args to get the name of the HTML file...
-#
-if {[llength $argv] != 1} {
-    puts stderr "usage: about.tcl <file.html>"
-    exit 1
-}
-set url [lindex $argv 0]
-
-Rappture::Scroller .scroller -xscrollmode auto -yscrollmode auto
-pack .scroller -expand yes -fill both
-
-Rappture::HTMLviewer .scroller.html -width 640 -height 480
-.scroller contents .scroller.html
-
-switch -regexp -- $url {
-    ^https?:// {
-        if {[catch {http::geturl $url} token] == 0} {
-            set html [http::data $token]
-            http::cleanup $token
-        } else {
-            set html "<html><body><h1>Oops! Internal Error</h1><p>[escapeChars $token]</p></body></html>"
-        }
-        .scroller.html load $html
-    }
-    default {
-        if {[string range $url 0 6] == "file://"} {
-            set file [string range $url 7 end]
-        } else {
-            set file $url
-        }
-        set cmds {
-            set fid [open $file r]
-            set html [read $fid]
-            close $fid
-        }
-        if {[catch $cmds result]} {
-            set html "<html><body><h1>Oops! File Not Found</h1><p>[escapeChars $result]</p></body></html>"
-        }
-
-        # not HTML? then escape nasty characters and display it.
-        if {![regexp {<html>.*</html>} $html]} {
-            set html "<html><body><p>[escapeChars $html]</p></body></html>"
-        }
-        .scroller.html load $html -in $file
-    }
-}
Index: trunk/gui/apps/copy_rappture_examples.in
===================================================================
--- trunk/gui/apps/copy_rappture_examples.in	(revision 6716)
+++ 	(revision )
@@ -1,37 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ======================================================================
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-dir=`dirname $0` ; \
-. $dir/rappture.env ; \
-exec $dir/wish "$0" $*
-
-wm withdraw .
-proc RecursiveCopy { src dest } {
-   set tail [file tail $src]
-   if { [file isdirectory $src] } {
-       set subdir [file join $dest $tail]
-       file mkdir $subdir
-       foreach item [glob -nocomplain $src/*] {
-          RecursiveCopy $item $subdir
-       }
-   } else {
-       set file [file join $dest $tail]
-       file copy $src $dest
-       file attributes $file -permissions +rw
-   }
-}
-set installdir [file normalize [file dirname [info script]]]
-set examplesdir [file join [file dirname $installdir] examples]
-set dir [tk_chooseDirectory -title "Select where to create \"examples\""]
-if  { $dir != "" } {
-   file mkdir $dir
-   RecursiveCopy $examplesdir $dir
-}
-exit 0
-
Index: trunk/gui/apps/driver
===================================================================
--- trunk/gui/apps/driver	(revision 1)
+++ trunk/gui/apps/driver	(revision 1)
@@ -0,0 +1,202 @@
+#!/bin/sh
+# ----------------------------------------------------------------------
+#  USER INTERFACE DRIVER
+#
+#  This driver program loads a tool description from a tool.xml file,
+#  and a UI configuration from a config.xml file, and produces a
+#  user interface automatically to drive an application.  The user
+#  can set up input, click and button to launch a tool, and browse
+#  through output.
+#
+#  RUN AS FOLLOWS:
+#    driver ?-tool <toolfile>? ?-config <configfile>?
+#
+#  If the <toolfile> is not specified, this program looks for a
+#  file called "tool.xml" in the current directory.  If the <configfile>
+#  is not specified, it looks for "config.xml" in the current directory.
+#
+# ======================================================================
+#  AUTHOR:  Michael McLennan, Purdue University
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
+# ======================================================================
+#\
+exec wish "$0" $*
+# ----------------------------------------------------------------------
+# wish executes everything from here on...
+
+package require Rappture
+
+option add *MainWin.mode web startupFile
+option add *MainWin.borderWidth 0 startupFile
+option add *MainWin.anchor center startupFile
+
+# "web site" look
+option add *MainWin.bgScript {
+    rectangle 0 0 200 <h> -outline "" -fill #5880BB
+    rectangle 200 0 300 <h> -outline "" -fill #425F8B
+    rectangle 300 0 <w> <h> -outline "" -fill #324565
+} startupFile
+
+# "clean" look
+option add *MainWin.bgScript "" startupFile
+option add *MainWin.bgColor white startupFile
+
+image create photo in2out \
+    -file [file join $Rappture::installdir scripts images in2out.gif]
+
+#
+# Process command line args to get the names of files to load...
+#
+set toolfile "tool.xml"
+set configfile "config.xml"
+
+while {[llength $argv] > 0} {
+    set first [lindex $argv 0]
+    set argv [lrange $argv 1 end]
+
+    switch -- $first {
+        -tool {
+            if {[llength $argv] > 0} {
+                set toolfile [lindex $argv 0]
+                set argv [lrange $argv 1 end]
+            } else {
+                puts stderr "$argv0: missing value for -tool"
+                exit 1
+            }
+        }
+        -config {
+            if {[llength $argv] > 0} {
+                set configfile [lindex $argv 0]
+                set argv [lrange $argv 1 end]
+            } else {
+                puts stderr "$argv0: missing value for -tool"
+                exit 1
+            }
+        }
+        default {
+            puts stderr "usage: $argv0 ?-tool file? ?-config file?"
+            exit 1
+        }
+    }
+}
+
+# open the XML file containing the material library
+set lib [Rappture::Library::open -std library.xml]
+                                                                                
+# open the XML file containing the tool parameters
+if {![file exists $toolfile]} {
+    puts stderr "tool file \"$toolfile\" doesn't exist"
+    exit 1
+}
+set tool [Rappture::Library::open $toolfile]
+                                                                                
+# open the XML file containing the configuration for this application
+if {![file exists $configfile]} {
+    puts stderr "config file \"$configfile\" doesn't exist"
+    exit 1
+}
+set config [Rappture::Library::open $configfile]
+
+# ----------------------------------------------------------------------
+# From here on, run in the directory containing the tool.xml file,
+# so driver.xml files, etc., are created there
+# ----------------------------------------------------------------------
+cd [file dirname $toolfile]
+
+# ----------------------------------------------------------------------
+# USAGE: main_device_select
+#
+# Invoked automatically when a user selects a new device from the
+# "Devices:" combobox.  Plugs the new device into the device viewer.
+# ----------------------------------------------------------------------
+proc main_device_select {} {
+    set win [.main component app]
+    set val [$win.input.devsel.dev value]
+    set val [$win.input.devsel.dev translate $val]
+    $win.input.device configure -device $val
+    $win.output.analyze configure -device $val
+}
+
+# ----------------------------------------------------------------------
+# MAIN WINDOW
+# ----------------------------------------------------------------------
+wm withdraw .
+Rappture::MainWin .main -borderwidth 0
+
+#.main configure -title [$config get title]
+
+# build everything inside this main window
+set win [.main component app]
+$win configure -background #a6a6a6
+
+frame $win.input -borderwidth 12 -relief flat
+pack $win.input -side left -expand yes -fill both -padx {0 5}
+
+frame $win.output -borderwidth 12 -relief flat
+pack $win.output -side left -expand yes -fill both -padx {5 0}
+
+# make an arrow that goes from input to output side
+label $win.arrow -borderwidth 0 -image in2out
+place $win.arrow -y 2 -anchor n
+bind $win.input <Configure> [list align_arrow $win]
+proc align_arrow {win} {
+    place $win.arrow -x [expr {[winfo width $win.input]+5}]
+}
+
+# ----------------------------------------------------------------------
+# INPUT AREA
+# ----------------------------------------------------------------------
+set w $win.input
+set ndevs [$config get -count controls.device]
+if {$ndevs > 0} {
+    for {set i 0} {$i < $ndevs} {incr i} {
+        set obj [$config get -object controls.device$i]
+        set name [$obj get label]
+        set devs($name) $obj
+    }
+    set devlist [lsort [array names devs]]
+
+    if {$ndevs > 1} {
+        frame $w.devsel
+        pack $w.devsel -side top -fill x
+        label $w.devsel.l -text "Device:"
+        pack $w.devsel.l -side left
+        Rappture::Combobox $w.devsel.dev -width 30 -editable no
+        pack $w.devsel.dev -side left
+        bind $w.devsel.dev <<Value>> main_device_select
+
+        foreach name $devlist {
+            $w.devsel.dev choices insert end $devs($name) $name
+        }
+        $w.devsel.dev value [lindex $devlist 0]
+    }
+
+    set first [lindex $devlist 0]
+    Rappture::DeviceViewer1D $w.device -device $devs($first) \
+        -tool $tool -library $lib
+    pack $w.device -expand yes -fill both
+
+    bind $w.device <<Edit>> [list $win.output.analyze reset]
+}
+
+# ----------------------------------------------------------------------
+# OUTPUT AREA
+# ----------------------------------------------------------------------
+set w $win.output
+Rappture::Analyzer $w.analyze -holdwindow $win.input \
+    -tool $tool -analysis [$config get -object analysis] \
+    -device $devs($first)
+pack $w.analyze -expand yes -fill both
+
+# ----------------------------------------------------------------------
+# HOOK UP ANY CONTROLS CALLED OUT IN CONFIG.XML
+# ----------------------------------------------------------------------
+set ncntls [$config get -count controls.access]
+for {set i 0} {$i < $ncntls} {incr i} {
+    set name [$config get access$i]
+    switch -glob -- $name {
+        parameters.ambient* - device* {
+            $win.input.device controls add $name
+        }
+    }
+}
Index: trunk/gui/apps/driver.cmd
===================================================================
--- trunk/gui/apps/driver.cmd	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-@REM %~dp0     = extract directory and path of argument 0 (command executed)
-@REM %M:~1,-1  = extract every between first and last charcter (the quotes)
-@REM These constructs require extended command options (Windows 2000 or later)
-@set M="%~dp0"
-@wish %M:~1,-1%driver %*
Index: trunk/gui/apps/encodedata.in
===================================================================
--- trunk/gui/apps/encodedata.in	(revision 6716)
+++ 	(revision )
@@ -1,102 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ======================================================================
-#  AUTHOR:  Derrick S. Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-exec wish "$0" "$@"
-
-package require Rappture
-
-proc printHelp {} {
-    set help {
-encodedata [OPTIONS] <infile> <outfile>
-
-simulator simulator - simulate simulation
-
-OPTIONS:
- -as z|b64|zb64      - how to encode the file
- -no-header          - don't include the header
-}
-    puts $help
-    exit 0
-}
-
-
-proc parseOptions {listVar returnVar} {
-    upvar $listVar argv
-    upvar $returnVar params
-
-    set argc [llength $argv]
-    for {set i 0} {$i < $argc} {incr i} {
-        set opt [lindex $argv $i]
-        if {("-as" == $opt)} {
-            if {[expr {$i+1}] < $argc} {
-                incr i
-                set params(-as) [lindex $argv $i]
-            } else {
-                printHelp
-            }
-        } elseif {("-no-header" == $opt)} {
-            set params(-no-header) "-no-header"
-        } else {
-            # place all extra params in the params array
-            lappend params(oParams) $opt
-        }
-    }
-}
-
-proc main {argv} {
-    array set params {
-        -as "zb64"
-        -no-header ""
-        oParams {}
-    }
-
-    parseOptions argv params
-
-    if {[llength $params(oParams)] < 2} {
-        printHelp
-        return
-    }
-    set infile [lindex $params(oParams) 0]
-    set outfile [lindex $params(oParams) 1]
-
-    if {[catch {
-            set fid [open $infile r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-         }] != 0 } {
-        puts "could not open $infile for reading"
-        return
-    }
-
-    puts "as = $params(-as)"
-    puts "header = $params(-no-header)"
-
-    # FIXME: i hate this
-    if {"" != $params(-no-header)} {
-        set encdata [Rappture::encoding::encode -as $params(-as) $params(-no-header) -- $info]
-    } else {
-        set encdata [Rappture::encoding::encode -as $params(-as) -- $info]
-    }
-
-    if {[catch {
-            set fid [open $outfile w]
-            fconfigure $fid -translation binary
-            puts $fid $encdata
-            close $fid
-         }] != 0 } {
-        puts "could not open $outfile for writing"
-        return
-    }
-
-}
-
-main $argv
-exit 0
Index: trunk/gui/apps/execute.tcl
===================================================================
--- trunk/gui/apps/execute.tcl	(revision 6716)
+++ 	(revision )
@@ -1,199 +1,0 @@
-#! /bin/sh
-# ----------------------------------------------------------------------
-#  RAPPTURE PROGRAM EXECUTION
-#
-#  This script implements the -execute option for Rappture.  It
-#  provides a way to run a specific Rappture simulation without
-#  invoking the Rappture GUI.  Instead, it takes a driver file with
-#  the required parameters, submits that for execution, and then
-#  returns the run.xml file.  If the -tool file is specified, then
-#  it double-checks the driver against the tool to make sure that
-#  the requested tool and version are compatible.
-#
-#  This is normally invoked by launcher.tcl, so it expects $driverxml
-#  and $toolxml variable to be already set.
-#
-#  USAGE: execute.tcl
-# ======================================================================
-#  AUTHORS:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-exec tclsh "$0" $*
-# ----------------------------------------------------------------------
-# tclsh executes everything from here on...
-
-# bring in the Rappture object system
-package require Rappture
-Rappture::objects::init
-Rappture::resources::load
-
-# Parse command line options
-# ----------------------------------------------------------------------
-Rappture::getopts argv params {
-    value -tool ""
-    value -status ""
-    value -output ""
-    value -cleanup no
-}
-
-# load the XML info in the driver file
-if {[catch {Rappture::library $driverxml} result]} {
-    puts stderr "ERROR while loading driver file \"$driverxml\""
-    puts stderr $result
-    exit 1
-}
-set driverobj $result
-
-# If tool.xml is not specified, try to find it the way Rappture would.
-if {$params(-tool) ne ""} {
-    set toolxml $params(-tool)
-}
-if {$toolxml eq ""} {
-    if {[file isfile tool.xml]} {
-        set toolxml [file normalize tool.xml]
-    } elseif {[file isfile [file join rappture tool.xml]]} {
-        set toolxml [file normalize [file join rappture tool.xml]]
-    }
-}
-
-# If there's still no tool.xml, then see if we can find tooldir in driver
-if {$toolxml eq ""} {
-    set tooldir [$driverobj get tool.version.application.directory(tool)]
-    if {$tooldir eq ""} {
-        puts stderr "ERROR: missing -tool option, and driver file doesn't contain sufficient detail to locate the desired tool."
-        exit 1
-    }
-
-    set toolxml [file join $tooldir tool.xml]
-    if {![file exists $toolxml]} {
-        puts stderr "ERROR: missing tool.xml file \"$toolxml\""
-        exit 1
-    }
-}
-
-set installdir [file dirname [file normalize $toolxml]]
-set toolobj [Rappture::library $toolxml]
-set TaskObj [Rappture::Task ::#auto $toolobj $installdir]
-set LogFid ""
-
-# Define some things that we need for logging status...
-# ----------------------------------------------------------------------
-proc log_output {message} {
-    global LogFid
-
-    if {$LogFid ne ""} {
-        #
-        # Scan through and pick out any =RAPPTURE-PROGRESS=> messages.
-        #
-        set percent ""
-        while {[regexp -indices \
-                {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)} $message \
-                 match percent mesg]} {
-
-            foreach {i0 i1} $percent break
-            set percent [string range $message $i0 $i1]
-
-            foreach {i0 i1} $mesg break
-            set mesg [string range $message $i0 $i1]
-
-            foreach {i0 i1} $match break
-            set message [string replace $message $i0 $i1]
-        }
-        if {$percent ne ""} {
-            # report the last percent progress found
-            log_append progress "$percent% - $mesg"
-        }
-    }
-}
-
-# Actually write to the log file
-proc log_append {level message} {
-    global LogFid
-
-    if {$LogFid ne ""} {
-        set date [clock format [clock seconds] -format {%Y-%m-%dT%H:%M:%S%z}]
-        set host [info hostname]
-        puts $LogFid "$date $host rappture [pid] \[$level\] $message"
-        flush $LogFid
-    }
-}
-
-# Actually write to the log file
-proc log_stats {args} {
-    set line ""
-    foreach {key val} $args {
-        append line "$key=$val "
-    }
-    log_append usage $line
-}
-
-# Apply effects of all other command line options
-# ----------------------------------------------------------------------
-if {$params(-status) ne ""} {
-    set LogFid [open $params(-status) w]
-    $TaskObj configure -logger {log_append status} -jobstats log_stats
-}
-
-if {$params(-output) eq ""} {
-    # no output? then run quietly and don't try to save results
-    $TaskObj configure -jobstats "" -resultdir ""
-}
-
-# Transfer input values from driver to TaskObj, and then run.
-# ----------------------------------------------------------------------
-
-# copy inputs from the test into the run file
-$TaskObj reset
-foreach path [Rappture::entities -as path $driverobj input] {
-    if {[$driverobj element -as type $path.current] ne ""} {
-        lappend args $path [$driverobj get $path.current]
-    }
-}
-
-if {$params(-status) ne ""} {
-    # recording status? then look through output for progress messages
-    lappend args -output log_output
-}
-
-# run the desired case...
-foreach {status result} [eval $TaskObj run $args] break
-
-if {$status == 0 && [Rappture::library isvalid $result]} {
-    set runxml $result
-    $runxml put output.status ok
-} else {
-    # build a run file for the result output
-    set info "<?xml version=\"1.0\"?>\n[$driverobj xml]"
-    set runxml [Rappture::LibraryObj ::#auto $info]
-    $runxml put output.log $result
-    $runxml put output.status failed
-}
-
-# Handle output
-# ----------------------------------------------------------------------
-switch -- $params(-output) {
-    "" {
-        # no output file -- write to stdout
-        puts "<?xml version=\"1.0\"?>\n[$runxml xml]"
-    }
-    "@default" {
-        # do the usual Rappture thing -- move to results dir
-        # but ignore any errors if it fails
-        catch {$TaskObj save $runxml}
-    }
-    default {
-        # save to the specified file
-        $TaskObj save $runxml $params(-output)
-    }
-}
-
-if {$params(-cleanup)} {
-    file delete -force -- $driverxml
-}
-
-log_append status "exit $status"
-exit $status
Index: trunk/gui/apps/flowvis-test
===================================================================
--- trunk/gui/apps/flowvis-test	(revision 6716)
+++ 	(revision )
@@ -1,366 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for flowVIS part of nanoVIS
-#
-#  This program is a test harness for the nanoVIS visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the nanoVIS
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-. $bindir/rappture.env ; \
-exec wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-
-set installdir [file root $argv0]
-set libdir [file join $installdir "lib"]
-
-lappend auto_path $libdir $libdir/vtk $libdir/vtk/tcl
-
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# Fake data object for sending DX or flow data...
-# ----------------------------------------------------------------------
-itcl::class visData {
-    constructor {args} {
-        set _data [Rappture::encoding::encode -as zb64 [lindex $args 0]]
-    }
-
-    public method components {args} {
-        if {[llength $args] == 0} {
-            return "one"
-        }
-        return ""
-    }
-    public method values {args} {
-        return $_data
-    }
-    public method hints {args} {
-        return ""
-    }
-    public method flowhints {args} {
-        return ""
-    }
-    public method extents {args} {
-        return "3"
-    }
-    private variable _data ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info]
-        $widgets(flowvis) add $obj
-        puts stderr "name of flow is $obj-component"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    $widgets(flowvis) sendto $cmd
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(flowvis) delete
-    $widgets(flowvis) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: activate_flow
-#
-# ----------------------------------------------------------------------
-proc activate_flow {} {
-    global widgets
-    set info {flow vectorid 0
-              flow particle visible on
-              flow lic on
-              flow capture 100}
-
-    $widgets(command) insert 0 $info
-    send_command
-
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(flowvis) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(flowvis) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "flowVIS: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-radiobutton .images.cntls.legend -text "Legend" -variable images(which) \
-    -value "legend" -command images_refresh
-pack .images.cntls.legend -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 700
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send Vector File..." -underline 0 -command send_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-menu .mbar.flow
-.mbar.flow add command -label "Activate Flow" -command {activate_flow}
-.mbar add cascade -label "Flow" -underline 0 -menu .mbar.flow
-
-
-
-. configure -menu .mbar
-
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4.75i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::FlowvisViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(flowvis) $f.viewer
-
-puts stderr [winfo class $widgets(flowvis)]
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/grabdata
===================================================================
--- trunk/gui/apps/grabdata	(revision 6716)
+++ 	(revision )
@@ -1,106 +1,0 @@
-#!/usr/bin/env python
-# ----------------------------------------------------------------------
-#  grabdata
-#
-#  script to grab dx files from a run.xml file
-#
-#  RUN AS FOLLOWS:
-#    grabdata [-h|-t] <runFile>
-#
-#      -h | --help    - print the help menu
-#      -t | --type    - type of data to grab
-#
-#      <runFile>      - the run.xml file containing dx files
-#
-# ======================================================================
-#  AUTHOR:  Derrick Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#
-#
-
-import re
-import os
-import sys
-import getopt
-import Rappture
-
-def help(argv=sys.argv):
-    return """%(prog)s [-h|-t] runFile
-      Grab DX, PDB, or other files from a run.xml file
-
-      -h | --help    - print the help menu
-      -t | --type    - type of data to grab
-
-      <runFile>      - the run.xml file containing dx, pdb or other files
-
-      Examples:
-        %(prog)s run1234.xml
-        %(prog)s -t dx run1234.xml
-        %(prog)s -t pdb run1234.xml
-""" % {'prog':os.path.basename(argv[0])}
-
-def main(argv=None):
-
-    if argv is None:
-        argv = sys.argv
-
-    if len(argv) < 2:
-        msg = "%(prog)s requires at least 1 arguments" % {'prog':argv[0]}
-        print >>sys.stderr, msg
-        print >>sys.stderr, help()
-        return 2
-
-    longOpts = ["type=","help"]
-    shortOpts = "t:h"
-    try:
-        opts, args = getopt.getopt(argv[1:], shortOpts, longOpts)
-    except getopt.GetoptError, msg:
-        print >>sys.stderr, msg
-        print >>sys.stderr, help()
-        return 2
-
-    tag = 'dx'
-
-    # match options
-    for o, v in opts:
-        if o in ("-t", "--type"):
-            tag = v
-        elif o in ("-h", "--help"):
-            print >>sys.stderr, help()
-            return 2
-
-    runFile = args[0]
-
-    # look for the text <tag> (any characters non-greedy) </tag>
-    regexp = r'<%(tag)s>(?P<data>.*?)</%(tag)s>' % {'tag':tag}
-    re_command = re.compile(regexp,re.I|re.DOTALL)
-
-    try:
-        xmlfile = open(runFile, "rb").read()
-    except IOError, msg:
-        print >>sys.stderr, msg
-        return 2
-
-    cnt = 0
-    runFileBase = os.path.basename(runFile)
-    prefix,ext = os.path.splitext(runFileBase)
-
-    outTextIter = re_command.finditer(xmlfile)
-    for match in outTextIter:
-        if match:
-            encoded_data = match.group('data')
-            # This needs to be a python static variable:
-            # RPENC_HDR == 4
-            unencoded_data = Rappture.encoding.decode(encoded_data,4)
-            newDXFile = open('%s_%i_.%s'%(prefix,cnt,tag),'wb')
-            newDXFile.write(unencoded_data)
-            newDXFile.close()
-            cnt += 1
-
-if __name__ == '__main__' :
-    # call main and exit gracefully
-    sys.exit(main())
Index: trunk/gui/apps/launcher.tcl
===================================================================
--- trunk/gui/apps/launcher.tcl	(revision 6716)
+++ 	(revision )
@@ -1,294 +1,0 @@
-#!/bin/sh
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  RAPPTURE LAUNCHER
-#
-#  This script is invoked by the "rappture" command.  It parses
-#  various input options and selects the proper main program to
-#  run depending on the function (build tool, run tool, tester, etc.).
-#
-#  RUN AS FOLLOWS:
-#    rappture ?-run? ?-tool <toolfile>?
-#    rappture -builder ?-tool <toolfile>?
-#    rappture -tester ?-tool <toolfile>? ?-testdir <directory>?
-#    rappture -execute driver.xml ?-tool <toolfile>?
-#
-#  The default option is "-run", which brings up the GUI used to
-#  run the tool.  If the <toolfile> is not specified, it defaults
-#  to "tool.xml" in the current working directory.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-set mainscript ""
-set alist ""
-set loadlist ""
-set toolxml ""
-
-# ----------------------------------------------------------------------
-#  Look for parameters passed into the tool session.  If there are
-#  any "file" parameters, they indicate files that should be loaded
-#  for browsing or executed to get results:
-#
-#    file(load):/path/to/run.xml
-#    file(execute):/path/to/driver.xml
-# ----------------------------------------------------------------------
-set params(opt) ""
-set params(load) ""
-set params(execute) ""
-set params(input) ""
-
-set rapptureInfo(cwd) [pwd]
-set rapptureInfo(appName) ""
-
-if {[info exists env(TOOL_PARAMETERS)]} {
-    # if we can't find the file, wait a little
-    set ntries 25
-    while {$ntries > 0 && ![file exists $env(TOOL_PARAMETERS)]} {
-        after 200
-        incr ntries -1
-    }
-
-    if {![file exists $env(TOOL_PARAMETERS)]} {
-        # still no file after all that? then skip parameters
-        puts stderr "WARNING: can't read tool parameters in file \"$env(TOOL_PARAMETERS)\"\nFile not found."
-
-    } elseif {[catch {
-        # read the file and parse the contents
-        set fid [open $env(TOOL_PARAMETERS) r]
-        set info [read $fid]
-        close $fid
-    } result] != 0} {
-        puts stderr "WARNING: can't read tool parameters in file \"$env(TOOL_PARAMETERS)\"\n$result"
-
-    } else {
-        # parse the contents of the tool parameter file
-        foreach line [split $info \n] {
-            set line [string trim $line]
-            if {$line eq "" || [regexp {^#} $line]} {
-                continue
-            }
-
-            if {[regexp {^([a-zA-Z]+)(\(into\:)(.+)\)\:(.+)$} $line match type name path value]
-                || [regexp {^([a-zA-Z]+)(\([^)]+\))?\:(.+)} $line match type name value]} {
-                if {$type eq "file"} {
-                    switch -exact -- $name {
-                        "(load)" - "" {
-                            lappend params(load) $value
-                            set params(opt) "-load"
-                        }
-                        "(simset)" - "" {
-                            lappend params(simset) $value
-                            set params(opt) "-simset"
-                        }
-                        "(execute)" {
-                            set params(execute) $value
-                            set params(opt) "-execute"
-                        }
-                        "(input)" {
-                            set params(input) $value
-                            set params(opt) "-input"
-                        }
-                        "(into:" {
-                            namespace eval ::Rappture { # forward decl }
-                            set ::Rappture::parameters($path) $value
-                        }
-                        default {
-                            puts stderr "WARNING: directive $name not recognized for file parameter \"$value\""
-                        }
-                    }
-                }
-            }
-        }
-    }
-}
-
-# scan through the arguments and look for the function
-while {[llength $argv] > 0} {
-    set opt [lindex $argv 0]
-    set argv [lrange $argv 1 end]
-
-    if {[string index $opt 0] == "-"} {
-        switch -- $opt {
-            -run {
-                package require RapptureGUI
-                set guidir $RapptureGUI::library
-                set mainscript [file join $guidir scripts main.tcl]
-                set reqpkgs Tk
-            }
-            -builder {
-                package require RapptureBuilder
-                set blddir $RapptureBuilder::library
-                set mainscript [file join $blddir scripts main.tcl]
-                set reqpkgs Tk
-            }
-            -tester {
-                package require RapptureTester
-                set testdir $RapptureTester::library
-                set mainscript [file join $testdir scripts main.tcl]
-                set reqpkgs Tk
-            }
-            -execute {
-                # for web services and simulation cache -- don't load Tk
-                set reqpkgs ""
-                if {[llength $argv] < 1} {
-                    puts stderr "error: missing driver.xml file for -execute option"
-                    exit 1
-                }
-                set driverxml [lindex $argv 0]
-                set argv [lrange $argv 1 end]
-
-                if {![file readable $driverxml]} {
-                    puts stderr "error: driver file \"$driverxml\" not found"
-                    exit 1
-                }
-
-                set dir [file dirname [info script]]
-                set mainscript [file join $dir execute.tcl]
-            }
-            -tool {
-                set toolxml [lindex $argv 0]
-                set argv [lrange $argv 1 end]
-                if {![file exists $toolxml]} {
-                    puts stderr "file not found: $toolxml"
-                    exit 1
-                }
-                lappend alist -tool $toolxml
-            }
-            -testdir - -nosim {
-                lappend alist $opt [lindex $argv 0]
-                set argv [lrange $argv 1 end]
-            }
-            -auto {
-                # for the tester in automatic mode -- don't load Tk
-                package require RapptureTester
-                set testdir $RapptureTester::library
-                set mainscript [file join $testdir scripts auto.tcl]
-                set reqpkgs ""
-            }
-            -load {
-                while { [llength $argv] > 0 } {
-                    set val [lindex $argv 0]
-                    if { [string index $val 0] == "-" } {
-                        break
-                    }
-                    lappend loadlist $val
-                    set argv [lrange $argv 1 end]
-                }
-            }
-            -simset {
-                lappend alist $opt [lindex $argv 0]
-                set argv [lrange $argv 1 end]
-            }
-            -appname {
-                global rapptureInfo
-                set rapptureInfo(appName) [lindex $argv 0]
-                set argv [lrange $argv 1 end]
-            }
-            default {
-                puts stderr "usage:"
-                puts stderr "  rappture ?-run? ?-tool toolFile? ?-nosim 0/1? ?-load file file ...?"
-                puts stderr "  rappture -builder ?-tool toolFile?"
-                puts stderr "  rappture -tester ?-auto? ?-tool toolFile? ?-testdir directory?"
-                puts stderr "  rappture -execute driver.xml ?-tool toolFile?"
-                exit 1
-            }
-        }
-    }
-}
-
-# If no arguments, check to see if there are any tool parameters.
-# If not, then assume that it's the -run option.
-if {$mainscript eq ""} {
-    switch -- $params(opt) {
-        -load {
-            # add tool parameters to the end of any files given on cmd line
-            set loadlist [concat $loadlist $params(load)]
-            set alist [concat $alist -load $loadlist]
-
-            package require RapptureGUI
-            set guidir $RapptureGUI::library
-            set mainscript [file join $guidir scripts main.tcl]
-            set reqpkgs Tk
-        }
-        -simset {
-            # add tool parameters to the end of any files given on cmd line
-            set loadlist [concat $loadlist $params(simset)]
-            set alist [concat $alist -simset $loadlist]
-
-            package require RapptureGUI
-            set guidir $RapptureGUI::library
-            set mainscript [file join $guidir scripts main.tcl]
-            set reqpkgs Tk
-        }
-        -execute {
-            if {[llength $params(execute)] != 1} {
-                puts stderr "ERROR: wrong number of (execute) files in TOOL_PARAMETERS (should be only 1)"
-                exit 1
-            }
-            set driverxml [lindex $params(execute) 0]
-            if {![file readable $driverxml]} {
-                puts stderr "error: driver file \"$driverxml\" not found"
-                exit 1
-            }
-            set dir [file dirname [info script]]
-            set mainscript [file join $dir execute.tcl]
-            set reqpkgs ""
-
-            # When executing from TOOL_PARAMETERS file directives,
-            # report status, clean up, and save output to data/results.
-            # This helps the web services interface do its thing.
-            set alist [list \
-                -output @default \
-                -status rappture.status \
-                -cleanup yes]
-        }
-        "" - "-input" {
-            package require RapptureGUI
-            set guidir $RapptureGUI::library
-            set mainscript [file join $guidir scripts main.tcl]
-            set reqpkgs Tk
-
-            # finalize the -input argument for "rappture -run"
-            if {$params(input) ne ""} {
-                if {![file readable $params(input)]} {
-                    puts stderr "error: driver file \"$params(input)\" not found"
-                    exit 1
-                }
-                set alist [concat $alist -input $params(input)]
-            }
-
-            # finalize any pending -load arguments for "rappture -run"
-            if {[llength $loadlist] > 0} {
-                set alist [concat $alist -load $loadlist]
-            }
-        }
-        default {
-            puts stderr "internal error: funny action \"$params(opt)\" inferred from TOOL_PARAMETERS"
-            exit 1
-        }
-    }
-} else {
-    # finalize any pending -load arguments for "rappture -run"
-    if {[llength $loadlist] > 0} {
-        set alist [concat $alist -load $loadlist]
-    }
-}
-
-# Invoke the main program with the args
-
-# Note: We're sourcing the driver file "main.tcl" rather than exec-ing
-#       wish because we want to see stderr and stdout messages when they
-#       are written, rather than when the program completes.  It also
-#       eliminates one process waiting for the other to complete. If
-#       "exec" is needed, then the following could be replaced with
-#       blt::bgexec.  It doesn't try to redirect stderr into a file.
-set argv $alist
-foreach name $reqpkgs {
-    package require $name
-}
-source  $mainscript
Index: trunk/gui/apps/mapviewer-test
===================================================================
--- trunk/gui/apps/mapviewer-test	(revision 6716)
+++ 	(revision )
@@ -1,331 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for MapViewer
-#
-#  This program is a test harness for the GeoVis visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the GeoVis
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-exec $bindir/wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-
-set installdir [file root $argv0]
-set libdir [file join $installdir "lib"]
-
-lappend auto_path $libdir
-
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Earth File as Map"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set len [string length $info]
-        $widgets(command) insert 0 "map load data follows $len\n$info"
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    namespace eval Rappture::MapViewer [list $widgets(mapviewer) SendCmd $cmd]
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(mapviewer) delete
-    $widgets(mapviewer) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-proc resetMapGeocentric {} {
-    global widgets
-    set cmd "map reset geocentric"
-    namespace eval Rappture::MapViewer [list $widgets(mapviewer) SendCmd $cmd]
-}
-
-proc resetMapGlobalGeodetic {} {
-    global widgets
-    set cmd "map reset projected global-geodetic"
-    namespace eval Rappture::MapViewer [list $widgets(mapviewer) SendCmd $cmd]
-}
-
-proc resetMapGlobalMercator {} {
-    global widgets
-    set cmd "map reset projected global-mercator"
-    namespace eval Rappture::MapViewer [list $widgets(mapviewer) SendCmd $cmd]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(mapviewer) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(mapviewer) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "Geoviewer: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 500
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send Earth File..." -underline 0 -command send_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset Map to Geocentric" -underline 0 -command resetMapGeocentric
-.mbar.file add command -label "Reset Map to Geodetic Projection" -underline 0 -command resetMapGlobalGeodetic
-.mbar.file add command -label "Reset Map to Mercator Projection" -underline 0 -command resetMapGlobalMercator
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-. configure -menu .mbar
-
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::MapViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(mapviewer) $f.viewer
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/nanovis-test
===================================================================
--- trunk/gui/apps/nanovis-test	(revision 6716)
+++ 	(revision )
@@ -1,377 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for nanoVIS
-#
-#  This program is a test harness for the nanoVIS visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the nanoVIS
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-. $bindir/rappture.env ; \
-exec $bindir/wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# Fake data object for sending DX or flow data...
-# ----------------------------------------------------------------------
-itcl::class visData {
-    constructor {args} {
-        set _data [Rappture::encoding::encode -as zb64 [lindex $args 0]]
-    }
-
-    public method components {args} {
-        if {[llength $args] == 0} {
-            return "one"
-        }
-        return ""
-    }
-    public method values {args} {
-        return $_data
-    }
-    public method hints {args} {
-        return ""
-    }
-
-    private variable _data ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info]
-        $widgets(nanovis) add $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_flow_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_flow_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set _data [Rappture::encoding::encode -as zb64 $info ]
-        set _data "flow data follows [string length $_data]\n$_data"
-        $widgets(command) insert 0 $_data
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    namespace eval Rappture::NanovisViewer [list $widgets(nanovis) SendCmd $cmd]
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(nanovis) delete
-    $widgets(nanovis) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: activate_flow
-#
-# ----------------------------------------------------------------------
-proc activate_flow {} {
-    global widgets
-    # global img_storage_dir
-    # "flow capture 117 $img_storage_dir"
-
-    set info {flow vectorid 0
-              flow particle visible on
-              flow lic on
-              flow capture 100}
-
-    $widgets(command) insert 0 $info
-    send_command
-
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(nanovis) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(nanovis) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "nanoVIS: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-radiobutton .images.cntls.legend -text "Legend" -variable images(which) \
-    -value "legend" -command images_refresh
-pack .images.cntls.legend -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 500
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send Volume File..." -underline 0 -command send_file
-.mbar.file add command -label "Send Flow File..." -underline 0 -command send_flow_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-menu .mbar.flow
-.mbar.flow add command -label "Activate Flow" -command {activate_flow}
-.mbar add cascade -label "Flow" -underline 0 -menu .mbar.flow
-
-. configure -menu .mbar
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::NanovisViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(nanovis) $f.viewer
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/rappture-csh.env.in
===================================================================
--- trunk/gui/apps/rappture-csh.env.in	(revision 6716)
+++ 	(revision )
@@ -1,108 +1,0 @@
-#!/bin/csh -f
-# ----------------------------------------------------------------------
-#  RAPPTURE ENVIRONMENT
-#
-#  This is the main script that most people use to invoke the
-#  Rappture GUI.  It sets environment variables so that the Rappture
-#  GUI driver will work properly for the current installation.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#
-
-# If you install Rappture elsewhere, edit the line below:
-set exec_prefix=@INSTALL_PREFIX@
-
-set bindir=@bindir@
-set libdir=@libdir@
-set vtk_tcl_dir=@VTK_TCL_DIR@
-set python_version=@PYTHON_VERSION@
-set tcl_version=@TCL_VERSION@
-set octave_version=@OCTAVE_VERSION_MAJOR@
-
-set path = ( $bindir $path )
-
-if ( $?LD_LIBRARY_PATH ) then
-  setenv LD_LIBRARY_PATH "${libdir}:$LD_LIBRARY_PATH"
-else
-  setenv LD_LIBRARY_PATH "${libdir}"
-endif
-
-if ( $?DYLD_LIBRARY_PATH ) then
-  setenv DYLD_LIBRARY_PATH "${libdir}:$DYLD_LIBRARY_PATH"
-else
-  setenv DYLD_LIBRARY_PATH "${libdir}"
-endif
-
-if ( $?MATLABPATH ) then
-  setenv MATLABPATH "${libdir}/matlab:$MATLABPATH"
-else
-  setenv MATLABPATH "${libdir}/matlab"
-endif
-
-if ( $?OCTAVE_PATH ) then
-  setenv OCTAVE_PATH "${libdir}/octave${octave_version}:$OCTAVE_PATH"
-else
-  setenv OCTAVE_PATH "${libdir}/octave${octave_version}"
-endif
-
-if ( $?OCTAVE_LOADPATH ) then
-  setenv OCTAVE_LOADPATH "${libdir}/octave3:$OCTAVE_LOADPATH"
-else
-  setenv OCTAVE_LOADPATH "${libdir}/octave3"
-endif
-
-if ( $?PERL5LIB ) then
-  setenv PERL5LIB "${libdir}/perl:$PERL5LIB"
-else
-  setenv PERL5LIB "${libdir}/perl"
-endif
-
-if ( $?PYTHONPATH ) then
-  setenv PYTHONPATH  "${libdir}/python${python_version}/site-packages:$PYTHONPATH"
-else
-  setenv PYTHONPATH  "${libdir}/python${python_version}/site-packages"
-endif
-
-if ( $?RUBYLIB ) then
-  setenv RUBYLIB "${libdir}/ruby:$RUBYLIB"
-else
-  setenv RUBYLIB "${libdir}/ruby"
-endif
-
-if ( $?TCL_LIBRARY ) then
-  setenv TCL_LIBRARY "${libdir}/tcl${tcl_version}:$TCL_LIBRARY"
-else
-  setenv TCL_LIBRARY "${libdir}/tcl${tcl_version}"
-endif
-
-if ( $?TK_LIBRARY ) then
-  setenv TK_LIBRARY "${libdir}/tk${tcl_version}:$TK_LIBRARY"
-else
-  setenv TK_LIBRARY "${libdir}/tk${tcl_version}"
-endif
-
-if ( $?TCLLIBPATH ) then
-  setenv TCLLIBPATH "${vtk_tcl_dir} $TCLLIBPATH"
-else
-  setenv TCLLIBPATH "${vtk_tcl_dir}"
-endif
-
-if ( $?CLASSPATH ) then
-  setenv CLASSPATH "${libdir}/java:$CLASSPATH"
-else
-  setenv CLASSPATH "${libdir}/java"
-endif
-
-if ( $?R_LIBS ) then
-  setenv R_LIBS "${libdir}/R:$R_LIBS"
-else
-  setenv R_LIBS "${libdir}/R"
-endif
-
-setenv RAPPTURE_PATH "${exec_prefix}"
Index: trunk/gui/apps/rappture.cmd
===================================================================
--- trunk/gui/apps/rappture.cmd	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-@REM %~dp0     = extract directory and path of argument 0 (command executed)
-@REM %M:~1,-1  = extract every between first and last charcter (the quotes)
-@REM These constructs require extended command options (Windows 2000 or later)
-@set M="%~dp0"
-@wish %M:~1,-1%driver %*
Index: trunk/gui/apps/rappture.env.in
===================================================================
--- trunk/gui/apps/rappture.env.in	(revision 6716)
+++ 	(revision )
@@ -1,65 +1,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------
-#  RAPPTURE ENVIRONMENT
-#
-#  This is the main script that most people use to invoke the
-#  Rappture GUI.  It sets environment variables so that the Rappture
-#  GUI driver will work properly for the current installation.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#
-# If you install Rappture elsewhere, edit the line below:
-exec_prefix=@INSTALL_PREFIX@
-
-libdir=@libdir@
-bindir=@bindir@
-vtk_tcl_dir=@VTK_TCL_DIR@
-python_version=@PYTHON_VERSION@
-tcl_version=@TCL_VERSION@
-octave_version=@OCTAVE_VERSION_MAJOR@
-
-# No need to edit anything else
-PATH=${bindir}:$PATH
-
-LD_LIBRARY_PATH=${libdir}:$LD_LIBRARY_PATH
-
-# For MacOS X
-DYLD_LIBRARY_PATH=${libdir}:$DYLD_LIBRARY_PATH
-
-export PATH LD_LIBRARY_PATH DYLD_LIBRARY_PATH
-
-MATLABPATH=${libdir}/matlab:$MATLABPATH
-OCTAVE_LOADPATH=:${libdir}/octave3:$OCTAVE_LOADPATH
-OCTAVE_PATH=:${libdir}/octave${octave_version}:$OCTAVE_PATH
-
-export MATLABPATH OCTAVE_PATH OCTAVE_LOADPATH
-
-PERL5LIB=${libdir}/perl:$PERL5LIB
-PYTHONPATH=${libdir}/python${python_version}/site-packages:${PYTHONPATH}
-RUBYLIB=${libdir}/ruby:$RUBYLIB
-
-export PERL5LIB RUBYLIB PYTHONPATH
-
-TCLLIBPATH="${vtk_tcl_dir} $TCLLIBPATH"
-TCL_LIBRARY=${libdir}/tcl${tcl_version}:$TCL_LIBRARY
-TK_LIBRARY=${libdir}/tk${tcl_version}:$TK_LIBRARY
-
-export TCL_LIBRARY TK_LIBRARY TCLLIBPATH
-
-CLASSPATH=.:${libdir}/java:$CLASSPATH
-
-export CLASSPATH
-
-R_LIBS=${libdir}/R:$R_LIBS
-
-export R_LIBS
-
-RAPPTURE_PATH=${exec_prefix}
-
-export RAPPTURE_PATH
Index: trunk/gui/apps/rappture.in
===================================================================
--- trunk/gui/apps/rappture.in	(revision 6716)
+++ 	(revision )
@@ -1,18 +1,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------
-#  RAPPTURE
-#
-#  This is the main script that most people use to invoke the
-#  Rappture GUI.  It sets environment variables so that the Rappture
-#  GUI driver will work properly for the current installation.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-dir=`dirname $0`
-. $dir/rappture.env
-exec tclsh $dir/launcher.tcl "$@"
Index: trunk/gui/apps/rappture.use.in
===================================================================
--- trunk/gui/apps/rappture.use.in	(revision 6716)
+++ 	(revision )
@@ -1,41 +1,0 @@
-
-conflict RAPPTURE_CHOICE
-
-desc "The Rappture tool environment (released version)."
-
-help "Rappture is a graphical tool wrapper.
-It can be used to add a graphical user interface to
-a conventional scientific application."
-
-exec_prefix=@prefix@
-libdir=@libdir@
-bindir=@bindir@
-vtk_tcl_dir=@VTK_TCL_DIR@
-python_version=@PYTHON_VERSION@
-tcl_version=@TCL_VERSION@
-octave_version=@OCTAVE_VERSION_MAJOR@
-
-prepend PATH ${bindir}
-
-prepend LD_LIBRARY_PATH ${libdir}
-prepend DYLD_LIBRARY_PATH ${libdir}
-
-prepend MATLABPATH ${libdir}/matlab
-prepend OCTAVE_PATH :${libdir}/octave${octave_version}:
-prepend OCTAVE_LOADPATH :${libdir}/octave3:
-
-prepend PERL5LIB ${libdir}/perl
-prepend RUBYLIB ${libdir}/ruby
-prepend PYTHONPATH ${libdir}/python${python_version}/site-packages
-
-prepend TCLLIBPATH ${vtk_tcl_dir}
-prepend TCL_LIBRARY ${libdir}/tcl${tcl_version}
-prepend TK_LIBRARY ${libdir}/tk${tcl_version}
-
-prepend CLASSPATH ${libdir}/java
-
-prepend R_LIBS ${libdir}/R
-
-setenv RAPPTURE_PATH ${exec_prefix}
-
-tags DEVEL
Index: trunk/gui/apps/rerun.cmd
===================================================================
--- trunk/gui/apps/rerun.cmd	(revision 6716)
+++ 	(revision )
@@ -1,6 +1,0 @@
-@REM %~dp0     = extract directory and path of argument 0 (command executed)
-@REM %M:~1,-1  = extract every between first and last charcter (the quotes)
-@REM These constructs require extended command options (Windows 2000 or later)
-@set M="%~dp0"
-@wish %M:~1,-1%driver -load %*
-
Index: trunk/gui/apps/rerun.in
===================================================================
--- trunk/gui/apps/rerun.in	(revision 6716)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------
-#  rerun
-#
-#  script to view the output of a previously created run.xml file.
-#  this is just a wrapper around the "rappture -load ..." command
-#  you can use this command to load and compare run.xml files from
-#  the same application. loading xml files from different applciations
-#  will result in undefined actions, and possibly errors.
-#  after loading a run.xml file, you can still enter new values into
-#  the rappture gui and continue simulation experiments.
-#
-#  RUN AS FOLLOWS:
-#    rerun <runFile>,...
-#
-#      <runFile>      - the run.xml file containing an output
-#                       section you would like to re-generate.
-#      ...            - optional comma separated list of runFiles
-#
-#
-#   ex: rerun run1234.xml,run5678.xml,run0123.xml
-#
-# ======================================================================
-#  AUTHOR:  Derrick Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#
-#
-dir=`dirname $0`
-. $dir/rappture.env
-exec $dir/rappture -nosim true -load "$@"
Index: trunk/gui/apps/rpdiff
===================================================================
--- trunk/gui/apps/rpdiff	(revision 6716)
+++ 	(revision )
@@ -1,585 +1,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------
-#  RPDIFF
-#
-#  Compares two Rappture run files and looks for differences in the
-#  output results.  This is useful for the BOINC integration and other
-#  job execution infrastructures, so we can compare the results from
-#  multiple runs.
-#
-#    USAGE:
-#    % rpdiff <runFile1> <runFile2>
-#
-#  Exits with status 0 if the files are the same, and non-zero status
-#  if the files are different.  Prints differences on stdout.  Prints
-#  any errors on stderr.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-# \
-exec tclsh "$0" ${1+"$@"}
-# tclsh executes the rest...
-package require Rappture
-
-# ----------------------------------------------------------------------
-# USAGE: diff <path> <lib1> <lib2>
-#
-# Used to compare two Rappture library objects at the specified <path>
-# in <lib1> and <lib2>.  Returns "" if they are the same, and a list
-# of differences if they are not.
-# ----------------------------------------------------------------------
-proc diff {path lib1 lib2} {
-    set knowntypes {boolean choice cloud curve field group histogram image integer loader log mesh note number periodicelement phase sequence string structure table unirect2d}
-    set type1 [$lib1 element -as type $path]
-    set type2 [$lib2 element -as type $path]
-    if {($type1 eq "" && $type2 ne "") || ($type1 ne "" && $type2 eq "")} {
-        return "missing component at $path"
-    } elseif {$type1 ne $type2} {
-        return "component mismatch at $path"
-    }
-
-    set diffs ""
-    switch -- $type1 {
-        input - output - group - phase {
-            set cpath1 [$lib1 children -as path $path]
-            set cpath2 [$lib2 children -as path $path]
-
-            # scan through all components in lib1 and diff against lib2
-            foreach cp $cpath1 {
-                set ct [$lib1 element -as type $cp]
-                if {[lsearch $knowntypes $ct] < 0} {
-                    # this isn't a real rappture object -- skip it
-                    set i [lsearch -exact $cpath2 $cp]
-                    if {$i >= 0} {
-                        set cpath2 [lreplace $cpath2 $i $i]
-                    }
-                    continue
-                }
-
-                set i [lsearch -exact $cpath2 $cp]
-                if {$i < 0} {
-                    lappend diffs "missing missing component at $cp"
-                } else {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                    eval lappend diffs [diff $cp $lib1 $lib2]
-                }
-            }
-
-            # components left over that are in lib2 but not in lib1?
-            foreach cp $cpath2 {
-                lappend diffs "missing component at $cp"
-            }
-        }
-
-        boolean {
-            eval lappend diffs [diffattrs {
-                about.label about.description default
-            } $path $lib1 $lib2]
-
-            set v1 [$lib1 get $path.current]
-            if {$v1 ne "" && [catch {expr $v1} newval] == 0} { set v1 $newval }
-
-            set v2 [$lib2 get $path.current]
-            if {$v2 ne "" && [catch {expr $v2} newval] == 0} { set v2 $newval }
-
-            if {$v1 ne $v2} {
-                lappend diffs "value mismatch at $path.current"
-            }
-        }
-        choice {
-            eval lappend diffs [diffattrs {
-                about.label about.description default
-            } $path $lib1 $lib2]
-
-            set v1 [$lib1 get $path.current]
-            set v2 [$lib2 get $path.current]
-            if {$v1 ne $v2} {
-                lappend diffs "value mismatch at $path.current"
-            }
-        }
-        cloud {
-            eval lappend diffs [diffattrs {
-                about.label about.description units hide
-            } $path $lib1 $lib2]
-
-            eval lappend diffs [diffdatalines $path.points $lib1 $lib2]
-        }
-        curve {
-            eval lappend diffs [diffattrs {
-                about.label about.description
-                xaxis.label xaxis.description xaxis.units
-                yaxis.label yaxis.description yaxis.units
-            } $path $lib1 $lib2]
-
-            set cpath2 [$lib2 children -as path $path.component]
-            foreach elem [$lib1 children -as path $path.component] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-
-                set data1 [$lib1 get $elem]
-                set data2 [$lib2 get $elem]
-                if {[llength $data1] != [llength $data2]} {
-                    lappend diffs "value mismatch at $elem"
-                    break
-                }
-
-                foreach d1 $data1 d2 $data2 {
-                    if {[Rappture::objects::ObjVal::cmpdbl $d1 $d2] != 0} {
-                        lappend diffs "value mismatch at $elem"
-                        break
-                    }
-                }
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-        }
-        field {
-            eval lappend diffs [diffattrs {
-                about.label about.description
-            } $path $lib1 $lib2]
-
-            set cpath2 [$lib2 children -as path -type component $path]
-            foreach elem [$lib1 children -as path -type component $path] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-
-                # the flow attributes may or may not exist
-                eval lappend diffs [diffattrs {
-                    flow.label flow.description
-                } $elem $lib1 $lib2]
-
-                # must have the same dx (if defined)
-                set v1 [$lib1 get $elem.dx]
-                set v2 [$lib2 get $elem.dx]
-                if {$v1 ne $v2} {
-                    lappend diffs "value mismatch at $elem.dx"
-                    continue
-                }
-
-                # must have the same mesh
-                set v1 [$lib1 get $elem.mesh]
-                set v2 [$lib2 get $elem.mesh]
-                if {$v1 ne $v2} {
-                    lappend diffs "value mismatch at $elem.mesh"
-                    continue
-                }
-
-                # must have the same values
-                eval lappend diffs [diffdatalines $elem.values $lib1 $lib2]
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-        }
-        histogram {
-            eval lappend diffs [diffattrs {
-                about.label about.description
-                xaxis.label xaxis.description xaxis.units
-                yaxis.label yaxis.description yaxis.units
-            } $path $lib1 $lib2]
-
-            set cpath2 [$lib2 children -as path $path.component]
-            foreach elem [$lib1 children -as path $path.component] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-
-                eval lappend diffs [diffdatalines $elem $lib1 $lib2]
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-        }
-        image {
-            eval lappend diffs [diffattrs {
-                about.label about.description resize convert
-            } $path $lib1 $lib2]
-
-            set v1 [$lib1 get $path.current]
-            set v2 [$lib2 get $path.current]
-            if {$v1 ne $v2} {
-                lappend diffs "value mismatch at $path.current"
-            }
-        }
-        integer {
-            eval lappend diffs [diffattrs {
-                about.label about.description min max default
-            } $path $lib1 $lib2]
-
-            set v1 [$lib1 get $path.current]
-            set v2 [$lib2 get $path.current]
-            if {[string is integer -strict $v1]
-                  && [string is integer -strict $v2]} {
-                if {$v1 != $v2} {
-                    lappend diffs "value mismatch at $path.current"
-                }
-            } elseif {$v1 ne $v2} {
-                lappend diffs "value mismatch at $path.current"
-            }
-        }
-        log {
-            set v1 [$lib1 get $path]
-            set v2 [$lib2 get $path]
-            if {$v1 ne $v2} {
-                lappend diffs "value mismatch at $path"
-            }
-        }
-        mesh {
-            eval lappend diffs [diffattrs {
-                about.label about.description units hide
-            } $path $lib1 $lib2]
-
-            # look for differences in nodes
-            set cpath2 [$lib2 children -as path -type node $path]
-            foreach elem [$lib1 children -as path -type node $path] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-
-                eval lappend diffs [diffdatalines $elem $lib1 $lib2]
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-
-            # look for differences in elements
-            set cpath2 [$lib2 children -as path -type element $path]
-            foreach elem [$lib1 children -as path -type element $path] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-
-                set v1 [$lib1 get $elem.node]
-                set v2 [$lib2 get $elem.node]
-                if {$v1 ne $v2} {
-                    lappend diffs "value mismatch at $path.node"
-                }
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-        }
-        note {
-            eval lappend diffs [diffattrs {contents} $path $lib1 $lib2]
-        }
-        number {
-            eval lappend diffs [diffattrs {
-                about.label about.description about.icon
-                min max units color default
-            } $path $lib1 $lib2]
-
-            set v1 [$lib1 get $path.current]
-            set v2 [$lib2 get $path.current]
-            if {[string is double -strict $v1]
-                  && [string is double -strict $v2]} {
-                if {[Rappture::objects::ObjVal::cmpdbl $v1 $v2] != 0} {
-                    lappend diffs "value mismatch at $path.current"
-                }
-            } elseif {$v1 ne $v2} {
-                lappend diffs "value mismatch at $path.current"
-            }
-        }
-        sequence {
-            eval lappend diffs [diffattrs {
-                about.label about.description index.label
-            } $path $lib1 $lib2]
-
-            set cpath2 [$lib2 children -as path -type element $path]
-            foreach elem [$lib1 children -as path -type element $path] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-
-                # must have the same index
-                set v1 [$lib1 get $elem.index]
-                set v2 [$lib2 get $elem.index]
-                if {$v1 ne $v2} {
-                    lappend diffs "value mismatch at $elem.index"
-                    continue
-                }
-
-                # must have the same values
-                set parts1 [lsort [$lib1 children -as path $elem]]
-                set parts2 [lsort [$lib2 children -as path $elem]]
-                if {$parts1 ne $parts2} {
-                    lappend diffs "value mismatch at $elem"
-                    continue
-                }
-
-                foreach p $parts1 {
-                    set ptype [$lib1 element -as type $p]
-                    if {[lsearch $knowntypes $ptype] >= 0} {
-                        eval lappend diffs [diff $p $lib1 $lib2]
-                    }
-                }
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-        }
-        string {
-            eval lappend diffs [diffattrs {
-                about.label about.description default size hints
-            } $path $lib1 $lib2]
-
-            set v1 [$lib1 get $path.current]
-            set v2 [$lib2 get $path.current]
-            if {$v1 ne $v2} {
-                lappend diffs "value mismatch at $path.current"
-            }
-        }
-        structure {
-            eval lappend diffs [diffattrs {
-                about.label about.description
-            } $path $lib1 $lib2]
-
-            # check all parameters associated with the structure
-            set cpath2 [$lib2 children -as path $path.current.parameters]
-            foreach elem [$lib1 children -as path $path.current.parameters] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-                eval lappend diffs [diff $elem $lib1 $lib2]
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-
-            # check all components in the structure
-            set cpath2 [$lib2 children -as path $path.current.components]
-            foreach elem [$lib1 children -as path $path.current.components] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-
-                switch -- [$lib1 element -as type $elem] {
-                    box {
-                        eval lappend diffs [diffattrs {
-                            about.label about.color about.icon material
-                        } $elem $lib1 $lib2]
-
-                        set c2 [$lib2 children -as path -type corner $elem]
-                        foreach c [$lib1 children -as path -type corner $elem] {
-                            set i [lsearch -exact $c2 $c]
-                            if {$i >= 0} {
-                                set c2 [lreplace $c2 $i $i]
-                            }
-
-                            set v1 [$lib1 get $c]
-                            set v2 [$lib2 get $c]
-                            if {$v1 ne $v2} {
-                                lappend diffs "value mismatch at $c"
-                            }
-                        }
-                        foreach c $c2 {
-                            # anything left in lib2 that's not in lib1?
-                            lappend diffs "missing component at $c"
-                        }
-                    }
-                    molecule {
-                        eval lappend diffs [diffattrs {
-                            about.emblems formula
-                        } $elem $lib1 $lib2]
-
-                        # check for PDB data
-                        set v1 [$lib1 get $elem.pdb]
-                        set v2 [$lib2 get $elem.pdb]
-                        if {$v1 ne $v2} {
-                            lappend diffs "value mismatch at $elem.pdb"
-                        }
-
-                        # check for the old-style atom data
-                        set c2 [$lib2 children -as path -type atom $elem]
-                        foreach c [$lib1 children -as path -type atom $elem] {
-                            set i [lsearch -exact $c2 $c]
-                            if {$i >= 0} {
-                                set c2 [lreplace $c2 $i $i]
-                            }
-
-                            set v1 [$lib1 get $c.symbol]
-                            set v2 [$lib2 get $c.symbol]
-                            if {$v1 ne $v2} {
-                                lappend diffs "value mismatch at $c"
-                            }
-
-                            set df [diffdatalines $c.xyz $lib1 $lib2]
-                            if {$df ne ""} {
-                                eval lappend diffs $df
-                            }
-                        }
-                        foreach c $c2 {
-                            # anything left in lib2 that's not in lib1?
-                            lappend diffs "missing component at $c"
-                        }
-                    }
-                    default {
-                        error "don't know how to diff $elem"
-                    }
-                }
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-        }
-        table {
-            eval lappend diffs [diffattrs {
-                about.label about.description
-            } $path $lib1 $lib2]
-
-            set cpath2 [$lib2 children -as path -type column $path]
-            foreach elem [$lib1 children -as path -type column $path] {
-                set i [lsearch -exact $cpath2 $elem]
-                if {$i >= 0} {
-                    set cpath2 [lreplace $cpath2 $i $i]
-                }
-
-                eval lappend diffs [diffattrs {label units} $elem $lib1 $lib2]
-            }
-            foreach elem $cpath2 {
-                # anything left in lib2 that's not in lib1?
-                lappend diffs "missing component at $elem"
-            }
-
-            # make sure the table data matches
-            eval lappend diffs [diffdatalines $path.data $lib1 $lib2]
-        }
-        unirect2D {
-            eval lappend diffs [diffattrs {
-                about.label about.description hide
-                xaxis.label xaxis.units xaxis.numpoints
-                yaxis.label yaxis.units yaxis.numpoints
-            } $path $lib1 $lib2]
-
-            foreach elem {xaxis.min xaxis.max yaxis.min yaxis.max} {
-                set v1 [$lib1 get $path.$elem]
-                set v2 [$lib2 get $path.$elem]
-
-                if {[string is double -strict $v1]
-                      && [string is double -strict $v2]} {
-                    if {[Rappture::objects::ObjVal::cmpdbl $v1 $v2] != 0} {
-                        lappend diffs "value mismatch at $path.$elem"
-                    }
-                } elseif {$v1 ne $v2} {
-                    lappend diffs "value mismatch at $path.$elem"
-                }
-            }
-        }
-        loader {
-        }
-        default {
-            puts stderr "ignoring \"$type1\" for \"$path\""
-        }
-    }
-    return $diffs
-}
-
-# ----------------------------------------------------------------------
-# USAGE: diffattrs <attrList> <path> <lib1> <lib2>
-#
-# Used internally by the "diff" proc to look for a list of attributes
-# at the given <path> and see if there are any differences.  It is
-# considered a difference if the attribute is defined on one object
-# but not another, or if the string values are different.  Returns ""
-# if they are the same, and a list of differences if they are not.
-# ----------------------------------------------------------------------
-proc diffattrs {attrlist path lib1 lib2} {
-    set diffs ""
-    foreach name $attrlist {
-        set t1 [$lib1 element -as type $path.$name]
-        set t2 [$lib2 element -as type $path.$name]
-        if {$t1 ne "" || $t2 ne ""} {
-            if {[$lib1 get $path.$name] ne [$lib2 get $path.$name]} {
-                lappend diffs "attribute mismatch at $path.$name"
-            }
-        }
-    }
-    return $diffs
-}
-
-# ----------------------------------------------------------------------
-# USAGE: diffdatalines <path> <lib1> <lib2>
-#
-# Used internally by the "diff" proc to look for a list of attributes
-# at the given <path> and see if there are any differences.  It is
-# considered a difference if the attribute is defined on one object
-# but not another, or if the string values are different.  Returns ""
-# if they are the same, and a list of differences if they are not.
-# ----------------------------------------------------------------------
-proc diffdatalines {path lib1 lib2} {
-    set diffs ""
-
-    set data1 [split [string trim [$lib1 get $path]] \n]
-    set data2 [split [string trim [$lib2 get $path]] \n]
-    if {[llength $data1] != [llength $data2]} {
-        return [list "value mismatch at $path"]
-    }
-
-    foreach line1 $data1 line2 $data2 {
-        if {[llength $line1] != [llength $line2]} {
-            return [list "value mismatch at $path"]
-        }
-        foreach d1 $line1 d2 $line2 {
-            if {[string is double -strict $d1]
-                  && [string is double -strict $d2]} {
-                if {[Rappture::objects::ObjVal::cmpdbl $d1 $d2] != 0} {
-                    return [list "value mismatch at $path"]
-                }
-            } elseif {$d1 ne $d2} {
-                return [list "value mismatch at $path"]
-            }
-        }
-    }
-    return ""
-}
-
-# ======================================================================
-
-if {$argc < 2} {
-    puts stderr "USAGE: rpdiff file1.xml file2.xml"
-    exit 9
-}
-set lib1 [Rappture::library [lindex $argv 0]]
-set lib2 [Rappture::library [lindex $argv 1]]
-set path "output"
-if { $argc > 2 } {
-   set arg [lindex $argv 2]
-   if { $arg == "-path" && $argc == 4 } {
-      set path [lindex $argv 3]
-   }
-}
-
-# compute the differences
-set diffs [diff $path $lib1 $lib2]
-
-if {[llength $diffs] == 0} {
-    exit 0
-}
-
-# print a list of differences and exit
-foreach mesg $diffs {
-    puts $mesg
-}
-exit 1
Index: trunk/gui/apps/rptimes
===================================================================
--- trunk/gui/apps/rptimes	(revision 6716)
+++ 	(revision )
@@ -1,311 +1,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------
-#  RPTIMES
-#
-#  Scans through a series of run.xml files and puts their runtime info
-#  into a SQLite database.  This database can be used to predict
-#  future runtimes for runs with similar parameters.
-#
-#    USAGE:
-#    % rptimes <run.xml> ?<run.xml>...?
-#    % rptimes -v <sqliteDB>
-#
-#  Exits with status 0 if successful, and non-zero if any run.xml
-#  files cannot be processed.
-#
-#  Creates an SQLite DB for each unique tool referenced by a run.xml
-#  file.  Each DB file contains a table of parameters and a table of
-#  "jobs" info.  The jobs table includes CPU time and Wall time
-#  measurements.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2013  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-# \
-exec tclsh "$0" ${1+"$@"}
-# tclsh executes the rest...
-
-package require Rappture
-package require sqlite3
-package require md5
-package require base64
-
-if {[llength $argv] < 1} {
-    puts stderr "USAGE: rptimes run.xml ?run.xml...?"
-    puts stderr "USAGE: rptimes -v tool.sql3"
-    exit 1
-}
-
-set op "ingest"
-while {[llength $argv] > 0} {
-    set flag [lindex $argv 0]
-    if {![string match -* $flag]} {
-        break
-    }
-    switch -- $flag {
-        -v {
-            set op "view"
-            if {[llength $argv] < 2} {
-                puts stderr "USAGE: rptimes -v tool.sql3"
-                exit 1
-            }
-            set dbfile [lindex $argv 1]
-            set argv [lrange $argv 2 end]
-        }
-        default {
-            puts stderr "bad flag \"$flag\": should be -v"
-            exit 1
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: normval <libObj> <rappturePath> ?-default?
-#
-# Returns information about the normalized value of a particular input
-# in the Rappture run <libObj> at the specified <rappturePath> for the
-# input.  The optional -default switch causes the processing to apply
-# to the default value instead of the current value.
-#
-# Returns info as a list of values in the form:
-#
-#   <rappturePath> <type> <normValue>
-#   <rappturePath2> <type2> <normValue2>
-#   ...
-#
-# Most inputs return just 3 values: path/type/value.  But some inputs
-# split into multiple parts and return several triples.  Images, for
-# example, return a hash for the image itself, but also width/height
-# parameters.  The width/height may actually be the better predictors
-# of CPU time required.
-# ----------------------------------------------------------------------
-proc normval {libobj path {what "-current"}} {
-    set rlist ""
-
-    # get the default or the current raw value
-    set raw ""
-    switch -- $what {
-        -default {
-            set raw [$libobj get $path.default]
-        }
-        -current {
-            if {[$libobj element $path.current] ne ""} {
-                set raw [$libobj get $path.current]
-            } else {
-                set raw [$libobj get $path.default]
-            }
-        }
-        default {
-            error "bad option \"$what\": should be -current or -default"
-        }
-    }
-
-    # normalize the value depending on the type
-    switch -- [$libobj element -as type $path] {
-        integer {
-            lappend rlist $path "INTEGER" $raw
-        }
-        number {
-            set norm ""
-            if {$raw ne ""} {
-                # then normalize to default units
-                set units [$libobj get $path.units]
-                if {$units ne ""} {
-                    set norm [Rappture::Units::convert $raw \
-                        -context $units -to $units -units off]
-                }
-            }
-            lappend rlist $path "REAL" $norm
-        }
-        boolean - choice - loader - periodicelement {
-            lappend rlist $path "TEXT" $raw
-        }
-        image {
-            # convert long string inputs into a unique (short) hash
-            set norm [base64::encode [md5::md5 $raw]]
-            if {[catch {package require Img; wm withdraw .} result]} {
-                error "can't analyze <image> types: $result"
-            }
-            if {[catch {image create photo -data $raw} result]} {
-                error "can't analyze <image> data: $result"
-            }
-            set width [image width $result]
-            set height [image height $result]
-
-            lappend rlist $path "TEXT" $norm
-            lappend rlist $path-WIDTH "INTEGER" $width
-            lappend rlist $path-HEIGHT "INTEGER" $height
-        }
-        string {
-            # convert long string inputs into a unique (short) hash
-            set norm [base64::encode [md5::md5 $raw]]
-            lappend rlist $path "TEXT" $norm
-        }
-        structure {
-            # oops! structure doesn't have a clear .current value
-            # use the XML dump of the data as its "value"
-            if {$what eq "-current"} {
-                if {[catch {$libobj xml $path.current} raw]} {
-                    if {[catch {$libobj xml $path.default} raw]} {
-                        set raw ""
-                    }
-                }
-            } elseif {[catch {$libobj xml $path.default} raw]} {
-                set raw ""
-            }
-            set norm [base64::encode [md5::md5 $raw]]
-            lappend rlist $path "TEXT" $norm
-        }
-        default {
-            # for anything else, punt and use the raw value
-            lappend rlist $path "TEXT" $raw
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: escapeQuotes <string>
-#
-# Escapes single quotes in the given <string> by escaping the quote.
-# In SQLite, this is done by doubling the quote.  This makes it
-# possible to embed the string in another quoted string like
-# 'hello ''world'''.  Returns a string with escaped quotes.
-# ----------------------------------------------------------------------
-proc escapeQuotes {str} {
-    regsub -all {([^\'])\'} $str {\1''} str
-    return $str
-}
-
-#
-# Handle "view" operation
-#
-if {$op eq "view"} {
-    sqlite3 db $dbfile
-
-    puts "PARAMETERS:"
-    db eval {SELECT nickName,rappturePath,type FROM parameters;} data {
-        puts " - $data(nickName) ($data(type)) = $data(rappturePath)"
-    }
-
-    puts "\nJOBS:"
-    set n 0
-    db eval {SELECT runToken,date,cpuTime,wallTime FROM jobs;} data {
-        puts [format " [incr n]) [clock format $data(date)]:  %6.2f CPU, %6.2f Wall" $data(cpuTime) $data(wallTime)]
-    }
-
-    catch {db close}
-    exit 0
-}
-
-#
-# Run through each run.xml file and load params and execution time
-#
-set status 0
-foreach fname $argv {
-    set db ""
-    set err ""
-    if {[catch {Rappture::library $fname} libobj]} {
-        set err "failed: $fname ($libobj)"
-    }
-
-    set app [$libobj get tool.id]
-    set rev [$libobj get tool.version.application.revision]
-    if {$err eq ""} {
-        if {$app eq "" || $rev eq ""} {
-            set err "failed: $fname (missing app info -- is tool deployed?)"
-        } else {
-            set dbfile "${app}_r$rev.sql3"
-            if {![file exists $dbfile]} {
-                sqlite3 db $dbfile
-                db eval {CREATE TABLE parameters(nickName TEXT PRIMARY KEY, rappturePath TEXT, defValue TEXT, type TEXT);}
-                db eval {CREATE TABLE jobs(runToken TEXT, date TEXT, cpuTime REAL, wallTime REAL, nCpus INTEGER, venue TEXT);}
-            } else {
-                sqlite3 db $dbfile
-            }
-        }
-    }
-
-    if {$err eq "" && [set cput [$libobj get output.cputime]] eq ""} {
-        set err "failed: $fname (missing cpu time)"
-    }
-    if {$err eq "" && [set wallt [$libobj get output.walltime]] eq ""} {
-        set err "failed: $fname (missing wall time)"
-    }
-
-    set date "?"
-    if {$err eq "" && [$libobj get output.time] ne "" && [catch {clock scan [$libobj get output.time]} d] == 0} {
-        set date $d
-    }
-
-    if {$err eq "" && [$libobj get output.venue.name] ne ""} {
-        set venue [$libobj get output.venue.name]
-    } else {
-        set venue ""
-    }
-
-    if {$err eq "" && [$libobj get output.venue.ncpus] ne ""} {
-        set ncpus [$libobj get output.venue.ncpus]
-    } else {
-        set ncpus 1
-    }
-
-    if {$err eq ""} {
-        set runtoken [base64::encode [md5::md5 [$libobj xml]]]
-
-        set cols ""
-        set vals ""
-        foreach path [Rappture::entities $libobj input] {
-            # get the nickname (column name) for this paraemter
-            set id [db eval "SELECT nickName from parameters where rappturePath='$path'"]
-            if {$id eq ""} {
-                # haven't seen this parameter before -- add it
-                foreach {rp type def} [normval $libobj $path -default] {
-                    set num [db eval "SELECT COUNT(nickName) from parameters;"]
-                    set id [format "x%03d" [incr num]]
-
-                    db eval "INSERT INTO parameters values('$id','$rp','[escapeQuotes $def]','$type')"
-                    db eval "ALTER TABLE jobs ADD COLUMN $id $type;"
-                }
-            }
-
-            # add the current value onto the values we're building up for ALTER
-            foreach {raw norm} [Rappture::LibraryObj::value $libobj $path] break
-
-            foreach {rp type val} [normval $libobj $path] {
-                set num [db eval "SELECT COUNT(nickName) from parameters;"]
-                set id [db eval "SELECT nickName FROM parameters WHERE rappturePath='$rp'"]
-                if {$id eq ""} {
-                    set err "INTERNAL ERROR: couldn't find nickName for existing parameter $rp"
-                    break
-                }
-                lappend cols $id
-                if {$type eq "TEXT"} {
-                    lappend vals '[escapeQuotes $val]'
-                } elseif {$val ne ""} {
-                    lappend vals $val
-                } else {
-                    lappend vals ''
-                }
-            }
-        }
-
-        if {$err eq ""} {
-            # add the info for this job
-            db eval "DELETE from jobs WHERE runToken='$runtoken';"
-            db eval "INSERT INTO jobs (runToken,date,cpuTime,wallTime,nCpus,venue,[join $cols ,]) values ('$runtoken','$date',$cput,$wallt,$ncpus,'$venue',[join $vals ,]);"
-        }
-    }
-
-    if {$err ne ""} {
-        puts stderr $err
-        set status 1
-    }
-    catch {db close}
-}
-
-exit $status
Index: trunk/gui/apps/simsim.in
===================================================================
--- trunk/gui/apps/simsim.in	(revision 6716)
+++ 	(revision )
@@ -1,810 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ======================================================================
-#  AUTHOR:  Derrick S. Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-dir=`dirname $0` ; \
-. $dir/rappture.env ; \
-exec $dir/tclsh "$0" "$@"
-
-package require Rappture
-package require RapptureGUI
-
-proc defaultHandler {child} {
-    set childchildList {}
-    set units [$child get "units"]
-    # this is for nanowire
-    if {[string is integer -strict $units]} {
-        set units ""
-    }
-    set defaultVal [$child get "default"]
-    if {"" != $defaultVal} {
-        if {"" != $units} {
-            set defaultVal [Rappture::Units::convert $defaultVal \
-                            -context $units -to $units -units on]
-        }
-        $child put "current" $defaultVal
-    } else {
-        if {"components" != [$child element -as type]} {
-            set childchildList [$child children]
-        } elseif {"parameters" != [$child element -as type]} {
-            set childchildList [$child children]
-        } else {
-            set childchildList [$child children]
-        }
-    }
-    return $childchildList
-}
-
-proc numberHandler {child} {
-    set value ""
-    set units [$child get "units"]
-    set min [$child get "min"]
-    set max [$child get "max"]
-
-    if {"" != $min} {
-        if {"" != $units} {
-            # check to see if the user added units to their min value
-            # apps like mosfet need this check.
-            set min [Rappture::Units::convert $min \
-                        -context $units -to $units -units off]
-            if {[string is double -strict $min]} {
-                # pass
-            }
-        }
-    }
-
-    if {"" != $max} {
-        if {"" != $units} {
-            # check to see if the user added units to their min value
-            # apps like mosfet need this check.
-            set max [Rappture::Units::convert $max \
-                        -context $units -to $units -units off]
-            if {[string is double -strict $max]} {
-                # pass
-            }
-        }
-    }
-
-    if {"yes" == [$child get "simset"]} {
-        $child remove "simset"
-    } else {
-        if { ("" != $min) && ("" != $max) } {
-            set value [random $min $max]
-            $child put current $value$units
-        } else {
-            defaultHandler $child
-        }
-    }
-}
-
-proc integerHandler {child} {
-    set value ""
-    set units [$child get "units"]
-    set min [$child get "min"]
-    set max [$child get "max"]
-
-    # nanowire needs this because they set units == 0 and 1 ???
-    if {[string is integer -strict $units]} {
-        set units ""
-    }
-
-    if {"" != $min} {
-        if {"" != $units} {
-            # check to see if the user added units to their min value
-            # apps like mosfet need this check.
-            set min [Rappture::Units::convert $min \
-                        -context $units -to $units -units off]
-            if {[string is integer -strict $min]} {
-                # pass
-            }
-        }
-    }
-
-    if {"" != $max} {
-        if {"" != $units} {
-            # check to see if the user added units to their min value
-            # apps like mosfet need this check.
-            set max [Rappture::Units::convert $max \
-                        -context $units -to $units -units off]
-            if {[string is integer -strict $max]} {
-                # pass
-            }
-        }
-    }
-
-    if {"yes" == [$child get "simset"]} {
-        $child remove "simset"
-    } else {
-        if { ("" != $min) && ("" != $max) } {
-            set value [randomInt $min $max]
-            $child put current $value$units
-        } else {
-            defaultHandler $child
-        }
-    }
-
-}
-
-proc booleanHandler {child} {
-    if {"yes" == [$child get "simset"]} {
-        $child remove "simset"
-    } else {
-        set value [expr {int(rand()*2)}]
-        if {$value == 1} {
-            set value "yes"
-        } else {
-            set value "no"
-        }
-        $child put "current" $value
-    }
-}
-
-proc loaderHandler {child toolDir} {
-
-    set exDir [file join $toolDir "examples"]
-    if {! [file isdirectory $exDir]} {
-        # in this case we should try to keep processing, not exit
-        puts "could not find examples directory: $exDir"
-        exit 0
-    }
-
-    set exPathExp [$child get example]
-    set fpath [file join $exDir $exPathExp]
-    set exFileList [glob -nocomplain $fpath]
-
-    if {0 == [llength $exFileList]} {
-        puts "while searching examples directory: $exDir"
-        puts "could not open find files matching regex: $exPathExp"
-        set defaultEx [$child get "default"]
-        if {[file exists [file join $exDir $defaultEx]]} {
-            lappend exFileList $defaultEx
-            puts "using default example file"
-        } else {
-            puts "default example file does not exists, exiting"
-            exit 0;
-        }
-    }
-
-    set importExFileIdx [expr {int(rand()*[llength $exFileList])}]
-    set importExFile [lindex $exFileList $importExFileIdx]
-
-    if {! [file exists $importExFile]} {
-        # importExFile does not exist
-    }
-
-    set exlib [Rappture::library $importExFile]
-
-    # get the about.label from the file
-    # if about.label does not exist, use the file name
-    set importExLabel [$exlib get about.label]
-    if {"" != $importExLabel} {
-        set currentVal $importExLabel
-    } else {
-        set currentVal [file tail $importExFile]
-    }
-
-    $child put "current" $currentVal
-
-    set exlibChildList [::Rappture::entities -as object $exlib "input"]
-    return $exlibChildList
-}
-
-proc groupHandler {child} {
-    return [$child children -as object]
-}
-
-proc choiceHandler {valType child} {
-    if {"yes" == [$child get "simset"]} {
-        $child remove "simset"
-    } else {
-        set optList [$child children -as object -type option]
-        set optLib ""
-        set value ""
-        if {[llength $optList] > 0} {
-            if {"random" == $valType} {
-                set optIdx [expr {int(rand()*[llength $optList])}]
-                set optLib [lindex $optList $optIdx]
-                set value [$optLib get value]
-            } elseif {"default" == $valType} {
-                set defaultVal [$child get default]
-                foreach optLib $optList {
-                    set label [$optLib get about.label]
-                    set valTag [$optLib get value]
-                    if {($defaultVal == $label) || ($defaultVal == $valTag)} {
-                        set value $valTag
-                        break
-                    }
-                }
-            }
-
-            if {"" == $value} {
-                set optLib [lindex $optList 0]
-                set value [$optLib get value]
-                if {"" == $value} {
-                    set value [$optLib get about.label]
-                }
-            }
-        }
-        $child put "current" $value
-    }
-}
-
-proc defaultize {xmlobj toolDir} {
-    set childList [$xmlobj children -as object input]
-
-    while {[llength $childList]} {
-        set child [lrange $childList 0 0]
-        set childList [lreplace $childList 0 0]
-
-        switch -- [$child element -as type] {
-            number      { defaultHandler $child }
-            integer     { defaultHandler $child }
-            boolean     { defaultHandler $child }
-            string      { defaultHandler $child }
-            choice      { choiceHandler default $child }
-            loader      { loaderHandler  $child $toolDir }
-            structure   { defaultHandler $child }
-            group       { set cclist [groupHandler $child]
-                          set childList [concat $childList $cclist] }
-            phase       { set cclist [groupHandler $child]
-                          set childList [concat $childList $cclist] }
-            default     { defaultHandler $child }
-        }
-    }
-}
-
-proc randomize {presetArr xmlobj toolDir} {
-    upvar $presetArr presets
-    set childList [$xmlobj children -as object input]
-
-    while {[llength $childList]} {
-
-        set child [lrange $childList 0 0]
-        set childList [lreplace $childList 0 0]
-
-        set cpath [cleanPath [$child element -as path]]
-
-        set ppath [$child parent -as path]
-        set cPresets [array get presets $cpath*]
-
-        foreach {cPresetsPath cPresetsVal} $cPresets {
-            set cutIdx [expr {[string length $cpath] + 1}]
-            set iPath [string range $cPresetsPath $cutIdx end]
-
-            # apply the preset value and remove from preset array
-            $child put $iPath $cPresetsVal
-            unset presets($cPresetsPath)
-
-            # if the value was set on a current node, then set a preset flag
-            if {"current" == $iPath} {
-                $child put simset "yes"
-            }
-        }
-
-        switch -- [$child element -as type] {
-            number    { numberHandler  $child }
-            integer   { integerHandler $child }
-            boolean   { booleanHandler $child }
-            string    { defaultHandler $child }
-            choice    { choiceHandler random  $child }
-            loader    {
-                set cpath [$child element -as path]
-                set ccList [loaderHandler $child $toolDir]
-                foreach cc $ccList {
-                    set ccpath [$cc element -as path]
-                    # even though the loader might have been returned in ccList
-                    # do not add the loader back to the childList or you might
-                    # get an infinite loop
-                    if {$cpath != $ccpath} {
-                        set ccpath [cleanPath $ccpath]
-                        $xmlobj copy $ccpath from $cc ""
-                        lappend childList [$xmlobj element -as object $ccpath]
-                    }
-                }
-            }
-            structure { defaultHandler $child }
-            group     {
-                set ccList [groupHandler $child]
-                set childList [concat $childList $ccList]
-            }
-            phase     {
-                set ccList [groupHandler $child]
-                set childList [concat $childList $ccList]
-            }
-            default   { defaultHandler $child }
-        }
-    }
-}
-
-proc random {m M} {
-    return [expr {$m+(rand()*($M-$m))}]
-}
-
-proc randomInt {m M} {
-    return [expr {int(rand()*($M-$m+1)+$m)}]
-}
-
-proc cleanPath { path } {
-    if {"." == [string index $path 0]} {
-        # this is because tcl's library module (element -as path)
-        # returns a crazy dot in the 0th position
-        set path [string range $path 1 end]
-    }
-    return $path
-}
-
-proc parsePathVal {listVar returnVar} {
-    upvar $listVar params
-    upvar $returnVar presetArr
-    catch {unset presetArr}
-
-    # initialize variables
-    set pathValStr ""
-    set match "junk"
-
-    while {"" != $match} {
-        set match ""
-        set path ""
-        set val ""
-        set val2 ""
-        set val3 ""
-        set val4 ""
-        set pathValStr [string trimleft [join $params " "]]
-
-        # search the params for:
-        # 1) xml path
-        # 2) followed by = sign
-        # 3) followed by a starting " sign
-        # 4) followed by any text (including spaces)
-        # 5) followed by an ending " sign
-        # ex: input.number(temperature).current="400K"
-        # ex: input.number(temperature).current=400K
-        # ex: input.string(blahh).current="hi momma, i love you!"
-        #    \"([^\"]+)\"
-        #    ((\"([^\"]+)\")|(:([^:]+):)|(\'([^\']+)\')|([^\s]+))
-        regexp -expanded {
-            (
-                [a-zA-Z0-9]+(\([a-zA-Z0-9._]+\))?
-                (\.[a-zA-Z0-9]+(\([a-zA-Z0-9._]+\))?)*
-            )
-            =
-            ((\"([^\"]+)\")|(\'([^\']+)\')|([^\s]+))
-        } $pathValStr match path junk junk junk val junk val2 junk val3 val4
-
-
-        if {"" != $match} {
-            # remove the matching element from orphaned params list
-            foreach p [split $match] {
-                set paramsIdx [lsearch -exact $params $p]
-                set params [lreplace $params $paramsIdx $paramsIdx]
-            }
-
-            if {("" != $val2) && ("" == $val3) && ("" == $val4)} {
-                set val $val2
-            } elseif {("" == $val2) && ("" != $val3) && ("" == $val4)} {
-                set val $val3
-            } elseif {("" == $val2) && ("" == $val3) && ("" != $val4)} {
-                set val $val4
-            }
-
-            # add the name and value to our preset array
-            set presetArr($path) $val
-        }
-    }
-}
-
-proc printHelp {} {
-    set help {
-simsim [OPTIONS] [CONST]
-
-simulator simulator - simulate simulation
-
-OPTIONS:
- -tool <path>        - use the tool.xml file specified at <path>
- -values <valtype>   - the type of values used to populate driver file.
-                       valid <valtype>'s include:
-                       "default" - replace <current> values with <default>'s,
-                       "current" - use <current> values (ie do nothing),
-                       "random" - generate random values for <current>.
- -driver <path>      - write a driver file to <path>.
- -compare <path>     - compare the results with the run.xml
-                       file at <path>.
- -runfile <path>     - move the run file to <path>
- -nosim              - no simulation.
- -help               - print this help menu.
-
-CONST:
- when -values is set to random, constant values can be set for
- specific inputs. the general form for constant values is:
-
-   xmlpath(id)=value
-
- where xmlpath is the path of the element in the xml tree,
- id is the id of the xml node and value is the constant value
- you want to place in the element. the following the constant
- will set input.number(Ef).current to the value "2eV":
-
-   input.number(Ef)=2eV
-
-EXAMPLES:
-simulate using ./tool.xml, default values, no comparisons or driver
-    simsim
-
-simulate using ./tool.xml, random values, no comparisons or driver
-    simsim -values random
-
-from ./tool.xml, create a driver file named "mydriverfile.xml"
-with default values
-    simsim -nosim -driver mydriverfile.xml
-
-from ./tool.xml, create a driver file named "mydriverfile.xml"
-with random values
-    simsim -values random -nosim -driver mydriverfile.xml
-
-from ./tool.xml, simulate with random values but set
-input.number(Ef) to "2eV"
-    simsim -values random input.number(Ef).current=2eV
-
-run a simulation using the current values from driver.xml,
-"-values current" is only useful if you are asking
-simsim to run the simulation and you provide a driver file.
-    simsim -tool driver.xml -values current
-
-compare two xml file, don't do a simulation, don't print a driver.xml
-    simsim -tool driver.xml -compare previousrun.xml -nosim
-
-run a simulation and compare the result to previousrun.xml
-    simsim -compare previousrun.xml
-
-}
-    puts $help
-    exit 0
-}
-
-proc diffs {xmlobj1 xmlobj2} {
-    set rlist ""
-
-    # query the values for all entities in both objects
-    set thisv [concat [Rappture::entities $xmlobj1 "input"] [Rappture::entities $xmlobj1 "output"]]
-    set otherv [concat [Rappture::entities $xmlobj2 "input"] [Rappture::entities $xmlobj2 "output"]]
-
-    # scan through values for this object and compare against other one
-    foreach path $thisv {
-        set i [lsearch -exact $otherv $path]
-        if {$i < 0} {
-            foreach {raw norm} [value $xmlobj1 $path] break
-            lappend rlist - $path $raw ""
-        } else {
-            foreach {traw tnorm} [value $xmlobj1 $path] break
-            foreach {oraw onorm} [value $xmlobj2 $path] break
-            if {![string equal $tnorm $onorm]} {
-                lappend rlist c $path $traw $oraw
-            }
-            set otherv [lreplace $otherv $i $i]
-        }
-    }
-
-    #add any values left over in the other object
-    foreach path $otherv {
-        foreach {oraw onorm} [Rappture::LibraryObj::value $xmlobj2 $path] break
-        lappend rlist + $path "" $oraw
-    }
-    return $rlist
-}
-
-proc value {libobj path} {
-    switch -- [$libobj element -as type $path] {
-        structure {
-            set raw $path
-            # try to find a label to represent the structure
-            set val [$libobj get $path.about.label]
-            if {"" == $val} {
-                set val [$libobj get $path.current.about.label]
-            }
-            if {"" == $val} {
-                if {[$libobj element $path.current] != ""} {
-                    set comps [$libobj children $path.current.components]
-                    set val "<structure> with [llength $comps] components"
-                } else {
-                    set val "<structure>"
-                }
-            }
-            return [list $raw $val]
-        }
-        number {
-            # get the usual value...
-            set raw ""
-            if {"" != [$libobj element $path.current]} {
-                set raw [$libobj get $path.current]
-            } elseif {"" != [$libobj element $path.default]} {
-                set raw [$libobj get $path.default]
-            }
-            if {"" != $raw} {
-                set val $raw
-                # then normalize to default units
-                set units [$libobj get $path.units]
-                if {"" != $units} {
-                    set val [Rappture::Units::convert $val \
-                        -context $units -to $units -units off]
-                }
-            }
-            return [list $raw $val]
-        }
-        curve {
-            set raw ""
-            if {"" != [$libobj element $path.component.xy]} {
-                set raw [$libobj get $path.component.xy]
-            }
-            return [list $raw $raw]
-        }
-        log {
-            set raw ""
-            if {"" != [$libobj element]} {
-                set raw [$libobj get]
-            }
-            return [list $raw $raw]
-        }
-        cloud {
-            set raw ""
-            if {"" != [$libobj element $path.points]} {
-                set raw [$libobj get $path.points]
-            }
-            return [list $raw $raw]
-        }
-        field {
-            set raw ""
-            if {"" != [$libobj element $path.component.values]} {
-                set raw [$libobj get $path.component.values]
-            }
-            return [list $raw $raw]
-        }
-
-
-    }
-
-    # for all other types, get the value (current, or maybe default)
-    set raw ""
-    if {"" != [$libobj element $path.current]} {
-        set raw [$libobj get $path.current]
-    } elseif {"" != [$libobj element $path.default]} {
-        set raw [$libobj get $path.default]
-    }
-    return [list $raw $raw]
-}
-
-proc compare {orig result} {
-    if {"" == $orig} {
-        return
-    }
-    if {"" == $result} {
-        return
-    }
-
-    if {![Rappture::library isvalid $orig]} {
-        set origObj [Rappture::library $orig]
-        if {![Rappture::library isvalid $origObj]} {
-            puts "cannot create Rappture library from $orig\n"
-            return
-        }
-    } else {
-        set origObj $orig
-    }
-
-    if {![Rappture::library isvalid $result]} {
-        set resultObj [Rappture::library $result]
-        if {![Rappture::library isvalid $resultObj]} {
-            puts "cannot create Rappture library from $result\n"
-            return
-        }
-    } else {
-        set resultObj $result
-    }
-
-    foreach {op vpath oldval newval} [diffs $origObj $resultObj] {
-        puts "$op $vpath $oldval $newval"
-    }
-}
-
-proc parseOptions {listVar returnVar} {
-    upvar $listVar argv
-    upvar $returnVar params
-
-    # parse command line arguments
-    set argc [llength $argv]
-    for {set i 0} {$i < $argc} {incr i} {
-        set opt [lindex $argv $i]
-        if { ("-t" == $opt)    ||
-             ("-tool" == $opt) ||
-             ("--tool" == $opt)   } {
-            if {[expr {$i + 1}] < $argc} {
-                incr i
-                set params(--tool) [lindex $argv $i]
-                # need to check to see if file exists, if not raise error
-            } else {
-                printHelp
-            }
-        } elseif {  ("-tooldir" == $opt) ||
-                    ("--tooldir" == $opt)    } {
-            if {[expr {$i + 1}] < $argc} {
-                incr i
-                set params(--tooldir) [lindex $argv $i]
-                # need to check to see if directory exists, if not raise error
-            } else {
-                printHelp
-            }
-        } elseif {  ("-d" == $opt)      ||
-                    ("-driver" == $opt) ||
-                    ("--driver" == $opt)    } {
-            if {[expr {$i + 1}] < $argc} {
-                incr i
-                set params(--driver) [lindex $argv $i]
-                # need to check to see if file exists, if not raise error
-            } else {
-                printHelp
-            }
-        } elseif {  ("-r" == $opt)      ||
-                    ("-runfile" == $opt) ||
-                    ("--runfile" == $opt)    } {
-            if {[expr {$i + 1}] < $argc} {
-                incr i
-                set params(--runfile) [lindex $argv $i]
-            } else {
-                printHelp
-            }
-        } elseif {  ("-v" == $opt)      ||
-                    ("-values" == $opt) ||
-                    ("--values" == $opt)    } {
-            if {[expr {$i + 1}] < $argc} {
-                incr i
-                set valuesFlag [lindex $argv $i]
-                if {("default" == $valuesFlag) ||
-                    ("current" == $valuesFlag) ||
-                    ("random" == $valuesFlag)  } {
-                    set params(--values) $valuesFlag
-                } else {
-                    printHelp
-                }
-            } else {
-                printHelp
-            }
-        } elseif {  ("-c" == $opt)      ||
-                    ("-compare" == $opt)||
-                    ("--compare" == $opt)   } {
-            if {[expr {$i + 1}] < $argc} {
-                incr i
-                set params(--compare) [lindex $argv $i]
-                # need to check to see if file exists, if not raise error
-            } else {
-                printHelp
-            }
-        } elseif {  ("-n" == $opt)      ||
-                    ("-nosim" == $opt)  ||
-                    ("--nosim" == $opt)     } {
-            set params(--nosim) true
-        } elseif {  ("-h" == $opt)      ||
-                    ("-help" == $opt)   ||
-                    ("--help" == $opt)      } {
-            printHelp
-        } else {
-            # place all extra params in the params array
-            lappend params(oParams) $opt
-        }
-    }
-}
-
-proc storeoutput {data} {
-    global _d
-    append _d $data
-}
-
-proc main {argv} {
-    # set default values
-    array set presets []
-    set i 0
-
-    array set params {
-        --compare ""
-        --values default
-        --nosim false
-        --driver ""
-        --runfile ""
-        --tool "./tool.xml"
-        --tooldir ""
-        oParams {}
-    }
-
-    parseOptions argv params
-
-    # keep the wish window from popping up
-    catch {wm withdraw .}
-
-    # parse out path=val combinations from the list of orphaned parameters
-    parsePathVal params(oParams) presets
-    if {0 != [llength $params(oParams)]} {
-        puts "Could not understand the following parameters"
-        puts "params(oParams) = $params(oParams)"
-        puts "length params(oParams) = [llength $params(oParams)]"
-    }
-
-    set err ""
-    if {! [file exists $params(--tool)]} {
-        append err "\ntool file \""
-        append err $params(--tool)
-        append err "\" does not exist, use -t option\n"
-        puts $err
-        printHelp
-    }
-
-    set xmlobj [Rappture::library $params(--tool)]
-    if {$params(--tooldir) == ""} {
-        set installdir [file dirname $params(--tool)]
-    } else {
-        set installdir $params(--tooldir)
-    }
-
-    # need a better way to do this,
-    # maybe just take xmldiff functionality out of simsim
-    if {(!$params(--nosim)) || ("" != $params(--driver))} {
-        switch -- $params(--values) {
-            random      { randomize presets $xmlobj $installdir }
-            current     { }
-            default     { defaultize $xmlobj $installdir }
-        }
-    }
-
-    if {"" != $params(--driver)} {
-        set fid [open $params(--driver) w]
-        puts $fid {<?xml version="1.0"?>}
-        puts $fid [$xmlobj xml]
-        close $fid
-    }
-
-    if {$params(--nosim)} {
-        if {"" != $params(--compare)} {
-            compare $xmlobj $params(--compare)
-        }
-        exit 0
-    }
-
-
-
-
-    set tool [Rappture::Tool ::#auto $xmlobj $installdir]
-
-    # read the run.xml file.
-    # from analyzer.tcl:
-
-    set result ""
-    # execute the job
-    foreach {status result} [eval $tool run -output storeoutput] break
-
-    # if run was successful, check to see if we should compare
-    if {$status == 0 && $result != "ABORT"} {
-        global _d
-        if {[regexp {=RAPPTURE-RUN=>([^\n]+)} $_d match result]} {
-            if {[string compare "" $params(--runfile)] != 0} {
-                if {[catch {file rename -force -- $result $params(--runfile)} out]} {
-                    puts stderr "while moving $result to $params(--runfile): $out"
-                }
-            }
-            # do comparison if user chose to compare with other results
-            if {"" != $params(--compare)} {
-                compare $params(--compare) $result
-            }
-        } else {
-            set status 1
-            puts "Can't find result file in output.\nDid you call Rappture::result in your simulator?"
-        }
-    } else {
-        puts $result
-    }
-}
-
-main $argv
-exit 0
Index: trunk/gui/apps/table
===================================================================
--- trunk/gui/apps/table	(revision 6716)
+++ 	(revision )
@@ -1,347 +1,0 @@
-# -*- mode: Tcl -*-
-
-package require Rappture
-package require RapptureGUI
-
-# TK code
-package require fileutil
-proc is_xml {name} {return [string match *.xml $name]}
-
-# Starting main tk code
-
-package require BLT
-if { $tcl_version >= 8.0 } {
-    namespace import blt::*
-    namespace import -force blt::tile::*
-}
-
-proc SortColumn { column } {
-    set old [.t sort cget -column]
-    set decreasing 0
-    if { "$old" == "$column" } {
-        set decreasing [.t sort cget -decreasing]
-        set decreasing [expr !$decreasing]
-    }
-    .t sort configure -decreasing $decreasing -column $column -mode integer
-    if { ![.t cget -flat] } {
-        .t configure -flat yes
-    }
-    .t sort auto yes
-    blt::busy hold .t
-    update
-    blt::busy release .t
-}
-
-proc resulttable {cmpfiles} {
-    # creating xml tables for each xml run files go here
-    set tree2 [tree create]
-    treeview .k \
-        -width 0 \
-        -yscrollcommand { .vvvs set } \
-        -xscrollcommand { .hhhs set } \
-        -selectmode single \
-        -tree $tree2
-    .k column configure treeView -text ""
-    .k column configure treeView -hide no -edit no \
-        -icon blt::tv::normalOpenFolder
-    focus .k
-    scrollbar .vvvs -orient vertical -command { .k yview }
-    scrollbar .hhhs -orient horizontal -command { .k xview }
-
-    table . \
-        0,0 .k -fill both \
-        0,1 .vvvs -fill y \
-        1,0 .hhhs -fill x
-    table configure . c1 r1 -resize none
-
-    puts "resulttable: $cmpfiles"
-
-    set flags [list]
-    set numfiles [llength $cmpfiles]
-    set biglist [list]
-
-    set memberlist [list]
-    set contentlist [list]
-    set counter 0
-    foreach filepath $cmpfiles {
-        set filename [file tail $filepath]
-        set lib [Rappture::library $filepath]
-        set inputs [$lib children -as component "input"]
-        foreach input $inputs {
-            set path "input.${input}.current"
-            if {$counter == 0} {
-                lappend memberlist $path
-            }
-            set value [$lib get $path]
-            puts "$path: $value"
-            lappend contentlist $value
-            unset value
-        }
-        set outputs [$lib children -as component "output"]
-        foreach output $outputs {
-            set path "output.${output}"
-            set value [$lib get $path]
-            if {"" != $value} {
-                if {$counter == 0} {
-                    lappend memberlist $path
-                }
-                puts "$path: $value"
-                lappend contentlist $value
-                unset value
-            }
-        }
-        set temp [list]
-        lappend temp $filename $contentlist
-        unset contentlist
-        lappend biglist $temp
-        unset temp
-        incr counter;
-    }
-    #puts memberlist
-    #puts $memberlist
-    puts "START_BIG_LIST [llength $biglist]"
-    puts $biglist
-    puts END_BIG_LIST
-    # Adding columns to table
-    #.k column insert end "filename" -text "File Name"
-    foreach path $memberlist {
-        puts "add column: $path"
-        if { "" == $path } {
-            continue
-        }
-        .k column insert end $path -text $path
-    }
-    # Comparing XML Tree
-    set count 0
-    set element1 [lindex $biglist 0]
-    set name1 [lindex $element1 0]
-    set content1 [lindex $element1 1]
-    foreach element2 $biglist {
-        if {$count != 0} {
-            foreach {name2 content2} $element2 {
-                set contentlen [llength $content2]
-                for {set i 0} {$i < $contentlen} {incr i} {
-                    #puts insideforloop
-                    set similarexisted 0
-                    if {[lindex $content1 $i] eq [lindex $content2 $i]} {
-                        #puts insidesame
-                    } else {
-                        #puts insidediff
-                        lappend flags 1
-                        continue
-                    }
-                    if { $similarexisted == 0 } {
-                        lappend flags 0
-                    }
-                }
-            }
-        }
-        incr count
-    }
-
-    foreach element $biglist {
-        set name [lindex $element 0]
-        set content [lindex $element 1]
-        set id [.k insert end $name]
-        set list_content [list]
-        foreach path $memberlist value $content flag $flags {
-            lappend list_content $path
-
-            if { $flag == 0} {
-                lappend list_content "Same"
-            } else {
-                lappend list_content $value
-            }
-        }
-        puts [llength $list_content]
-        puts $list_content
-        .k entry configure $id -data $list_content
-    }
-
-    #set templist [list]
-    #lappend templist "input.number(n1).current"
-    #lappend templist "h"
-    #lappend templist "input.number(n2).current"
-    #lappend templist "i"
-    #lappend templist "output.number(sum).current"
-    #lappend templist "k"
-    #.k entry configure $id -data $templist
-    #.k entry configure $id \
-    #    -data [list input.number(n1).current "h" input.number(n2).current "i" output.number(sum).current "k"]
-}
-
-proc newtable {appname} {
-    global tree1
-
-    set tree1 [tree create]
-    treeview .h \
-        -width 0 \
-        -yscrollcommand { .vvs set } \
-        -xscrollcommand { .hhs set } \
-        -selectmode single \
-        -tree $tree1
-    .h column configure treeView -text ""
-    .h column configure treeView -hide yes -edit no \
-        -icon blt::tv::normalOpenFolder
-    focus .h
-    scrollbar .vvs -orient vertical -command { .h yview }
-    scrollbar .hhs -orient horizontal -command { .h xview }
-
-    .h style checkbox mycheck -onvalue "yes" -offvalue "no" -showvalue yes
-    .h column insert end select -text "Select" -edit yes -style mycheck
-
-    table . \
-        0,0 .h  -fill both \
-        0,1 .vvs -fill y \
-        1,0 .hhs -fill x
-    table configure . c1 r1 -resize none
-
-    # Starting tk code
-    .h column insert end "tname" -text "Tool Name"
-    .h column insert end "date"  -text "Date"
-    global env
-    set files [fileutil::find $env(HOME)/data/results is_xml]
-    if {$files == ""} {
-    } else {
-        foreach line $files {
-            set fileone [open $line]
-            set content [read $fileone]
-            close $fileone
-            regexp {<title>(.*)</title>} $content junk title
-            if {![info exists title]} {
-                continue
-            }
-            set title [string trim $title]
-            set time ""
-            regexp {<time>(.*)</time>} $content junk time
-            set time [string trim $time]
-            #if {($params(-title) == "") || ($params(-title) == $title)} {
-            #    set id [.t insert end $line]
-            #    .t entry configure $id -data [list tname $title date $time]
-            #}
-            #
-            #set id [.h insert end $line]
-            if { $appname == $title } {
-                set id [.h insert end $line]
-                .h entry configure $id \
-                    -data [list tname $title date $time select yes]
-            }
-            unset fileone
-            unset content
-            unset title
-            unset time
-            if {[info exists junk]} { unset junk }
-            unset line
-        }
-    }
-    .h bind all <ButtonRelease-1> {
-    }
-
-    button .compare -text "Compare" -command compare
-    blt::table .  \
-        2,0 .compare -anchor e -columnspan 2
-
-    proc compare {} {
-        global tree1
-        # declaring lists
-        set filename [list]
-
-        foreach node [$tree1 children root] {
-            set label [$tree1 label $node]
-            set select [$tree1 get $node "select"]
-            set tname [$tree1 get $node "tname"]
-            puts stderr "found at node $node: select=$select tname=$tname"
-            if { $select == "yes" } {
-                puts $label
-                lappend filename $label
-            }
-        }
-        set cmpfileslen [llength $filename]
-        resulttable $filename
-    }
-    #foreach column [.h column names] {
-    #    .h column configure $column -command [list SortColumn $column]
-    #}
-}
-
-proc startupcode {} {
-    set tree [tree create]
-    treeview .t \
-        -width 0 \
-        -yscrollcommand { .vs set } \
-        -xscrollcommand { .hs set } \
-        -selectmode single \
-        -tree $tree
-    .t column configure treeView -text ""
-    .t column configure treeView -hide yes -edit no \
-        -icon blt::tv::normalOpenFolder
-    focus .t
-    scrollbar .vs -orient vertical -command { .t yview }
-    scrollbar .hs -orient horizontal -command { .t xview }
-    table . \
-        0,0 .t -fill both \
-        0,1 .vs -fill y \
-        1,0 .hs -fill x
-    table configure . c1 r1 -resize none
-    .t column insert end "appname" -text "Application Name"
-    .t column insert end "xmlfilename" -text "File Name"
-    global env
-    set files [fileutil::find $env(HOME)/data/results is_xml]
-    set appnamelist [list]
-    if {$files == ""} {
-    } else {
-        foreach line $files {
-            set existed false
-            set fileone [open $line]
-            set content [read $fileone]
-            close $fileone
-            regexp {<title>(.*)</title>} $content junk title
-            if {![info exists title]} {
-                puts stderr "ERROR: No title found in $line"
-                continue
-            }
-            set title [string trim $title]
-            #puts "found title: $title"
-
-            foreach app $appnamelist {
-                if {$title == $app} {
-                    set existed true
-                    break
-                }
-            }
-            if { ! $existed } {
-                set temp [file tail $line]
-                set id [.t insert end $line]
-                .t entry configure $id \
-                    -data [list appname $title xmlfilename $temp]
-                lappend appnamelist $title
-            }
-            unset existed
-            unset fileone
-            unset content
-            unset title
-            unset line
-        }
-        #puts $appnamelist
-    }
-
-    .t bind all <ButtonRelease-1> {
-        set ids [.t curselection]
-        set name [eval .t get -full $ids]
-        set fileone [open $name]
-        set content [read $fileone]
-        close $fileone
-        regexp {<title>(.*)</title>} $content junk title
-        set title [string trim $title]
-        # pass title and display the result in new page
-        newtable $title
-    }
-}
-
-startupcode
-
-#blt::treeview .t
-#set node [.t insert end root "one"]
-#treeview .h -bg white
-#.h configure -background "green"
-#set id [.h insert end "myEntry"]
Index: trunk/gui/apps/vtkglyphs-test
===================================================================
--- trunk/gui/apps/vtkglyphs-test	(revision 6716)
+++ 	(revision )
@@ -1,374 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for VtkGlyphViewer
-#
-#  This program is a test harness for the VtkVis visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the VtkVis
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-. $bindir/rappture.env ; \
-exec $bindir/wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# Fake data object for sending VTK data file...
-# ----------------------------------------------------------------------
-itcl::class visData {
-    inherit Rappture::Field
-
-    constructor {args} {
-        Rappture::Field::constructor [Rappture::library standard] ""
-    } {
-        set _data [lindex $args 0]
-        GetTypeAndSize $_cname
-        GetAssociation $_cname
-        ReadVtkDataSet $_cname $_data
-        set _type [lindex $args 1]
-    }
-
-    public method components {args} {
-        Rappture::getopts args params {
-            flag what -name default
-            flag what -dimensions
-            flag what -style
-            flag what -particles
-            flag what -flow
-            flag what -box
-        }
-        if { $params(what) == "-dimensions" } {
-            return "${_dim}D"
-        }
-        if {[llength $args] == 0} {
-            return $_cname
-        }
-        return ""
-    }
-    public method isvalid {} {
-        return 1
-    }
-    public method data {args} {
-        return $_data
-    }
-    public method vtkdata {args} {
-        return $_data
-    }
-    public method values {args} {
-        return $_data
-    }
-    public method style {args} {
-        return ""
-    }
-    public method hints {args} {
-        return ""
-    }
-    public method type {args} {
-        return $_type
-    }
-    public method viewer {args} {
-        return "glyphs"
-    }
-    public method shape {args} {
-        return "arrow"
-    }
-
-    private variable _cname "one"
-    private variable _data ""
-    private variable _type ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "vtk"]
-        $widgets(vtkglyphviewer) add $obj
-        $widgets(vtkglyphviewer) scale $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    namespace eval Rappture::VtkGlyphViewer [list $widgets(vtkglyphviewer) SendCmd $cmd]
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(vtkglyphviewer) delete
-    $widgets(vtkglyphviewer) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(vtkglyphviewer) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(vtkglyphviewer) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "VtkGlyphViewer: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-radiobutton .images.cntls.legend -text "Legend" -variable images(which) \
-    -value "legend" -command images_refresh
-pack .images.cntls.legend -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 500
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send VTK File..." -underline 0 -command send_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-. configure -menu .mbar
-
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::VtkGlyphViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(vtkglyphviewer) $f.viewer
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/vtkheightmap-test
===================================================================
--- trunk/gui/apps/vtkheightmap-test	(revision 6716)
+++ 	(revision )
@@ -1,371 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for VtkHeightmapViewer
-#
-#  This program is a test harness for the VtkVis visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the VtkVis
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-. $bindir/rappture.env ; \
-exec $bindir/wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# Fake data object for sending VTK data file...
-# ----------------------------------------------------------------------
-itcl::class visData {
-    inherit Rappture::Field
-
-    constructor {args} {
-        Rappture::Field::constructor [Rappture::library standard] ""
-    } {
-        set _data [lindex $args 0]
-        GetTypeAndSize $_cname
-        GetAssociation $_cname
-        ReadVtkDataSet $_cname $_data
-        set _type [lindex $args 1]
-    }
-
-    public method components {args} {
-        Rappture::getopts args params {
-            flag what -name default
-            flag what -dimensions
-            flag what -style
-            flag what -particles
-            flag what -flow
-            flag what -box
-        }
-        if { $params(what) == "-dimensions" } {
-            return "${_dim}D"
-        }
-        if {[llength $args] == 0} {
-            return $_cname
-        }
-        return ""
-    }
-    public method isvalid {} {
-        return 1
-    }
-    public method data {args} {
-        return $_data
-    }
-    public method vtkdata {args} {
-        return $_data
-    }
-    public method values {args} {
-        return $_data
-    }
-    public method style {args} {
-        return ""
-    }
-    public method hints {args} {
-        return ""
-    }
-    public method type {args} {
-        return $_type
-    }
-    public method viewer {args} {
-        return "contour"
-    }
-
-    private variable _cname "one"
-    private variable _data ""
-    private variable _type ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File As Contour"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "vtk"]
-        $widgets(vtkheightmapviewer) add $obj
-        $widgets(vtkheightmapviewer) scale $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    namespace eval Rappture::VtkHeightmapViewer [list $widgets(vtkheightmapviewer) SendCmd $cmd]
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(vtkheightmapviewer) delete
-    $widgets(vtkheightmapviewer) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(vtkheightmapviewer) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(vtkheightmapviewer) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "VtkHeightmapViewer: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-radiobutton .images.cntls.legend -text "Legend" -variable images(which) \
-    -value "legend" -command images_refresh
-pack .images.cntls.legend -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 500
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send VTK File..." -underline 0 -command send_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-. configure -menu .mbar
-
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::VtkHeightmapViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(vtkheightmapviewer) $f.viewer
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/vtkisosurface-test
===================================================================
--- trunk/gui/apps/vtkisosurface-test	(revision 6716)
+++ 	(revision )
@@ -1,371 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for VtkIsosurfaceViewer
-#
-#  This program is a test harness for the VtkVis visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the VtkVis
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-. $bindir/rappture.env ; \
-exec $bindir/wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# Fake data object for sending VTK data file...
-# ----------------------------------------------------------------------
-itcl::class visData {
-    inherit Rappture::Field
-
-    constructor {args} {
-        Rappture::Field::constructor [Rappture::library standard] ""
-    } {
-        set _data [lindex $args 0]
-        GetTypeAndSize $_cname
-        GetAssociation $_cname
-        ReadVtkDataSet $_cname $_data
-        set _type [lindex $args 1]
-    }
-
-    public method components {args} {
-        Rappture::getopts args params {
-            flag what -name default
-            flag what -dimensions
-            flag what -style
-            flag what -particles
-            flag what -flow
-            flag what -box
-        }
-        if { $params(what) == "-dimensions" } {
-            return "${_dim}D"
-        }
-        if {[llength $args] == 0} {
-            return $_cname
-        }
-        return ""
-    }
-    public method isvalid {} {
-        return 1
-    }
-    public method data {args} {
-        return $_data
-    }
-    public method vtkdata {args} {
-        return $_data
-    }
-    public method values {args} {
-        return $_data
-    }
-    public method style {args} {
-        return ""
-    }
-    public method hints {args} {
-        return ""
-    }
-    public method type {args} {
-        return $_type
-    }
-    public method viewer {args} {
-        return "isosurface"
-    }
-
-    private variable _cname "one"
-    private variable _data ""
-    private variable _type ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "vtk"]
-        $widgets(vtkisosurfaceviewer) add $obj
-        $widgets(vtkisosurfaceviewer) scale $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    namespace eval Rappture::VtkIsosurfaceViewer [list $widgets(vtkisosurfaceviewer) SendCmd $cmd]
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(vtkisosurfaceviewer) delete
-    $widgets(vtkisosurfaceviewer) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(vtkisosurfaceviewer) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(vtkisosurfaceviewer) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "VtkIsosurfaceViewer: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-radiobutton .images.cntls.legend -text "Legend" -variable images(which) \
-    -value "legend" -command images_refresh
-pack .images.cntls.legend -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 500
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send VTK File..." -underline 0 -command send_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-. configure -menu .mbar
-
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::VtkIsosurfaceViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(vtkisosurfaceviewer) $f.viewer
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/vtkstreamlines-test
===================================================================
--- trunk/gui/apps/vtkstreamlines-test	(revision 6716)
+++ 	(revision )
@@ -1,371 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for VtkStreamlinesViewer
-#
-#  This program is a test harness for the VtkVis visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the VtkVis
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-. $bindir/rappture.env ; \
-exec $bindir/wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# Fake data object for sending VTK data file...
-# ----------------------------------------------------------------------
-itcl::class visData {
-    inherit Rappture::Field
-
-    constructor {args} {
-        Rappture::Field::constructor [Rappture::library standard] ""
-    } {
-        set _data [lindex $args 0]
-        GetTypeAndSize $_cname
-        GetAssociation $_cname
-        ReadVtkDataSet $_cname $_data
-        set _type [lindex $args 1]
-    }
-
-    public method components {args} {
-        Rappture::getopts args params {
-            flag what -name default
-            flag what -dimensions
-            flag what -style
-            flag what -particles
-            flag what -flow
-            flag what -box
-        }
-        if { $params(what) == "-dimensions" } {
-            return "${_dim}D"
-        }
-        if {[llength $args] == 0} {
-            return $_cname
-        }
-        return ""
-    }
-    public method isvalid {} {
-        return 1
-    }
-    public method data {args} {
-        return $_data
-    }
-    public method vtkdata {args} {
-        return $_data
-    }
-    public method values {args} {
-        return $_data
-    }
-    public method style {args} {
-        return ""
-    }
-    public method hints {args} {
-        return ""
-    }
-    public method type {args} {
-        return $_type
-    }
-    public method viewer {args} {
-        return "streamlines"
-    }
-
-    private variable _cname "one"
-    private variable _data ""
-    private variable _type ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "vtk"]
-        $widgets(vtkviewer) add $obj
-        $widgets(vtkviewer) scale $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    namespace eval Rappture::VtkStreamlinesViewer [list $widgets(vtkviewer) SendCmd $cmd]
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(vtkviewer) delete
-    $widgets(vtkviewer) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(vtkviewer) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(vtkviewer) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "Vtkviewer: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-radiobutton .images.cntls.legend -text "Legend" -variable images(which) \
-    -value "legend" -command images_refresh
-pack .images.cntls.legend -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 500
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send VTK File..." -underline 0 -command send_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-. configure -menu .mbar
-
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::VtkStreamlinesViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(vtkviewer) $f.viewer
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/vtkviewer-test
===================================================================
--- trunk/gui/apps/vtkviewer-test	(revision 6716)
+++ 	(revision )
@@ -1,415 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for VtkViewer
-#
-#  This program is a test harness for the VtkVis visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the VtkVis
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-. $bindir/rappture.env ; \
-exec $bindir/wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# Fake data object for sending VTK data file...
-# ----------------------------------------------------------------------
-itcl::class visData {
-    inherit Rappture::Drawing
-
-    constructor {args} {
-        Rappture::Drawing::constructor [Rappture::library standard] ""
-    } {
-        set _data [lindex $args 0]
-        set _type [lindex $args 1]
-    }
-
-    public method components {args} {
-        if {[llength $args] == 0} {
-            return "one"
-        }
-        return ""
-    }
-    public method data {args} {
-        return $_data
-    }
-    public method vtkdata {args} {
-        return $_data
-    }
-    public method values {args} {
-        return $_data
-    }
-    public method hints {args} {
-        return ""
-    }
-    public method type {args} {
-        return $_type
-    }
-    public method shape {args} {
-        return "sphere"
-    }
-
-    private variable _data ""
-    private variable _type ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File as PolyData"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "polydata"]
-        $widgets(vtkviewer) add $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_streamlines_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_streamlines_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File as Streamlines"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "streamlines"]
-        $widgets(vtkviewer) add $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_glyphs_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_glyphs_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File as Glyphs"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "glyphs"]
-        $widgets(vtkviewer) add $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_molecule_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_molecule_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File as Molecule"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "molecule"]
-        $widgets(vtkviewer) add $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    namespace eval Rappture::VtkViewer [list $widgets(vtkviewer) SendCmd $cmd]
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(vtkviewer) delete
-    $widgets(vtkviewer) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(vtkviewer) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(vtkviewer) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "Vtkviewer: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-radiobutton .images.cntls.legend -text "Legend" -variable images(which) \
-    -value "legend" -command images_refresh
-pack .images.cntls.legend -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 500
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send VTK File..." -underline 0 -command send_file
-.mbar.file add command -label "Send VTK File as Streamlines..." -underline 0 -command send_streamlines_file
-.mbar.file add command -label "Send VTK File as Glyphs..." -underline 0 -command send_glyphs_file
-.mbar.file add command -label "Send VTK File as Molecule..." -underline 0 -command send_molecule_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-. configure -menu .mbar
-
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::VtkViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(vtkviewer) $f.viewer
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/vtkvolume-test
===================================================================
--- trunk/gui/apps/vtkvolume-test	(revision 6716)
+++ 	(revision )
@@ -1,371 +1,0 @@
-#!/bin/sh
-# -*- mode: Tcl -*-
-# ----------------------------------------------------------------------
-#  TEST PROGRAM for VtkVolumeViewer
-#
-#  This program is a test harness for the VtkVis visualization
-#  engine.  It allows you to monitor the commands being sent back
-#  and forth between a standard Rappture application and the VtkVis
-#  server.  You can also send your own commands to the server, to
-#  debug new features.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-#\
-bindir=`dirname $0` ; \
-. $bindir/rappture.env ; \
-exec $bindir/wish "$0" "$@"
-# ----------------------------------------------------------------------
-# wish executes everything from here on...
-package require Itcl
-package require Rappture
-package require RapptureGUI
-
-option add *comm.font -*-courier-medium-r-normal-*-*-120-*
-option add *Menu.tearOff off
-
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-*-120-*
-option add *ResultSet.controlbarBackground #6666cc
-option add *ResultSet.controlbarForeground white
-option add *ResultSet.activeControlBackground #ccccff
-option add *ResultSet.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-*-180-*
-
-# fix the "grab" command to support a stack of grab windows
-#Rappture::grab::init
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# Fake data object for sending VTK data file...
-# ----------------------------------------------------------------------
-itcl::class visData {
-    inherit Rappture::Field
-
-    constructor {args} {
-        Rappture::Field::constructor [Rappture::library standard] ""
-    } {
-        set _data [lindex $args 0]
-        GetTypeAndSize $_cname
-        GetAssociation $_cname
-        ReadVtkDataSet $_cname $_data
-        set _type [lindex $args 1]
-    }
-
-    public method components {args} {
-        Rappture::getopts args params {
-            flag what -name default
-            flag what -dimensions
-            flag what -style
-            flag what -particles
-            flag what -flow
-            flag what -box
-        }
-        if { $params(what) == "-dimensions" } {
-            return "${_dim}D"
-        }
-        if {[llength $args] == 0} {
-            return "one"
-        }
-        return ""
-    }
-    public method isvalid {} {
-        return 1
-    }
-    public method data {args} {
-        return $_data
-    }
-    public method vtkdata {args} {
-        return $_data
-    }
-    public method values {args} {
-        return $_data
-    }
-    public method style {args} {
-        return ""
-    }
-    public method hints {args} {
-        return ""
-    }
-    public method type {args} {
-        return $_type
-    }
-    public method viewer {args} {
-        return "vtkvolume"
-    }
-
-    private variable _cname "one"
-    private variable _data ""
-    private variable _type ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_file
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc send_file {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open VTK File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary -encoding binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-        set obj [visData #auto $info "vtkvolume"]
-        $widgets(vtkvolumeviewer) add $obj
-        $widgets(vtkvolumeviewer) scale $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load_script
-#
-# Prompts the user for a text file, and then sends the text within
-# that file along to the rendering widget.
-# ----------------------------------------------------------------------
-proc load_script {} {
-    global widgets
-
-    set file [tk_getOpenFile -title "Open Command File"]
-    if {"" != $file && [catch {
-            set fid [open $file r]
-            fconfigure $fid -translation binary
-            set info [read $fid]
-            close $fid
-          }] == 0} {
-
-        $widgets(command) insert 0 $info
-        send_command
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send_command
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-proc send_command {} {
-    global widgets
-    global last_command
-
-    set cmd [$widgets(command) get]
-
-    if {[string length $cmd] > 0} {
-        set last_command $cmd
-    } else {
-        set cmd $last_command
-    }
-    namespace eval Rappture::VtkVolumeViewer [list $widgets(vtkvolumeviewer) SendCmd $cmd]
-    $widgets(command) delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Used internally to reset the connection to the rendering server.
-# Discards all data and resets the widget connection to the server.
-# ----------------------------------------------------------------------
-proc reset {} {
-    global widgets
-    $widgets(vtkvolumeviewer) delete
-    $widgets(vtkvolumeviewer) disconnect
-    $widgets(comm) configure -state normal
-    $widgets(comm) delete 1.0 end
-    $widgets(comm) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: show_comm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-proc show_comm {channel {data ""}} {
-    global widgets
-
-    $widgets(comm) configure -state normal
-    switch -- $channel {
-        closed {
-            $widgets(comm) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $widgets(comm) insert end $data incoming "\n" incoming
-            images_refresh
-        }
-        >>line {
-            $widgets(comm) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $widgets(comm) insert end $data error "\n" error
-        }
-        default {
-            $widgets(comm) insert end "$data\n"
-        }
-    }
-    $widgets(comm) configure -state disabled
-    $widgets(comm) see end
-}
-
-# ----------------------------------------------------------------------
-# TOPLEVEL FOR IMAGES
-# ----------------------------------------------------------------------
-# USAGE: images_save
-#
-# Invoked when the user presses the "Save As..." button on the
-# images panel.  Saves the current image in a file, which can be
-# examined by some external program.
-# ----------------------------------------------------------------------
-proc images_save {} {
-    global widgets images
-
-    set imh [$widgets(vtkvolumeviewer) get -image $images(which)]
-
-    set file [tk_getSaveFile -title "Save Image File" \
-        -defaultextension .jpg -filetypes {{{JPEG files} .jpg} {{All Files} *}}]
-
-    if {"" != $file} {
-        set cmds {
-            $imh write $file -format jpeg
-        }
-        if {[catch $cmds err]} {
-            tk_messageBox -icon error -message "Oops!  Save failed:\n$err"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: images_refresh
-#
-# Invoked automatically whenever there is a change in the view/legend
-# controls on the images panel.  Updates the image being shown based
-# on the current selection.
-# ----------------------------------------------------------------------
-proc images_refresh {} {
-    global widgets images
-    set c $widgets(viewer)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set imh [$widgets(vtkvolumeviewer) get -image $images(which)]
-    set iw [image width $imh]
-    set ih [image height $imh]
-
-    $c coords image [expr {$w/2}] [expr {$h/2}]
-    $c itemconfigure image -image $imh
-    $c coords outline [expr {$w/2-$iw/2}] [expr {$h/2-$ih/2}] \
-        [expr {$w/2+$iw/2}] [expr {$h/2+$ih/2}]
-}
-
-toplevel .images
-wm title .images "Vtkvolumeviewer: Images"
-wm withdraw .images
-wm protocol .images WM_DELETE_WINDOW {wm withdraw .images}
-
-frame .images.cntls
-pack .images.cntls -side bottom -fill x
-button .images.cntls.save -text "Save As..." -command images_save
-pack .images.cntls.save -side right -padx 4
-radiobutton .images.cntls.view -text "3D View" -variable images(which) \
-    -value "view" -command images_refresh
-pack .images.cntls.view -side top -anchor w
-radiobutton .images.cntls.legend -text "Legend" -variable images(which) \
-    -value "legend" -command images_refresh
-pack .images.cntls.legend -side top -anchor w
-set images(which) "view"
-
-canvas .images.viewer -background black -width 500 -height 500
-pack .images.viewer -expand yes -fill both
-bind .images.viewer <Configure> images_refresh
-set widgets(viewer) .images.viewer
-
-$widgets(viewer) create image 0 0 -anchor c \
-    -image [image create photo] -tags image
-$widgets(viewer) create rectangle 0 0 1 1 -width 2 -outline red -fill "" \
-    -tags outline
-
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-menu .mbar
-menu .mbar.file
-.mbar.file add command -label "Send VTK File..." -underline 0 -command send_file
-.mbar.file add command -label "Load script..." -underline 0 -command load_script
-.mbar.file add command -label "Reset" -underline 0 -command reset
-.mbar.file add separator
-.mbar.file add command -label "Exit" -underline 1 -command exit
-.mbar add cascade -label "File" -underline 0 -menu .mbar.file
-
-menu .mbar.view
-.mbar.view add command -label "Images..." -underline 0 \
-    -command {wm deiconify .images}
-.mbar add cascade -label "View" -underline 0 -menu .mbar.view
-
-. configure -menu .mbar
-
-
-Rappture::Panes .main -sashwidth 4 -sashrelief raised -sashpadding 4 \
-    -width 6i -height 4i
-pack .main -expand yes -fill both
-
-set f [.main pane 0]
-Rappture::VtkVolumeViewer $f.viewer
-pack $f.viewer -expand yes -fill both
-set widgets(vtkvolumeviewer) $f.viewer
-
-$f.viewer configure \
-    -sendcommand show_comm \
-    -receivecommand show_comm
-
-set f [.main insert end -fraction 0.5]
-frame $f.send
-pack $f.send -side bottom -fill x
-label $f.send.l -text "Send:"
-pack $f.send.l -side left
-set widgets(command) [entry $f.send.e]
-pack $f.send.e -side left -expand yes -fill x
-bind $f.send.e <KeyPress-Return> send_command
-
-scrollbar $f.sb -orient vertical -command "$f.comm yview"
-pack $f.sb -side right -fill y
-text $f.comm -wrap char -yscrollcommand "$f.sb set"
-pack $f.comm -expand yes -fill both
-set widgets(comm) $f.comm
-
-$widgets(comm) tag configure error -foreground red \
-    -font -*-courier-medium-o-normal-*-*-120-*
-$widgets(comm) tag configure incoming -foreground blue
Index: trunk/gui/apps/xmldiff.in
===================================================================
--- trunk/gui/apps/xmldiff.in	(revision 6716)
+++ 	(revision )
@@ -1,14 +1,0 @@
-#!/bin/sh
-# ----------------------------------------------------------------------
-#  XMLDIFF
-#
-#  get a text list of differences between two xml files
-#
-# ======================================================================
-#  AUTHOR:  Derrick S. Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-exec simsim --nosim --tool $1 --compare $2
Index: trunk/gui/configure
===================================================================
--- trunk/gui/configure	(revision 6716)
+++ 	(revision )
@@ -1,4341 +1,0 @@
-#! /bin/sh
-# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for RapptureGUI 1.9.
-#
-# Report bugs to <rappture@nanohub.org>.
-#
-#
-# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
-#
-#
-# This configure script is free software; the Free Software Foundation
-# gives unlimited permission to copy, distribute and modify it.
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-# Use a proper internal environment variable to ensure we don't fall
-  # into an infinite loop, continuously re-executing ourselves.
-  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
-    _as_can_reexec=no; export _as_can_reexec;
-    # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-as_fn_exit 255
-  fi
-  # We don't want this to propagate to other subprocesses.
-          { _as_can_reexec=; unset _as_can_reexec;}
-if test "x$CONFIG_SHELL" = x; then
-  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '\${1+\"\$@\"}'='\"\$@\"'
-  setopt NO_GLOB_SUBST
-else
-  case \`(set -o) 2>/dev/null\` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-"
-  as_required="as_fn_return () { (exit \$1); }
-as_fn_success () { as_fn_return 0; }
-as_fn_failure () { as_fn_return 1; }
-as_fn_ret_success () { return 0; }
-as_fn_ret_failure () { return 1; }
-
-exitcode=0
-as_fn_success || { exitcode=1; echo as_fn_success failed.; }
-as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
-as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
-as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
-if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
-
-else
-  exitcode=1; echo positional parameters were not saved.
-fi
-test x\$exitcode = x0 || exit 1
-test -x / || exit 1"
-  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
-  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
-  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
-  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1"
-  if (eval "$as_required") 2>/dev/null; then :
-  as_have_required=yes
-else
-  as_have_required=no
-fi
-  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
-
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-as_found=false
-for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  as_found=:
-  case $as_dir in #(
-	 /*)
-	   for as_base in sh bash ksh sh5; do
-	     # Try only shells that exist, to save several forks.
-	     as_shell=$as_dir/$as_base
-	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
-		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  CONFIG_SHELL=$as_shell as_have_required=yes
-		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
-  break 2
-fi
-fi
-	   done;;
-       esac
-  as_found=false
-done
-$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
-	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
-  CONFIG_SHELL=$SHELL as_have_required=yes
-fi; }
-IFS=$as_save_IFS
-
-
-      if test "x$CONFIG_SHELL" != x; then :
-  export CONFIG_SHELL
-             # We cannot yet assume a decent shell, so we have to provide a
-# neutralization value for shells without unset; and this also
-# works around shells that cannot unset nonexistent variables.
-# Preserve -v and -x to the replacement shell.
-BASH_ENV=/dev/null
-ENV=/dev/null
-(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
-case $- in # ((((
-  *v*x* | *x*v* ) as_opts=-vx ;;
-  *v* ) as_opts=-v ;;
-  *x* ) as_opts=-x ;;
-  * ) as_opts= ;;
-esac
-exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
-# Admittedly, this is quite paranoid, since all the known shells bail
-# out after a failed `exec'.
-$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
-exit 255
-fi
-
-    if test x$as_have_required = xno; then :
-  $as_echo "$0: This script requires a shell more modern than all"
-  $as_echo "$0: the shells that I found on your system."
-  if test x${ZSH_VERSION+set} = xset ; then
-    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
-    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
-  else
-    $as_echo "$0: Please tell bug-autoconf@gnu.org and
-$0: rappture@nanohub.org about your system, including any
-$0: error possibly output before this message. Then install
-$0: a modern shell, or manually run the script under such a
-$0: shell if you do have one."
-  fi
-  exit 1
-fi
-fi
-fi
-SHELL=${CONFIG_SHELL-/bin/sh}
-export SHELL
-# Unset more variables known to interfere with behavior of common tools.
-CLICOLOR_FORCE= GREP_OPTIONS=
-unset CLICOLOR_FORCE GREP_OPTIONS
-
-## --------------------- ##
-## M4sh Shell Functions. ##
-## --------------------- ##
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-
-  as_lineno_1=$LINENO as_lineno_1a=$LINENO
-  as_lineno_2=$LINENO as_lineno_2a=$LINENO
-  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
-  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
-  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
-  sed -n '
-    p
-    /[$]LINENO/=
-  ' <$as_myself |
-    sed '
-      s/[$]LINENO.*/&-/
-      t lineno
-      b
-      :lineno
-      N
-      :loop
-      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
-      t loop
-      s/-\n.*//
-    ' >$as_me.lineno &&
-  chmod +x "$as_me.lineno" ||
-    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
-
-  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
-  # already done that, so ensure we don't try to do so again and fall
-  # in an infinite loop.  This has already happened in practice.
-  _as_can_reexec=no; export _as_can_reexec
-  # Don't try to exec as it changes $[0], causing all sort of problems
-  # (the dirname of $[0] is not the place where we might find the
-  # original and so on.  Autoconf is especially sensitive to this).
-  . "./$as_me.lineno"
-  # Exit status is that of the last command.
-  exit
-}
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... but there are two gotchas:
-    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -pR'
-  fi
-else
-  as_ln_s='cp -pR'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-test -n "$DJDIR" || exec 7<&0 </dev/null
-exec 6>&1
-
-# Name of the host.
-# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
-# so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
-
-#
-# Initializations.
-#
-ac_default_prefix=/usr/local
-ac_clean_files=
-ac_config_libobj_dir=.
-LIBOBJS=
-cross_compiling=no
-subdirs=
-MFLAGS=
-MAKEFLAGS=
-
-# Identity of this package.
-PACKAGE_NAME='RapptureGUI'
-PACKAGE_TARNAME='rappturegui'
-PACKAGE_VERSION='1.9'
-PACKAGE_STRING='RapptureGUI 1.9'
-PACKAGE_BUGREPORT='rappture@nanohub.org'
-PACKAGE_URL=''
-
-ac_subst_vars='LTLIBOBJS
-LIBOBJS
-TK_VERSION
-TK_XLIBSW
-TK_SRC_DIR
-TK_LIB_SPEC
-TK_INC_SPEC
-TCL_VERSION
-TCL_STLIB_LD
-TCL_SRC_DIR
-TCL_SHLIB_SUFFIX
-TCL_SHLIB_LDFLAGS
-TCL_SHLIB_LD
-TCL_SHLIB_CFLAGS
-TCL_LIB_SPEC
-TCL_INC_SPEC
-TCL_CFLAGS_OPTIMIZE
-TCL_CFLAGS_DEBUG
-SVN_VERSION
-SVN_URL
-INSTALL_PREFIX
-TCLSH
-ENABLE_GUI
-MAKE
-OBJEXT
-EXEEXT
-ac_ct_CC
-CPPFLAGS
-LDFLAGS
-CFLAGS
-CC
-SET_MAKE
-MKDIR_P
-LN_S
-RANLIB
-INSTALL_DATA
-INSTALL_SCRIPT
-INSTALL_PROGRAM
-LIB_SEARCH_DIRS
-target_os
-target_vendor
-target_cpu
-target
-host_os
-host_vendor
-host_cpu
-host
-build_os
-build_vendor
-build_cpu
-build
-target_alias
-host_alias
-build_alias
-LIBS
-ECHO_T
-ECHO_N
-ECHO_C
-DEFS
-mandir
-localedir
-libdir
-psdir
-pdfdir
-dvidir
-htmldir
-infodir
-docdir
-oldincludedir
-includedir
-localstatedir
-sharedstatedir
-sysconfdir
-datadir
-datarootdir
-libexecdir
-sbindir
-bindir
-program_transform_name
-prefix
-exec_prefix
-PACKAGE_URL
-PACKAGE_BUGREPORT
-PACKAGE_STRING
-PACKAGE_VERSION
-PACKAGE_TARNAME
-PACKAGE_NAME
-PATH_SEPARATOR
-SHELL'
-ac_subst_files=''
-ac_user_opts='
-enable_option_checking
-enable_gui
-with_tclsh
-'
-      ac_precious_vars='build_alias
-host_alias
-target_alias
-CC
-CFLAGS
-LDFLAGS
-LIBS
-CPPFLAGS'
-
-
-# Initialize some variables set by options.
-ac_init_help=
-ac_init_version=false
-ac_unrecognized_opts=
-ac_unrecognized_sep=
-# The variables have the same names as the options, with
-# dashes changed to underlines.
-cache_file=/dev/null
-exec_prefix=NONE
-no_create=
-no_recursion=
-prefix=NONE
-program_prefix=NONE
-program_suffix=NONE
-program_transform_name=s,x,x,
-silent=
-site=
-srcdir=
-verbose=
-x_includes=NONE
-x_libraries=NONE
-
-# Installation directory options.
-# These are left unexpanded so users can "make install exec_prefix=/foo"
-# and all the variables that are supposed to be based on exec_prefix
-# by default will actually change.
-# Use braces instead of parens because sh, perl, etc. also accept them.
-# (The list follows the same order as the GNU Coding Standards.)
-bindir='${exec_prefix}/bin'
-sbindir='${exec_prefix}/sbin'
-libexecdir='${exec_prefix}/libexec'
-datarootdir='${prefix}/share'
-datadir='${datarootdir}'
-sysconfdir='${prefix}/etc'
-sharedstatedir='${prefix}/com'
-localstatedir='${prefix}/var'
-includedir='${prefix}/include'
-oldincludedir='/usr/include'
-docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
-infodir='${datarootdir}/info'
-htmldir='${docdir}'
-dvidir='${docdir}'
-pdfdir='${docdir}'
-psdir='${docdir}'
-libdir='${exec_prefix}/lib'
-localedir='${datarootdir}/locale'
-mandir='${datarootdir}/man'
-
-ac_prev=
-ac_dashdash=
-for ac_option
-do
-  # If the previous option needs an argument, assign it.
-  if test -n "$ac_prev"; then
-    eval $ac_prev=\$ac_option
-    ac_prev=
-    continue
-  fi
-
-  case $ac_option in
-  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
-  *=)   ac_optarg= ;;
-  *)    ac_optarg=yes ;;
-  esac
-
-  # Accept the important Cygnus configure options, so we can diagnose typos.
-
-  case $ac_dashdash$ac_option in
-  --)
-    ac_dashdash=yes ;;
-
-  -bindir | --bindir | --bindi | --bind | --bin | --bi)
-    ac_prev=bindir ;;
-  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
-    bindir=$ac_optarg ;;
-
-  -build | --build | --buil | --bui | --bu)
-    ac_prev=build_alias ;;
-  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
-    build_alias=$ac_optarg ;;
-
-  -cache-file | --cache-file | --cache-fil | --cache-fi \
-  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
-    ac_prev=cache_file ;;
-  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
-  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
-    cache_file=$ac_optarg ;;
-
-  --config-cache | -C)
-    cache_file=config.cache ;;
-
-  -datadir | --datadir | --datadi | --datad)
-    ac_prev=datadir ;;
-  -datadir=* | --datadir=* | --datadi=* | --datad=*)
-    datadir=$ac_optarg ;;
-
-  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
-  | --dataroo | --dataro | --datar)
-    ac_prev=datarootdir ;;
-  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
-  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
-    datarootdir=$ac_optarg ;;
-
-  -disable-* | --disable-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"enable_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval enable_$ac_useropt=no ;;
-
-  -docdir | --docdir | --docdi | --doc | --do)
-    ac_prev=docdir ;;
-  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
-    docdir=$ac_optarg ;;
-
-  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
-    ac_prev=dvidir ;;
-  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
-    dvidir=$ac_optarg ;;
-
-  -enable-* | --enable-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid feature name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"enable_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval enable_$ac_useropt=\$ac_optarg ;;
-
-  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
-  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
-  | --exec | --exe | --ex)
-    ac_prev=exec_prefix ;;
-  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
-  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
-  | --exec=* | --exe=* | --ex=*)
-    exec_prefix=$ac_optarg ;;
-
-  -gas | --gas | --ga | --g)
-    # Obsolete; use --with-gas.
-    with_gas=yes ;;
-
-  -help | --help | --hel | --he | -h)
-    ac_init_help=long ;;
-  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
-    ac_init_help=recursive ;;
-  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
-    ac_init_help=short ;;
-
-  -host | --host | --hos | --ho)
-    ac_prev=host_alias ;;
-  -host=* | --host=* | --hos=* | --ho=*)
-    host_alias=$ac_optarg ;;
-
-  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
-    ac_prev=htmldir ;;
-  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
-  | --ht=*)
-    htmldir=$ac_optarg ;;
-
-  -includedir | --includedir | --includedi | --included | --include \
-  | --includ | --inclu | --incl | --inc)
-    ac_prev=includedir ;;
-  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
-  | --includ=* | --inclu=* | --incl=* | --inc=*)
-    includedir=$ac_optarg ;;
-
-  -infodir | --infodir | --infodi | --infod | --info | --inf)
-    ac_prev=infodir ;;
-  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
-    infodir=$ac_optarg ;;
-
-  -libdir | --libdir | --libdi | --libd)
-    ac_prev=libdir ;;
-  -libdir=* | --libdir=* | --libdi=* | --libd=*)
-    libdir=$ac_optarg ;;
-
-  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
-  | --libexe | --libex | --libe)
-    ac_prev=libexecdir ;;
-  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
-  | --libexe=* | --libex=* | --libe=*)
-    libexecdir=$ac_optarg ;;
-
-  -localedir | --localedir | --localedi | --localed | --locale)
-    ac_prev=localedir ;;
-  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
-    localedir=$ac_optarg ;;
-
-  -localstatedir | --localstatedir | --localstatedi | --localstated \
-  | --localstate | --localstat | --localsta | --localst | --locals)
-    ac_prev=localstatedir ;;
-  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
-  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
-    localstatedir=$ac_optarg ;;
-
-  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
-    ac_prev=mandir ;;
-  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
-    mandir=$ac_optarg ;;
-
-  -nfp | --nfp | --nf)
-    # Obsolete; use --without-fp.
-    with_fp=no ;;
-
-  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
-  | --no-cr | --no-c | -n)
-    no_create=yes ;;
-
-  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
-  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
-    no_recursion=yes ;;
-
-  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
-  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
-  | --oldin | --oldi | --old | --ol | --o)
-    ac_prev=oldincludedir ;;
-  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
-  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
-  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
-    oldincludedir=$ac_optarg ;;
-
-  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
-    ac_prev=prefix ;;
-  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
-    prefix=$ac_optarg ;;
-
-  -program-prefix | --program-prefix | --program-prefi | --program-pref \
-  | --program-pre | --program-pr | --program-p)
-    ac_prev=program_prefix ;;
-  -program-prefix=* | --program-prefix=* | --program-prefi=* \
-  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
-    program_prefix=$ac_optarg ;;
-
-  -program-suffix | --program-suffix | --program-suffi | --program-suff \
-  | --program-suf | --program-su | --program-s)
-    ac_prev=program_suffix ;;
-  -program-suffix=* | --program-suffix=* | --program-suffi=* \
-  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
-    program_suffix=$ac_optarg ;;
-
-  -program-transform-name | --program-transform-name \
-  | --program-transform-nam | --program-transform-na \
-  | --program-transform-n | --program-transform- \
-  | --program-transform | --program-transfor \
-  | --program-transfo | --program-transf \
-  | --program-trans | --program-tran \
-  | --progr-tra | --program-tr | --program-t)
-    ac_prev=program_transform_name ;;
-  -program-transform-name=* | --program-transform-name=* \
-  | --program-transform-nam=* | --program-transform-na=* \
-  | --program-transform-n=* | --program-transform-=* \
-  | --program-transform=* | --program-transfor=* \
-  | --program-transfo=* | --program-transf=* \
-  | --program-trans=* | --program-tran=* \
-  | --progr-tra=* | --program-tr=* | --program-t=*)
-    program_transform_name=$ac_optarg ;;
-
-  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
-    ac_prev=pdfdir ;;
-  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
-    pdfdir=$ac_optarg ;;
-
-  -psdir | --psdir | --psdi | --psd | --ps)
-    ac_prev=psdir ;;
-  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
-    psdir=$ac_optarg ;;
-
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil)
-    silent=yes ;;
-
-  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
-    ac_prev=sbindir ;;
-  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
-  | --sbi=* | --sb=*)
-    sbindir=$ac_optarg ;;
-
-  -sharedstatedir | --sharedstatedir | --sharedstatedi \
-  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
-  | --sharedst | --shareds | --shared | --share | --shar \
-  | --sha | --sh)
-    ac_prev=sharedstatedir ;;
-  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
-  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
-  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
-  | --sha=* | --sh=*)
-    sharedstatedir=$ac_optarg ;;
-
-  -site | --site | --sit)
-    ac_prev=site ;;
-  -site=* | --site=* | --sit=*)
-    site=$ac_optarg ;;
-
-  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
-    ac_prev=srcdir ;;
-  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
-    srcdir=$ac_optarg ;;
-
-  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
-  | --syscon | --sysco | --sysc | --sys | --sy)
-    ac_prev=sysconfdir ;;
-  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
-  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
-    sysconfdir=$ac_optarg ;;
-
-  -target | --target | --targe | --targ | --tar | --ta | --t)
-    ac_prev=target_alias ;;
-  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
-    target_alias=$ac_optarg ;;
-
-  -v | -verbose | --verbose | --verbos | --verbo | --verb)
-    verbose=yes ;;
-
-  -version | --version | --versio | --versi | --vers | -V)
-    ac_init_version=: ;;
-
-  -with-* | --with-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"with_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval with_$ac_useropt=\$ac_optarg ;;
-
-  -without-* | --without-*)
-    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
-    # Reject names that are not valid shell variable names.
-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
-      as_fn_error $? "invalid package name: $ac_useropt"
-    ac_useropt_orig=$ac_useropt
-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
-    case $ac_user_opts in
-      *"
-"with_$ac_useropt"
-"*) ;;
-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
-	 ac_unrecognized_sep=', ';;
-    esac
-    eval with_$ac_useropt=no ;;
-
-  --x)
-    # Obsolete; use --with-x.
-    with_x=yes ;;
-
-  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
-  | --x-incl | --x-inc | --x-in | --x-i)
-    ac_prev=x_includes ;;
-  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
-  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
-    x_includes=$ac_optarg ;;
-
-  -x-libraries | --x-libraries | --x-librarie | --x-librari \
-  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
-    ac_prev=x_libraries ;;
-  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
-  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
-    x_libraries=$ac_optarg ;;
-
-  -*) as_fn_error $? "unrecognized option: \`$ac_option'
-Try \`$0 --help' for more information"
-    ;;
-
-  *=*)
-    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
-    # Reject names that are not valid shell variable names.
-    case $ac_envvar in #(
-      '' | [0-9]* | *[!_$as_cr_alnum]* )
-      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
-    esac
-    eval $ac_envvar=\$ac_optarg
-    export $ac_envvar ;;
-
-  *)
-    # FIXME: should be removed in autoconf 3.0.
-    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
-    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
-      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
-    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
-    ;;
-
-  esac
-done
-
-if test -n "$ac_prev"; then
-  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
-  as_fn_error $? "missing argument to $ac_option"
-fi
-
-if test -n "$ac_unrecognized_opts"; then
-  case $enable_option_checking in
-    no) ;;
-    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
-    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
-  esac
-fi
-
-# Check all directory arguments for consistency.
-for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
-		datadir sysconfdir sharedstatedir localstatedir includedir \
-		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir
-do
-  eval ac_val=\$$ac_var
-  # Remove trailing slashes.
-  case $ac_val in
-    */ )
-      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
-      eval $ac_var=\$ac_val;;
-  esac
-  # Be sure to have absolute directory names.
-  case $ac_val in
-    [\\/$]* | ?:[\\/]* )  continue;;
-    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
-  esac
-  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
-done
-
-# There might be people who depend on the old broken behavior: `$host'
-# used to hold the argument of --host etc.
-# FIXME: To remove some day.
-build=$build_alias
-host=$host_alias
-target=$target_alias
-
-# FIXME: To remove some day.
-if test "x$host_alias" != x; then
-  if test "x$build_alias" = x; then
-    cross_compiling=maybe
-  elif test "x$build_alias" != "x$host_alias"; then
-    cross_compiling=yes
-  fi
-fi
-
-ac_tool_prefix=
-test -n "$host_alias" && ac_tool_prefix=$host_alias-
-
-test "$silent" = yes && exec 6>/dev/null
-
-
-ac_pwd=`pwd` && test -n "$ac_pwd" &&
-ac_ls_di=`ls -di .` &&
-ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
-  as_fn_error $? "working directory cannot be determined"
-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
-  as_fn_error $? "pwd does not report name of working directory"
-
-
-# Find the source files, if location was not specified.
-if test -z "$srcdir"; then
-  ac_srcdir_defaulted=yes
-  # Try the directory containing this script, then the parent directory.
-  ac_confdir=`$as_dirname -- "$as_myself" ||
-$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_myself" : 'X\(//\)[^/]' \| \
-	 X"$as_myself" : 'X\(//\)$' \| \
-	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_myself" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-  srcdir=$ac_confdir
-  if test ! -r "$srcdir/$ac_unique_file"; then
-    srcdir=..
-  fi
-else
-  ac_srcdir_defaulted=no
-fi
-if test ! -r "$srcdir/$ac_unique_file"; then
-  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
-  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
-fi
-ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
-ac_abs_confdir=`(
-	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
-	pwd)`
-# When building in place, set srcdir=.
-if test "$ac_abs_confdir" = "$ac_pwd"; then
-  srcdir=.
-fi
-# Remove unnecessary trailing slashes from srcdir.
-# Double slashes in file names in object file debugging info
-# mess up M-x gdb in Emacs.
-case $srcdir in
-*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
-esac
-for ac_var in $ac_precious_vars; do
-  eval ac_env_${ac_var}_set=\${${ac_var}+set}
-  eval ac_env_${ac_var}_value=\$${ac_var}
-  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
-  eval ac_cv_env_${ac_var}_value=\$${ac_var}
-done
-
-#
-# Report the --help message.
-#
-if test "$ac_init_help" = "long"; then
-  # Omit some internal or obsolete options to make the list less imposing.
-  # This message is too long to be a string in the A/UX 3.1 sh.
-  cat <<_ACEOF
-\`configure' configures RapptureGUI 1.9 to adapt to many kinds of systems.
-
-Usage: $0 [OPTION]... [VAR=VALUE]...
-
-To assign environment variables (e.g., CC, CFLAGS...), specify them as
-VAR=VALUE.  See below for descriptions of some of the useful variables.
-
-Defaults for the options are specified in brackets.
-
-Configuration:
-  -h, --help              display this help and exit
-      --help=short        display options specific to this package
-      --help=recursive    display the short help of all the included packages
-  -V, --version           display version information and exit
-  -q, --quiet, --silent   do not print \`checking ...' messages
-      --cache-file=FILE   cache test results in FILE [disabled]
-  -C, --config-cache      alias for \`--cache-file=config.cache'
-  -n, --no-create         do not create output files
-      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
-
-Installation directories:
-  --prefix=PREFIX         install architecture-independent files in PREFIX
-                          [$ac_default_prefix]
-  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
-                          [PREFIX]
-
-By default, \`make install' will install all the files in
-\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
-an installation prefix other than \`$ac_default_prefix' using \`--prefix',
-for instance \`--prefix=\$HOME'.
-
-For better control, use the options below.
-
-Fine tuning of the installation directories:
-  --bindir=DIR            user executables [EPREFIX/bin]
-  --sbindir=DIR           system admin executables [EPREFIX/sbin]
-  --libexecdir=DIR        program executables [EPREFIX/libexec]
-  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
-  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
-  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --libdir=DIR            object code libraries [EPREFIX/lib]
-  --includedir=DIR        C header files [PREFIX/include]
-  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
-  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
-  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
-  --infodir=DIR           info documentation [DATAROOTDIR/info]
-  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
-  --mandir=DIR            man documentation [DATAROOTDIR/man]
-  --docdir=DIR            documentation root [DATAROOTDIR/doc/rappturegui]
-  --htmldir=DIR           html documentation [DOCDIR]
-  --dvidir=DIR            dvi documentation [DOCDIR]
-  --pdfdir=DIR            pdf documentation [DOCDIR]
-  --psdir=DIR             ps documentation [DOCDIR]
-_ACEOF
-
-  cat <<\_ACEOF
-
-System types:
-  --build=BUILD     configure for building on BUILD [guessed]
-  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
-  --target=TARGET   configure for building compilers for TARGET [HOST]
-_ACEOF
-fi
-
-if test -n "$ac_init_help"; then
-  case $ac_init_help in
-     short | recursive ) echo "Configuration of RapptureGUI 1.9:";;
-   esac
-  cat <<\_ACEOF
-
-Optional Features:
-  --disable-option-checking  ignore unrecognized --enable/--with options
-  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
-  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
-  --enable-gui            build code related to the graphical user interface
-                          [default=yes]
-
-Optional Packages:
-  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
-  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
-  --with-tclsh=DIR        location of tclsh [default=yes]
-
-Some influential environment variables:
-  CC          C compiler command
-  CFLAGS      C compiler flags
-  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
-              nonstandard directory <lib dir>
-  LIBS        libraries to pass to the linker, e.g. -l<library>
-  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
-              you have headers in a nonstandard directory <include dir>
-
-Use these variables to override the choices made by `configure' or to help
-it to find libraries and programs with nonstandard names/locations.
-
-Report bugs to <rappture@nanohub.org>.
-_ACEOF
-ac_status=$?
-fi
-
-if test "$ac_init_help" = "recursive"; then
-  # If there are subdirs, report their specific --help.
-  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
-    test -d "$ac_dir" ||
-      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
-      continue
-    ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-    cd "$ac_dir" || { ac_status=$?; continue; }
-    # Check for guested configure.
-    if test -f "$ac_srcdir/configure.gnu"; then
-      echo &&
-      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
-    elif test -f "$ac_srcdir/configure"; then
-      echo &&
-      $SHELL "$ac_srcdir/configure" --help=recursive
-    else
-      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
-    fi || ac_status=$?
-    cd "$ac_pwd" || { ac_status=$?; break; }
-  done
-fi
-
-test -n "$ac_init_help" && exit $ac_status
-if $ac_init_version; then
-  cat <<\_ACEOF
-RapptureGUI configure 1.9
-generated by GNU Autoconf 2.69
-
-Copyright (C) 2012 Free Software Foundation, Inc.
-This configure script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it.
-_ACEOF
-  exit
-fi
-
-## ------------------------ ##
-## Autoconf initialization. ##
-## ------------------------ ##
-
-# ac_fn_c_try_compile LINENO
-# --------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_c_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_c_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_c_try_compile
-cat >config.log <<_ACEOF
-This file contains any messages produced by compilers while
-running configure, to aid debugging if configure makes a mistake.
-
-It was created by RapptureGUI $as_me 1.9, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
-
-  $ $0 $@
-
-_ACEOF
-exec 5>>config.log
-{
-cat <<_ASUNAME
-## --------- ##
-## Platform. ##
-## --------- ##
-
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
-uname -m = `(uname -m) 2>/dev/null || echo unknown`
-uname -r = `(uname -r) 2>/dev/null || echo unknown`
-uname -s = `(uname -s) 2>/dev/null || echo unknown`
-uname -v = `(uname -v) 2>/dev/null || echo unknown`
-
-/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
-/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
-
-/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
-/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
-/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
-/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
-/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
-/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
-/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
-
-_ASUNAME
-
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    $as_echo "PATH: $as_dir"
-  done
-IFS=$as_save_IFS
-
-} >&5
-
-cat >&5 <<_ACEOF
-
-
-## ----------- ##
-## Core tests. ##
-## ----------- ##
-
-_ACEOF
-
-
-# Keep a trace of the command line.
-# Strip out --no-create and --no-recursion so they do not pile up.
-# Strip out --silent because we don't want to record it for future runs.
-# Also quote any args containing shell meta-characters.
-# Make two passes to allow for proper duplicate-argument suppression.
-ac_configure_args=
-ac_configure_args0=
-ac_configure_args1=
-ac_must_keep_next=false
-for ac_pass in 1 2
-do
-  for ac_arg
-  do
-    case $ac_arg in
-    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
-    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-    | -silent | --silent | --silen | --sile | --sil)
-      continue ;;
-    *\'*)
-      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    esac
-    case $ac_pass in
-    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
-    2)
-      as_fn_append ac_configure_args1 " '$ac_arg'"
-      if test $ac_must_keep_next = true; then
-	ac_must_keep_next=false # Got value, back to normal.
-      else
-	case $ac_arg in
-	  *=* | --config-cache | -C | -disable-* | --disable-* \
-	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
-	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
-	  | -with-* | --with-* | -without-* | --without-* | --x)
-	    case "$ac_configure_args0 " in
-	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
-	    esac
-	    ;;
-	  -* ) ac_must_keep_next=true ;;
-	esac
-      fi
-      as_fn_append ac_configure_args " '$ac_arg'"
-      ;;
-    esac
-  done
-done
-{ ac_configure_args0=; unset ac_configure_args0;}
-{ ac_configure_args1=; unset ac_configure_args1;}
-
-# When interrupted or exit'd, cleanup temporary files, and complete
-# config.log.  We remove comments because anyway the quotes in there
-# would cause problems or look ugly.
-# WARNING: Use '\'' to represent an apostrophe within the trap.
-# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
-trap 'exit_status=$?
-  # Save into config.log some information that might help in debugging.
-  {
-    echo
-
-    $as_echo "## ---------------- ##
-## Cache variables. ##
-## ---------------- ##"
-    echo
-    # The following way of writing the cache mishandles newlines in values,
-(
-  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-  (set) 2>&1 |
-    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      sed -n \
-	"s/'\''/'\''\\\\'\'''\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
-      ;; #(
-    *)
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-)
-    echo
-
-    $as_echo "## ----------------- ##
-## Output variables. ##
-## ----------------- ##"
-    echo
-    for ac_var in $ac_subst_vars
-    do
-      eval ac_val=\$$ac_var
-      case $ac_val in
-      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
-      esac
-      $as_echo "$ac_var='\''$ac_val'\''"
-    done | sort
-    echo
-
-    if test -n "$ac_subst_files"; then
-      $as_echo "## ------------------- ##
-## File substitutions. ##
-## ------------------- ##"
-      echo
-      for ac_var in $ac_subst_files
-      do
-	eval ac_val=\$$ac_var
-	case $ac_val in
-	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
-	esac
-	$as_echo "$ac_var='\''$ac_val'\''"
-      done | sort
-      echo
-    fi
-
-    if test -s confdefs.h; then
-      $as_echo "## ----------- ##
-## confdefs.h. ##
-## ----------- ##"
-      echo
-      cat confdefs.h
-      echo
-    fi
-    test "$ac_signal" != 0 &&
-      $as_echo "$as_me: caught signal $ac_signal"
-    $as_echo "$as_me: exit $exit_status"
-  } >&5
-  rm -f core *.core core.conftest.* &&
-    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
-    exit $exit_status
-' 0
-for ac_signal in 1 2 13 15; do
-  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
-done
-ac_signal=0
-
-# confdefs.h avoids OS command line length limits that DEFS can exceed.
-rm -f -r conftest* confdefs.h
-
-$as_echo "/* confdefs.h */" > confdefs.h
-
-# Predefined preprocessor variables.
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_NAME "$PACKAGE_NAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_VERSION "$PACKAGE_VERSION"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_STRING "$PACKAGE_STRING"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
-_ACEOF
-
-cat >>confdefs.h <<_ACEOF
-#define PACKAGE_URL "$PACKAGE_URL"
-_ACEOF
-
-
-# Let the site file select an alternate cache file if it wants to.
-# Prefer an explicitly selected file to automatically selected ones.
-ac_site_file1=NONE
-ac_site_file2=NONE
-if test -n "$CONFIG_SITE"; then
-  # We do not want a PATH search for config.site.
-  case $CONFIG_SITE in #((
-    -*)  ac_site_file1=./$CONFIG_SITE;;
-    */*) ac_site_file1=$CONFIG_SITE;;
-    *)   ac_site_file1=./$CONFIG_SITE;;
-  esac
-elif test "x$prefix" != xNONE; then
-  ac_site_file1=$prefix/share/config.site
-  ac_site_file2=$prefix/etc/config.site
-else
-  ac_site_file1=$ac_default_prefix/share/config.site
-  ac_site_file2=$ac_default_prefix/etc/config.site
-fi
-for ac_site_file in "$ac_site_file1" "$ac_site_file2"
-do
-  test "x$ac_site_file" = xNONE && continue
-  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
-$as_echo "$as_me: loading site script $ac_site_file" >&6;}
-    sed 's/^/| /' "$ac_site_file" >&5
-    . "$ac_site_file" \
-      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "failed to load site script $ac_site_file
-See \`config.log' for more details" "$LINENO" 5; }
-  fi
-done
-
-if test -r "$cache_file"; then
-  # Some versions of bash will fail to source /dev/null (special files
-  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
-  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
-$as_echo "$as_me: loading cache $cache_file" >&6;}
-    case $cache_file in
-      [\\/]* | ?:[\\/]* ) . "$cache_file";;
-      *)                      . "./$cache_file";;
-    esac
-  fi
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
-$as_echo "$as_me: creating cache $cache_file" >&6;}
-  >$cache_file
-fi
-
-# Check that the precious variables saved in the cache have kept the same
-# value.
-ac_cache_corrupted=false
-for ac_var in $ac_precious_vars; do
-  eval ac_old_set=\$ac_cv_env_${ac_var}_set
-  eval ac_new_set=\$ac_env_${ac_var}_set
-  eval ac_old_val=\$ac_cv_env_${ac_var}_value
-  eval ac_new_val=\$ac_env_${ac_var}_value
-  case $ac_old_set,$ac_new_set in
-    set,)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,set)
-      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
-$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
-      ac_cache_corrupted=: ;;
-    ,);;
-    *)
-      if test "x$ac_old_val" != "x$ac_new_val"; then
-	# differences in whitespace do not lead to failure.
-	ac_old_val_w=`echo x $ac_old_val`
-	ac_new_val_w=`echo x $ac_new_val`
-	if test "$ac_old_val_w" != "$ac_new_val_w"; then
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
-	  ac_cache_corrupted=:
-	else
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
-	  eval $ac_var=\$ac_old_val
-	fi
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
-$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
-	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
-$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
-      fi;;
-  esac
-  # Pass precious variables to config.status.
-  if test "$ac_new_set" = set; then
-    case $ac_new_val in
-    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
-    *) ac_arg=$ac_var=$ac_new_val ;;
-    esac
-    case " $ac_configure_args " in
-      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
-      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
-    esac
-  fi
-done
-if $ac_cache_corrupted; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
-  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
-fi
-## -------------------- ##
-## Main body of script. ##
-## -------------------- ##
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-ac_aux_dir=
-for ac_dir in cf "$srcdir"/cf; do
-  if test -f "$ac_dir/install-sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install-sh -c"
-    break
-  elif test -f "$ac_dir/install.sh"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/install.sh -c"
-    break
-  elif test -f "$ac_dir/shtool"; then
-    ac_aux_dir=$ac_dir
-    ac_install_sh="$ac_aux_dir/shtool install -c"
-    break
-  fi
-done
-if test -z "$ac_aux_dir"; then
-  as_fn_error $? "cannot find install-sh, install.sh, or shtool in cf \"$srcdir\"/cf" "$LINENO" 5
-fi
-
-# These three variables are undocumented and unsupported,
-# and are intended to be withdrawn in a future Autoconf release.
-# They can cause serious problems if a builder's source tree is in a directory
-# whose full name contains unusual characters.
-ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
-ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
-ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
-
-
-#------------------------------------------------------------------------
-# Handle the --prefix=... option
-#------------------------------------------------------------------------
-
-if test "${prefix}" = "NONE"; then
-    prefix=/usr/local
-fi
-if test "${exec_prefix}" = "NONE"; then
-    exec_prefix=$prefix
-fi
-
-INSTALL_PREFIX=$prefix
-
-if test "${libdir}" != "${prefix}/lib"; then
-    LIB_SEARCH_DIRS="-L${prefix}/lib -L${libdir}"
-else
-    LIB_SEARCH_DIRS="-L${libdir}"
-fi
-# Make sure we can run config.sub.
-$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
-  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
-$as_echo_n "checking build system type... " >&6; }
-if ${ac_cv_build+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_build_alias=$build_alias
-test "x$ac_build_alias" = x &&
-  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
-test "x$ac_build_alias" = x &&
-  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
-ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
-  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
-$as_echo "$ac_cv_build" >&6; }
-case $ac_cv_build in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
-esac
-build=$ac_cv_build
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_build
-shift
-build_cpu=$1
-build_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-build_os=$*
-IFS=$ac_save_IFS
-case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
-$as_echo_n "checking host system type... " >&6; }
-if ${ac_cv_host+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$host_alias" = x; then
-  ac_cv_host=$ac_cv_build
-else
-  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
-$as_echo "$ac_cv_host" >&6; }
-case $ac_cv_host in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
-esac
-host=$ac_cv_host
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_host
-shift
-host_cpu=$1
-host_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-host_os=$*
-IFS=$ac_save_IFS
-case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
-$as_echo_n "checking target system type... " >&6; }
-if ${ac_cv_target+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test "x$target_alias" = x; then
-  ac_cv_target=$ac_cv_host
-else
-  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
-    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
-$as_echo "$ac_cv_target" >&6; }
-case $ac_cv_target in
-*-*-*) ;;
-*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
-esac
-target=$ac_cv_target
-ac_save_IFS=$IFS; IFS='-'
-set x $ac_cv_target
-shift
-target_cpu=$1
-target_vendor=$2
-shift; shift
-# Remember, the first character of IFS is used to create $*,
-# except with old shells:
-target_os=$*
-IFS=$ac_save_IFS
-case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac
-
-
-# The aliases save the names the user supplied, while $host etc.
-# will get canonicalized.
-test -n "$target_alias" &&
-  test "$program_prefix$program_suffix$program_transform_name" = \
-    NONENONEs,x,x, &&
-  program_prefix=${target_alias}-
-
-
-# Find a good install program.  We prefer a C program (faster),
-# so one script is as good as another.  But avoid the broken or
-# incompatible versions:
-# SysV /etc/install, /usr/sbin/install
-# SunOS /usr/etc/install
-# IRIX /sbin/install
-# AIX /bin/install
-# AmigaOS /C/install, which installs bootblocks on floppy discs
-# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
-# AFS /usr/afsws/bin/install, which mishandles nonexistent args
-# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
-# OS/2's system install, which has a completely different semantic
-# ./install, which can be erroneously created by make from ./install.sh.
-# Reject install programs that cannot install multiple files.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
-$as_echo_n "checking for a BSD-compatible install... " >&6; }
-if test -z "$INSTALL"; then
-if ${ac_cv_path_install+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    # Account for people who put trailing slashes in PATH elements.
-case $as_dir/ in #((
-  ./ | .// | /[cC]/* | \
-  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
-  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
-  /usr/ucb/* ) ;;
-  *)
-    # OSF1 and SCO ODT 3.0 have their own names for install.
-    # Don't use installbsd from OSF since it installs stuff as root
-    # by default.
-    for ac_prog in ginstall scoinst install; do
-      for ac_exec_ext in '' $ac_executable_extensions; do
-	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
-	  if test $ac_prog = install &&
-	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-	    # AIX install.  It has an incompatible calling convention.
-	    :
-	  elif test $ac_prog = install &&
-	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
-	    # program-specific install script used by HP pwplus--don't use.
-	    :
-	  else
-	    rm -rf conftest.one conftest.two conftest.dir
-	    echo one > conftest.one
-	    echo two > conftest.two
-	    mkdir conftest.dir
-	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
-	      test -s conftest.one && test -s conftest.two &&
-	      test -s conftest.dir/conftest.one &&
-	      test -s conftest.dir/conftest.two
-	    then
-	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
-	      break 3
-	    fi
-	  fi
-	fi
-      done
-    done
-    ;;
-esac
-
-  done
-IFS=$as_save_IFS
-
-rm -rf conftest.one conftest.two conftest.dir
-
-fi
-  if test "${ac_cv_path_install+set}" = set; then
-    INSTALL=$ac_cv_path_install
-  else
-    # As a last resort, use the slow shell script.  Don't cache a
-    # value for INSTALL within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the value is a relative name.
-    INSTALL=$ac_install_sh
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
-$as_echo "$INSTALL" >&6; }
-
-# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
-# It thinks the first close brace ends the variable substitution.
-test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
-
-test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
-
-test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
-
-
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_RANLIB" = x; then
-    RANLIB=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    RANLIB=$ac_ct_RANLIB
-  fi
-else
-  RANLIB="$ac_cv_prog_RANLIB"
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
-$as_echo_n "checking whether ln -s works... " >&6; }
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
-$as_echo "no, using $LN_S" >&6; }
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
-$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
-if test -z "$MKDIR_P"; then
-  if ${ac_cv_path_mkdir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in mkdir gmkdir; do
-	 for ac_exec_ext in '' $ac_executable_extensions; do
-	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
-	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
-	     'mkdir (GNU coreutils) '* | \
-	     'mkdir (coreutils) '* | \
-	     'mkdir (fileutils) '4.1*)
-	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
-	       break 3;;
-	   esac
-	 done
-       done
-  done
-IFS=$as_save_IFS
-
-fi
-
-  test -d ./--version && rmdir ./--version
-  if test "${ac_cv_path_mkdir+set}" = set; then
-    MKDIR_P="$ac_cv_path_mkdir -p"
-  else
-    # As a last resort, use the slow shell script.  Don't cache a
-    # value for MKDIR_P within a source directory, because that will
-    # break other packages using the cache if that directory is
-    # removed, or if the value is a relative name.
-    MKDIR_P="$ac_install_sh -d"
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
-$as_echo "$MKDIR_P" >&6; }
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
-$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
-set x ${MAKE-make}
-ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
-if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat >conftest.make <<\_ACEOF
-SHELL = /bin/sh
-all:
-	@echo '@@@%%%=$(MAKE)=@@@%%%'
-_ACEOF
-# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
-case `${MAKE-make} -f conftest.make 2>/dev/null` in
-  *@@@%%%=?*=@@@%%%*)
-    eval ac_cv_prog_make_${ac_make}_set=yes;;
-  *)
-    eval ac_cv_prog_make_${ac_make}_set=no;;
-esac
-rm -f conftest.make
-fi
-if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-  SET_MAKE=
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-  SET_MAKE="MAKE=${MAKE-make}"
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-else
-  CC="$ac_cv_prog_CC"
-fi
-
-if test -z "$CC"; then
-          if test -n "$ac_tool_prefix"; then
-    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="${ac_tool_prefix}cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  fi
-fi
-if test -z "$CC"; then
-  # Extract the first word of "cc", so it can be a program name with args.
-set dummy cc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-  ac_prog_rejected=no
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
-       ac_prog_rejected=yes
-       continue
-     fi
-    ac_cv_prog_CC="cc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-if test $ac_prog_rejected = yes; then
-  # We found a bogon in the path, so make sure we never use it.
-  set dummy $ac_cv_prog_CC
-  shift
-  if test $# != 0; then
-    # We chose a different compiler from the bogus one.
-    # However, it has the same basename, so the bogon will be chosen
-    # first if we set CC to just the basename; use the full file name.
-    shift
-    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
-  fi
-fi
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-fi
-if test -z "$CC"; then
-  if test -n "$ac_tool_prefix"; then
-  for ac_prog in cl.exe
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-    test -n "$CC" && break
-  done
-fi
-if test -z "$CC"; then
-  ac_ct_CC=$CC
-  for ac_prog in cl.exe
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_prog_ac_ct_CC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-  test -n "$ac_ct_CC" && break
-done
-
-  if test "x$ac_ct_CC" = x; then
-    CC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-fi
-
-fi
-
-
-test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "no acceptable C compiler found in \$PATH
-See \`config.log' for more details" "$LINENO" 5; }
-
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
-# Try to create an executable without -o first, disregard a.out.
-# It will help us diagnose broken compilers, and finding out an intuition
-# of exeext.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
-$as_echo_n "checking whether the C compiler works... " >&6; }
-ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
-
-# The possible output files:
-ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
-
-ac_rmfiles=
-for ac_file in $ac_files
-do
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
-  esac
-done
-rm -f $ac_rmfiles
-
-if { { ac_try="$ac_link_default"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link_default") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
-# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
-# in a Makefile.  We should not override ac_cv_exeext if it was cached,
-# so that the user can short-circuit this test for compilers unknown to
-# Autoconf.
-for ac_file in $ac_files ''
-do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
-	;;
-    [ab].out )
-	# We found the default executable, but exeext='' is most
-	# certainly right.
-	break;;
-    *.* )
-	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
-	then :; else
-	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	fi
-	# We set ac_cv_exeext here because the later test for it is not
-	# safe: cross compilers may not add the suffix if given an `-o'
-	# argument, so we may need to know it at that point already.
-	# Even if this section looks crufty: it has the advantage of
-	# actually working.
-	break;;
-    * )
-	break;;
-  esac
-done
-test "$ac_cv_exeext" = no && ac_cv_exeext=
-
-else
-  ac_file=''
-fi
-if test -z "$ac_file"; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-$as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error 77 "C compiler cannot create executables
-See \`config.log' for more details" "$LINENO" 5; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
-$as_echo_n "checking for C compiler default output file name... " >&6; }
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
-$as_echo "$ac_file" >&6; }
-ac_exeext=$ac_cv_exeext
-
-rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
-$as_echo_n "checking for suffix of executables... " >&6; }
-if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  # If both `conftest.exe' and `conftest' are `present' (well, observable)
-# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
-# work properly (i.e., refer to `conftest.exe'), while it won't with
-# `rm'.
-for ac_file in conftest.exe conftest conftest.*; do
-  test -f "$ac_file" || continue
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
-    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
-	  break;;
-    * ) break;;
-  esac
-done
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of executables: cannot compile and link
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest conftest$ac_cv_exeext
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
-$as_echo "$ac_cv_exeext" >&6; }
-
-rm -f conftest.$ac_ext
-EXEEXT=$ac_cv_exeext
-ac_exeext=$EXEEXT
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-FILE *f = fopen ("conftest.out", "w");
- return ferror (f) || fclose (f) != 0;
-
-  ;
-  return 0;
-}
-_ACEOF
-ac_clean_files="$ac_clean_files conftest.out"
-# Check that the compiler produces executables we can run.  If not, either
-# the compiler is broken, or we cross compile.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
-$as_echo_n "checking whether we are cross compiling... " >&6; }
-if test "$cross_compiling" != yes; then
-  { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-  if { ac_try='./conftest$ac_cv_exeext'
-  { { case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_try") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; }; then
-    cross_compiling=no
-  else
-    if test "$cross_compiling" = maybe; then
-	cross_compiling=yes
-    else
-	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot run C compiled programs.
-If you meant to cross compile, use \`--host'.
-See \`config.log' for more details" "$LINENO" 5; }
-    fi
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
-$as_echo "$cross_compiling" >&6; }
-
-rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
-ac_clean_files=$ac_clean_files_save
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
-$as_echo_n "checking for suffix of object files... " >&6; }
-if ${ac_cv_objext+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-rm -f conftest.o conftest.obj
-if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  for ac_file in conftest.o conftest.obj conftest.*; do
-  test -f "$ac_file" || continue;
-  case $ac_file in
-    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
-    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
-       break;;
-  esac
-done
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "cannot compute suffix of object files: cannot compile
-See \`config.log' for more details" "$LINENO" 5; }
-fi
-rm -f conftest.$ac_cv_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
-$as_echo "$ac_cv_objext" >&6; }
-OBJEXT=$ac_cv_objext
-ac_objext=$OBJEXT
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
-$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
-if ${ac_cv_c_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_c_compiler_gnu=$ac_compiler_gnu
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
-$as_echo "$ac_cv_c_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
-  GCC=yes
-else
-  GCC=
-fi
-ac_test_CFLAGS=${CFLAGS+set}
-ac_save_CFLAGS=$CFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
-$as_echo_n "checking whether $CC accepts -g... " >&6; }
-if ${ac_cv_prog_cc_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_c_werror_flag=$ac_c_werror_flag
-   ac_c_werror_flag=yes
-   ac_cv_prog_cc_g=no
-   CFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_g=yes
-else
-  CFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-
-else
-  ac_c_werror_flag=$ac_save_c_werror_flag
-	 CFLAGS="-g"
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_c_werror_flag=$ac_save_c_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
-$as_echo "$ac_cv_prog_cc_g" >&6; }
-if test "$ac_test_CFLAGS" = set; then
-  CFLAGS=$ac_save_CFLAGS
-elif test $ac_cv_prog_cc_g = yes; then
-  if test "$GCC" = yes; then
-    CFLAGS="-g -O2"
-  else
-    CFLAGS="-g"
-  fi
-else
-  if test "$GCC" = yes; then
-    CFLAGS="-O2"
-  else
-    CFLAGS=
-  fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
-$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
-if ${ac_cv_prog_cc_c89+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c89=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdio.h>
-struct stat;
-/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
-struct buf { int x; };
-FILE * (*rcsopen) (struct buf *, struct stat *, int);
-static char *e (p, i)
-     char **p;
-     int i;
-{
-  return p[i];
-}
-static char *f (char * (*g) (char **, int), char **p, ...)
-{
-  char *s;
-  va_list v;
-  va_start (v,p);
-  s = g (p, va_arg (v,int));
-  va_end (v);
-  return s;
-}
-
-/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
-   function prototypes and stuff, but not '\xHH' hex character constants.
-   These don't provoke an error unfortunately, instead are silently treated
-   as 'x'.  The following induces an error, until -std is added to get
-   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
-   array size at least.  It's necessary to write '\x00'==0 to get something
-   that's true only with -std.  */
-int osf4_cc_array ['\x00' == 0 ? 1 : -1];
-
-/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
-   inside strings and character constants.  */
-#define FOO(x) 'x'
-int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
-
-int test (int i, double x);
-struct s1 {int (*f) (int a);};
-struct s2 {int (*f) (double a);};
-int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
-int argc;
-char **argv;
-int
-main ()
-{
-return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
-	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c89=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c89" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
-
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c89" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c89"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
-$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c89" != xno; then :
-
-fi
-
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-
-
-#SC_CONFIG_CFLAGS
-#SC_ENABLE_SHARED
-
-SVN_VERSION=`svnversion $srcdir | sed 's/Unversioned directory/unknown/'`
-SVN_URL=`readlink -e $srcdir | xargs svn info | sed -ne 's/^URL: //p'`
-
-gui_with_tcl=""
-
-make_command=""
-for m in "$MAKE" make gmake gnumake ; do
-  if test "x${m}" != "x" ; then
-    if  ( sh -c "$m --version" 2>/dev/null | grep GNU >/dev/null ) ; then
-      make_command=$m; break;
-    fi
-  fi
-done
-if test "x${make_command}" = "x" ; then
-  as_fn_error $? "Requires GNU make. You can specify a version with \$MAKE" "$LINENO" 5
-fi
-MAKE=${make_command}
-
-
-# Check whether --enable-gui was given.
-if test "${enable_gui+set}" = set; then :
-  enableval=$enable_gui;
-else
-  enable_gui=yes
-fi
-
-
-ENABLE_GUI=
-if test "$enable_gui" != "no" ; then
-    ENABLE_GUI="yes"
-fi
-
-
-with_tclsh="yes"
-
-# Check whether --with-tclsh was given.
-if test "${with_tclsh+set}" = set; then :
-  withval=$with_tclsh;
-else
-  with_tclsh=yes
-fi
-
-
-TCLSH=
-# -----------------------------------------------------------------------
-#
-#	Find the Tcl build configuration file "tclConfig.sh"
-#
-# -----------------------------------------------------------------------
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tclConfig.sh" >&5
-$as_echo_n "checking for tclConfig.sh... " >&6; }
-tcl_config_sh=""
-if test "x$gui_with_tcl" != "x" ; then
-
-  # Verify that a tclConfig.sh file exists in the directory specified
-  # by --with-tcl.
-
-  for dir in \
-   $gui_with_tcl
-  do
-    if test -r "$dir/tclConfig.sh" ; then
-      tcl_config_sh="$dir/tclConfig.sh"
-      break
-    elif test -r "$dir/lib/tclConfig.sh" ; then
-      tcl_config_sh="$dir/lib/tclConfig.sh"
-      break
-    fi
-  done
-else
-
-  # Otherwise, search for Tcl configuration file.
-
-  #  1. Search previously named locations.
-
-  for dir in \
-   $prefix \
-   $exec_prefix \
-   $gui_cv_tcl_lib
-  do
-    if test -r "$dir/tclConfig.sh" ; then
-      tcl_config_sh="$dir/tclConfig.sh"
-      break
-    elif test -r "$dir/lib/tclConfig.sh" ; then
-      tcl_config_sh="$dir/lib/tclConfig.sh"
-      break
-    fi
-  done
-fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${tcl_config_sh}" >&5
-$as_echo "${tcl_config_sh}" >&6; }
-
-if test "x$tcl_config_sh" = "x" ; then
-  echo "can't find Tcl configuration script \"tclConfig.sh\""
-  exit 1
-fi
-. ${tcl_config_sh}
-TCL_INC_SPEC="$TCL_INCLUDE_SPEC"
-
-case $target in
-  *-*-cygwin*|*-*-mingw*)
-    gui_platform="win"
-    TCLSH=${TCL_PREFIX}/bin/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}
-    ;;
-  *-*-darwin*)
-    gui_platform="macosx"
-    TCLSH=${TCL_PREFIX}/bin/tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}
-    ;;
-  *)
-    blt_platform="unix"
-    TCLSH=${TCL_PREFIX}/bin/tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}
-    ;;
-esac
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${TCLSH}" >&5
-$as_echo "${TCLSH}" >&6; }
-
-
-if test -f "${exec_prefix}/lib/tclConfig.sh" ; then
-  . ${exec_prefix}/lib/tclConfig.sh
-fi
-if test -f "${exec_prefix}/lib/tkConfig.sh" ; then
-  . ${exec_prefix}/lib/tkConfig.sh
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-ac_config_files="$ac_config_files Makefile pkgIndex.tcl apps/Makefile apps/about apps/encodedata apps/rappture apps/rappture-csh.env apps/rappture.env apps/rappture.use apps/rerun apps/simsim apps/xmldiff scripts/Makefile src/Makefile"
-
-cat >confcache <<\_ACEOF
-# This file is a shell script that caches the results of configure
-# tests run on this system so they can be shared between configure
-# scripts and configure runs, see configure's option --config-cache.
-# It is not useful on other systems.  If it contains results you don't
-# want to keep, you may remove or edit it.
-#
-# config.status only pays attention to the cache file if you give it
-# the --recheck option to rerun configure.
-#
-# `ac_cv_env_foo' variables (set or unset) will be overridden when
-# loading this file, other *unset* `ac_cv_foo' will be assigned the
-# following values.
-
-_ACEOF
-
-# The following way of writing the cache mishandles newlines in values,
-# but we know of no workaround that is simple, portable, and efficient.
-# So, we kill variables containing newlines.
-# Ultrix sh set writes to stderr and can't be redirected directly,
-# and sets the high bit in the cache file unless we assign to the vars.
-(
-  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
-    eval ac_val=\$$ac_var
-    case $ac_val in #(
-    *${as_nl}*)
-      case $ac_var in #(
-      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
-      esac
-      case $ac_var in #(
-      _ | IFS | as_nl) ;; #(
-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
-      *) { eval $ac_var=; unset $ac_var;} ;;
-      esac ;;
-    esac
-  done
-
-  (set) 2>&1 |
-    case $as_nl`(ac_space=' '; set) 2>&1` in #(
-    *${as_nl}ac_space=\ *)
-      # `set' does not quote correctly, so add quotes: double-quote
-      # substitution turns \\\\ into \\, and sed turns \\ into \.
-      sed -n \
-	"s/'/'\\\\''/g;
-	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
-      ;; #(
-    *)
-      # `set' quotes correctly as required by POSIX, so do not add quotes.
-      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
-      ;;
-    esac |
-    sort
-) |
-  sed '
-     /^ac_cv_env_/b end
-     t clear
-     :clear
-     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
-     t end
-     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
-     :end' >>confcache
-if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
-  if test -w "$cache_file"; then
-    if test "x$cache_file" != "x/dev/null"; then
-      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
-$as_echo "$as_me: updating cache $cache_file" >&6;}
-      if test ! -f "$cache_file" || test -h "$cache_file"; then
-	cat confcache >"$cache_file"
-      else
-        case $cache_file in #(
-        */* | ?:*)
-	  mv -f confcache "$cache_file"$$ &&
-	  mv -f "$cache_file"$$ "$cache_file" ;; #(
-        *)
-	  mv -f confcache "$cache_file" ;;
-	esac
-      fi
-    fi
-  else
-    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
-$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
-  fi
-fi
-rm -f confcache
-
-test "x$prefix" = xNONE && prefix=$ac_default_prefix
-# Let make expand exec_prefix.
-test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-
-# Transform confdefs.h into DEFS.
-# Protect against shell expansion while executing Makefile rules.
-# Protect against Makefile macro expansion.
-#
-# If the first sed substitution is executed (which looks for macros that
-# take arguments), then branch to the quote section.  Otherwise,
-# look for a macro that doesn't take arguments.
-ac_script='
-:mline
-/\\$/{
- N
- s,\\\n,,
- b mline
-}
-t clear
-:clear
-s/^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 (][^	 (]*([^)]*)\)[	 ]*\(.*\)/-D\1=\2/g
-t quote
-s/^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 ][^	 ]*\)[	 ]*\(.*\)/-D\1=\2/g
-t quote
-b any
-:quote
-s/[	 `~#$^&*(){}\\|;'\''"<>?]/\\&/g
-s/\[/\\&/g
-s/\]/\\&/g
-s/\$/$$/g
-H
-:any
-${
-	g
-	s/^\n//
-	s/\n/ /g
-	p
-}
-'
-DEFS=`sed -n "$ac_script" confdefs.h`
-
-
-ac_libobjs=
-ac_ltlibobjs=
-U=
-for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
-  # 1. Remove the extension, and $U if already installed.
-  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
-  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
-  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
-  #    will be set to the directory where LIBOBJS objects are built.
-  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
-  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
-done
-LIBOBJS=$ac_libobjs
-
-LTLIBOBJS=$ac_ltlibobjs
-
-
-
-: "${CONFIG_STATUS=./config.status}"
-ac_write_fail=0
-ac_clean_files_save=$ac_clean_files
-ac_clean_files="$ac_clean_files $CONFIG_STATUS"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
-as_write_fail=0
-cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
-#! $SHELL
-# Generated by $as_me.
-# Run this file to recreate the current configuration.
-# Compiler output produced by configure, useful for debugging
-# configure, is in config.log if it exists.
-
-debug=false
-ac_cs_recheck=false
-ac_cs_silent=false
-
-SHELL=\${CONFIG_SHELL-$SHELL}
-export SHELL
-_ASEOF
-cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
-## -------------------- ##
-## M4sh Initialization. ##
-## -------------------- ##
-
-# Be more Bourne compatible
-DUALCASE=1; export DUALCASE # for MKS sh
-if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
-  emulate sh
-  NULLCMD=:
-  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
-  # is contrary to our usage.  Disable this feature.
-  alias -g '${1+"$@"}'='"$@"'
-  setopt NO_GLOB_SUBST
-else
-  case `(set -o) 2>/dev/null` in #(
-  *posix*) :
-    set -o posix ;; #(
-  *) :
-     ;;
-esac
-fi
-
-
-as_nl='
-'
-export as_nl
-# Printing a long string crashes Solaris 7 /usr/bin/printf.
-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
-# Prefer a ksh shell builtin over an external printf program on Solaris,
-# but without wasting forks for bash or zsh.
-if test -z "$BASH_VERSION$ZSH_VERSION" \
-    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='print -r --'
-  as_echo_n='print -rn --'
-elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
-  as_echo='printf %s\n'
-  as_echo_n='printf %s'
-else
-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
-    as_echo_n='/usr/ucb/echo -n'
-  else
-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
-    as_echo_n_body='eval
-      arg=$1;
-      case $arg in #(
-      *"$as_nl"*)
-	expr "X$arg" : "X\\(.*\\)$as_nl";
-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
-      esac;
-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
-    '
-    export as_echo_n_body
-    as_echo_n='sh -c $as_echo_n_body as_echo'
-  fi
-  export as_echo_body
-  as_echo='sh -c $as_echo_body as_echo'
-fi
-
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  PATH_SEPARATOR=:
-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
-      PATH_SEPARATOR=';'
-  }
-fi
-
-
-# IFS
-# We need space, tab and new line, in precisely that order.  Quoting is
-# there to prevent editors from complaining about space-tab.
-# (If _AS_PATH_WALK were called with IFS unset, it would disable word
-# splitting by setting IFS to empty value.)
-IFS=" ""	$as_nl"
-
-# Find who we are.  Look in the path if we contain no directory separator.
-as_myself=
-case $0 in #((
-  *[\\/]* ) as_myself=$0 ;;
-  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
-  done
-IFS=$as_save_IFS
-
-     ;;
-esac
-# We did not find ourselves, most probably we were run as `sh COMMAND'
-# in which case we are not to be found in the path.
-if test "x$as_myself" = x; then
-  as_myself=$0
-fi
-if test ! -f "$as_myself"; then
-  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
-  exit 1
-fi
-
-# Unset variables that we do not need and which cause bugs (e.g. in
-# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
-# suppresses any "Segmentation fault" message there.  '((' could
-# trigger a bug in pdksh 5.2.14.
-for as_var in BASH_ENV ENV MAIL MAILPATH
-do eval test x\${$as_var+set} = xset \
-  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
-done
-PS1='$ '
-PS2='> '
-PS4='+ '
-
-# NLS nuisances.
-LC_ALL=C
-export LC_ALL
-LANGUAGE=C
-export LANGUAGE
-
-# CDPATH.
-(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
-# as_fn_error STATUS ERROR [LINENO LOG_FD]
-# ----------------------------------------
-# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
-# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
-# script with STATUS, using 1 if that was 0.
-as_fn_error ()
-{
-  as_status=$1; test $as_status -eq 0 && as_status=1
-  if test "$4"; then
-    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
-  fi
-  $as_echo "$as_me: error: $2" >&2
-  as_fn_exit $as_status
-} # as_fn_error
-
-
-# as_fn_set_status STATUS
-# -----------------------
-# Set $? to STATUS, without forking.
-as_fn_set_status ()
-{
-  return $1
-} # as_fn_set_status
-
-# as_fn_exit STATUS
-# -----------------
-# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
-as_fn_exit ()
-{
-  set +e
-  as_fn_set_status $1
-  exit $1
-} # as_fn_exit
-
-# as_fn_unset VAR
-# ---------------
-# Portably unset VAR.
-as_fn_unset ()
-{
-  { eval $1=; unset $1;}
-}
-as_unset=as_fn_unset
-# as_fn_append VAR VALUE
-# ----------------------
-# Append the text in VALUE to the end of the definition contained in VAR. Take
-# advantage of any shell optimizations that allow amortized linear growth over
-# repeated appends, instead of the typical quadratic growth present in naive
-# implementations.
-if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
-  eval 'as_fn_append ()
-  {
-    eval $1+=\$2
-  }'
-else
-  as_fn_append ()
-  {
-    eval $1=\$$1\$2
-  }
-fi # as_fn_append
-
-# as_fn_arith ARG...
-# ------------------
-# Perform arithmetic evaluation on the ARGs, and store the result in the
-# global $as_val. Take advantage of shells that can avoid forks. The arguments
-# must be portable across $(()) and expr.
-if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
-  eval 'as_fn_arith ()
-  {
-    as_val=$(( $* ))
-  }'
-else
-  as_fn_arith ()
-  {
-    as_val=`expr "$@" || test $? -eq 1`
-  }
-fi # as_fn_arith
-
-
-if expr a : '\(a\)' >/dev/null 2>&1 &&
-   test "X`expr 00001 : '.*\(...\)'`" = X001; then
-  as_expr=expr
-else
-  as_expr=false
-fi
-
-if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
-  as_basename=basename
-else
-  as_basename=false
-fi
-
-if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
-  as_dirname=dirname
-else
-  as_dirname=false
-fi
-
-as_me=`$as_basename -- "$0" ||
-$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
-	 X"$0" : 'X\(//\)$' \| \
-	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X/"$0" |
-    sed '/^.*\/\([^/][^/]*\)\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\/\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-
-# Avoid depending upon Character Ranges.
-as_cr_letters='abcdefghijklmnopqrstuvwxyz'
-as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
-as_cr_Letters=$as_cr_letters$as_cr_LETTERS
-as_cr_digits='0123456789'
-as_cr_alnum=$as_cr_Letters$as_cr_digits
-
-ECHO_C= ECHO_N= ECHO_T=
-case `echo -n x` in #(((((
--n*)
-  case `echo 'xy\c'` in
-  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
-  xy)  ECHO_C='\c';;
-  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
-       ECHO_T='	';;
-  esac;;
-*)
-  ECHO_N='-n';;
-esac
-
-rm -f conf$$ conf$$.exe conf$$.file
-if test -d conf$$.dir; then
-  rm -f conf$$.dir/conf$$.file
-else
-  rm -f conf$$.dir
-  mkdir conf$$.dir 2>/dev/null
-fi
-if (echo >conf$$.file) 2>/dev/null; then
-  if ln -s conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s='ln -s'
-    # ... but there are two gotchas:
-    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
-    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
-    # In both cases, we have to default to `cp -pR'.
-    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
-      as_ln_s='cp -pR'
-  elif ln conf$$.file conf$$ 2>/dev/null; then
-    as_ln_s=ln
-  else
-    as_ln_s='cp -pR'
-  fi
-else
-  as_ln_s='cp -pR'
-fi
-rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
-rmdir conf$$.dir 2>/dev/null
-
-
-# as_fn_mkdir_p
-# -------------
-# Create "$as_dir" as a directory, including parents if necessary.
-as_fn_mkdir_p ()
-{
-
-  case $as_dir in #(
-  -*) as_dir=./$as_dir;;
-  esac
-  test -d "$as_dir" || eval $as_mkdir_p || {
-    as_dirs=
-    while :; do
-      case $as_dir in #(
-      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
-      *) as_qdir=$as_dir;;
-      esac
-      as_dirs="'$as_qdir' $as_dirs"
-      as_dir=`$as_dirname -- "$as_dir" ||
-$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$as_dir" : 'X\(//\)[^/]' \| \
-	 X"$as_dir" : 'X\(//\)$' \| \
-	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$as_dir" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-      test -d "$as_dir" && break
-    done
-    test -z "$as_dirs" || eval "mkdir $as_dirs"
-  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
-
-
-} # as_fn_mkdir_p
-if mkdir -p . 2>/dev/null; then
-  as_mkdir_p='mkdir -p "$as_dir"'
-else
-  test -d ./-p && rmdir ./-p
-  as_mkdir_p=false
-fi
-
-
-# as_fn_executable_p FILE
-# -----------------------
-# Test if FILE is an executable regular file.
-as_fn_executable_p ()
-{
-  test -f "$1" && test -x "$1"
-} # as_fn_executable_p
-as_test_x='test -x'
-as_executable_p=as_fn_executable_p
-
-# Sed expression to map a string onto a valid CPP name.
-as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
-
-# Sed expression to map a string onto a valid variable name.
-as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
-
-
-exec 6>&1
-## ----------------------------------- ##
-## Main body of $CONFIG_STATUS script. ##
-## ----------------------------------- ##
-_ASEOF
-test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# Save the log message, to keep $0 and so on meaningful, and to
-# report actual input values of CONFIG_FILES etc. instead of their
-# values after options handling.
-ac_log="
-This file was extended by RapptureGUI $as_me 1.9, which was
-generated by GNU Autoconf 2.69.  Invocation command line was
-
-  CONFIG_FILES    = $CONFIG_FILES
-  CONFIG_HEADERS  = $CONFIG_HEADERS
-  CONFIG_LINKS    = $CONFIG_LINKS
-  CONFIG_COMMANDS = $CONFIG_COMMANDS
-  $ $0 $@
-
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
-"
-
-_ACEOF
-
-case $ac_config_files in *"
-"*) set x $ac_config_files; shift; ac_config_files=$*;;
-esac
-
-
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-# Files that config.status was made for.
-config_files="$ac_config_files"
-
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-ac_cs_usage="\
-\`$as_me' instantiates files and other configuration actions
-from templates according to the current configuration.  Unless the files
-and actions are specified as TAGs, all are instantiated by default.
-
-Usage: $0 [OPTION]... [TAG]...
-
-  -h, --help       print this help, then exit
-  -V, --version    print version number and configuration settings, then exit
-      --config     print configuration, then exit
-  -q, --quiet, --silent
-                   do not print progress messages
-  -d, --debug      don't remove temporary files
-      --recheck    update $as_me by reconfiguring in the same conditions
-      --file=FILE[:TEMPLATE]
-                   instantiate the configuration file FILE
-
-Configuration files:
-$config_files
-
-Report bugs to <rappture@nanohub.org>."
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
-ac_cs_version="\\
-RapptureGUI config.status 1.9
-configured by $0, generated by GNU Autoconf 2.69,
-  with options \\"\$ac_cs_config\\"
-
-Copyright (C) 2012 Free Software Foundation, Inc.
-This config.status script is free software; the Free Software Foundation
-gives unlimited permission to copy, distribute and modify it."
-
-ac_pwd='$ac_pwd'
-srcdir='$srcdir'
-INSTALL='$INSTALL'
-MKDIR_P='$MKDIR_P'
-test -n "\$AWK" || AWK=awk
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# The default lists apply if the user does not specify any file.
-ac_need_defaults=:
-while test $# != 0
-do
-  case $1 in
-  --*=?*)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
-    ac_shift=:
-    ;;
-  --*=)
-    ac_option=`expr "X$1" : 'X\([^=]*\)='`
-    ac_optarg=
-    ac_shift=:
-    ;;
-  *)
-    ac_option=$1
-    ac_optarg=$2
-    ac_shift=shift
-    ;;
-  esac
-
-  case $ac_option in
-  # Handling of the options.
-  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    ac_cs_recheck=: ;;
-  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
-    $as_echo "$ac_cs_version"; exit ;;
-  --config | --confi | --conf | --con | --co | --c )
-    $as_echo "$ac_cs_config"; exit ;;
-  --debug | --debu | --deb | --de | --d | -d )
-    debug=: ;;
-  --file | --fil | --fi | --f )
-    $ac_shift
-    case $ac_optarg in
-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
-    '') as_fn_error $? "missing file argument" ;;
-    esac
-    as_fn_append CONFIG_FILES " '$ac_optarg'"
-    ac_need_defaults=false;;
-  --he | --h |  --help | --hel | -h )
-    $as_echo "$ac_cs_usage"; exit ;;
-  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
-  | -silent | --silent | --silen | --sile | --sil | --si | --s)
-    ac_cs_silent=: ;;
-
-  # This is an error.
-  -*) as_fn_error $? "unrecognized option: \`$1'
-Try \`$0 --help' for more information." ;;
-
-  *) as_fn_append ac_config_targets " $1"
-     ac_need_defaults=false ;;
-
-  esac
-  shift
-done
-
-ac_configure_extra_args=
-
-if $ac_cs_silent; then
-  exec 6>/dev/null
-  ac_configure_extra_args="$ac_configure_extra_args --silent"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-if \$ac_cs_recheck; then
-  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
-  shift
-  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
-  CONFIG_SHELL='$SHELL'
-  export CONFIG_SHELL
-  exec "\$@"
-fi
-
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-exec 5>>config.log
-{
-  echo
-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
-## Running $as_me. ##
-_ASBOX
-  $as_echo "$ac_log"
-} >&5
-
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-
-# Handling of arguments.
-for ac_config_target in $ac_config_targets
-do
-  case $ac_config_target in
-    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
-    "pkgIndex.tcl") CONFIG_FILES="$CONFIG_FILES pkgIndex.tcl" ;;
-    "apps/Makefile") CONFIG_FILES="$CONFIG_FILES apps/Makefile" ;;
-    "apps/about") CONFIG_FILES="$CONFIG_FILES apps/about" ;;
-    "apps/encodedata") CONFIG_FILES="$CONFIG_FILES apps/encodedata" ;;
-    "apps/rappture") CONFIG_FILES="$CONFIG_FILES apps/rappture" ;;
-    "apps/rappture-csh.env") CONFIG_FILES="$CONFIG_FILES apps/rappture-csh.env" ;;
-    "apps/rappture.env") CONFIG_FILES="$CONFIG_FILES apps/rappture.env" ;;
-    "apps/rappture.use") CONFIG_FILES="$CONFIG_FILES apps/rappture.use" ;;
-    "apps/rerun") CONFIG_FILES="$CONFIG_FILES apps/rerun" ;;
-    "apps/simsim") CONFIG_FILES="$CONFIG_FILES apps/simsim" ;;
-    "apps/xmldiff") CONFIG_FILES="$CONFIG_FILES apps/xmldiff" ;;
-    "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
-    "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;;
-
-  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
-  esac
-done
-
-
-# If the user did not use the arguments to specify the items to instantiate,
-# then the envvar interface is used.  Set only those that are not.
-# We use the long form for the default assignment because of an extremely
-# bizarre bug on SunOS 4.1.3.
-if $ac_need_defaults; then
-  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
-fi
-
-# Have a temporary directory for convenience.  Make it in the build tree
-# simply because there is no reason against having it here, and in addition,
-# creating and moving files from /tmp can sometimes cause problems.
-# Hook for its removal unless debugging.
-# Note that there is a small window in which the directory will not be cleaned:
-# after its creation but before its name has been assigned to `$tmp'.
-$debug ||
-{
-  tmp= ac_tmp=
-  trap 'exit_status=$?
-  : "${ac_tmp:=$tmp}"
-  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
-' 0
-  trap 'as_fn_exit 1' 1 2 13 15
-}
-# Create a (secure) tmp directory for tmp files.
-
-{
-  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
-  test -d "$tmp"
-}  ||
-{
-  tmp=./conf$$-$RANDOM
-  (umask 077 && mkdir "$tmp")
-} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
-ac_tmp=$tmp
-
-# Set up the scripts for CONFIG_FILES section.
-# No need to generate them if there are no CONFIG_FILES.
-# This happens for instance with `./config.status config.h'.
-if test -n "$CONFIG_FILES"; then
-
-
-ac_cr=`echo X | tr X '\015'`
-# On cygwin, bash can eat \r inside `` if the user requested igncr.
-# But we know of no other shell where ac_cr would be empty at this
-# point, so we can use a bashism as a fallback.
-if test "x$ac_cr" = x; then
-  eval ac_cr=\$\'\\r\'
-fi
-ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
-if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
-  ac_cs_awk_cr='\\r'
-else
-  ac_cs_awk_cr=$ac_cr
-fi
-
-echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
-_ACEOF
-
-
-{
-  echo "cat >conf$$subs.awk <<_ACEOF" &&
-  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
-  echo "_ACEOF"
-} >conf$$subs.sh ||
-  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
-ac_delim='%!_!# '
-for ac_last_try in false false false false false :; do
-  . ./conf$$subs.sh ||
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-
-  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
-  if test $ac_delim_n = $ac_delim_num; then
-    break
-  elif $ac_last_try; then
-    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
-  else
-    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
-  fi
-done
-rm -f conf$$subs.sh
-
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
-_ACEOF
-sed -n '
-h
-s/^/S["/; s/!.*/"]=/
-p
-g
-s/^[^!]*!//
-:repl
-t repl
-s/'"$ac_delim"'$//
-t delim
-:nl
-h
-s/\(.\{148\}\)..*/\1/
-t more1
-s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
-p
-n
-b repl
-:more1
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t nl
-:delim
-h
-s/\(.\{148\}\)..*/\1/
-t more2
-s/["\\]/\\&/g; s/^/"/; s/$/"/
-p
-b
-:more2
-s/["\\]/\\&/g; s/^/"/; s/$/"\\/
-p
-g
-s/.\{148\}//
-t delim
-' <conf$$subs.awk | sed '
-/^[^""]/{
-  N
-  s/\n//
-}
-' >>$CONFIG_STATUS || ac_write_fail=1
-rm -f conf$$subs.awk
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-_ACAWK
-cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
-  for (key in S) S_is_set[key] = 1
-  FS = ""
-
-}
-{
-  line = $ 0
-  nfields = split(line, field, "@")
-  substed = 0
-  len = length(field[1])
-  for (i = 2; i < nfields; i++) {
-    key = field[i]
-    keylen = length(key)
-    if (S_is_set[key]) {
-      value = S[key]
-      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
-      len += length(value) + length(field[++i])
-      substed = 1
-    } else
-      len += 1 + keylen
-  }
-
-  print line
-}
-
-_ACAWK
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
-  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
-else
-  cat
-fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
-  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
-_ACEOF
-
-# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
-# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
-# trailing colons and then remove the whole line if VPATH becomes empty
-# (actually we leave an empty line to preserve line numbers).
-if test "x$srcdir" = x.; then
-  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
-h
-s///
-s/^/:/
-s/[	 ]*$/:/
-s/:\$(srcdir):/:/g
-s/:\${srcdir}:/:/g
-s/:@srcdir@:/:/g
-s/^:*//
-s/:*$//
-x
-s/\(=[	 ]*\).*/\1/
-G
-s/\n//
-s/^[^=]*=[	 ]*$//
-}'
-fi
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-fi # test -n "$CONFIG_FILES"
-
-
-eval set X "  :F $CONFIG_FILES      "
-shift
-for ac_tag
-do
-  case $ac_tag in
-  :[FHLC]) ac_mode=$ac_tag; continue;;
-  esac
-  case $ac_mode$ac_tag in
-  :[FHL]*:*);;
-  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
-  :[FH]-) ac_tag=-:-;;
-  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
-  esac
-  ac_save_IFS=$IFS
-  IFS=:
-  set x $ac_tag
-  IFS=$ac_save_IFS
-  shift
-  ac_file=$1
-  shift
-
-  case $ac_mode in
-  :L) ac_source=$1;;
-  :[FH])
-    ac_file_inputs=
-    for ac_f
-    do
-      case $ac_f in
-      -) ac_f="$ac_tmp/stdin";;
-      *) # Look for the file first in the build tree, then in the source tree
-	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
-	 # because $ac_f cannot contain `:'.
-	 test -f "$ac_f" ||
-	   case $ac_f in
-	   [\\/$]*) false;;
-	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
-	   esac ||
-	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
-      esac
-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
-      as_fn_append ac_file_inputs " '$ac_f'"
-    done
-
-    # Let's still pretend it is `configure' which instantiates (i.e., don't
-    # use $as_me), people would be surprised to read:
-    #    /* config.h.  Generated by config.status.  */
-    configure_input='Generated from '`
-	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
-	`' by configure.'
-    if test x"$ac_file" != x-; then
-      configure_input="$ac_file.  $configure_input"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
-$as_echo "$as_me: creating $ac_file" >&6;}
-    fi
-    # Neutralize special characters interpreted by sed in replacement strings.
-    case $configure_input in #(
-    *\&* | *\|* | *\\* )
-       ac_sed_conf_input=`$as_echo "$configure_input" |
-       sed 's/[\\\\&|]/\\\\&/g'`;; #(
-    *) ac_sed_conf_input=$configure_input;;
-    esac
-
-    case $ac_tag in
-    *:-:* | *:-) cat >"$ac_tmp/stdin" \
-      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
-    esac
-    ;;
-  esac
-
-  ac_dir=`$as_dirname -- "$ac_file" ||
-$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
-	 X"$ac_file" : 'X\(//\)[^/]' \| \
-	 X"$ac_file" : 'X\(//\)$' \| \
-	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
-$as_echo X"$ac_file" |
-    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)[^/].*/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\/\)$/{
-	    s//\1/
-	    q
-	  }
-	  /^X\(\/\).*/{
-	    s//\1/
-	    q
-	  }
-	  s/.*/./; q'`
-  as_dir="$ac_dir"; as_fn_mkdir_p
-  ac_builddir=.
-
-case "$ac_dir" in
-.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
-*)
-  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
-  # A ".." for each directory in $ac_dir_suffix.
-  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
-  case $ac_top_builddir_sub in
-  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
-  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
-  esac ;;
-esac
-ac_abs_top_builddir=$ac_pwd
-ac_abs_builddir=$ac_pwd$ac_dir_suffix
-# for backward compatibility:
-ac_top_builddir=$ac_top_build_prefix
-
-case $srcdir in
-  .)  # We are building in place.
-    ac_srcdir=.
-    ac_top_srcdir=$ac_top_builddir_sub
-    ac_abs_top_srcdir=$ac_pwd ;;
-  [\\/]* | ?:[\\/]* )  # Absolute name.
-    ac_srcdir=$srcdir$ac_dir_suffix;
-    ac_top_srcdir=$srcdir
-    ac_abs_top_srcdir=$srcdir ;;
-  *) # Relative name.
-    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
-    ac_top_srcdir=$ac_top_build_prefix$srcdir
-    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
-esac
-ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
-
-
-  case $ac_mode in
-  :F)
-  #
-  # CONFIG_FILE
-  #
-
-  case $INSTALL in
-  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
-  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
-  esac
-  ac_MKDIR_P=$MKDIR_P
-  case $MKDIR_P in
-  [\\/$]* | ?:[\\/]* ) ;;
-  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
-  esac
-_ACEOF
-
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-# If the template does not know about datarootdir, expand it.
-# FIXME: This hack should be removed a few years after 2.60.
-ac_datarootdir_hack=; ac_datarootdir_seen=
-ac_sed_dataroot='
-/datarootdir/ {
-  p
-  q
-}
-/@datadir@/p
-/@docdir@/p
-/@infodir@/p
-/@localedir@/p
-/@mandir@/p'
-case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
-*datarootdir*) ac_datarootdir_seen=yes;;
-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
-_ACEOF
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-  ac_datarootdir_hack='
-  s&@datadir@&$datadir&g
-  s&@docdir@&$docdir&g
-  s&@infodir@&$infodir&g
-  s&@localedir@&$localedir&g
-  s&@mandir@&$mandir&g
-  s&\\\${datarootdir}&$datarootdir&g' ;;
-esac
-_ACEOF
-
-# Neutralize VPATH when `$srcdir' = `.'.
-# Shell code in configure.ac might set extrasub.
-# FIXME: do we really want to maintain this feature?
-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
-ac_sed_extra="$ac_vpsub
-$extrasub
-_ACEOF
-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
-:t
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
-s|@configure_input@|$ac_sed_conf_input|;t t
-s&@top_builddir@&$ac_top_builddir_sub&;t t
-s&@top_build_prefix@&$ac_top_build_prefix&;t t
-s&@srcdir@&$ac_srcdir&;t t
-s&@abs_srcdir@&$ac_abs_srcdir&;t t
-s&@top_srcdir@&$ac_top_srcdir&;t t
-s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
-s&@builddir@&$ac_builddir&;t t
-s&@abs_builddir@&$ac_abs_builddir&;t t
-s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
-s&@INSTALL@&$ac_INSTALL&;t t
-s&@MKDIR_P@&$ac_MKDIR_P&;t t
-$ac_datarootdir_hack
-"
-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
-  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
-
-test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
-  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
-  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
-      "$ac_tmp/out"`; test -z "$ac_out"; } &&
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&5
-$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
-which seems to be undefined.  Please make sure it is defined" >&2;}
-
-  rm -f "$ac_tmp/stdin"
-  case $ac_file in
-  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
-  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
-  esac \
-  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
- ;;
-
-
-
-  esac
-
-done # for ac_tag
-
-
-as_fn_exit 0
-_ACEOF
-ac_clean_files=$ac_clean_files_save
-
-test $ac_write_fail = 0 ||
-  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
-
-
-# configure is writing to config.log, and then calls config.status.
-# config.status does its own redirection, appending to config.log.
-# Unfortunately, on DOS this fails, as config.log is still kept open
-# by configure, so config.status won't be able to write to it; its
-# output is simply discarded.  So we exec the FD to /dev/null,
-# effectively closing config.log, so it can be properly (re)opened and
-# appended to by config.status.  When coming back to configure, we
-# need to make the FD available again.
-if test "$no_create" != yes; then
-  ac_cs_success=:
-  ac_config_status_args=
-  test "$silent" = yes &&
-    ac_config_status_args="$ac_config_status_args --quiet"
-  exec 5>/dev/null
-  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
-  exec 5>>config.log
-  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
-  # would make configure fail if this is the last instruction.
-  $ac_cs_success || as_fn_exit 1
-fi
-if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
-$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
-fi
-
Index: trunk/gui/configure.in
===================================================================
--- trunk/gui/configure.in	(revision 6716)
+++ 	(revision )
@@ -1,191 +1,0 @@
-
-AC_INIT([RapptureGUI],[1.9],[rappture@nanohub.org])
-AC_CONFIG_AUX_DIR(cf)
-#------------------------------------------------------------------------
-# Handle the --prefix=... option
-#------------------------------------------------------------------------
-
-if test "${prefix}" = "NONE"; then
-    prefix=/usr/local
-fi
-if test "${exec_prefix}" = "NONE"; then
-    exec_prefix=$prefix
-fi
-
-INSTALL_PREFIX=$prefix
-
-if test "${libdir}" != "${prefix}/lib"; then
-    LIB_SEARCH_DIRS="-L${prefix}/lib -L${libdir}"
-else
-    LIB_SEARCH_DIRS="-L${libdir}"
-fi
-AC_CANONICAL_TARGET
-AC_SUBST(LIB_SEARCH_DIRS)
-
-AC_PROG_INSTALL
-AC_PROG_INSTALL
-AC_PROG_RANLIB
-AC_PROG_LN_S
-AC_PROG_MKDIR_P
-AC_PROG_MAKE_SET
-AC_PROG_CC
-
-#SC_CONFIG_CFLAGS
-#SC_ENABLE_SHARED
-
-SVN_VERSION=`svnversion $srcdir | sed 's/Unversioned directory/unknown/'`
-SVN_URL=`readlink -e $srcdir | xargs svn info | sed -ne 's/^URL: //p'`
-
-gui_with_tcl=""
-
-make_command=""
-for m in "$MAKE" make gmake gnumake ; do
-  if test "x${m}" != "x" ; then
-    if  ( sh -c "$m --version" 2>/dev/null | grep GNU >/dev/null ) ; then
-      make_command=$m; break;
-    fi
-  fi
-done
-if test "x${make_command}" = "x" ; then
-  AC_MSG_ERROR([Requires GNU make. You can specify a version with \$MAKE])
-fi
-AC_SUBST(MAKE, ${make_command})
-
-AC_ARG_ENABLE(
-    [gui],
-    [AS_HELP_STRING([--enable-gui], [build code related to the graphical user interface @<:@default=yes@:>@])],
-    [],
-    [enable_gui=yes])
-
-ENABLE_GUI=
-if test "$enable_gui" != "no" ; then
-    ENABLE_GUI="yes"
-fi
-AC_SUBST(ENABLE_GUI)
-
-with_tclsh="yes"
-AC_ARG_WITH(
-    [tclsh],
-    [AS_HELP_STRING([--with-tclsh[=DIR]],
-        [location of tclsh @<:@default=yes@:>@])],
-    [],
-    [with_tclsh=yes])
-
-TCLSH=
-# -----------------------------------------------------------------------
-#
-#	Find the Tcl build configuration file "tclConfig.sh"
-#
-# -----------------------------------------------------------------------
-
-AC_MSG_CHECKING([for tclConfig.sh])
-tcl_config_sh=""
-if test "x$gui_with_tcl" != "x" ; then
-
-  # Verify that a tclConfig.sh file exists in the directory specified 
-  # by --with-tcl. 
-
-  for dir in \
-   $gui_with_tcl 
-  do
-    if test -r "$dir/tclConfig.sh" ; then
-      tcl_config_sh="$dir/tclConfig.sh"
-      break
-    elif test -r "$dir/lib/tclConfig.sh" ; then
-      tcl_config_sh="$dir/lib/tclConfig.sh"
-      break
-    fi
-  done
-else 
-
-  # Otherwise, search for Tcl configuration file.  
-
-  #  1. Search previously named locations.
-
-  for dir in \
-   $prefix \
-   $exec_prefix \
-   $gui_cv_tcl_lib 
-  do
-    if test -r "$dir/tclConfig.sh" ; then
-      tcl_config_sh="$dir/tclConfig.sh"
-      break
-    elif test -r "$dir/lib/tclConfig.sh" ; then
-      tcl_config_sh="$dir/lib/tclConfig.sh"
-      break
-    fi
-  done
-fi
-
-AC_MSG_RESULT([${tcl_config_sh}])
-
-if test "x$tcl_config_sh" = "x" ; then
-  echo "can't find Tcl configuration script \"tclConfig.sh\""
-  exit 1
-fi
-. ${tcl_config_sh}
-TCL_INC_SPEC="$TCL_INCLUDE_SPEC"
-
-case $target in
-  *-*-cygwin*|*-*-mingw*)
-    gui_platform="win"
-    TCLSH=${TCL_PREFIX}/bin/tclsh${TCL_MAJOR_VERSION}${TCL_MINOR_VERSION}
-    ;;
-  *-*-darwin*)
-    gui_platform="macosx"
-    TCLSH=${TCL_PREFIX}/bin/tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}
-    ;;
-  *)
-    blt_platform="unix" 
-    TCLSH=${TCL_PREFIX}/bin/tclsh${TCL_MAJOR_VERSION}.${TCL_MINOR_VERSION}
-    ;;
-esac
-
-AC_MSG_RESULT([${TCLSH}])
-AC_SUBST(TCLSH)
-
-if test -f "${exec_prefix}/lib/tclConfig.sh" ; then 
-  . ${exec_prefix}/lib/tclConfig.sh
-fi
-if test -f "${exec_prefix}/lib/tkConfig.sh" ; then 
-  . ${exec_prefix}/lib/tkConfig.sh	
-fi
-
-AC_SUBST(INSTALL_PREFIX)
-AC_SUBST(SVN_URL)
-AC_SUBST(SVN_VERSION)
-AC_SUBST(TCL_CFLAGS_DEBUG)
-AC_SUBST(TCL_CFLAGS_OPTIMIZE)
-AC_SUBST(TCL_INC_SPEC)
-AC_SUBST(TCL_LIB_SPEC)
-AC_SUBST(TCL_SHLIB_CFLAGS)
-AC_SUBST(TCL_SHLIB_LD)
-AC_SUBST(TCL_SHLIB_LDFLAGS)
-AC_SUBST(TCL_SHLIB_SUFFIX)
-AC_SUBST(TCL_SRC_DIR)
-AC_SUBST(TCL_STLIB_LD)
-AC_SUBST(TCL_VERSION)
-AC_SUBST(TK_INC_SPEC)
-AC_SUBST(TK_LIB_SPEC)
-AC_SUBST(TK_SRC_DIR)
-AC_SUBST(TK_XLIBSW)
-AC_SUBST(TK_VERSION)
-
-
-AC_CONFIG_FILES([
-    Makefile
-    pkgIndex.tcl
-    apps/Makefile
-    apps/about
-    apps/encodedata
-    apps/rappture
-    apps/rappture-csh.env
-    apps/rappture.env
-    apps/rappture.use
-    apps/rerun
-    apps/simsim
-    apps/xmldiff
-    scripts/Makefile
-    src/Makefile
-])
-AC_OUTPUT
Index: trunk/gui/pkgIndex.tcl.in
===================================================================
--- trunk/gui/pkgIndex.tcl.in	(revision 6716)
+++ 	(revision )
@@ -1,18 +1,0 @@
-# HACK: The Img library needs to be loaded before RapptureGUI
-# to avoid conflicts with libjpeg, libtiff, etc.
-package ifneeded RapptureGUI @PACKAGE_VERSION@ [format {
-    package require Img
-    set dir [file normalize "%s"]
-    set version @PACKAGE_VERSION@
-    lappend auto_path [file join $dir scripts]
-    namespace eval RapptureGUI {
-	variable version $version
-	variable build "@SVN_VERSION@"
-	variable svnurl "@SVN_URL@"
-	variable installdir $dir
-	variable library $dir
-    }
-    set ext [info sharedlibextension]
-    load [file join $dir "RapptureGUI${version}${ext}"]
-    package provide RapptureGUI $version
-} $dir]
Index: trunk/gui/scripts/Makefile.in
===================================================================
--- trunk/gui/scripts/Makefile.in	(revision 6716)
+++ 	(revision )
@@ -1,190 +1,0 @@
-
-
-srcdir		= @srcdir@
-prefix		= @prefix@
-exec_prefix	= @exec_prefix@
-bindir		= @bindir@
-libdir		= @libdir@
-datadir		= @datadir@
-datarootdir	= @datarootdir@
-mandir		= @mandir@
-includedir	= @includedir@
-
-SHELL		= @SHELL@
-INSTALL		= @INSTALL@
-MKDIR_P		= @MKDIR_P@
-TCLSH		= @TCLSH@
-VPATH		= $(srcdir)
-PACKAGE_VERSION = @PACKAGE_VERSION@
-
-FILES		= \
-		$(srcdir)/analyzer.tcl \
-		$(srcdir)/animicon.tcl \
-		$(srcdir)/animover.tcl \
-		$(srcdir)/balloon.tcl \
-		$(srcdir)/barchartresult.tcl \
-		$(srcdir)/booleanentry.tcl \
-		$(srcdir)/bugreport.tcl \
-		$(srcdir)/choiceentry.tcl \
-		$(srcdir)/cloud.tcl \
-		$(srcdir)/color.tcl \
-		$(srcdir)/combobox.tcl \
-		$(srcdir)/combochecks.tcl \
-		$(srcdir)/controlOwner.tcl \
-		$(srcdir)/controls.tcl \
-		$(srcdir)/coverflow.tcl \
-		$(srcdir)/curve.tcl \
-		$(srcdir)/datatable.tcl \
-		$(srcdir)/datatableresult.tcl \
-		$(srcdir)/deviceEditor.tcl \
-		$(srcdir)/deviceLayout1D.tcl \
-		$(srcdir)/deviceViewer1D.tcl \
-		$(srcdir)/deviceresult.tcl \
-		$(srcdir)/diffview.tcl \
-		$(srcdir)/dispatcher.tcl \
-		$(srcdir)/drawing.tcl \
-		$(srcdir)/drawingentry.tcl \
-		$(srcdir)/dropdown.tcl \
-		$(srcdir)/dropdownchecks.tcl \
-		$(srcdir)/dropdownlist.tcl \
-		$(srcdir)/editor.tcl \
-		$(srcdir)/energyLevels.tcl \
-		$(srcdir)/field.tcl \
-		$(srcdir)/fieldresult.tcl \
-		$(srcdir)/filechoiceentry.tcl \
-		$(srcdir)/filelistentry.tcl \
-		$(srcdir)/filexfer.tcl \
-		$(srcdir)/flowdial.tcl \
-		$(srcdir)/flowhints.tcl \
-		$(srcdir)/flowspeed.tcl \
-		$(srcdir)/flowvisviewer.tcl \
-		$(srcdir)/gauge.tcl \
-		$(srcdir)/getopts.tcl \
-		$(srcdir)/grab.tcl \
-		$(srcdir)/groupentry.tcl \
-		$(srcdir)/histogram.tcl \
-		$(srcdir)/histogramresult.tcl \
-		$(srcdir)/htmlviewer.tcl \
-		$(srcdir)/icons.tcl \
-		$(srcdir)/image.tcl \
-		$(srcdir)/imageentry.tcl \
-		$(srcdir)/imageresult.tcl \
-		$(srcdir)/integerentry.tcl \
-		$(srcdir)/isomarker.tcl \
-		$(srcdir)/transferfunctioneditor.tcl \
-		$(srcdir)/loader.tcl \
-		$(srcdir)/logger.tcl \
-		$(srcdir)/main.tcl \
-		$(srcdir)/mainwin.tcl \
-		$(srcdir)/map.tcl \
-		$(srcdir)/mapentry.tcl \
-		$(srcdir)/mapviewer.tcl \
-		$(srcdir)/mesh.tcl \
-		$(srcdir)/meshresult.tcl \
-		$(srcdir)/molvisviewer.tcl \
-		$(srcdir)/multichoiceentry.tcl \
-		$(srcdir)/nanovisviewer.tcl \
-		$(srcdir)/note.tcl \
-		$(srcdir)/notebook.tcl \
-		$(srcdir)/numberentry.tcl \
-		$(srcdir)/numberresult.tcl \
-		$(srcdir)/page.tcl \
-		$(srcdir)/pager.tcl \
-		$(srcdir)/panes.tcl \
-		$(srcdir)/periodicelement.tcl \
-		$(srcdir)/periodicelemententry.tcl \
-		$(srcdir)/periodictable.tcl \
-		$(srcdir)/postern.tcl \
-		$(srcdir)/probdisteditor.tcl \
-		$(srcdir)/progress.tcl \
-		$(srcdir)/pushbutton.tcl \
-		$(srcdir)/radiodial.tcl \
-		$(srcdir)/resultset.tcl \
-		$(srcdir)/response.tcl \
-		$(srcdir)/responseviewer.tcl \
-		$(srcdir)/resultselector.tcl \
-		$(srcdir)/resultviewer.tcl \
-		$(srcdir)/scroller.tcl \
-		$(srcdir)/sequence.tcl \
-		$(srcdir)/sequencedial.tcl \
-		$(srcdir)/sequenceresult.tcl \
-		$(srcdir)/service.tcl \
-		$(srcdir)/sidebarframe.tcl \
-		$(srcdir)/spectrum.tcl \
-		$(srcdir)/spinint.tcl \
-		$(srcdir)/switch.tcl \
-		$(srcdir)/table.tcl \
-		$(srcdir)/tempgauge.tcl \
-		$(srcdir)/textentry.tcl \
-		$(srcdir)/textresult.tcl \
-		$(srcdir)/tool.tcl \
-		$(srcdir)/tooltip.tcl \
-		$(srcdir)/tuples.tcl \
-		$(srcdir)/tweener.tcl \
-		$(srcdir)/unirect2d.tcl \
-		$(srcdir)/unirect3d.tcl \
-		$(srcdir)/units.tcl \
-		$(srcdir)/utils.tcl \
-		$(srcdir)/uq.tcl \
-		$(srcdir)/uqcurve.tcl \
-		$(srcdir)/uqinfo.tcl \
-		$(srcdir)/uqnotebook.tcl \
-		$(srcdir)/valueresult.tcl \
-		$(srcdir)/videochooser.tcl \
-		$(srcdir)/videochooserinfo.tcl \
-		$(srcdir)/videodial.tcl \
-		$(srcdir)/videodial1.tcl \
-		$(srcdir)/videodial2.tcl \
-		$(srcdir)/videodistance.tcl \
-		$(srcdir)/videoscreen.tcl \
-		$(srcdir)/videospeed.tcl \
-		$(srcdir)/videoparticle.tcl \
-		$(srcdir)/videopreview.tcl \
-		$(srcdir)/visviewer.tcl \
-		$(srcdir)/vtkviewer.tcl \
-		$(srcdir)/vtkglyphviewer.tcl \
-		$(srcdir)/vtkisosurfaceviewer.tcl \
-		$(srcdir)/vtkmeshviewer.tcl \
-		$(srcdir)/vtkstreamlinesviewer.tcl \
-		$(srcdir)/vtksurfaceviewer.tcl \
-		$(srcdir)/vtkvolumeviewer.tcl \
-		$(srcdir)/vtkheightmapviewer.tcl \
-		$(srcdir)/vtkimageviewer.tcl \
-		$(srcdir)/xylegend.tcl \
-		$(srcdir)/xyprint.tcl \
-		$(srcdir)/xyresult.tcl
-
-version 	= $(PACKAGE_VERSION)
-name 		= RapptureGUI$(version)
-
-destdir		= $(libdir)/$(name)/scripts
-
-all: tclIndex
-
-tclIndex: $(FILES)
-	$(TCLSH) $(srcdir)/../cf/mkindex.tcl --srcdir $(srcdir) \
-		--outfile tclIndex
-
-install: all install_scripts install_images
-
-install_scripts:
-	$(MKDIR_P) -m 0755 $(destdir)
-	@for i in $(FILES); do \
-	    echo "Installing $$i" ; \
-	    $(INSTALL) -m 0444 $$i $(destdir) ; \
-	done
-	$(INSTALL) -m 0444 tclIndex $(destdir)
-
-install_images:
-	$(MKDIR_P) -m 0755 $(destdir)/images
-	@for i in $(srcdir)/images/*.gif $(srcdir)/images/*.png $(srcdir)/images/*.xbm; do \
-	    echo "Installing $$i" ; \
-	    $(INSTALL) -m 0444 $$i $(destdir)/images ; \
-	done
-
-clean:
-	$(RM) tclIndex
-
-distclean: clean
-	$(RM) Makefile *~
-
Index: trunk/gui/scripts/analyzer.tcl
===================================================================
--- trunk/gui/scripts/analyzer.tcl	(revision 6716)
+++ trunk/gui/scripts/analyzer.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: analyzer - output area for Rappture
@@ -11,124 +10,36 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
-
-option add *Analyzer.width 3.5i widgetDefault
-option add *Analyzer.height 4i widgetDefault
-option add *Analyzer.simControl "auto" widgetDefault
-option add *Analyzer.simControlBackground "" widgetDefault
-option add *Analyzer.simControlOutline gray widgetDefault
-option add *Analyzer.simControlActiveBackground #ffffcc widgetDefault
-option add *Analyzer.simControlActiveOutline black widgetDefault
-option add *Analyzer.notebookpage "about" widgetDefault
-
-option add *Analyzer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-option add *Analyzer.codeFont \
-    -*-courier-medium-r-normal-*-12-* widgetDefault
+package require BLT
+
 option add *Analyzer.textFont \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-option add *Analyzer.boldTextFont \
-    -*-helvetica-bold-r-normal-*-12-* widgetDefault
+    -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
 
 itcl::class Rappture::Analyzer {
     inherit itk::Widget
 
-    itk_option define -codefont codeFont Font ""
-    itk_option define -textfont textFont Font ""
-    itk_option define -boldtextfont boldTextFont Font ""
-    itk_option define -simcontrol simControl SimControl ""
-    itk_option define -simcontroloutline simControlOutline Background ""
-    itk_option define -simcontrolbackground simControlBackground Background ""
-    itk_option define -simcontrolactiveoutline simControlActiveOutline Background ""
-    itk_option define -simcontrolactivebackground simControlActiveBackground Background ""
+    itk_option define -tool tool Tool ""
+    itk_option define -device device Device ""
+    itk_option define -analysis analysis Analysis ""
     itk_option define -holdwindow holdWindow HoldWindow ""
-    itk_option define -notebookpage notebookPage NotebookPage ""
-
-    constructor {tool args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method simulate {args}
-    public method reset {{when -eventually}}
-    public method load {xmlobj}
-    public method reload { fileName }
-    public method clear {{xmlobj "all"}}
-    public method download {option args}
-    public method buildMenu { w url appName }
-
-    protected method _plot {args}
-    protected method _reorder {comps}
-    protected method _autoLabel {xmlobj path title cntVar}
+
+    constructor {args} { # defined below }
+    destructor { # defined below }
+
+    public method simulate {}
+    public method reset {}
+    public method load {file}
+
     protected method _fixResult {}
-    protected method _fixResultSet {args}
-    protected method _fixSize {}
-    protected method _fixSimControl {}
-    protected method _fixNotebook {}
-    protected method _simState {state args}
-    protected method _simOutput {message}
-    protected method _resultTooltip {}
-    protected method _isPdbTrajectory {data}
-    protected method _isLammpsTrajectory {data}
-    protected method _pdbToSequence {xmlobj path id child data}
-    protected method _lammpsToSequence {xmlobj path id child data}
-    protected method _trajToSequence {xmlobj {path ""}}
-    protected method _pop_uq_dialog {win}
-    protected method _setWaitVariable {state}
-    protected method _adjust_level {win}
-
-    private variable _done 0
-    private variable _tree ""
-    private variable _saved 
-    private variable _name "" 
-    private variable _revision 0;       # Tool revision
-    private variable _tool ""          ;# belongs to this tool
-    private variable _appName ""       ;# Name of application
+
+    private variable _run ""           ;# results from last run
     private variable _control "manual" ;# start mode
-    private variable _resultset ""     ;# ResultSet object with all results
-    private variable _pages 0          ;# number of pages for result sets
-    private variable _label2page       ;# maps output label => result set
-    private variable _label2desc       ;# maps output label => description
-    private variable _label2item       ;# maps output label => output.xxx item
-    private variable _lastlabel ""     ;# label of last example loaded
-    private variable _plotlist ""      ;# items currently being plotted
-    private variable _lastPlot
-    private variable _uq_active 0      ;# a UQ variables has been used
-    private variable _wait_uq 0
+    private variable _widgets          ;# maps analyze section => widget
+
     private common job                 ;# array var used for blt::bgexec jobs
-
-    private method BuildQuestionDialog { popup }
-    private method BuildSimulationTable { w }
-    private method Cancel {}
-    private method CheckSimsetDetails {}
-    private method CleanName { name }
-    private method CreateSharedPath { path } 
-    private method EditSimset {}
-    private method ExportFile { src msgFile }
-    private method ExportURL { appName installdir } 
-    private method FindSimsetsForApp { appName }
-    private method GetSimset { name }
-    private method InstallSharedFile { installdir file } 
-    private method LoadSimulations { runfiles }
-    private method Ok {}
-    private method OverwriteSaveFile {}
-    private method PostMenu { menu }
-    private method ReadSimsetFile { fileName }
-    private method Save {}
-    private method SaveSimulations {}
-    private method SelectSimsetForDeletion {}
-    private method SelectSimsetForLoading {}
-    private method SelectSimsetNameAndSave {}
-    private method SelectSimsetToShare {}
-    private method WriteSimsetFile { appName fileName share }
-}
-
+}
+                                                                                
 itk::usual Analyzer {
     keep -background -cursor foreground -font
@@ -138,126 +49,9 @@
 # CONSTRUCTOR
 # ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::constructor {tool args} {
-    set _tool $tool
-    set _tree [blt::tree create]
-
-    # use this to store all simulation results
-    set _resultset [Rappture::ResultSet ::\#auto]
-    $_resultset notify add $this [itcl::code $this _fixResultSet]
-
-    # widget settings...
-    itk_option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    frame $itk_interior.simol -borderwidth 1 -relief flat
-    pack $itk_interior.simol -fill x
-
-    itk_component add simbg {
-        frame $itk_interior.simol.simbg -borderwidth 0
-    } {
-        usual
-        rename -background -simcontrolcolor simControlColor Color
-    }
-    pack $itk_component(simbg) -expand yes -fill both
-
-    set simtxt [string trim [$tool xml get tool.action.label]]
-    if {"" == $simtxt} {
-        set simtxt "Simulate"
-    }
-    itk_component add simulate {
-        button $itk_component(simbg).simulate -text $simtxt \
-            -command [itcl::code $this simulate]
-    } {
-        usual
-        rename -highlightbackground -simcontrolcolor simControlColor Color
-    }
-    pack $itk_component(simulate) -side left -padx 4 -pady 4
-
-    # BE CAREFUL: Shift focus when we click on "Simulate".
-    #   This shifts focus away from input widgets and causes them to
-    #   finalize and log any pending changes.  A better way would be
-    #   to have the "sync" operation finalize/sync, but this works
-    #   for now.
-    bind $itk_component(simulate) <ButtonPress> {focus %W}
-
-    # if there's a hub url, then add "About" and "Questions" links
-    global rapptureInfo
-    if { $rapptureInfo(appName) == "" } {
-        set _appName [$_tool xml get "tool.id"]
-    } else {
-        set _appName $rapptureInfo(appName)
-    }
-    set num [$_tool xml get "tool.version.application.revision"]
-    if { $num == "" } {
-        set num 0
-    }
-    set _revision $num
-    set url [Rappture::Tool::resources -huburl]
-
-    itk_component add hubcntls {
-        frame $itk_component(simbg).hubcntls
-    } {
-        usual
-        rename -background -simcontrolcolor simControlColor Color
-    }
-    pack $itk_component(hubcntls) -side right -padx 4
-    
-    itk_component add help {
-        menubutton $itk_component(hubcntls).help \
-            -image [Rappture::icon hamburger_menu] \
-            -highlightthickness 0 \
-            -menu $itk_component(hubcntls).help.menu
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -simcontrolcolor simControlColor Color
-    }
-    pack $itk_component(help) -side left
-    buildMenu $itk_component(help).menu $url $_appName
-    
-    itk_component add simstatus {
-        text $itk_component(simbg).simstatus -borderwidth 0 \
-            -highlightthickness 0 -height 1 -width 1 -wrap none \
-            -state disabled
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -simcontrolcolor simControlColor Color
-        rename -font -textfont textFont Font
-    }
-    pack $itk_component(simstatus) -side left -expand yes -fill x
-
-    $itk_component(simstatus) tag configure popup \
-        -underline 1 -foreground blue
-
-    $itk_component(simstatus) tag bind popup \
-        <Enter> {%W configure -cursor center_ptr}
-    $itk_component(simstatus) tag bind popup \
-        <Leave> {%W configure -cursor ""}
-    $itk_component(simstatus) tag bind popup \
-        <ButtonPress> {after idle {Rappture::Tooltip::tooltip show %W}}
-
-
+itcl::body Rappture::Analyzer::constructor {args} {
     itk_component add notebook {
         Rappture::Notebook $itk_interior.nb
     }
     pack $itk_interior.nb -expand yes -fill both
-
-    # ------------------------------------------------------------------
-    # ABOUT PAGE
-    # ------------------------------------------------------------------
-    set w [$itk_component(notebook) insert end about]
-
-    Rappture::Scroller $w.info -xscrollmode off -yscrollmode auto
-    pack $w.info -expand yes -fill both -padx 4 -pady 20
-    itk_component add toolinfo {
-        text $w.info.text -width 1 -height 1 -wrap word \
-            -borderwidth 0 -highlightthickness 0
-    } {
-        usual
-        ignore -borderwidth -relief
-        rename -font -textfont textFont Font
-    }
-    $w.info contents $w.info.text
 
     # ------------------------------------------------------------------
@@ -266,18 +60,24 @@
     set w [$itk_component(notebook) insert end simulate]
     frame $w.cntls
-    pack $w.cntls -side bottom -fill x -pady 12
-    frame $w.cntls.sep -background black -height 1
-    pack $w.cntls.sep -side top -fill x
-
-    itk_component add abort {
-        button $w.cntls.abort -text "Abort" \
-            -command [itcl::code $_tool abort]
-    }
-    pack $itk_component(abort) -side left -expand yes -padx 4 -pady 4
-
-    Rappture::Scroller $w.info -xscrollmode auto -yscrollmode auto
-    pack $w.info -expand yes -fill both -padx 4 -pady 4
-    itk_component add runinfo {
-        text $w.info.text -width 1 -height 1 -wrap none \
+    pack $w.cntls -side top -fill x -padx {20 2}
+
+    itk_component add simulate {
+        button $w.cntls.sim -text "Simulate" \
+            -command [itcl::code $this simulate]
+    }
+    pack $itk_component(simulate) -side left
+
+    itk_component add status {
+        label $w.cntls.info -width 1 -text "" -anchor w
+    } {
+        usual
+        rename -font -textfont textFont Font
+    }
+    pack $itk_component(status) -side left -expand yes -fill both
+
+    Rappture::Scroller $w.info -xscrollmode off -yscrollmode auto
+    pack $w.info -expand yes -fill both -padx {20 2} -pady {20 2}
+    itk_component add info {
+        text $w.info.text -width 1 -height 1 -wrap word \
             -borderwidth 0 -highlightthickness 0 \
             -state disabled
@@ -285,11 +85,7 @@
         usual
         ignore -borderwidth -relief
-        rename -font -codefont codeFont Font
+        rename -font -textfont textFont Font
     }
     $w.info contents $w.info.text
-
-    itk_component add progress {
-        Rappture::Progress $w.progress
-    }
 
     # ------------------------------------------------------------------
@@ -298,103 +94,19 @@
     set w [$itk_component(notebook) insert end analyze]
 
-    frame $w.top
-    pack $w.top -side top -fill x -pady 8
-    label $w.top.l -text "Result:" -font $itk_option(-font)
-    pack $w.top.l -side left
-
-    itk_component add viewselector {
-        Rappture::Combobox $w.top.sel -width 10 -editable no
+    itk_component add resultselector {
+        Rappture::Combobox $w.sel -width 30 -editable no
     } {
         usual
         rename -font -textfont textFont Font
     }
-    pack $itk_component(viewselector) -side left -expand yes -fill x
-    bind $itk_component(viewselector) <<Value>> [itcl::code $this _fixResult]
-    bind $itk_component(viewselector) <Enter> \
-        [itcl::code $this download coming]
-
-    Rappture::Tooltip::for $itk_component(viewselector) \
-        "@[itcl::code $this _resultTooltip]"
-
-    $itk_component(viewselector) choices insert end \
-        --- "---"
-
-    itk_component add download {
-        button $w.top.dl -image [Rappture::icon download] -anchor e \
-            -borderwidth 1 -relief flat -overrelief raised \
-            -command [itcl::code $this download start $w.top.dl]
-    }
-    pack $itk_component(download) -side right -padx {4 0}
-    bind $itk_component(download) <Enter> \
-        [itcl::code $this download coming]
-
-    $itk_component(viewselector) choices insert end \
-        @download [Rappture::filexfer::label download]
-
-    if {[Rappture::filexfer::enabled]} {
-        Rappture::Tooltip::for $itk_component(download) "Downloads the current result to a new web browser window on your desktop.  From there, you can easily print or save results.
-
-NOTE:  Your web browser must allow pop-ups from this site.  If your output does not appear, look for a 'pop-up blocked' message and enable pop-ups."
-    } else {
-        Rappture::Tooltip::for $itk_component(download) "Saves the current result to a file on your desktop."
-    }
+    pack $itk_component(resultselector) -side top -fill x -padx {20 2}
+    bind $itk_component(resultselector) <<Value>> [itcl::code $this _fixResult]
 
     itk_component add results {
-        Rappture::Panes $w.pane \
-            -sashwidth 2 -sashrelief solid -sashpadding {2 0}
-    } {
-        usual
-        ignore -sashwidth -sashrelief -sashpadding
-    }
-    pack $itk_component(results) -expand yes -fill both
-    set f [$itk_component(results) pane 0]
-
-    itk_component add resultpages {
-        Rappture::Notebook $f.nb
-    }
-    pack $itk_component(resultpages) -expand yes -fill both
-    set f [$itk_component(results) insert end -fraction 0.1]
-    itk_component add resultselector {
-        Rappture::ResultSelector $f.rsel -resultset $_resultset \
-            -settingscommand [itcl::code $this _plot]
-    }
-    pack $itk_component(resultselector) -expand yes -fill both
-    bind $itk_component(resultselector) <<Layout>> [itcl::code $this _fixSize]
-    bind $itk_component(results) <Configure> [itcl::code $this _fixSize]
+        Rappture::Notebook $w.nb
+    }
+    pack $itk_component(results) -expand yes -fill both -pady 4
 
     eval itk_initialize $args
-
-    $itk_component(runinfo) tag configure ERROR -foreground red
-    $itk_component(runinfo) tag configure text -font $itk_option(-textfont)
-
-    #
-    # Load up tool info on the first page.
-    #
-    $itk_component(toolinfo) tag configure title \
-        -font $itk_option(-boldtextfont)
-
-    set mesg [string trim [$tool xml get tool.title]]
-    if {"" != $mesg} {
-        $itk_component(toolinfo) insert end $mesg title
-        $itk_component(toolinfo) insert end "\n\n"
-    }
-
-    set mesg [string trim [$tool xml get tool.about]]
-    if {"" != $mesg} {
-        $itk_component(toolinfo) insert end $mesg
-    }
-    $itk_component(toolinfo) configure -state disabled
-    $itk_component(notebook) current about
-
-    # tool can run on "manual" (default) or "auto"
-    set cntl [string trim [$tool xml get tool.control]]
-    if {"" == $cntl} {
-        set cntl [string trim [$tool xml get tool.control.type]]
-    }
-    if {"" != $cntl} {
-        set _control $cntl
-    }
-
-    # reset everything to a clean state
     reset
 }
@@ -404,123 +116,89 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Analyzer::destructor {} {
-    after cancel [itcl::code $this simulate]
-    $_resultset notify remove $this
-    itcl::delete object $_resultset
-}
-
-# ----------------------------------------------------------------------
-# USAGE: simulate ?-ifneeded?
-# USAGE: simulate ?<path1> <value1> <path2> <value2> ...?
-#
-# Kicks off the simulator by executing the tool.command associated
-# with the tool.  If any arguments are specified, they are used to
-# set parameters for the simulation.  While the simulation is running,
-# it shows status.  When the simulation is finished, it switches
-# automatically to "analyze" mode and shows the results.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::simulate {args} {
-
-    set uq [$_tool get_uq -uq_type smolyak -uq_args 2]
-
-    # pop up UQ window
-    if {[$uq num_runs] > 1} {
-        set _uq_active 1
-        set status [$uq run_dialog $itk_component(simulate)]
+    if {$_run != ""} {
+        itcl::delete object $_run
+    }
+}
+
+# ----------------------------------------------------------------------
+# USAGE: simulate
+#
+# If the simulation page is showing, this kicks off the simulator
+# by executing the executable.command associated with the -tool.  While
+# the simulation is running, it shows status.  When the simulation is
+# finished, it switches automatically to "analyze" mode and shows
+# the results.
+# ----------------------------------------------------------------------
+itcl::body Rappture::Analyzer::simulate {} {
+    if {[$itk_component(notebook) current] == "simulate"} {
+        $itk_component(status) configure -text "Running simulation..."
+        $itk_component(simulate) configure -text "Abort" \
+            -command {set ::Rappture::Analyzer::job(control) abort}
+
+        set job(control) ""
+
+        # if the hold window is set, then put up a busy cursor
+        if {$itk_option(-holdwindow) != ""} {
+            blt::busy hold $itk_option(-holdwindow)
+            raise $itk_component(hull)
+            update
+        }
+
+        # write out the driver.xml file for the tool
+        set status [catch {
+            set fid [open driver.xml w]
+            puts $fid "<?xml version=\"1.0\"?>"
+            set xml [$itk_option(-tool) xml]
+            set xml2 [$itk_option(-device) xml]
+            regsub -all {&} $xml2 {\\\&} xml2
+            regsub {</tool>} $xml "$xml2</tool>" xml
+            puts $fid $xml
+            close $fid
+        } result]
+
+        # execute the tool using the path from the tool description
         if {$status == 0} {
-            # cancelled
-            return
-        }
-        lappend args -uq_type [$uq type]
-        lappend args -uq_args [$uq args]
-        # Need to put these UQ values into the driver file
-        # so the call to resultset::contains will be correct.
-        set _xml [$_tool xml object]
-        $_xml put uq.type.current [$uq type]
-        $_xml put uq.args.current [$uq args]
-        $_xml put uq.args.about.label "level"
-        $_xml put uq.args.about.description "Polynomial Degree of Smolyak GPC method."
-    }
-    #puts "simulate args=$args"
-
-    if {[lindex $args 0] == "-ifneeded"} {
-        # check to see if simulation is really needed
-        $_tool sync
-        if {[$_resultset contains [$_tool xml object]] &&
-            ![string equal $_control "manual-resim"]} {
-            # not needed -- show results and return
+            set cmd [$itk_option(-tool) get executable.command]
+
+            set status [catch {eval blt::bgexec \
+                ::Rappture::Analyzer::job(control) \
+                -output ::Rappture::Analyzer::job(output) \
+                -error ::Rappture::Analyzer::job(error) $cmd} result]
+        }
+
+        # read back the results from run.xml
+        if {$status == 0} {
+            set status [catch {load run.xml} result]
+        }
+
+        # back to normal
+        if {$itk_option(-holdwindow) != ""} {
+            blt::busy release $itk_option(-holdwindow)
+        }
+        $itk_component(status) configure -text ""
+        $itk_component(simulate) configure -text "Simulate" \
+            -command [itcl::code $this simulate]
+
+        # if anything went wrong, tell the user; otherwise, analyze
+        if {[regexp {^KILLED} $job(control)]} {
+            # job aborted -- do nothing
+        } elseif {$status != 0} {
+            $itk_component(info) configure -state normal
+            $itk_component(info) delete 1.0 end
+            $itk_component(info) insert end "Problem launching job:\n"
+            if {[string length $job(error)] > 0} {
+                $itk_component(info) insert end $job(error)
+            } else {
+                $itk_component(info) insert end $result
+            }
+            $itk_component(info) configure -state disabled
+        } else {
             $itk_component(notebook) current analyze
-            return
-        }
-        set args [lreplace $args 0 0]
-    }
-
-    # simulation is needed -- go to simulation page
-    $itk_component(notebook) current simulate
-
-    # no progress messages yet
-    pack forget $itk_component(progress)
-    lappend args -output [itcl::code $this _simOutput]
-
-    _simState off
-    $itk_component(runinfo) configure -state normal
-    $itk_component(runinfo) delete 1.0 end
-    $itk_component(runinfo) insert end "Running simulation...\n\n" text
-    $itk_component(runinfo) configure -state disabled
-
-    # if the hold window is set, then put up a busy cursor
-    if {$itk_option(-holdwindow) != ""} {
-        blt::busy hold $itk_option(-holdwindow)
-        raise $itk_component(hull)
-    }
-
-    # execute the job
-    #puts "$_tool run $args"
-
-    foreach {status result} [eval $_tool run $args] break
-
-    # if job was aborted, then allow simulation again
-    if {$result == "ABORT"} {
-        _simState on "Aborted"
-    }
-
-    # load results from run.xml into analyzer
-    if {$status == 0 && $result != "ABORT"} {
-        set status [catch {load $result} result]
-    }
-
-    # back to normal
-    if {$itk_option(-holdwindow) != ""} {
-        blt::busy release $itk_option(-holdwindow)
-    }
-    $itk_component(abort) configure -state disabled
-
-    if {$status != 0} {
-        $itk_component(runinfo) configure -state normal
-        # Don't erase program error messages.
-        # $itk_component(runinfo) delete 1.0 end
-        $itk_component(runinfo) insert end "\n\nProblem launching job:\n\n" text
-        _simOutput $result
-        $itk_component(runinfo) configure -state disabled
-        $itk_component(runinfo) see 1.0
-
-        # Try to create a support ticket for this error.
-        # It may be a real problem.
-        if {[Rappture::bugreport::shouldReport for jobs]} {
-            set ::errorInfo "\n\n== RAPPTURE INPUT ==\n[$_tool xml xml]"
-            Rappture::bugreport::register "Problem launching job:\n$result"
-            Rappture::bugreport::attachment [$_tool xml xml]
-            Rappture::bugreport::send
-        }
-    } else {
-        $itk_component(notebook) current analyze
-    }
-
-    # do this last -- after _simOutput above
-    pack forget $itk_component(progress)
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: reset ?-eventually|-now?
+        }
+    }
+}
+
+# ----------------------------------------------------------------------
+# USAGE: reset
 #
 # Used to reset the analyzer whenever the input to a simulation has
@@ -529,253 +207,34 @@
 # to "auto", the simulation is invoked immediately.
 # ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::reset {{when -eventually}} {
-    if {$when == "-eventually"} {
-        after cancel [list catch [itcl::code $this reset -now]]
-        after idle [list catch [itcl::code $this reset -now]]
-        return
-    }
-
-    # check to see if simulation is really needed
-    $_tool sync
-    if {![$_resultset contains [$_tool xml object]] ||
-        [string equal $_control "manual-resim"]} {
-        # if control mode is "auto", then simulate right away
-        if {[string match auto* $_control]} {
-            # auto control -- don't need button
-            pack forget $itk_interior.simol
-
-            after cancel [itcl::code $this simulate]
-            after idle [itcl::code $this simulate]
-        } else {
-            _simState on "new input parameters"
-        }
-    } else {
-        _simState off
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load <xmlobj>
-#
-# Loads the data from the given <xmlobj> into the appropriate results
-# sets.  If necessary, new results sets are created to store the data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::load {xmlobj} {
-    # only show the last result? then clear first
-    if {[string trim [$_tool xml get tool.analyzer]] == "last"} {
-        clear
-    }
-    #puts "Analyzer::load"
-    $_resultset add $xmlobj
-
-    # NOTE: Adding will trigger a !change event on the ResultSet
-    # object, which will trigger calls to _fixResultSet to add
-    # the results to display.
-}
-
-# ----------------------------------------------------------------------
-# USAGE: clear ?<xmlobj>?
-#
-# Discards one or more results previously loaded into the analyzer.
-# If an <xmlobj> is specified, then that one result is cleared.
-# Otherwise, all results are cleared.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::clear {{xmlobj "all"}} {
-    if {$xmlobj eq "" || $xmlobj eq "all"} {
-        $_resultset clear
-    } else {
-        $_resultset clear $xmlobj
-    }
-
-    # NOTE: Clearing will trigger a !change event on the ResultSet
-    # object, which will trigger calls to _fixResultSet to clean up
-    # the results being displayed.
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download start ?widget?
-# USAGE: download now ?widget?
-#
-# Spools the current result so the user can download it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::download {option args} {
-    set title [$itk_component(viewselector) value]
-    set page [$itk_component(viewselector) translate $title]
-
-    switch -- $option {
-        coming {
-            #
-            # Warn result that a download is coming, in case
-            # it needs to take a screen snap.
-            #
-            if {![regexp {^(|@download|---)$} $page]} {
-                set f [$itk_component(resultpages) page $page]
-                $f.rviewer download coming
-            }
-        }
-        controls {
-            # no controls for this download yet
-            return ""
-        }
-        start {
-            set widget $itk_component(download)
-            if {[llength $args] > 0} {
-                set widget [lindex $args 0]
-                if {[catch {winfo class $widget}]} {
-                    set widget $itk_component(download)
-                }
-            }
-            #
-            # See if this download has any controls.  If so, then
-            # post them now and let the user continue the download
-            # after selecting a file format.
-            #
-            if {$page != ""} {
-                set ext ""
-                set f [$itk_component(resultpages) page $page]
-                set arg [itcl::code $this download now $widget]
-                set popup [$f.rviewer download controls $arg]
-                if {"" != $popup} {
-                    $popup activate $widget below
-                } else {
-                    download now $widget
-                }
-            } else {
-                # this shouldn't happen
-                set file error.html
-                set data "<h1>Not Found</h1>There is no result selected."
-            }
-        }
-        now {
-            set widget $itk_component(download)
-            if {[llength $args] > 0} {
-                set widget [lindex $args 0]
-                if {[catch {winfo class $widget}]} {
-                    set widget $itk_component(download)
-                }
-            }
-            #
-            # Perform the actual download.
-            #
-            if {$page != ""} {
-                set ext ""
-                set f [$itk_component(resultpages) page $page]
-                set item [$itk_component(viewselector) value]
-                set result [$f.rviewer download now $widget $_appName $item]
-                if { $result == "" } {
-                    return;                # User cancelled the download.
-                }
-                foreach {ext data} $result break
-                if {"" == $ext} {
-                    if {"" != $widget} {
-                        Rappture::Tooltip::cue $widget \
-                            "Can't download this result."
-                    }
-                    return
-                }
-                regsub -all {[\ -\/\:-\@\{-\~]} $title {} title
-                set file "$title$ext"
-            } else {
-                # this shouldn't happen
-                set file error.html
-                set data "<h1>Not Found</h1>There is no result selected."
-            }
-
-            Rappture::Logger::log download [$itk_component(viewselector) value]
-            set mesg [Rappture::filexfer::download $data $file]
-            if {[string length $mesg] > 0} {
-                Rappture::Tooltip::cue $widget $mesg
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now, start"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _plot ?<index> <options> <index> <options>...?
-#
-# Used internally to update the plot shown in the current result
-# viewer whenever the resultselector settings have changed.  Causes the
-# desired results to show up on screen.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_plot {args} {
-    #puts "analyzer::_plot"
-    set _plotlist $args
-
-    set page [$itk_component(viewselector) value]
-    set page [$itk_component(viewselector) translate $page]
-    if {"" != $page} {
-        set f [$itk_component(resultpages) page $page]
-        $f.rviewer plot clear
-        foreach {index opts} $_plotlist {
-            $f.rviewer plot add $index $opts
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _reorder <compList>
-#
-# Used internally to change the order of a series of output components
-# found in the <output> section.  Moves the <log> elements to the end
-# and returns the updated list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_reorder {comps} {
-    set i 0
-    set max [llength $comps]
-    while {$i < $max} {
-        set c [lindex $comps $i]
-        if {[string match log* $c]} {
-            set comps [lreplace $comps $i $i]
-            lappend comps $c
-            incr max -1
-        } else {
-            incr i
-        }
-    }
-    return $comps
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _autoLabel <xmlobj> <path> <title> <cntVar>
-#
-# Used internally to check for an about.label property at the <path>
-# in <xmlobj>.  If this object doesn't have a label, then one is
-# supplied using the given <title>.  The <cntVar> is an array of
-# counters in the calling scopes for titles that have been used
-# in the past.  This is used to create titles like "Plot #2" the
-# second time it is encountered.
-#
-# The <xmlobj> is updated so that the label is inserted directly in
-# the tree.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_autoLabel {xmlobj path title cntVar} {
-    upvar $cntVar counters
-
-    set group [$xmlobj get $path.about.group]
-    set label [$xmlobj get $path.about.label]
-    if {"" == $label} {
-        # no label -- make one up using the title specified
-        if {![info exists counters($group-$title)]} {
-            set counters($group-$title) 1
-            set label $title
-        } else {
-            set label "$title (#[incr counters($group-$title)])"
-        }
-        $xmlobj put $path.about.label $label
-    } else {
-        # handle the case of two identical labels in <output>
-        if {![info exists counters($group-$label)]} {
-            set counters($group-$label) 1
-        } else {
-            set label "$label (#[incr counters($group-$label)])"
-            $xmlobj put $path.about.label $label
-        }
-    }
-    return $label
+itcl::body Rappture::Analyzer::reset {} {
+    $itk_component(notebook) current simulate
+
+    # if control mode is "auto", then simulate right away
+    if {$_control == "auto"} {
+        simulate
+    }
+}
+
+# ----------------------------------------------------------------------
+# USAGE: load <file>
+#
+# Used to reset the analyzer whenever the input to a simulation has
+# changed.  Sets the mode back to "simulate", so the user has to
+# simulate again to see the output.
+# ----------------------------------------------------------------------
+itcl::body Rappture::Analyzer::load {file} {
+    # clear any old results
+    if {$_run != ""} {
+        itcl::delete object $_run
+        set _run ""
+    }
+
+    # try to load new results from the given file
+    set _run [Rappture::Library::open $file]
+
+    # go through the analysis and create widgets to display results
+    foreach item [array names _widgets] {
+        $_widgets($item) configure -run $_run
+    }
 }
 
@@ -787,1394 +246,88 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Analyzer::_fixResult {} {
-    set name [$itk_component(viewselector) value]
-    set page ""
-    if {"" != $name} {
-        set page [$itk_component(viewselector) translate $name]
-    }
-    if {$page == "@download"} {
-        # put the combobox back to its last value
-        $itk_component(viewselector) component entry configure -state normal
-        $itk_component(viewselector) component entry delete 0 end
-        $itk_component(viewselector) component entry insert end $_lastlabel
-        $itk_component(viewselector) component entry configure -state disabled
-        # perform the actual download
-        download start $itk_component(download)
-    } elseif {$page == "---"} {
-        # put the combobox back to its last value
-        $itk_component(viewselector) component entry configure -state normal
-        $itk_component(viewselector) component entry delete 0 end
-        $itk_component(viewselector) component entry insert end $_lastlabel
-        $itk_component(viewselector) component entry configure -state disabled
-    } elseif {$page != ""} {
-        set _lastlabel $name
-        $itk_component(resultpages) current $page
-        set f [$itk_component(resultpages) page $page]
-        # We don't want to replot if we're using an existing viewer with the
-        # the same list of objects to plot.  So track the viewer and the list.
-        if { ![info exists _lastPlot($f)] || $_plotlist != $_lastPlot($f) } {
-            set _lastPlot($f) $_plotlist
-            set win [winfo toplevel $itk_component(hull)]
-            blt::busy hold $win
-            #puts "rviewer = $f.rviewer"
-            #puts "_plotlist = $_plotlist"
-            $f.rviewer plot clear
-            eval $f.rviewer plot add $_plotlist
-            blt::busy release $win
-        }
-        Rappture::Logger::log output $_label2item($name)
-        Rappture::Tooltip::for $itk_component(viewselector) \
-            "@[itcl::code $this _resultTooltip]" -log $_label2item($name)
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixResultSet ?<eventData>...?
-#
-# Used internally to react to changes within the ResultSet.  When a
-# result is added, a new result viewer is created for the object.
-# When all results are cleared, the viewers are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_fixResultSet {args} {
-    #puts "Analyzer::_fixResultSet $args"
-    array set eventData $args
-    switch -- $eventData(op) {
-        add {
-            set xmlobj $eventData(what)
-
-            # Detect molecule elements that contain trajectory data
-            # and convert to sequences.
-            _trajToSequence $xmlobj output
-
-            # Go through the analysis and find all result sets.
-            set haveresults 0
-            foreach item [_reorder [$xmlobj children output]] {
-                if {[$xmlobj get output.$item.about.uqtype] == ""} {
-                    switch -glob -- $item {
-                        log* {
-                            _autoLabel $xmlobj output.$item "Output Log" counters
-                        }
-                        number* {
-                            _autoLabel $xmlobj output.$item "Number" counters
-                        }
-                        integer* {
-                            _autoLabel $xmlobj output.$item "Integer" counters
-                        }
-                        mesh* {
-                            _autoLabel $xmlobj output.$item "Mesh" counters
-                        }
-                        string* {
-                            _autoLabel $xmlobj output.$item "String" counters
-                        }
-                        histogram* - curve* - field* {
-                            _autoLabel $xmlobj output.$item "Plot" counters
-                        }
-                        map* {
-                            _autoLabel $xmlobj output.$item "Map" counters
-                        }
-                        drawing* {
-                            _autoLabel $xmlobj output.$item "Drawing" counters
-                        }
-                        structure* {
-                            _autoLabel $xmlobj output.$item "Structure" counters
-                        }
-                        table* {
-                            _autoLabel $xmlobj output.$item "Energy Levels" counters
-                        }
-                        sequence* {
-                            _autoLabel $xmlobj output.$item "Sequence" counters
-                        }
-                    }
-                }
-                set label [$xmlobj get output.$item.about.group]
-                if {"" == $label} {
-                    set label [$xmlobj get output.$item.about.label]
-                }
-
-                set hidden [$xmlobj get output.$item.hide]
-                set hidden [expr {"" != $hidden && $hidden}]
-
-                if {"" != $label && !$hidden} {
-                    set haveresults 1
-                }
+    set page [$itk_component(resultselector) value]
+    set page [$itk_component(resultselector) translate $page]
+    $itk_component(results) current $page
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -tool
+#
+# Set to the Rappture::Library object representing the tool being
+# run in this analyzer.
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Analyzer::tool {
+    if {![Rappture::Library::valid $itk_option(-tool)]} {
+        error "bad value \"$itk_option(-tool)\": should be Rappture::Library"
+    }
+
+    $itk_component(info) configure -state normal
+    $itk_component(info) delete 1.0 end
+    $itk_component(info) insert end [$itk_option(-tool) get executable.about]
+    $itk_component(info) configure -state disabled
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -device
+#
+# Set to the Rappture::Library object representing the device being
+# run in this analyzer.
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Analyzer::device {
+    if {$itk_option(-device) != ""
+          && ![Rappture::Library::valid $itk_option(-device)]} {
+        error "bad value \"$itk_option(-device)\": should be Rappture::Library"
+    }
+    reset
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -analysis
+#
+# Set to the Rappture::Library object representing the analysis that
+# should be shown in this analyzer.
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Analyzer::analysis {
+    if {![Rappture::Library::valid $itk_option(-analysis)]} {
+        error "bad value \"$itk_option(-analysis)\": should be Rappture::Library"
+    }
+    set _control [$itk_option(-analysis) get control]
+
+    # go through the analysis and create widgets to display results
+    $itk_component(results) delete -all
+    catch {unset _widgets}
+
+    set counter 0
+    foreach item [$itk_option(-analysis) get -children] {
+        switch -glob -- $item {
+            xyplot* {
+                set name "page[incr counter]"
+                set label [$itk_option(-analysis) get $item.label]
+                if {$label == ""} { set label $name }
+
+                set page [$itk_component(results) insert end $name]
+                $itk_component(resultselector) choices insert end \
+                    $name $label
+
+                set _widgets($item) [Rappture::Xyplot $page.#auto \
+                    -layout [$itk_option(-analysis) get -object $item]]
+                pack $_widgets($item) -expand yes -fill both
             }
-
-            # if there are any valid results, add them to the resultset
-            if {$haveresults} {
-                set index [$_resultset get simnum $xmlobj]
-
-                # add each result to a result viewer
-                foreach item [_reorder [$xmlobj children output]] {
-                    set label [$xmlobj get output.$item.about.group]
-                    if {"" == $label} {
-                        set label [$xmlobj get output.$item.about.label]
-                    }
-                    set hidden [$xmlobj get output.$item.hide]
-                    if {$hidden == ""} {
-                        set hidden 0
-                    }
-                    if {"" != $label && !$hidden} {
-                        set uq_part [$xmlobj get output.$item.about.uqtype]
-
-                        #puts "label=$label uq_part=$uq_part"
-
-                        if {![info exists _label2page($label)]} {
-                            #puts "Adding label: '$label'"
-                            set name "page[incr _pages]"
-                            #puts "Inserting $name into resultpages"
-                            set page [$itk_component(resultpages) \
-                                insert end $name]
-                            set _label2page($label) $page
-                            set _label2item($label) output.$item
-                            set _label2desc($label) \
-                                [$xmlobj get output.$item.about.description]
-                            Rappture::ResultViewer $page.rviewer
-                            pack $page.rviewer -expand yes -fill both -pady 4
-
-                            set end [$itk_component(viewselector) \
-                                choices index -value ---]
-                            if {$end < 0} {
-                                set end "end"
-                            }
-                            $itk_component(viewselector) choices insert $end \
-                                $name $label
-                        }
-
-                        # add/replace the latest result into this viewer
-                        set page $_label2page($label)
-
-                        if {![info exists reset($page)]} {
-                            $page.rviewer clear $index
-                            set reset($page) 1
-                        }
-                        $page.rviewer add $index $xmlobj output.$item $label $uq_part
-                    }
-                }
-            }
-
-            # show the first page by default
-            set max [$itk_component(viewselector) choices size]
-            for {set i 0} {$i < $max} {incr i} {
-                set first [$itk_component(viewselector) choices get -label $i]
-                if {$first != ""} {
-                    set page [$itk_component(viewselector) choices get -value $i]
-                    set char [string index $page 0]
-                    if {$char != "@" && $char != "-"} {
-                        $itk_component(resultpages) current $page
-                        $itk_component(viewselector) value $first
-                        set _lastlabel $first
-                        break
-                    }
-                }
-            }
-        }
-        clear {
-            if {$eventData(what) ne "all"} {
-                # delete this result from all viewers
-                array set params $eventData(what)
-                foreach label [array names _label2page] {
-                    set page $_label2page($label)
-                    $page.rviewer clear $params(simnum)
-                }
-            }
-
-            if {[$_resultset size] == 0} {
-                # reset the size of the controls area
-                set ht [winfo height $itk_component(results)]
-                set cntlht [$itk_component(resultselector) size -controlarea]
-                set frac [expr {double($cntlht)/$ht}]
-                $itk_component(results) fraction end $frac
-
-                foreach label [array names _label2page] {
-                    set page $_label2page($label)
-                    destroy $page.rviewer
-                }
-                $itk_component(resultpages) delete -all
-                set _pages 0
-
-                $itk_component(viewselector) value ""
-                $itk_component(viewselector) choices delete 0 end
-                catch {unset _label2page}
-                catch {unset _label2item}
-                catch {unset _label2desc}
-                set _plotlist ""
-
-                $itk_component(viewselector) choices insert end --- "---"
-                $itk_component(viewselector) choices insert end \
-                    @download [Rappture::filexfer::label download]
-                set _lastlabel ""
-            }
-
-            # fix Simulate button state
-            reset
-        }
-        default {
-            error "don't know how to handle op \"$eventData(op)\""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Used internally to change the size of the result set area whenever
-# a new control appears.  Adjusts the size available for the result
-# set up to some maximum.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_fixSize {} {
-    set ht [winfo height $itk_component(results)]
-    if {$ht <= 1} { set ht [winfo reqheight $itk_component(results)] }
-    set cntlht [$itk_component(resultselector) size -controlarea]
-    set frac [expr {double($cntlht)/$ht}]
-
-    if {$frac < 0.4} {
-        $itk_component(results) fraction end $frac
-    }
-    _fixSimControl
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _simState <boolean> ?<message>? ?<settings>?
-#
-# Used internally to change the "Simulation" button on or off.
-# If the <boolean> is on, then any <message> and <settings> are
-# displayed as well.  If the <boolean> is off, then only display
-# the message. The <message> is a note to the user about
-# what will be simulated, and the <settings> are a list of
-# tool parameter settings of the form {path1 val1 path2 val2 ...}.
-# When these are in place, the next Simulate operation will use
-# these settings.  This helps fill in missing data values.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_simState {state args} {
-    if {$state} {
-        $itk_interior.simol configure \
-            -background $itk_option(-simcontrolactiveoutline)
-        configure -simcontrolcolor $itk_option(-simcontrolactivebackground)
-
-        $itk_component(abort) configure -state disabled
-        $itk_component(simulate) configure -state normal \
-            -command [itcl::code $this simulate]
-
-        #
-        # If there's a special message, then put it up next to the button.
-        #
-        set mesg [lindex $args 0]
-        if {"" != $mesg} {
-            $itk_component(simstatus) configure -state normal
-            $itk_component(simstatus) delete 1.0 end
-            $itk_component(simstatus) insert end $mesg
-
-            #
-            # If there are any settings, then install them in the
-            # "Simulate" button.  Also, pop them up as a tooltip
-            # for the message.
-            #
-            set settings [lindex $args 1]
-            if {[llength $settings] > 0} {
-                $itk_component(simulate) configure \
-                    -command [eval itcl::code $this simulate $settings]
-
-                set details ""
-                foreach {path val} $settings {
-                    set str [string trim [$_tool xml get $path.about.label]]
-                    if {"" == $str} {
-                        set str [$_tool xml element -as id $path]
-                    }
-                    append details "$str = $val\n"
-                }
-                set details [string trim $details]
-
-                Rappture::Tooltip::for $itk_component(simstatus) $details
-                $itk_component(simstatus) insert end " "
-                $itk_component(simstatus) insert end "(details...)" popup
-            }
-            $itk_component(simstatus) configure -state disabled
-        }
+        }
+    }
+
+    # if there is only one page, take down the selector
+    if {[$itk_component(resultselector) choices size] <= 1} {
+        pack forget $itk_component(resultselector)
     } else {
-        if {"" != $itk_option(-simcontrolbackground)} {
-            set simcbg $itk_option(-simcontrolbackground)
-        } else {
-            set simcbg $itk_option(-background)
-        }
-        $itk_interior.simol configure \
-            -background $itk_option(-simcontroloutline)
-        configure -simcontrolcolor $simcbg
-
-        if {$_uq_active == 0} {
-            $itk_component(simulate) configure -state disabled
-        }
-        $itk_component(abort) configure -state normal
-
-        $itk_component(simstatus) configure -state normal
-        $itk_component(simstatus) delete 1.0 end
-        set mesg [lindex $args 0]
-        if {"" != $mesg} {
-            $itk_component(simstatus) insert end $mesg
-        }
-        $itk_component(simstatus) configure -state disabled
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _simOutput <message>
-#
-# Invoked automatically whenever output comes in while running the
-# tool.  Extracts any =RAPPTURE-???=> messages from the output and
-# sends the output to the display.  For example, any
-# =RAPPTURE-PROGRESS=> message pops up the progress meter and updates
-# it to show the latest progress message.  This is useful for
-# long-running tools, to let the user know how much longer the
-# simulation will take.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_simOutput {message} {
-    #
-    # Scan through and pick out any =RAPPTURE-PROGRESS=> messages first.
-    #
-    set pattern {=RAPPTURE-PROGRESS=> *([-+]?[0-9]+) +([^\n]*)(\n|$)}
-    while {[regexp -indices $pattern $message match percent mesg]} {
-
-        foreach {i0 i1} $percent break
-        set percent [string range $message $i0 $i1]
-
-        foreach {i0 i1} $mesg break
-        set mesg [string range $message $i0 $i1]
-
-        pack $itk_component(progress) -fill x -padx 10 -pady 10
-        $itk_component(progress) settings -percent $percent -message $mesg
-
-        foreach {i0 i1} $match break
-        set message [string replace $message $i0 $i1]
-    }
-
-    #
-    # Now handle SUBMIT-PROGRESS
-    #
-    while {[regexp -indices {=SUBMIT-PROGRESS=> aborted=([0-9]+) finished=([0-9]+) failed=([0-9]+) executing=([0-9]+)\
-        waiting=([0-9]+) setting_up=([0-9]+) setup=([0-9]+) %done=([0-9.]+) timestamp=([0-9.]+)(\n|$)} $message \
-        match aborted finished failed executing waiting setting_up setup percent ts mesg]} {
-
-        set mesg ""
-        foreach {i0 i1} $percent break
-        set percent [string range $message $i0 $i1]
-        foreach {i0 i1} $failed break
-        set failed [string range $message $i0 $i1]
-        foreach {i0 i1} $match break
-        set message [string replace $message $i0 $i1]
-
-        if {$failed != 0} {set mesg "$failed jobs failed!"}
-        if {$percent >= 100} { set mesg "Jobs finished.  Analyzing results..."}
-
-        pack $itk_component(progress) -fill x -padx 10 -pady 10
-        $itk_component(progress) settings -percent $percent -message $mesg
-    }
-
-    #
-    # Break up the remaining lines according to =RAPPTURE-ERROR=> messages.
-    # Show errors in a special color.
-    #
-    $itk_component(runinfo) configure -state normal
-    set pattern {=RAPPTURE-([a-zA-Z]+)=>([^\n]*)(\n|$)}
-    while {[regexp -indices $pattern $message match type mesg]} {
-        foreach {i0 i1} $match break
-        set first [string range $message 0 [expr {$i0-1}]]
-        if {[string length $first] > 0} {
-            $itk_component(runinfo) insert end $first
-            $itk_component(runinfo) insert end \n
-        }
-
-        foreach {t0 t1} $type break
-        set type [string range $message $t0 $t1]
-        foreach {m0 m1} $mesg break
-        set mesg [string range $message $m0 $m1]
-        if {[string length $mesg] > 0 && $type != "RUN"} {
-            $itk_component(runinfo) insert end $mesg $type
-            $itk_component(runinfo) insert end \n $type
-        }
-
-        set message [string range $message [expr {$i1+1}] end]
-    }
-
-    if {[string length $message] > 0} {
-        $itk_component(runinfo) insert end $message
-        if {[$itk_component(runinfo) get end-2char] != "\n"} {
-            $itk_component(runinfo) insert end "\n"
-        }
-        $itk_component(runinfo) see end
-    }
-    $itk_component(runinfo) configure -state disabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _resultTooltip
-#
-# Used internally to build the tooltip string displayed for the
-# result selector.  If the current page has an associated description,
-# then it is displayed beneath the result.
-#
-# Returns the string for the tooltip.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_resultTooltip {} {
-    set tip ""
-    set name [$itk_component(viewselector) value]
-    if {[info exists _label2desc($name)] &&
-        [string length $_label2desc($name)] > 0} {
-        append tip "$_label2desc($name)\n\n"
-    }
-    if {[array size _label2page] > 1} {
-        append tip "Use this control to display other output results."
-    }
-    return $tip
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSimControl
-#
-# Used internally to add or remove the simulation control at the
-# top of the analysis area.  This is controlled by the -simcontrol
-# option.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_fixSimControl {} {
-    switch -- $itk_option(-simcontrol) {
-        on {
-            pack $itk_interior.simol -fill x -before $itk_interior.nb
-        }
-        off {
-            pack forget $itk_interior.simol
-        }
-        auto {
-            #
-            # If we have two or more radiodials, then there is a
-            # chance of encountering a combination of parameters
-            # with no data, requiring simulation.
-            #
-            if {[$itk_component(resultselector) size -controls] >= 2} {
-                pack $itk_interior.simol -fill x -before $itk_interior.nb
-            } else {
-                pack forget $itk_interior.simol
-            }
-        }
-        default {
-            error "bad value \"$itk_option(-simcontrol)\": should be on, off, auto"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixNotebook
-#
-# Used internally to switch the active notebook page
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_fixNotebook {} {
-    switch -- $itk_option(-notebookpage) {
-        about {
-            $itk_component(notebook) current about
-        }
-        simulate {
-            $itk_component(notebook) current simulate
-        }
-        analyze {
-            $itk_component(notebook) current analyze
-        }
-        default {
-            error "bad value \"$itk_option(-notebookpage)\": should be about, simulate, analyze"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _isPdbTrajectory <data>
-#
-# Used internally to determine whether pdb or lammps data represents a
-# trajectory rather than a single frame
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_isPdbTrajectory {data} {
-    if { [llength $data] == 0 } {
-        return 0
-    }
-    set nModels 0
-    foreach line $data {
-        if { [string match "MODEL*" $line] }  {
-            incr nModels
-            if { $nModels > 1 } {
-                # Stop if more than one model found.  No need to count them
-                # all.
-                return 1
-            }
-        }
-    }
-    return 0
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _isLammpsTrajectory <data>
-#
-# Used internally to determine whether pdb or lammps data represents a
-# trajectory rather than a single frame
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_isLammpsTrajectory { data } {
-    if { [llength $data] == 0 } {
-        return 0
-    }
-    set nModels 0
-    foreach line $data {
-        if { [regexp {^[\t ]*ITEM:[ \t]+TIMESTEP} $line] } {
-            incr nModels
-            if { $nModels > 1 } {
-                # Stop if more than one model found.  No need to count them
-                # all.
-                return 1
-            }
-        }
-    }
-    return 0
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _pdbToSequence <xmlobj> ?<path>?
-#
-# If the molecule element is a trajectory, delete the original
-# and create a sequence of individual molecules.
-# Used internally to detect any molecule output elements that contain
-# trajectory data.  Trajectories will be converted into sequences of
-# individual molecules.  All other elements will be unaffected. Scans
-# the entire xml tree if a starting path is not specified.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_pdbToSequence {xmlobj path id child data} {
-
-    set seqLabel [$xmlobj get ${child}.about.label]
-    set descr    [$xmlobj get ${child}.about.description]
-    set formula  [$xmlobj get ${child}.components.molecule.formula]
-    $xmlobj remove $child
-
-    set sequence  $path.sequence($id)
-    $xmlobj put ${sequence}.about.label $seqLabel
-    $xmlobj put ${sequence}.about.description $descr
-    $xmlobj put ${sequence}.index.label "Frame"
-
-    set frameNum 0
-    set numLines [llength $data]
-    for { set i 0 } { $i < $numLines } { incr i } {
-        set line [lindex $data $i]
-        set line [string trim $line]
-        set contents {}
-        if { [string match "MODEL*" $line] } {
-            # Save the contents until we get an ENDMDL record.
-            for {} { $i < $numLines } { incr i } {
-                set line [lindex $data $i]
-                set line [string trim $line]
-                if { $line == "" } {
-                    continue;           # Skip blank lines.
-                }
-                if { [string match "ENDMDL*" $line] } {
-                    break;
-                }
-                append contents $line\n
-            }
-            set frame ${sequence}.element($frameNum)
-            $xmlobj put ${frame}.index $frameNum
-
-            set molecule ${frame}.structure.components.molecule
-            $xmlobj put ${molecule}.pdb $contents
-            $xmlobj put ${molecule}.formula $formula
-            incr frameNum
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _lammpsToSequence <xmlobj> ?<path>?
-#
-# If the molecule element is a trajectory, delete the original
-# and create a sequence of individual molecules.
-# Used internally to detect any molecule output elements that contain
-# trajectory data.  Trajectories will be converted into sequences of
-# individual molecules.  All other elements will be unaffected. Scans
-# the entire xml tree if a starting path is not specified.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_lammpsToSequence {xmlobj path id child data} {
-
-    set seqLabel [$xmlobj get ${child}.about.label]
-    set descr    [$xmlobj get ${child}.about.description]
-    set typemap  [$xmlobj get ${child}.components.molecule.lammpstypemap]
-    $xmlobj remove $child
-
-    set sequence ${path}.sequence($id)
-    $xmlobj put ${sequence}.about.label $seqLabel
-    $xmlobj put ${sequence}.about.description $descr
-    $xmlobj put ${sequence}.index.label "Frame"
-
-    set frameNum 0
-    set frameContents ""
-    set inModel 0
-    foreach line $data {
-        set line [string trim $line]
-        if { $line == "" } {
-            continue;                   # Skip blank lines
-        }
-        if {[regexp {^[\t ]*ITEM:[ \t]+ATOMS} $line] } {
-            if { $inModel && $frameContents != "" } {
-                set frame ${sequence}.element($frameNum)
-                $xmlobj put ${frame}.index $frameNum
-
-                set molecule ${frame}.structure.components.molecule
-                $xmlobj put ${molecule}.lammps $frameContents
-                $xmlobj put ${molecule}.lammpstypemap $typemap
-
-                incr frameNum
-                set frameContents ""
-            }
-            set inModel 1
-        } elseif { [scan $line "%d %d %f %f %f" a b c d e] == 5 } {
-            if { !$inModel } {
-                puts stderr "found \"$line\" without previous \"ITEM: ATOMS\""
-                set inModel 1
-            }
-            append frameContents $line\n
-        }
-    }
-    if { $frameContents != "" } {
-        set frame ${sequence}.element($frameNum)
-        $xmlobj put ${frame}.index $frameNum
-
-        set molecule ${frame}.structure.components.molecule
-        $xmlobj put ${molecule}.lammps $frameContents
-        $xmlobj put ${molecule}.lammpstypemap $typemap
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _trajToSequence <xmlobj> ?<path>?
-#
-#       Check for PDB and LAMMPS trajectories in molecule data and rewrite
-#       the individual models as a sequence of molecules.  Used internally
-#       to detect any molecule output elements that contain trajectory data.
-#       Trajectories will be converted into sequences of individual molecules.
-#       All other elements will be unaffected. Scans the entire xml tree if a
-#       starting path is not specified.
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Analyzer::_trajToSequence {xmlobj {path ""}} {
-    # Remove leading dot from path, if present.
-    if { [string index $path 0] == "." } {
-        set path [string range $path 1 end]
-    }
-    # Otherwise check each child.
-    foreach child [$xmlobj children $path] {
-        set current ${path}.${child}
-        if { [string match "structure*" $child] } {
-            set isTraj [$xmlobj get ${current}.components.molecule.trajectory]
-            if { $isTraj == "" || !$isTraj } {
-                continue;               # Not a trajectory.
-            }
-            # Look for trajectory if molecule element found.  Check both pdb
-            # data and lammps data.
-            set type [$xmlobj element -as type $current]
-            set id   [$xmlobj element -as id $current]
-            set pdbdata    [$xmlobj get ${current}.components.molecule.pdb]
-            set lammpsdata [$xmlobj get ${current}.components.molecule.lammps]
-            if { $pdbdata != "" && $lammpsdata != "" } {
-                puts stderr \
-                    "found both <pdb> and <lammps> elements: picking pdb"
-            }
-            set pdbdata [split $pdbdata \n]
-            set lammpsdata [split $lammpsdata \n]
-            if { [_isPdbTrajectory $pdbdata] } {
-                _pdbToSequence $xmlobj $path $id $current $pdbdata
-            } elseif { [_isLammpsTrajectory $lammpsdata] } {
-                _lammpsToSequence $xmlobj $path $id $current $lammpsdata
-            }
-            continue
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -simcontrol
-#
-# Controls whether or not the Simulate button is showing.  In some
-# cases, it is not needed.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Analyzer::simcontrol {
-    _fixSimControl
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -notebookpage
-#
-# Controls which page of the analyzer notebook is shown. It is
-# particularly needed when using rerun, when you don't want to
-# "simulate -ifneeded" because an actual simulation might be
-# kicked off due to differences between tool.xml and run.xml
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Analyzer::notebookpage {
-    _fixNotebook
-}
-
-itcl::body Rappture::Analyzer::PostMenu { m } {
-    if { [FindSimsetsForApp $_appName] == 0 } {
-        $m entryconfigure "Load Simulations" -state disable
-        $m entryconfigure "Share Simulations" -state disable
-        $m entryconfigure "Delete Simulations" -state disabled
-    } else {
-        $m entryconfigure "Load Simulations" -state normal
-        $m entryconfigure "Share Simulations" -state normal
-        $m entryconfigure "Delete Simulations" -state normal
-    }
-    if { [$_resultset size] == 0 } {
-        $m entryconfigure "Save Simulations" -state disabled
-    } else {
-        $m entryconfigure "Save Simulations" -state normal
-    }
-}
-        
-#
-# Build Help menu 
-#
-itcl::body Rappture::Analyzer::buildMenu { m url appName } {
-    menu $m \
-        -tearoff 0 \
-        -postcommand [itcl::code $this PostMenu $m]
-    if { $appName == "" || $url == "" } {
-        set state disabled
-    } else {
-        set state normal
-    }
-    set webcmd Rappture::filexfer::webpage
-    set group "app-$_appName"
-    if { [info exists env(SESSION)] }  {
-        set referer "&referrer=$url/tools/$appName/session?sess=$env(SESSION)"
-    } else {
-        set referer ""
-    }
-    $m add command -label "About this tool" \
-        -command [list $webcmd "$url/tools/$appName"] \
-        -state $state
-    $m add command -label "Questions?" \
-        -command [list $webcmd "$url/resources/$_appName/questions"] \
-        -state $state
-    $m add command -label "Tickets" -state $state \
-        -command [list $webcmd "$url/feedback/report_problems?group=$group$referer"]
-    $m add command -label "Wish List" -state disabled
-    $m add separator
-    $m add command -label "Save Simulations" \
-        -command [itcl::code $this SelectSimsetNameAndSave] \
-        -state $state
-    $m add command -label "Load Simulations" \
-        -command [itcl::code $this SelectSimsetForLoading] \
-        -state $state
-    $m add command -label "Delete Simulations" \
-        -command [itcl::code $this SelectSimsetForDeletion] \
-        -state $state
-    $m add command -label "Share Simulations" \
-        -command [itcl::code $this SelectSimsetToShare] \
-        -state $state
-    return $m
-}
-
-itcl::body Rappture::Analyzer::BuildSimulationTable { top } {
-    # All weirdness is due to the Resultset object.
-
-    # First create nodes for each simulation.  The node label is the
-    # simulation number (such as #1, #2, etc).  
-    eval $_tree delete 0
-    set labels "selected simnum"
-    foreach {name index} [$_resultset diff values simnum] {
-        set node [$_tree insert 0 -label $name]
-        $_tree set $node "simnum" $name
-        set index2name($index) $name
-        
-    }
-    # Next fill in the xmlobj associated with each simulation.  We assume
-    # that the order is the the same as the simulation number.
-    set index 0
-    foreach {xmlobj dummy} [$_resultset diff values xmlobj]  {
-        set node [$_tree findchild 0 $index2name($index)]
-        set runfile [$xmlobj get output.filename]
-        set version [$xmlobj get output.version]
-        $_tree set $node \
-            "selected" 1 "xmlobj" $xmlobj "runfile" $runfile "version" $version
-        incr index
-    }
-    # Finally for each different input, for each simulation add the
-    # label and value for the specific input.
-    foreach name [$_resultset diff names] {
-        # Ignore non-input names.
-        if { $name == "xmlobj" || $name == "simnum" } {
-            continue
-        }
-        foreach node [$_tree children 0] {
-            set xmlobj [$_tree get $node xmlobj]
-            set label [$xmlobj get $name.about.label]
-            set value [$xmlobj get $name.current]
-            if { [$_tree exists $node $label] } {
-                puts stderr "This can't be: $label already exists in $node"
-            }
-            if { [lsearch $labels $label] < 0 } {
-                lappend labels $label
-            }
-            $_tree set $node $label $value
-        }
-    }
-    frame $top
-    set tv $top.tv
-    blt::treeview $top.tv -tree $_tree \
-        -height 1i \
-        -xscrollcommand [list $top.xs set] \
-        -yscrollcommand [list $top.ys set] \
-        -font "Arial 10"
-    scrollbar $top.xs -orient horizontal -command "$tv xview"
-    scrollbar $top.ys -orient vertical -command "$tv yview"
-        
-    eval $tv column insert end $labels
-    $tv style checkbox checkbox -showvalue no 
-    $tv column configure simnum -title "Simulation" 
-    $tv column configure selected -title "Save" -style checkbox \
-        -width .5i -edit yes 
-    $tv column configure treeView -hide yes 
-    blt::table $top \
-        0,0 $top.tv -fill both \
-        0,1 $top.ys -fill y \
-        1,0 $top.xs -fill x
-    blt::table configure $top r* c* -resize none
-    blt::table configure $top r0 c0 -resize both
-}
-
-itcl::body Rappture::Analyzer::CleanName { name } {
-    regsub -all {/} $name {_} name
-    return $name
-}
-
-#
-# Get the results and display them in a table.
-#
-# Use the table to omit specific results
-# Use file chooser to save to specific 
-itcl::body Rappture::Analyzer::SelectSimsetNameAndSave {} {
-    if { [EditSimset] } {
-        set name [CleanName $_saved(Name)]
-        set saveDir [file join ~/data/saved $_appName $name]
-        set saveDir [file normalize $saveDir]
-        file mkdir $saveDir 
-        set fileName [file join $saveDir $name.sav]
-        if { [file exists $fileName] } {
-            if { ![OverwriteSaveFile] } {
-                return
-            }
-        }
-        WriteSimsetFile $_appName $fileName 0
-    }
-}
-
-#
-# Get the results and display them in a table.
-#
-# Use the table to omit specific results
-# Use file chooser to save to specific 
-itcl::body Rappture::Analyzer::SelectSimsetToShare {} {
-    if { [GetSimset "share"] } {
-        global env
-        set name [CleanName $_saved(Name)]
-        set shareDir [file join /data/tools/shared $env(USER) $_appName $name]
-        if { [catch {
-            CreateSharedPath $shareDir
-        } errs] != 0 } {
-            puts stderr errs=$errs
-            return 
-        }
-        set fileName [file join $shareDir $name.sav]
-        if { [file exists $fileName] } {
-            if { ![OverwriteSaveFile] } {
-                return
-            }
-        }
-        WriteSimsetFile $_appName $fileName 1
-        ExportURL $_appName $shareDir
-    }
-}
-
-#
-# Checks editor widgets to see if the name and description have been
-# set.  If this is so it enables the save button in the editor.
-#
-itcl::body Rappture::Analyzer::CheckSimsetDetails {} {
-    set popup .savesimset
-    if { ![winfo exists $popup] } {
-        return
-    }
-    set inner [$popup component inner]
-    set name [string trim [$inner.name get]]
-    set desc [string trim [$inner.desc get 0.0 end]]
-    $inner.controls.save configure -state disabled
-    if { $name == "" || $desc == "" } {
-        return
-    }
-    $inner.controls.save configure -state normal
-}
-
-#
-# Gathers all the information from the simset editor into the _saved array
-#
-itcl::body Rappture::Analyzer::SaveSimulations {} {
-    set popup .savesimset
-    if { ![winfo exists $popup] } {
-        return
-    }
-    set inner [$popup component inner]
-    array unset _saved
-    set name [string trim [$inner.name get]]
-    set desc [string trim [$inner.desc get 0.0 end]]
-    set _saved(Application) $_appName
-    set _saved(Revision) $_revision
-    set _saved(Date) [clock format [clock seconds]]
-    set _saved(Name) $name
-    set _saved(Description) $desc
-    set files {}
-    foreach node [$_tree children root] {
-        set fileName [$_tree get $node runfile]
-        lappend files $fileName
-    }
-    set _saved(Files) $files
-    set _done 1 
-}
-
-itcl::body Rappture::Analyzer::Cancel {} {
-    set _done 0
-}
-
-itcl::body Rappture::Analyzer::Ok {} {
-    set popup .selectsimset
-    if { ![winfo exists $popup] } {
-        return
-    }
-    set inner [$popup component inner]
-    set tv $inner.tv
-    if { ![$tv selection present] } {
-        return
-    }
-    set node [$tv curselection]
-    array unset _saved
-    array set _saved [$_tree get $node]
-    set saveDir [file dirname $_saved(FileName)]
-    set files {}
-    foreach file $_saved(Files) {
-        if { [file pathtype $file] == "relative" } {
-            set file [file join $saveDir $file]
-        }
-        lappend files $file
-    }
-    set _saved(Files) $files
-    set _done 1 
-}
-
-#
-# WriteSimsetFile --
-#
-#       Write the .sav file and the runfiles in the 
-#            ~/data/saved/$_appName/$name
-#       directory.  
-# The run files will be in the same directory as the .sav file.  
-# For example, if the simset file is /path/to/appName/myName/myName.sav, 
-# the runfile directory is /path/to/appName/myName.
-#
-itcl::body Rappture::Analyzer::WriteSimsetFile { appName fileName share } {
-    set saveDir [file dirname $fileName]
-    if { [file exists $saveDir] } {
-        file delete -force $saveDir
-    }
-    if { [catch {
-        if { $share } {
-            CreateSharedPath $saveDir
-        } else {
-            file mkdir $saveDir
-        }
-        set f [open $fileName "w"]
-        puts $f [list "Name"        $_saved(Name)]
-        puts $f [list "Description" $_saved(Description)]
-        puts $f [list "Date"        $_saved(Date)]
-        global env
-        puts $f [list "Creator"     $env(USER)]
-        puts $f [list "Application" $_saved(Application)]
-        puts $f [list "Revision"    $_saved(Revision)]
-        set runfiles ""
-        foreach file $_saved(Files) {
-            set tail [file tail $file]
-            set dest [file join $saveDir $tail]
-            if { $share } {
-                InstallSharedFile $saveDir $file
-            } else {
-                file copy -force $file $dest
-            }
-            lappend runfiles $tail
-        }
-        puts $f [list "Files" $runfiles]
-        close $f
-        if { $share } {
-            file attributes $fileName -permissions o+r,g+rw
-        }
-    } errs] != 0 } {
-        global errorInfo
-        puts stderr "errs=$errs errorInfo=$errorInfo"
-    }
-}
-
-itcl::body Rappture::Analyzer::EditSimset {} {
-    set popup .savesimset
-    if { [winfo exists $popup] } {
-        destroy $popup
-    }
-    # Create a popup for the print dialog
-    Rappture::Balloon $popup -title "Save set of simulations..."
-    set inner [$popup component inner]
-
-    label $inner.name_l -text "Simulation Set Name"
-    entry $inner.name -background white
-    label $inner.desc_l -text "Simulation Set Description" -height 5 
-    text $inner.desc  -background white
-    label $inner.select_l -text "Selected Simulations"
-    BuildSimulationTable $inner.select
-    frame $inner.controls
-    bind $inner.desc <KeyPress> [itcl::code $this CheckSimsetDetails]
-    bind $inner.name <KeyPress> [itcl::code $this CheckSimsetDetails]
-    bind $inner.desc <Motion> [itcl::code $this CheckSimsetDetails]
-    bind $inner.name <Motion> [itcl::code $this CheckSimsetDetails]
-    button $inner.controls.cancel -text "Cancel" \
-        -command [itcl::code $this Cancel]
-    button $inner.controls.save -text "Save" \
-        -command [itcl::code $this SaveSimulations]
-    blt::table $inner.controls \
-        0,0 $inner.controls.cancel \
-        0,1 $inner.controls.save
-    
-    blt::table $inner \
-        0,0 $inner.name_l -anchor ne \
-        0,1 $inner.name -fill x \
-        1,0 $inner.desc_l -anchor ne \
-        1,1 $inner.desc -fill both \
-        2,0 $inner.select_l -anchor ne \
-        2,1 $inner.select -fill both \
-        3,1 $inner.controls  -fill x
-    blt::table configure $inner r1 -height 1i
-    blt::table configure $inner r2 -pad 20
-    $popup configure \
-        -deactivatecommand [itcl::code $this Cancel] 
-
-    set inner [$popup component inner]
-    if {[$_resultset size] > 1} {
-        blt::table $inner \
-            2,0 $inner.select_l -anchor ne \
-            2,1 $inner.select -fill both 
-    } else {
-        blt::table forget $inner.select $inner.select_l
-    }
-    CheckSimsetDetails
-    update
-    # Activate the popup and call for the output.
-    $popup activate $itk_component(help) below
-    Cancel
-    tkwait variable [itcl::scope _done]
-    set doSave $_done
-    $popup deactivate 
-    return $doSave
-}
-
-
-itcl::body Rappture::Analyzer::ReadSimsetFile { fileName } {
-    if { [catch {
-        set f [open $fileName "r"]
-        set contents [read $f]
-        close $f
-        array set _saved $contents
-    } errs] != 0 } {
-        return 0
-    }
-    if { ![info exists _saved(Files)] } {
-        return 0
-    }
-    set saveDir [file dirname $fileName]
-    foreach file $_saved(Files) {
-        if { [file pathtype $file] == "relative" } {
-            set file [file join $saveDir $file]
-        }
-        if { ![file readable $file] } {
-            puts stderr "runfile $file isn't readable"
-            return 0
-        }
-    }
-    set _saved(FileName) $fileName
-    return 1
-}
-
-#
-# Run files can be either explicitly named with their absolute or
-# relative path.  If the path is relative it is assumed the parent
-# directory is relative to the simset file.
-#
-#   /my/path/to/myfile.sav 
-#   /my/path/to/myfile/runfiles...
-#
-itcl::body Rappture::Analyzer::LoadSimulations { files } {
-    set loadobjs {}
-    set saveDir [file dirname $_saved(FileName)]
-    foreach runfile $files {
-        if { [file pathtype $runfile] == "relative" } {
-            set runfile [file join $saveDir $runfile]
-        }
-        if { ![file exists $runfile] } {
-            puts stderr "can't find run: \"$runfile\""
-            continue
-        }
-        set status [catch {Rappture::library $runfile} result]
-        lappend loadobjs $result
-    }
-    clear
-    foreach runobj $loadobjs {
-        load $runobj
-    }
-    configure -notebookpage analyze
-    global win
-    $win.pager configure -nosim 1 
-    $win.pager current analyzer
-    $win.pager configure -nosim 0 
-}
-
-#
-# Delete selected simulation set.
-#
-itcl::body Rappture::Analyzer::SelectSimsetForDeletion {} {
-    if { [FindSimsetsForApp $_appName] == 0 } {
-        return
-    }
-    if { [GetSimset "delete"] } {
-        set saveDir [file dirname $_saved(FileName)]
-        file delete -force $saveDir
-    }
-}
-
-#
-# Find all .sav files for an application and load them into the tree.
-#
-itcl::body Rappture::Analyzer::FindSimsetsForApp { appName } {
-    if { $appName == "" } {
-        puts stderr "No application name found"
-        return 0
-    }
-    $_tree delete 0
-    foreach fileName [glob -nocomplain ~/data/saved/$appName/*/*.sav] {
-        if { [ReadSimsetFile $fileName] } {
-            if { $_revision > 0 && [info exists _saved(Revision)] &&
-                 $_revision != $_saved(Revision) } {
-                continue;               # Revision doesn't match.
-            }
-            $_tree insert 0 -label $_saved(Name) -data [array get _saved] 
-        }
-    }
-    return [$_tree degree 0]
-}
-
-#
-# Create dialog to select a simset from the currently available simsets.
-#
-itcl::body Rappture::Analyzer::GetSimset { name } {
-    set popup .selectsimset
-    if { [winfo exists $popup] } {
-        destroy $popup
-    }
-    # Create a popup for the print dialog
-    set title [string tolower $name]
-    Rappture::Balloon $popup -title "Select set of simulations to $title..."
-    set inner [$popup component inner]
-    
-    set tv $inner.tv
-    blt::treeview $inner.tv -tree $_tree \
-        -height 1i \
-        -width 5i \
-        -xscrollcommand [list $inner.xs set] \
-        -yscrollcommand [list $inner.ys set] \
-        -font "Arial 10"
-    scrollbar $inner.xs -orient horizontal -command "$tv xview"
-    scrollbar $inner.ys -orient vertical -command "$tv yview"
-    frame $inner.controls
-    
-    $tv column insert end "Name" "Description" "Date" "Creator"
-    $tv column configure treeView -hide yes 
-    blt::table $inner \
-        0,0 $inner.tv -fill both \
-        0,1 $inner.ys -fill y \
-        1,0 $inner.xs -fill x
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r0 c0 -resize both
-
-    button $inner.controls.cancel -text "Cancel" \
-        -command [itcl::code $this Cancel]
-    set title [string totitle $name]
-    button $inner.controls.save -text $title \
-        -command [itcl::code $this Ok]
-    blt::table $inner.controls \
-        0,0 $inner.controls.cancel \
-        0,1 $inner.controls.save
-    
-    blt::table $inner \
-        0,0 $inner.tv -fill both \
-        0,1 $inner.ys -fill y \
-        1,0 $inner.xs -fill x \
-        3,0 $inner.controls  -fill x -cspan 2
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r0 c0 -resize both
-    blt::table configure $inner r2 -height 0.1i
-    
-    $popup configure \
-        -deactivatecommand [itcl::code $this Cancel] 
-
-    $tv selection set [$_tree firstchild 0]
-    set inner [$popup component inner]
-    update
-    # Activate the popup and call for the output.
-    $popup activate $itk_component(help) below
-    Cancel
-    tkwait variable [itcl::scope _done]
-    set result $_done
-    $popup deactivate 
-    return $result
-}
-
-itcl::body Rappture::Analyzer::SelectSimsetForLoading {} {
-    if { [FindSimsetsForApp $_appName] == 0 } {
-        return
-    }
-    if { [GetSimset "load"] } {
-        LoadSimulations $_saved(Files)
-    }
-}
-
-itcl::body Rappture::Analyzer::reload { fileName } {
-    if { [catch {
-        ReadSimsetFile $fileName
-        if { [llength $_saved(Files)] > 0 } {
-            #StartSplashScreen
-            LoadSimulations $_saved(Files)
-            #HideSplashScreen
-        }
-    } errs] != 0 } {
-        puts stderr "can't load \"$fileName\": errs=$errs"
-    }
-}
-
-itcl::body Rappture::Analyzer::BuildQuestionDialog { popup } {
-    toplevel $popup -background grey92 -bd 2 -relief raised
-    wm withdraw $popup
-    wm overrideredirect $popup true
-    set inner $popup
-    # Create the print dialog widget and add it to the the balloon popup.
-    label $popup.title -text " " \
-        -padx 10 -pady 10 \
-        -background grey92 
-    button $popup.yes -text "Yes" \
-        -highlightthickness 0 \
-        -bd 2  \
-        -command [itcl::code $this Save] 
-    button $popup.no -text "No" \
-        -highlightthickness 0 \
-        -bd 2 \
-        -command [itcl::code $this Cancel] 
-    blt::table $popup \
-        0,0 $popup.title -cspan 2  -fill x -pady 4 \
-        1,0 $popup.yes -width { 0 1i .6i } -pady 4 \
-        1,1 $popup.no -width { 0 1i .6i }  -pady 4 
-    blt::table configure $popup  r2 -height 0.125i
-}
-
-itcl::body Rappture::Analyzer::Save {} {
-    set _done 1
-}
-
-itcl::body Rappture::Analyzer::OverwriteSaveFile {} {
-    set popup .question
-    if { ![winfo exists $popup] } {
-        BuildQuestionDialog $popup 
-    }
-    set text "Simulation set \"$_saved(Name)\" already exists. Overwrite?"
-    $popup.title configure -text $text 
-    $popup.yes configure -text "Save" 
-    $popup.no configure -text "Cancel" 
-    set main [winfo toplevel $itk_component(help)]
-    set pw [winfo reqwidth $popup]
-    set ph [winfo reqheight $popup]
-    set sw [winfo reqwidth $main]
-    set sh [winfo reqheight $main]
-    set rootx [winfo rootx $main]
-    set rooty [winfo rooty $main]
-    set x [expr $rootx + (($sw - $pw) / 2)]
-    set y [expr $rooty + (($sh - $ph) / 2)]
-    wm geometry $popup +$x+$y
-    wm deiconify $popup 
-    update
-    grab $popup 
-    # Activate the popup and call for the output.
-    Cancel
-    tkwait variable [itcl::scope _done]
-    set doSave $_done
-    grab release $popup 
-    destroy $popup 
-    return $doSave
-}
-
-itcl::body Rappture::Analyzer::InstallSharedFile { installdir file } {
-    set dst [file join $installdir [file tail $file]]
-    file copy -force $file $dst
-    file attributes $dst -permissions g+rw,o+r
-    return $dst
-}
-
-itcl::body Rappture::Analyzer::CreateSharedPath { path } {
-    set dir ""
-    foreach file [file split $path] {
-        set dir [file join $dir $file]
-        if { [file exists $dir] } {
-            if { ![file isdirectory $dir] } {
-                error "error in path \"$path\": \"$dir\" is not a directory."
-            }
-        } else {
-            file mkdir $dir 
-            file attributes $dir -permissions g+rwx,o+rx
-        }
-    }
-}
-
-itcl::body Rappture::Analyzer::ExportURL { appName installdir } {
-    set fileName [file join $installdir url.txt]
-    set name [file tail $installdir]
-    set f [open $fileName "w"]
-    puts $f "https://nanohub.org/tools/$appName/invoke?params=file(simset):$installdir/$name.sav\n"
-    close $f
-    file attributes $fileName -permissions g+rw,o+r
-    if { [file exists /usr/bin/exportfile] } {
-        set msgFile [file join $::Rappture::installdir export.html]
-        ExportFile $fileName $msgFile
-    }
-}
-
-itcl::body Rappture::Analyzer::ExportFile { src msgFile } {
-    set dstdir ~/.filexfer/exportfile
-    file mkdir $dstdir
-    set dst [file join $dstdir [file tail $src]]
-    if { [file exists $dst] } {
-        puts stderr "could be a problem: already waiting to export $dst"
-    }
-    file copy -force $src $dst
-    # Now export the file.
-    if { [catch {
-        global exportFileVar 
-        set exportFileVar 0;            # Kill any previous export.
-        set mesg "Select file to export to desktop/laptop"
-        update
-        set cmd "/usr/bin/exportfile --delete $dst --timeout 3 "
-        if { [file exists $msgFile] } { 
-            append cmd "--message $msgFile"
-        }
-        blt::bgexec exportFileVar /bin/sh -c $cmd &
-    } errs]  != 0 } {
-        global errorInfo
-        puts stderr "err: $errorInfo"
-        file delete -force $dst
-    }
-}
-
+        pack $itk_component(resultselector) -before $itk_component(results) \
+            -side top -fill x -padx {20 2}
+    }
+
+    # show the first page by default
+    set first [$itk_component(resultselector) choices get -label 0]
+    if {$first != ""} {
+        $itk_component(results) current page1
+        $itk_component(resultselector) value $first
+    }
+}
Index: trunk/gui/scripts/animicon.tcl
===================================================================
--- trunk/gui/scripts/animicon.tcl	(revision 6716)
+++ 	(revision )
@@ -1,137 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: animicon - an animated icon
-#
-#  This widget displays an animated icon.  It acts like a label, but
-#  it allows you to start/stop the animation.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *Animicon.delay 100 widgetDefault
-option add *Animicon.textBackground white widgetDefault
-
-itcl::class Rappture::Animicon {
-    inherit itk::Widget
-
-    itk_option define -delay delay Delay 100
-    itk_option define -images images Images ""
-
-    constructor {args} { # defined below }
-
-    public method start {}
-    public method stop {}
-    public method isrunning {}
-
-    protected method _next {}
-    protected method _loadFrames {}
-
-    private variable _frames      ;# array of frames indexed from 0
-    private variable _pos 0       ;# current position in anim sequence
-    private variable _afterid ""  ;# after ID for next animation step
-}
-
-itk::usual Animicon {
-    keep -cursor -background
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Animicon::constructor {args} {
-    itk_component add icon {
-        label $itk_interior.icon
-    }
-    pack $itk_component(icon) -expand yes -fill both
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: start
-#
-# Clients use this to start the animation.  If the animation is
-# already running, it does nothing.  Otherwise, it starts the
-# animation.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Animicon::start {} {
-    if {![isrunning]} {
-        _next
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: stop
-#
-# Clients use this to stop the animation.  If the animation is
-# not running, it does nothing.  Otherwise, it stops the
-# animation on the current frame.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Animicon::stop {} {
-    if {[isrunning]} {
-        after cancel $_afterid
-        set _afterid ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: isrunning
-#
-# Returns true if the animation is currently running, and false
-# otherwise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Animicon::isrunning {} {
-    return [expr {"" != $_afterid}]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _next
-#
-# Used internally to load the next animation frame.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Animicon::_next {} {
-    $itk_component(icon) configure -image $_frames($_pos)
-    if {[incr _pos] >= [array size _frames]} {
-        set _pos 0
-    }
-    set _afterid [after $itk_option(-delay) [itcl::code $this _next]]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -images
-#
-# Sets a sequence of icon names that will be loaded for an animation.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Animicon::images {
-    set restart [isrunning]
-    stop
-
-    array unset _frames
-    if {[llength $itk_option(-images)] >= 1} {
-        set w 0
-        set h 0
-        set i 0
-        foreach name $itk_option(-images) {
-            set imh [Rappture::icon $name]
-            if {"" == $imh} {
-                error "image not found: $name"
-            }
-            set _frames($i) $imh
-            if {[image width $imh] > $w} { set w [image width $imh] }
-            if {[image height $imh] > $h} { set h [image height $imh] }
-            incr i
-        }
-    }
-
-    $itk_component(icon) configure -width $w -height $h -image $_frames(0)
-    set _pos 0
-
-    if {$restart} {
-        start
-    }
-}
Index: trunk/gui/scripts/animover.tcl
===================================================================
--- trunk/gui/scripts/animover.tcl	(revision 6716)
+++ trunk/gui/scripts/animover.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: animover - animated move
@@ -8,8 +7,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -32,5 +28,5 @@
 
     constructor {args} { # defined below }
-
+                                                                                
     protected method _redraw {}
     protected variable _x0 0   ;# min value for middle image
@@ -51,5 +47,5 @@
         [file join $dir images bgr.gif]]
 }
-
+                                                                                
 itk::usual Animover {
 }
Index: trunk/gui/scripts/balloon.tcl
===================================================================
--- trunk/gui/scripts/balloon.tcl	(revision 6716)
+++ 	(revision )
@@ -1,678 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Balloon - toplevel popup window, like a cartoon balloon
-#
-#  This widget is used as a container for pop-up panels in Rappture.
-#  If shape extensions are supported, then the window is drawn as
-#  a cartoon balloon.  Otherwise, it is a raised panel, with a little
-#  line connecting it to the widget that brought it up.  When active,
-#  the panel has a global grab and focus, so the user must interact
-#  with it or dismiss it.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-namespace eval Rappture { # forward declaration }
-
-option add *Balloon.dismissButton on widgetDefault
-option add *Balloon.padX 4 widgetDefault
-option add *Balloon.padY 4 widgetDefault
-option add *Balloon.titleBackground #999999 widgetDefault
-option add *Balloon.titleForeground white widgetDefault
-option add *Balloon.relief raised widgetDefault
-option add *Balloon.stemLength 16 widgetDefault
-
-itcl::class Rappture::Balloon {
-    inherit itk::Toplevel
-
-    itk_option define -background background Background ""
-    itk_option define -deactivatecommand deactivateCommand DeactivateCommand ""
-    itk_option define -dismissbutton dismissButton DismissButton "on"
-    itk_option define -padx padX Pad 0
-    itk_option define -pady padY Pad 0
-    itk_option define -title title Title ""
-    itk_option define -titlebackground titleBackground Background ""
-    itk_option define -titleforeground titleForeground Foreground ""
-    itk_option define -stemlength stemLength StemLength 20
-
-    constructor {args} { # defined below }
-
-    public method activate {where placement}
-    public method deactivate {}
-
-    protected method _createStems {}
-    protected method _place {where placement w h sw sh}
-
-    protected variable _stems   ;# windows for cartoon balloon stems
-    protected variable _masks   ;# masks for cartoon balloon stems
-    protected variable _fills   ;# lines for cartoon balloon stems
-
-    public proc outside {widget x y}
-
-    bind RapptureBalloon <ButtonPress> \
-        {if {[Rappture::Balloon::outside %W %X %Y]} {%W deactivate}}
-}
-
-itk::usual Balloon {
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Balloon::constructor {args} {
-    wm overrideredirect $itk_component(hull) yes
-    wm withdraw $itk_component(hull)
-    component hull configure -borderwidth 1 -relief solid -padx 0 -pady 0
-
-    itk_component add border {
-        frame $itk_interior.border -borderwidth 2
-    } {
-        usual
-        keep -relief
-    }
-    pack $itk_component(border) -expand yes -fill both
-
-    itk_component add titlebar {
-        frame $itk_component(border).tbar
-    } {
-        usual
-        rename -background -titlebackground titleBackground Background
-    }
-
-    itk_component add title {
-        label $itk_component(titlebar).title -width 1 -anchor w
-    } {
-        usual
-        rename -background -titlebackground titleBackground Background
-        rename -foreground -titleforeground titleForeground Foreground
-        rename -highlightbackground -titlebackground titleBackground Background
-        rename -text -title title Title
-    }
-    pack $itk_component(title) -side left -expand yes -fill both -padx 2
-
-    itk_component add dismiss {
-        button $itk_component(titlebar).dismiss \
-            -bitmap [Rappture::icon dismiss] \
-            -relief flat -overrelief raised -command "
-              Rappture::Tooltip::cue hide
-              [list $itk_component(hull) deactivate]
-            "
-    } {
-        usual
-        rename -background -titlebackground titleBackground Background
-        rename -foreground -titleforeground titleForeground Foreground
-        rename -highlightbackground -titlebackground titleBackground Background
-    }
-
-    itk_component add inner {
-        frame $itk_component(border).inner
-    }
-    pack $itk_component(inner) -expand yes -fill both
-
-    # add bindings to release the grab
-    set btags [bindtags $itk_component(hull)]
-    bindtags $itk_component(hull) [linsert $btags 1 RapptureBalloon]
-
-    eval itk_initialize $args
-
-    _createStems
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _place <where> <place> <pw> <ph> <screenw> <screenh>
-#
-# Called by activate. Returns the exact location information given
-# the parameters.  If the window will not fit on the screen with the
-# requested placement, will loop through all possible placements to
-# find the best alternative.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Balloon::_place {where place pw ph screenw screenh} {
-    # pw and ph are requested balloon window size
-
-    # set placement preference order
-    switch $place {
-        left {set plist {left above below right}}
-        right {set plist {right above below left}}
-        above {set plist {above below right left}}
-        below {set plist {below above right left}}
-    }
-
-    set ph_orig $ph
-    set pw_orig $pw
-
-    foreach placement $plist {
-        set pw $pw_orig
-        set ph $ph_orig
-        if {[winfo exists $where]} {
-            # location of top-left corner of root window
-            set rx [winfo rootx $where]
-            set ry [winfo rooty $where]
-
-            # size of widget we want to popup over
-            set width  [winfo width $where]
-            set height [winfo height $where]
-
-            # x and y will be location for popup
-            set x [expr {$rx + $width/2}]
-            set y [expr {$ry + $height/2}]
-
-            switch -- $placement {
-                left { set x [expr {$rx + 5}] }
-                right { set x [expr {$rx + $width - 5}] }
-                above { set y [expr {$ry + 5}] }
-                below { set y [expr {$ry + $height - 5}] }
-            }
-        } elseif {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} {
-            # got x and y
-        } else {
-            error "bad location \"$where\": should be widget or @x,y"
-        }
-
-        # compute stem image size
-        set s $_stems($placement)
-        set sw [image width $_fills($placement)]
-        set sh [image height $_fills($placement)]
-        set offscreen 0
-
-        switch -- $placement {
-            left {
-                set sx [expr {$x-$sw+3}]
-                set sy [expr {$y-$sh/2}]
-                set px [expr {$sx-$pw+3}]
-                set py [expr {$y-$ph/2}]
-
-                # make sure that the panel doesn't go off-screen
-                if {$py < 0} {
-                    incr offscreen [expr -$py]
-                    set py 0
-                }
-                if {$py+$ph > $screenh} {
-                    incr offscreen [expr {$py + $ph - $screenh}]
-                    set py [expr {$screenh - $ph}]
-                }
-                if {$px < 0} {
-                    incr offscreen [expr -$px]
-                    set pw [expr {$pw + $px}]
-                    set px 0
-                }
-            }
-            right {
-                set sx $x
-                set sy [expr {$y-$sh/2}]
-                set px [expr {$x+$sw-3}]
-                set py [expr {$y-$ph/2}]
-
-                # make sure that the panel doesn't go off-screen
-                if {$py < 0} {
-                    incr offscreen [expr -$py]
-                    set py 0
-                }
-                if {$py+$ph > $screenh} {
-                    incr offscreen [expr {$py + $ph - $screenh}]
-                    set py [expr {$screenh-$ph}]
-                }
-                if {$px+$pw > $screenw} {
-                    incr offscreen [expr {$px + $pw - $screenw}]
-                    set pw [expr {$screenw-$px}]
-                }
-            }
-            above {
-                set sx [expr {$x-$sw/2}]
-                set sy [expr {$y-$sh+3}]
-                set px [expr {$x-$pw/2}]
-                set py [expr {$sy-$ph+3}]
-
-                # make sure that the panel doesn't go off-screen
-                if {$px < 0} {
-                    incr offscreen [expr -$px]
-                    set px 0
-                }
-                if {$px+$pw > $screenw} {
-                    incr offscreen [expr {$px + $pw - $screenw}]
-                    set px [expr {$screenw-$pw}]
-                }
-                if {$py < 0} {
-                    incr offscreen [expr -$py]
-                    set ph [expr {$ph+$py}]
-                    set py 0
-                }
-            }
-            below {
-                set sx [expr {$x-$sw/2}]
-                set sy $y
-                set px [expr {$x-$pw/2}]
-                set py [expr {$y+$sh-3}]
-
-                # make sure that the panel doesn't go off-screen
-                if {$px < 0} {
-                    incr offscreen [expr -$px]
-                    set px 0
-                }
-                if {$px+$pw > $screenw} {
-                    incr offscreen [expr {$px + $pw - $screenw}]
-                    set px [expr {$screenw-$pw}]
-                }
-                if {$py+$ph > $screenh} {
-                    incr offscreen [expr {$py + $py - $screenh}]
-                    set ph [expr {$screenh-$py}]
-                }
-            }
-        }
-        set res($placement) [list $placement $offscreen $pw $ph $px $py $sx $sy]
-        if {$offscreen == 0} {
-            return "$placement $pw $ph $px $py $sx $sy"
-        }
-    }
-
-    # In the unlikely event that we arrived here, it is because no
-    # placement allowed the entire balloon window to be displayed.
-    # Loop through the results and return the best-case placement.
-    set _min 10000
-    foreach pl $plist {
-        set offscreen [lindex $res($pl) 1]
-        if {$offscreen < $_min} {
-            set _min $offscreen
-            set _min_pl $pl
-        }
-    }
-    return "$_min_pl [lrange $res($_min_pl) 2 end]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: activate <where> <placement>
-#
-# Clients use this to pop up this balloon panel pointing to the
-# <where> location, which should be a widget name or @X,Y.  The
-# <placement> indicates whether the panel should be left, right,
-# above, or below the <where> coordinate. Plecement is considered
-# a suggestion and may be changed to fit the popup in the screen.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Balloon::activate {where placement} {
-    if {![info exists _stems($placement)]} {
-        error "bad placement \"$placement\": should be [join [lsort [array names _stems]] {, }]"
-    }
-
-    # if the panel is already up, take it down
-    deactivate
-
-    set p $itk_component(hull)
-    set screenw [winfo screenwidth $p]
-    set screenh [winfo screenheight $p]
-
-    set pw [winfo reqwidth $p]
-    if {$pw > $screenw} { set pw [expr {$screenw-10}] }
-    set ph [winfo reqheight $p]
-    if {$ph > $screenh} { set ph [expr {$screenh-10}] }
-
-    foreach {place pw ph px py sx sy} [_place $where $placement $pw $ph $screenw $screenh] break
-
-    set s $_stems($place)
-    if {[info exists _masks($place)]} {
-        shape set $s -bound photo $_masks($place)
-    }
-
-    if { $pw < 1 || $ph < 1 }  {
-        # I really don't know why this is happenning.  I believe this occurs
-        # when in a work space (i.e the main window is smaller than the root
-        # window). So for now, better to place the balloon window somewhere
-        # than to fail with a bad geometry.
-        wm geometry $p +$px+$py
-    } else {
-        wm geometry $p ${pw}x${ph}+$px+$py
-    }
-    wm deiconify $p
-    raise $p
-
-    wm geometry $s +$sx+$sy
-    wm deiconify $s
-    raise $s
-
-    # grab the mouse pointer
-    update
-    while {[catch {grab set $itk_component(hull)}]} {
-        after 100
-    }
-    focus $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: deactivate
-#
-# Clients use this to take down the balloon panel if it is on screen.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Balloon::deactivate {} {
-    if {[string length $itk_option(-deactivatecommand)] > 0} {
-        uplevel #0 $itk_option(-deactivatecommand)
-    }
-
-    grab release $itk_component(hull)
-    wm withdraw $itk_component(hull)
-    foreach dir {left right above below} {
-        wm withdraw $_stems($dir)
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _createStems
-#
-# Used internally to create the stems that connect a balloon panel
-# to its anchor point, in all four possible directions:  left, right,
-# above, and below.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Balloon::_createStems {} {
-    # destroy any existing stems
-    foreach dir [array names _stems] {
-        destroy $_stems($dir)
-        unset _stems($dir)
-    }
-    foreach dir [array names _masks] {
-        image delete $_masks($dir)
-        unset _masks($dir)
-    }
-    foreach dir [array names _fills] {
-        image delete $_fills($dir)
-        unset _fills($dir)
-    }
-
-    if {[catch {package require Shape}] == 0} {
-        #
-        # We have the Shape extension.  Use it to create nice
-        # looking (triangle-shaped) stems.
-        #
-        set s $itk_option(-stemlength)
-        foreach dir {left right above below} {
-            switch -- $dir {
-                left - right {
-                    set sw [expr {$s+2}]
-                    set sh $s
-                }
-                above - below {
-                    set sw $s
-                    set sh [expr {$s+2}]
-                }
-            }
-
-            set _stems($dir) [toplevel $itk_interior.s$dir -borderwidth 0]
-            label $_stems($dir).l \
-                -width $sw -height $sh -borderwidth 0
-            pack $_stems($dir).l -expand yes -fill both
-
-            wm withdraw $_stems($dir)
-            wm overrideredirect $_stems($dir) yes
-
-            #
-            # Draw the triangle part of the stem, with a black outline
-            # and light/dark highlights:
-            #
-            #     --------  ---       LEFT STEM
-            #    |..##    |  ^
-            #    |  ..##  |  |        . = light color
-            #    |    ..##|  | s      @ = dark color
-            #    |    @@##|  |        # = black
-            #    |  @@##  |  |
-            #    |@@##    |  v
-            #     --------  ---
-            #    |<------>|
-            #        s+2
-            #
-            set _masks($dir) [image create photo -width $sw -height $sh]
-            set _fills($dir) [image create photo -width $sw -height $sh]
-
-            set bg $itk_option(-background)
-            set light [Rappture::color::brightness $bg 0.4]
-            set dark [Rappture::color::brightness $bg -0.4]
-            set rgb [winfo rgb . $bg]
-            set flatbg [format "#%04x%04x%04x" [lindex $rgb 0] [lindex $rgb 1] [lindex $rgb 2]]
-            switch -- $itk_option(-relief) {
-                raised {
-                    set light [Rappture::color::brightness $bg 0.4]
-                    set dark [Rappture::color::brightness $bg -0.4]
-                    set bg $flatbg
-                }
-                flat - solid {
-                    set light $flatbg
-                    set dark $flatbg
-                    set bg $flatbg
-                }
-                sunken {
-                    set light [Rappture::color::brightness $bg -0.4]
-                    set dark [Rappture::color::brightness $bg 0.4]
-                    set bg $flatbg
-                }
-            }
-            set bg [format "#%04x%04x%04x" [lindex $rgb 0] [lindex $rgb 1] [lindex $rgb 2]]
-
-            $_fills($dir) put $bg -to 0 0 $sw $sh
-
-            switch -- $dir {
-              left {
-                set i 0
-                for {set j 0} {$j < $s/2} {incr j} {
-                    set ybtm [expr {$s-$j-1}]
-                    $_fills($dir) put $dark \
-                        -to $i [expr {$ybtm-1}] [expr {$i+2}] [expr {$ybtm+1}]
-                    $_fills($dir) put black \
-                        -to [expr {$i+2}] $ybtm [expr {$i+4}] [expr {$ybtm+1}]
-
-                    set ytop $j
-                    set ytoffs [expr {($j == $s/2-1) ? 1 : 2}]
-                    $_fills($dir) put $light \
-                        -to $i $ytop [expr {$i+2}] [expr {$ytop+$ytoffs}]
-                    $_fills($dir) put black \
-                        -to [expr {$i+2}] $ytop [expr {$i+4}] [expr {$ytop+1}]
-                    incr i 2
-                }
-                $_stems($dir).l configure -image $_fills($dir)
-
-                $_masks($dir) put black -to 0 0 $sw $sh
-                set i 0
-                for {set j 0} {$j < $s/2} {incr j} {
-                    for {set k [expr {$i+4}]} {$k < $s+2} {incr k} {
-                        $_masks($dir) transparency set $k $j yes
-                        $_masks($dir) transparency set $k [expr {$s-$j-1}] yes
-                    }
-                    incr i 2
-                }
-              }
-              right {
-                set i $sw
-                for {set j 0} {$j < $s/2} {incr j} {
-                    set ybtm [expr {$s-$j-1}]
-                    $_fills($dir) put $dark \
-                        -to [expr {$i-2}] [expr {$ybtm-1}] $i [expr {$ybtm+1}]
-                    $_fills($dir) put black \
-                        -to [expr {$i-4}] $ybtm [expr {$i-2}] [expr {$ybtm+1}]
-
-                    set ytop $j
-                    set ytoffs [expr {($j == $s/2-1) ? 1 : 2}]
-                    $_fills($dir) put $light \
-                        -to [expr {$i-2}] $ytop $i [expr {$ytop+$ytoffs}]
-                    $_fills($dir) put black \
-                        -to [expr {$i-4}] $ytop [expr {$i-2}] [expr {$ytop+1}]
-                    incr i -2
-                }
-                $_stems($dir).l configure -image $_fills($dir)
-
-                $_masks($dir) put black -to 0 0 $sw $sh
-                set i $sw
-                for {set j 0} {$j < $s/2} {incr j} {
-                    for {set k 0} {$k < $i-4} {incr k} {
-                        $_masks($dir) transparency set $k $j yes
-                        $_masks($dir) transparency set $k [expr {$s-$j-1}] yes
-                    }
-                    incr i -2
-                }
-              }
-              above {
-                set i 0
-                for {set j 0} {$j < $s/2} {incr j} {
-                    set xrhs [expr {$s-$j-1}]
-                    $_fills($dir) put $dark \
-                        -to [expr {$xrhs-1}] $i [expr {$xrhs+1}] [expr {$i+2}]
-                    $_fills($dir) put black \
-                        -to $xrhs [expr {$i+2}] [expr {$xrhs+1}] [expr {$i+4}]
-
-                    set xlhs $j
-                    set xloffs [expr {($j == $s/2-1) ? 1 : 2}]
-                    $_fills($dir) put $light \
-                        -to $xlhs $i [expr {$xlhs+$xloffs}] [expr {$i+2}]
-                    $_fills($dir) put black \
-                        -to $xlhs [expr {$i+2}] [expr {$xlhs+1}] [expr {$i+4}]
-                    incr i 2
-                }
-                $_stems($dir).l configure -image $_fills($dir)
-
-                $_masks($dir) put black -to 0 0 $sw $sh
-                set i 0
-                for {set j 0} {$j < $s/2} {incr j} {
-                    for {set k [expr {$i+4}]} {$k < $s+2} {incr k} {
-                        $_masks($dir) transparency set $j $k yes
-                        $_masks($dir) transparency set [expr {$s-$j-1}] $k yes
-                    }
-                    incr i 2
-                }
-              }
-              below {
-                set i $sh
-                for {set j 0} {$j < $s/2} {incr j} {
-                    set xrhs [expr {$s-$j-1}]
-                    $_fills($dir) put $dark \
-                        -to [expr {$xrhs-1}] [expr {$i-2}] [expr {$xrhs+1}] $i
-                    $_fills($dir) put black \
-                        -to $xrhs [expr {$i-4}] [expr {$xrhs+1}] [expr {$i-2}]
-
-                    set xlhs $j
-                    set xloffs [expr {($j == $s/2-1) ? 1 : 2}]
-                    $_fills($dir) put $light \
-                        -to $xlhs [expr {$i-2}] [expr {$xlhs+$xloffs}] $i
-                    $_fills($dir) put black \
-                        -to $xlhs [expr {$i-4}] [expr {$xlhs+1}] [expr {$i-2}]
-                    incr i -2
-                }
-                $_stems($dir).l configure -image $_fills($dir)
-
-                $_masks($dir) put black -to 0 0 $sw $sh
-                set i $sh
-                for {set j 0} {$j < $s/2} {incr j} {
-                    for {set k 0} {$k < $i-4} {incr k} {
-                        $_masks($dir) transparency set $j $k yes
-                        $_masks($dir) transparency set [expr {$s-$j-1}] $k yes
-                    }
-                    incr i -2
-                }
-              }
-            }
-        }
-    } else {
-        #
-        # No shape extension.  Do the best we can by creating a
-        # black line for all directions.
-        #
-        foreach {dir w h} [list \
-            left   $itk_option(-stemlength) 3 \
-            right  $itk_option(-stemlength) 3 \
-            above  3 $itk_option(-stemlength) \
-            below  3 $itk_option(-stemlength) \
-        ] {
-            set _stems($dir) [toplevel $itk_interior.s$dir \
-                -width $w -height $h \
-                -borderwidth 1 -relief solid -background black]
-            wm withdraw $_stems($dir)
-            wm overrideredirect $_stems($dir) yes
-
-            # create this for size, even though we don't really use it
-            set _fills($dir) [image create photo -width $w -height $h]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: outside <widget> <x> <y>
-#
-# Used internally to see if the click point <x>,<y> is outside of
-# this widget.  If so, the widget usually releases is grab and
-# deactivates.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Balloon::outside {widget x y} {
-    return [expr {$x < [winfo rootx $widget]
-             || $x > [winfo rootx $widget]+[winfo width $widget]
-             || $y < [winfo rooty $widget]
-             || $y > [winfo rooty $widget]+[winfo height $widget]}]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -background
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Balloon::background {
-    _createStems
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -stemlength
-#
-# Used internally to create the stems that connect a balloon panel
-# to its anchor point, in all four possible directions:  left, right,
-# above, and below.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Balloon::stemlength {
-    if {$itk_option(-stemlength) % 2 != 0} {
-        error "stem length should be an even number of pixels"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -dismissbutton
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Balloon::dismissbutton {
-    if {![string is boolean $itk_option(-dismissbutton)]} {
-        error "bad value \"$itk_option(-dismissbutton)\": should be on/off, 1/0, true/false, yes/no"
-    }
-    if {$itk_option(-dismissbutton)} {
-        pack $itk_component(titlebar) -before $itk_component(inner) \
-            -side top -fill x
-        pack $itk_component(dismiss) -side right -padx 4
-    } elseif {"" != $itk_option(-title)} {
-        pack $itk_component(titlebar) -before $itk_component(inner) \
-            -side top -fill x
-        pack forget $itk_component(dismiss)
-    } else {
-        pack forget $itk_component(titlebar)
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -padx
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Balloon::padx {
-    pack $itk_component(inner) -padx $itk_option(-padx)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -pady
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Balloon::pady {
-    pack $itk_component(inner) -pady $itk_option(-pady)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -title
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Balloon::title {
-    if {"" != $itk_option(-title) || $itk_option(-dismissbutton)} {
-        pack $itk_component(titlebar) -before $itk_component(inner) \
-            -side top -fill x
-        if {$itk_option(-dismissbutton)} {
-            pack $itk_component(dismiss) -side right -padx 4
-        } else {
-            pack forget $itk_component(dismiss)
-        }
-    } else {
-        pack forget $itk_component(titlebar)
-    }
-}
Index: trunk/gui/scripts/barchartresult.tcl
===================================================================
--- trunk/gui/scripts/barchartresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1628 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: barchartresult - X/Y plot in a ResultSet
-#
-#  This widget is an X/Y plot, meant to view line graphs produced
-#  as output from the run of a Rappture tool.  Use the "add" and
-#  "delete" methods to control the dataobjs showing on the plot.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *BarchartResult.width 3i widgetDefault
-option add *BarchartResult.height 3i widgetDefault
-option add *BarchartResult.gridColor #d9d9d9 widgetDefault
-option add *BarchartResult.activeColor blue widgetDefault
-option add *BarchartResult.dimColor gray widgetDefault
-# Don't let the step size default to 1.0 (for barcharts)
-option add *BarchartResult*x.loose 0 widgetDefault
-option add *BarchartResult*y.loose 1 widgetDefault
-option add *BarchartResult*x.stepSize 0.0 widgetDefault
-option add *BarchartResult.controlBackground gray widgetDefault
-option add *BarchartResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-set autocolors {
-    #0000ff #ff0000 #00cc00
-    #cc00cc #ff9900 #cccc00
-    #000080 #800000 #006600
-    #660066 #996600 #666600
-}
-set autocolors {
-#0000cd
-#cd0000
-#00cd00
-#3a5fcd
-#cdcd00
-#cd1076
-#009acd
-#00c5cd
-#a2b5cd
-#7ac5cd
-#66cdaa
-#a2cd5a
-#cd9b9b
-#cdba96
-#cd3333
-#cd6600
-#cd8c95
-#cd00cd
-#9a32cd
-#6ca6cd
-#9ac0cd
-#9bcd9b
-#00cd66
-#cdc673
-#cdad00
-#cd5555
-#cd853f
-#cd7054
-#cd5b45
-#cd6889
-#cd69c9
-#551a8b
-}
-
-option add *BarchartResult.autoColors $autocolors widgetDefault
-option add *BarchartResult*Balloon*Entry.background white widgetDefault
-
-itcl::class Rappture::BarchartResult {
-    inherit itk::Widget
-
-    itk_option define -gridcolor gridColor GridColor ""
-    itk_option define -activecolor activeColor ActiveColor ""
-    itk_option define -dimcolor dimColor DimColor ""
-    itk_option define -autocolors autoColors AutoColors ""
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method download {option args}
-
-    protected method _rebuild {}
-    protected method _resetLimits {}
-    protected method _zoom {option args}
-    protected method _hilite {state x y}
-    protected method _axis {option args}
-    protected method _getAxes {dataobj}
-    protected method _getLineMarkerOptions { style }
-    protected method _getTextMarkerOptions { style }
-    protected method _enterMarker { g name x y text }
-    protected method _leaveMarker { g name }
-    private method _formatTickLabel { w value }
-    private method ResetLegend {}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-    private variable _dlist ""     ;# list of dataobjs
-    private variable _dataobj2color  ;# maps dataobj => plotting color
-    private variable _dataobj2width  ;# maps dataobj => line width
-    private variable _dataobj2dashes ;# maps dataobj => BLT -dashes list
-    private variable _dataobj2raise  ;# maps dataobj => raise flag 0/1
-    private variable _dataobj2desc   ;# maps dataobj => description of data
-    private variable _elem2dataobj   ;# maps graph element => dataobj
-    private variable _label2axis   ;# maps axis label => axis ID
-    private variable _limits       ;# axis limits:  x-min, x-max, etc.
-    private variable _autoColorI 0 ;# index for next "-color auto"
-
-    private variable _hilite       ;# info for element currently highlighted
-    private variable _axis         ;# info for axis manipulations
-    private variable _axisPopup    ;# info for axis being edited in popup
-    common _downloadPopup          ;# download options from popup
-    private variable _markers
-    private variable _tickLabels
-}
-
-itk::usual BarchartResult {
-    keep -background -foreground -cursor -font
-}
-
-itk::usual Panedwindow {
-    keep -background -cursor
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this _rebuild]; list"
-
-    array set _downloadPopup {
-        format csv
-    }
-
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add main {
-        Rappture::SidebarFrame $itk_interior.main
-    }
-    pack $itk_component(main) -expand yes -fill both
-    set f [$itk_component(main) component controls]
-
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this _zoom reset]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(reset) -padx 4 -pady 2 -anchor e
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    set f [$itk_component(main) component frame]
-    itk_component add plot {
-        blt::barchart $f.plot \
-            -highlightthickness 0 -plotpadx 0 -plotpady 0 \
-            -barmode aligned -rightmargin 1
-    } {
-        keep -background -foreground -cursor -font
-    }
-    pack $itk_component(plot) -expand yes -fill both
-
-    $itk_component(plot) pen configure activeBar \
-        -borderwidth 2 -foreground black -background red
-
-    # Add bindings so you can mouse over points to see values:
-    bind $itk_component(plot) <Motion> \
-        [itcl::code $this _hilite at %x %y]
-    bind $itk_component(plot) <Leave> \
-        [itcl::code $this _hilite off %x %y]
-
-    # Add support for editing axes:
-    Rappture::Balloon $itk_component(hull).axes -title "Axis Options"
-    set inner [$itk_component(hull).axes component inner]
-
-    label $inner.labell -text "Label:"
-    entry $inner.label -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.labell -row 1 -column 0 -sticky e
-    grid $inner.label -row 1 -column 1 -sticky ew -pady 4
-
-    label $inner.minl -text "Minimum:"
-    entry $inner.min -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.minl -row 2 -column 0 -sticky e
-    grid $inner.min -row 2 -column 1 -sticky ew -pady 4
-
-    label $inner.maxl -text "Maximum:"
-    entry $inner.max -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.maxl -row 3 -column 0 -sticky e
-    grid $inner.max -row 3 -column 1 -sticky ew -pady 4
-
-    label $inner.formatl -text "Format:"
-    Rappture::Combobox $inner.format -width 15 -editable no
-    $inner.format choices insert end \
-        "%.6g"  "Auto"         \
-        "%.0f"  "X"          \
-        "%.1f"  "X.X"          \
-        "%.2f"  "X.XX"         \
-        "%.3f"  "X.XXX"        \
-        "%.6f"  "X.XXXXXX"     \
-        "%.1e"  "X.Xe+XX"      \
-        "%.2e"  "X.XXe+XX"     \
-        "%.3e"  "X.XXXe+XX"    \
-        "%.6e"  "X.XXXXXXe+XX"
-    grid $inner.formatl -row 4 -column 0 -sticky e
-    grid $inner.format -row 4 -column 1 -sticky ew -pady 4
-
-    label $inner.scalel -text "Scale:"
-    frame $inner.scales
-    radiobutton $inner.scales.linear -text "Linear" \
-        -variable [itcl::scope _axisPopup(scale)] -value "linear"
-    pack $inner.scales.linear -side left
-    radiobutton $inner.scales.log -text "Logarithmic" \
-        -variable [itcl::scope _axisPopup(scale)] -value "log"
-    pack $inner.scales.log -side left
-    grid $inner.scalel -row 5 -column 0 -sticky e
-    grid $inner.scales -row 5 -column 1 -sticky ew -pady 4
-
-    foreach axis {x y} {
-        set _axisPopup(format-$axis) "%.6g"
-    }
-    _axis scale x linear
-    _axis scale y linear
-
-    $itk_component(plot) legend configure -hide yes
-
-    #
-    # Add legend for editing hidden/elements:
-    #
-    set inner [$itk_component(main) insert end \
-        -title "Legend" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    itk_component add legend {
-        Rappture::XyLegend $inner.legend $itk_component(plot)
-    }
-    pack $itk_component(legend) -expand yes -fill both
-    after idle [itcl::code $this ResetLegend]
-
-    # quick-and-dirty zoom functionality, for now...
-    Blt_ZoomStack $itk_component(plot)
-    eval itk_initialize $args
-
-    set _hilite(elem) ""
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a dataobj to the plot.  The optional <settings>
-# are used to configure the plot.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -type "bar"
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-    # if the color is "auto", then select a color from -autocolors
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        if {$params(-color) == "autoreset"} {
-            set _autoColorI 0
-        }
-        set color [lindex $itk_option(-autocolors) $_autoColorI]
-        if {"" == $color} { set color black }
-        set params(-color) $color
-
-        # set up for next auto color
-        if {[incr _autoColorI] >= [llength $itk_option(-autocolors)]} {
-            set _autoColorI 0
-        }
-    }
-
-    # convert -linestyle to BLT -dashes
-    switch -- $params(-linestyle) {
-        dashed { set params(-linestyle) {4 4} }
-        dotted { set params(-linestyle) {2 4} }
-        default { set params(-linestyle) {} }
-    }
-
-    # if -brightness is set, then update the color
-    if {$params(-brightness) != 0} {
-        set params(-color) [Rappture::color::brightness \
-            $params(-color) $params(-brightness)]
-
-        set bg [$itk_component(plot) cget -plotbackground]
-        foreach {h s v} [Rappture::color::RGBtoHSV $bg] break
-        if {$v > 0.5} {
-            set params(-color) [Rappture::color::brightness_max \
-                $params(-color) 0.8]
-        } else {
-            set params(-color) [Rappture::color::brightness_min \
-                $params(-color) 0.2]
-        }
-    }
-
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-        set _dataobj2color($dataobj) $params(-color)
-        set _dataobj2width($dataobj) $params(-width)
-        set _dataobj2dashes($dataobj) $params(-linestyle)
-        set _dataobj2raise($dataobj) $params(-raise)
-        set _dataobj2desc($dataobj) $params(-description)
-
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-    foreach obj $dlist {
-        if {[info exists _dataobj2raise($obj)] && $_dataobj2raise($obj)} {
-            set i [lsearch -exact $dlist $obj]
-            if {$i >= 0} {
-                set dlist [lreplace $clist $i $i]
-                lappend dlist $obj
-            }
-        }
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            catch {unset _dataobj2color($dataobj)}
-            catch {unset _dataobj2width($dataobj)}
-            catch {unset _dataobj2dashes($dataobj)}
-            catch {unset _dataobj2raise($dataobj)}
-            foreach elem [array names _elem2dataobj] {
-                if {$_elem2dataobj($elem) == $dataobj} {
-                    unset _elem2dataobj($elem)
-                }
-            }
-            set changed 1
-        }
-    }
-
-    # If anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-
-    # Nothing left? then start over with auto colors
-    if {[llength $_dlist] == 0} {
-        set _autoColorI 0
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all dataobjs--even those not showing on the screen.
-# Because of this, the limits are appropriate for all dataobjs as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::scale {args} {
-    set allx [$itk_component(plot) x2axis use]
-    lappend allx x  ;# fix main x-axis too
-    foreach axis $allx {
-        _axis scale $axis linear
-    }
-
-    set ally [$itk_component(plot) y2axis use]
-    lappend ally y  ;# fix main y-axis too
-    foreach axis $ally {
-        _axis scale $axis linear
-    }
-
-    catch {unset _limits}
-    foreach dataobj $args {
-        # find the axes for this dataobj (e.g., {x y2})
-        foreach {map(x) map(y)} [_getAxes $dataobj] break
-
-        foreach axis {x y} {
-            # get defaults for both linear and log scales
-            foreach type {lin log} {
-                # store results -- ex: _limits(x2log-min)
-                set id $map($axis)$type
-                foreach {min max} [$dataobj limits $axis$type] break
-                if {"" != $min && "" != $max} {
-                    if {![info exists _limits($id-min)]} {
-                        set _limits($id-min) $min
-                        set _limits($id-max) $max
-                    } else {
-                        if {$min < $_limits($id-min)} {
-                            set _limits($id-min) $min
-                        }
-                        if {$max > $_limits($id-max)} {
-                            set _limits($id-max) $max
-                        }
-                    }
-                }
-            }
-
-            if {[$dataobj hints ${axis}scale] == "log"} {
-                _axis scale $map($axis) log
-            }
-        }
-    }
-    _resetLimits
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            set popup .barchartresultdownload
-            if {![winfo exists .barchartresultdownload]} {
-                # if we haven't created the popup yet, do it now
-                Rappture::Balloon $popup \
-                    -title "[Rappture::filexfer::label downloadWord] as..."
-                set inner [$popup component inner]
-                label $inner.summary -text "" -anchor w
-                pack $inner.summary -side top
-                radiobutton $inner.csv -text "Data as Comma-Separated Values" \
-                    -variable Rappture::BarchartResult::_downloadPopup(format) \
-                    -value csv
-                pack $inner.csv -anchor w
-                radiobutton $inner.image -text "Image (PS/PDF/PNG/JPEG)" \
-                    -variable Rappture::BarchartResult::_downloadPopup(format) \
-                    -value image
-                pack $inner.image -anchor w
-                button $inner.go -text [Rappture::filexfer::label download] \
-                    -command [lindex $args 0]
-                pack $inner.go -pady 4
-            } else {
-                set inner [$popup component inner]
-            }
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:"
-            update idletasks ;# fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .barchartresultdownload
-            if {[winfo exists .barchartresultdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                csv {
-                    # reverse the objects so the selected data appears on top
-                    set dlist ""
-                    foreach dataobj [get] {
-                        set dlist [linsert $dlist 0 $dataobj]
-                    }
-
-                    # generate the comma-separated value data for these objects
-                    set csvdata ""
-                    foreach dataobj $dlist {
-                        append csvdata "[string repeat - 60]\n"
-                        append csvdata " [$dataobj hints label]\n"
-                        if {[info exists _dataobj2desc($dataobj)]
-                            && [llength [split $_dataobj2desc($dataobj) \n]] > 1} {
-                            set indent "for:"
-                            foreach line [split $_dataobj2desc($dataobj) \n] {
-                                append csvdata " $indent $line\n"
-                                set indent "    "
-                            }
-                        }
-                        append csvdata "[string repeat - 60]\n"
-
-                        append csvdata "[$dataobj hints xlabel], [$dataobj hints ylabel]\n"
-                        set first 1
-                        foreach comp [$dataobj components] {
-                            if {!$first} {
-                                # blank line between components
-                                append csvdata "\n"
-                            }
-                            set xv [$dataobj mesh $comp]
-                            set yv [$dataobj values $comp]
-                            foreach x [$xv range 0 end] y [$yv range 0 end] {
-                                append csvdata [format "%20.15g, %20.15g\n" $x $y]
-                            }
-                            set first 0
-                        }
-                        append csvdata "\n"
-                    }
-                    return [list .txt $csvdata]
-                }
-                image {
-                    set popup .barprintdownload
-                    if { ![winfo exists $popup] } {
-                        # Create a popup for the print dialog
-                        Rappture::Balloon $popup -title "Save as image..."
-                        set inner [$popup component inner]
-                        # Create the print dialog widget and add it to the
-                        # the balloon popup.
-                        Rappture::XyPrint $inner.print
-                        $popup configure \
-                            -deactivatecommand [list $inner.print reset]
-                        blt::table $inner 0,0 $inner.print -fill both
-                    }
-                    update
-                    # Activate the popup and call for the output.
-                    foreach { widget toolName plotName } $args break
-                    $popup activate $widget left
-                    set inner [$popup component inner]
-                    set output [$inner.print print $itk_component(plot) \
-                                    $toolName $plotName]
-                    $popup deactivate
-                    return $output
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::_rebuild {} {
-    set g $itk_component(plot)
-
-    # First clear out the widget
-    eval $g element delete [$g element names]
-    eval $g marker delete [$g marker names]
-    foreach axis [$g axis names] {
-        $g axis configure $axis -hide yes -checklimits no
-    }
-    # Presumably you want at least an X-axis and Y-axis displayed.
-    $g xaxis configure -hide no
-    $g yaxis configure -hide no
-    array unset _label2axis
-
-    #
-    # Scan through all objects and create a list of all axes.
-    # The first x-axis gets mapped to "x".  The second, to "x2".
-    # Beyond that, we must create new axes "x3", "x4", etc.
-    # We do the same for y.
-    #
-    set anum(x) 0
-    set anum(y) 0
-    foreach dataobj [get] {
-        foreach ax {x y} {
-            set label [$dataobj hints ${ax}label]
-            if {"" != $label} {
-                if {![info exists _label2axis($ax-$label)]} {
-                    switch [incr anum($ax)] {
-                        1 { set axis $ax }
-                        2 { set axis ${ax}2 }
-                        default {
-                            set axis $ax$anum($ax)
-                            catch {$g axis create $axis}
-                        }
-                    }
-                    $g axis configure $axis -title $label -hide no \
-                        -checklimits no
-                    set _label2axis($ax-$label) $axis
-
-                    # if this axis has a description, add it as a tooltip
-                    set desc [string trim [$dataobj hints ${ax}desc]]
-                    Rappture::Tooltip::text $g-$axis $desc
-                }
-            }
-        }
-    }
-
-    #
-    # All of the extra axes get mapped to the x2/y2 (top/right)
-    # position.
-    #
-    set all ""
-    foreach ax {x y} {
-        lappend all $ax
-
-        set extra ""
-        for {set i 2} {$i <= $anum($ax)} {incr i} {
-            lappend extra ${ax}$i
-        }
-        eval lappend all $extra
-        $g ${ax}2axis use $extra
-        if {$ax == "y"} {
-            $g configure -rightmargin [expr {($extra == "") ? 10 : 0}]
-        }
-    }
-
-    foreach axis $all {
-        set _axisPopup(format-$axis) "%.6g"
-
-        $g axis bind $axis <Enter> \
-            [itcl::code $this _axis hilite $axis on]
-        $g axis bind $axis <Leave> \
-            [itcl::code $this _axis hilite $axis off]
-        $g axis bind $axis <ButtonPress-1> \
-            [itcl::code $this _axis click $axis %x %y]
-        $g axis bind $axis <B1-Motion> \
-            [itcl::code $this _axis drag $axis %x %y]
-        $g axis bind $axis <ButtonRelease-1> \
-            [itcl::code $this _axis release $axis %x %y]
-        $g axis bind $axis <KeyPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-    }
-
-    #
-    # Plot all of the dataobjs.
-    #
-    set count 0
-    foreach dataobj $_dlist {
-        set label [$dataobj hints label]
-        foreach {mapx mapy} [_getAxes $dataobj] break
-
-        foreach comp [$dataobj components] {
-            set xv [$dataobj mesh $comp]
-            set yv [$dataobj values $comp]
-
-            if {[info exists _dataobj2color($dataobj)]} {
-                set color $_dataobj2color($dataobj)
-            } else {
-                set color [$dataobj hints color]
-                if {"" == $color} {
-                    set color black
-                }
-            }
-
-            if {[info exists _dataobj2width($dataobj)]} {
-                set lwidth $_dataobj2width($dataobj)
-            } else {
-                set lwidth 2
-            }
-
-            if {[info exists _dataobj2dashes($dataobj)]} {
-                set dashes $_dataobj2dashes($dataobj)
-            } else {
-                set dashes ""
-            }
-
-            if {([$xv length] <= 1) || ($lwidth == 0)} {
-                set sym square
-                set pixels 2
-            } else {
-                set sym ""
-                set pixels 6
-            }
-
-            set elem "elem[incr count]"
-            set _elem2dataobj($elem) $dataobj
-            set labels [$dataobj hints xticks]
-            if { $labels != "" } {
-                $g axis configure $mapx \
-                    -command [itcl::code $this _formatTickLabel] \
-                    -minorticks 0
-                set _tickLabels $labels
-            }
-            $g element create $elem -x $xv -y $yv \
-                -borderwidth $lwidth -label $label \
-                -background $color -foreground $color -mapx $mapx -mapy $mapy
-        }
-    }
-
-    # Fix duplicate labels by appending the simulation number
-    foreach label [array names label2elem] {
-        if { [llength $label2elem($label)] == 1 } {
-            continue
-        }
-        foreach elem $label2elem($label) {
-            set dataobj $_elem2dataobj($elem)
-            scan [$dataobj hints xmlobj] "::libraryObj%d" suffix
-            incr suffix
-            set elabel [format "%s \#%d" $label $suffix]
-            $g element configure $elem -label $elabel
-        }
-    }
-
-    foreach dataobj $_dlist {
-        set xmin -Inf
-        set ymin -Inf
-        set xmax Inf
-        set ymax Inf
-        #
-        # Create text/line markers for each *axis.marker specified.
-        #
-        foreach m [$dataobj xmarkers] {
-            foreach {at label style} $m break
-            set id [$g marker create line -coords [list $at $ymin $at $ymax]]
-            $g marker bind $id <Enter> \
-                [itcl::code $this _enterMarker $g x-$label $at $ymin $at]
-            $g marker bind $id <Leave> \
-                [itcl::code $this _leaveMarker $g x-$label]
-            set options [_getLineMarkerOptions $style]
-            if { $options != "" } {
-                eval $g marker configure $id $options
-            }
-            if { $label != "" } {
-                set id [$g marker create text -anchor nw \
-                            -text $label -coords [list $at $ymax]]
-                set options [_getTextMarkerOptions $style]
-                if { $options != "" } {
-                    eval $g marker configure $id $options
-                }
-            }
-        }
-        foreach m [$dataobj ymarkers] {
-            foreach {at label style} $m break
-            set id [$g marker create line -coords [list $xmin $at $xmax $at]]
-            $g marker bind $id <Enter> \
-                [itcl::code $this _enterMarker $g y-$label $at $xmin $at]
-            $g marker bind $id <Leave> \
-                [itcl::code $this _leaveMarker $g y-$label]
-            set options [_getLineMarkerOptions $style]
-            if { $options != "" } {
-                eval $g marker configure $id $options
-            }
-            if { $label != "" } {
-                set id [$g marker create text -anchor se \
-                        -text $label -coords [list $xmax $at]]
-                set options [_getTextMarkerOptions $style]
-                if { $options != "" } {
-                    eval $g marker configure $id $options
-                }
-            }
-        }
-    }
-    ResetLegend
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _resetLimits
-#
-# Used internally to apply automatic limits to the axes for the
-# current plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::_resetLimits {} {
-    set g $itk_component(plot)
-    foreach axis [$g axis names] {
-        $g axis configure $axis -min "" -max ""
-    }
-    return
-
-    #
-    # HACK ALERT!
-    # Use this code to fix up the y-axis limits for the BLT graph.
-    # The auto-limits don't always work well.  We want them to be
-    # set to a "nice" number slightly above or below the min/max
-    # limits.
-    #
-    foreach axis [$g axis names] {
-        if {[info exists _limits(${axis}lin-min)]} {
-            set log [$g axis cget $axis -logscale]
-            if {$log} {
-                set min $_limits(${axis}log-min)
-                if {$min == 0} { set min 1 }
-                set max $_limits(${axis}log-max)
-                if {$max == 0} { set max 1 }
-
-                if {$min == $max} {
-                    set logmin [expr {floor(log10(abs(0.9*$min)))}]
-                    set logmax [expr {ceil(log10(abs(1.1*$max)))}]
-                } else {
-                    set logmin [expr {floor(log10(abs($min)))}]
-                    set logmax [expr {ceil(log10(abs($max)))}]
-                    if {[string match y* $axis]} {
-                        # add a little padding
-                        set delta [expr {$logmax-$logmin}]
-                        if {$delta == 0} { set delta 1 }
-                        set logmin [expr {$logmin-0.05*$delta}]
-                        set logmax [expr {$logmax+0.05*$delta}]
-                    }
-                }
-                if {$logmin < -300} {
-                    set min 1e-300
-                } elseif {$logmin > 300} {
-                    set min 1e+300
-                } else {
-                    set min [expr {pow(10.0,$logmin)}]
-                }
-
-                if {$logmax < -300} {
-                    set max 1e-300
-                } elseif {$logmax > 300} {
-                    set max 1e+300
-                } else {
-                    set max [expr {pow(10.0,$logmax)}]
-                }
-            } else {
-                set min $_limits(${axis}lin-min)
-                set max $_limits(${axis}lin-max)
-
-                if {[string match y* $axis]} {
-                    # add a little padding
-                    set delta [expr {$max-$min}]
-                    set min [expr {$min-0.05*$delta}]
-                    set max [expr {$max+0.05*$delta}]
-                }
-            }
-            if {$min < $max} {
-                $g axis configure $axis -min $min -max $max
-            } else {
-                $g axis configure $axis -min "" -max ""
-            }
-        } else {
-            $g axis configure $axis -min "" -max ""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::_zoom {option args} {
-    switch -- $option {
-        reset {
-            _resetLimits
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _hilite <state> <x> <y>
-#
-# Called automatically when the user brushes one of the elements
-# on the plot.  Causes the element to highlight and a tooltip to
-# pop up with element info.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::_hilite {state x y} {
-    set g $itk_component(plot)
-    set elem ""
-
-    # Peek inside of Blt_ZoomStack package to see if we're currently in the
-    # middle of a zoom selection.
-    if {[info exists ::zoomInfo($g,corner)] && $::zoomInfo($g,corner) == "B" } {
-        return;
-    }
-    set tip ""
-    if {$state == "at"} {
-        set state 0
-        if {[$g element closest $x $y info -interpolate yes]} {
-            # for dealing with xy line plots
-            set elem $info(name)
-
-            # Some elements are generated dynamically and therefore will
-            # not have a dataobj associated with them.
-            set mapx [$g element cget $elem -mapx]
-            set mapy [$g element cget $elem -mapy]
-            if {[info exists _elem2dataobj($elem)]} {
-                foreach {mapx mapy} [_getAxes $_elem2dataobj($elem)] break
-            }
-
-            # search again for an exact point -- this time don't interpolate
-            set tip ""
-            array unset info
-            if {[$g element closest $x $y info -interpolate no]
-                && $info(name) == $elem} {
-
-                set x [$g axis transform $mapx $info(x)]
-                set y [$g axis transform $mapy $info(y)]
-
-                if {[info exists _elem2dataobj($elem)]} {
-                    set dataobj $_elem2dataobj($elem)
-                    set yunits [$dataobj hints yunits]
-                    set xunits [$dataobj hints xunits]
-                } else {
-                    set xunits ""
-                    set yunits ""
-                }
-                set tip [$g element cget $elem -label]
-                set yval [_axis format y dummy $info(y)]
-                append tip "\n$yval$yunits"
-                set xval [_axis format x dummy $info(x)]
-                append tip " @ $xval$xunits"
-                set tip [string trim $tip]
-            }
-            set state 1
-        } elseif {[$g element closest $x $y info -interpolate no]} {
-            # for dealing with xy scatter plot
-            set elem $info(name)
-
-            # Some elements are generated dynamically and therefore will
-            # not have a dataobj associated with them.
-            set mapx [$g element cget $elem -mapx]
-            set mapy [$g element cget $elem -mapy]
-            if {[info exists _elem2dataobj($elem)]} {
-                foreach {mapx mapy} [_getAxes $_elem2dataobj($elem)] break
-            }
-
-            set tip ""
-            set x [$g axis transform $mapx $info(x)]
-            set y [$g axis transform $mapy $info(y)]
-
-            if {[info exists _elem2dataobj($elem)]} {
-                set dataobj $_elem2dataobj($elem)
-                set yunits [$dataobj hints yunits]
-                set xunits [$dataobj hints xunits]
-            } else {
-                set xunits ""
-                set yunits ""
-            }
-            set tip [$g element cget $elem -label]
-            set yval [_axis format y dummy $info(y)]
-            append tip "\n$yval$yunits"
-            set xval [_axis format x dummy $info(x)]
-            append tip " @ $xval$xunits"
-            set tip [string trim $tip]
-            set state 1
-        }
-    } else {
-        set state 0
-    }
-
-    if { $state } {
-        #
-        # Highlight ON:
-        # - activate trace
-        # - multiple axes? dim other axes
-        # - pop up tooltip about data
-        #
-        if { [$g element exists $_hilite(elem)] && $_hilite(elem) != $elem } {
-            $g element deactivate $_hilite(elem)
-            $g crosshairs configure -hide yes
-            Rappture::Tooltip::tooltip cancel
-        }
-        set bg [$g element cget $elem -background]
-        set fg [$g element cget $elem -background]
-        foreach {h s v} [Rappture::color::RGBtoHSV $fg] break
-        if { $v > 0.2 } {
-            set v [expr $v - 0.2]
-        }
-        set fg [Rappture::color::HSVtoRGB $h $s $v]
-        $g pen configure activeBar -background $bg -foreground $fg
-        $g element activate $elem
-        set _hilite(elem) $elem
-
-        set mapx [$g element cget $elem -mapx]
-        set mapy [$g element cget $elem -mapy]
-        if {[info exists _elem2dataobj($elem)]} {
-            foreach {mapx mapy} [_getAxes $_elem2dataobj($elem)] break
-        }
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;# fix main x-axis too
-            foreach axis $allx {
-                if {$axis == $mapx} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;# fix main y-axis too
-            foreach axis $ally {
-                if {$axis == $mapy} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-
-        if {"" != $tip} {
-            $g crosshairs configure -hide no -position @$x,$y
-
-            if {$x > 0.5*[winfo width $g]} {
-                if {$x < 4} {
-                    set tipx "-0"
-                } else {
-                    set tipx "-[expr {$x-4}]"  ;# move tooltip to the left
-                }
-            } else {
-                if {$x < -4} {
-                    set tipx "+0"
-                } else {
-                    set tipx "+[expr {$x+4}]"  ;# move tooltip to the right
-                }
-            }
-            if {$y > 0.5*[winfo height $g]} {
-                if {$y < 4} {
-                    set tipy "-0"
-                } else {
-                    set tipy "-[expr {$y-4}]"  ;# move tooltip to the top
-                }
-            } else {
-                if {$y < -4} {
-                    set tipy "+0"
-                } else {
-                    set tipy "+[expr {$y+4}]"  ;# move tooltip to the bottom
-                }
-            }
-            Rappture::Tooltip::text $g $tip
-            Rappture::Tooltip::tooltip show $g $tipx,$tipy
-        }
-    } else {
-        #
-        # Highlight OFF:
-        # - deactivate (color back to normal)
-        # - put all axes back to normal color
-        # - take down tooltip
-        #
-        if { [$g element exists $_hilite(elem)] } {
-            $g element deactivate $_hilite(elem)
-        }
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;# fix main x-axis too
-            foreach axis $allx {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;# fix main y-axis too
-            foreach axis $ally {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        $g crosshairs configure -hide yes
-
-        # only cancel in plotting area or we'll mess up axes
-        if {[$g inside $x $y]} {
-            Rappture::Tooltip::tooltip cancel
-        }
-
-        # There is no currently highlighted element
-        set _hilite(elem) ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _axis hilite <axis> <state>
-#
-# USAGE: _axis click <axis> <x> <y>
-# USAGE: _axis drag <axis> <x> <y>
-# USAGE: _axis release <axis> <x> <y>
-#
-# USAGE: _axis edit <axis>
-# USAGE: _axis changed <axis> <what>
-# USAGE: _axis format <axis> <widget> <value>
-# USAGE: _axis scale <axis> linear|log
-#
-# Used internally to handle editing of the x/y axes.  The hilite
-# operation causes the axis to light up.  The edit operation pops
-# up a panel with editing options.  The changed operation applies
-# changes from the panel.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::_axis {option args} {
-    set inner [$itk_component(hull).axes component inner]
-    switch -- $option {
-        hilite {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"_axis hilite axis state\""
-            }
-            set g $itk_component(plot)
-            set axis [lindex $args 0]
-            set state [lindex $args 1]
-
-            if {$state} {
-                $g axis configure $axis \
-                    -color $itk_option(-activecolor) \
-                    -titlecolor $itk_option(-activecolor)
-
-                set x [expr {[winfo pointerx $g]+4}]
-                set y [expr {[winfo pointery $g]+4}]
-                Rappture::Tooltip::tooltip pending $g-$axis @$x,$y
-            } else {
-                $g axis configure $axis \
-                    -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-                Rappture::Tooltip::tooltip cancel
-            }
-        }
-        click {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"_axis click axis x y\""
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            set g $itk_component(plot)
-
-            set _axis(moved) 0
-            set _axis(click-x) $x
-            set _axis(click-y) $y
-            foreach {min max} [$g axis limits $axis] break
-            set _axis(min0) $min
-            set _axis(max0) $max
-            Rappture::Tooltip::tooltip cancel
-        }
-        drag {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"_axis drag axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            set g $itk_component(plot)
-
-            if {[info exists _axis(click-x)] && [info exists _axis(click-y)]} {
-                foreach {x0 y0 pw ph} [$g extents plotarea] break
-                switch -glob $axis {
-                  x* {
-                    set pix $x
-                    set pix0 $_axis(click-x)
-                    set pixmin $x0
-                    set pixmax [expr {$x0+$pw}]
-                  }
-                  y* {
-                    set pix $y
-                    set pix0 $_axis(click-y)
-                    set pixmin [expr {$y0+$ph}]
-                    set pixmax $y0
-                  }
-                }
-                set log [$g axis cget $axis -logscale]
-                set min $_axis(min0)
-                set max $_axis(max0)
-                set dpix [expr {abs($pix-$pix0)}]
-                set v0 [$g axis invtransform $axis $pixmin]
-                set v1 [$g axis invtransform $axis [expr {$pixmin+$dpix}]]
-                if {$log} {
-                    set v0 [expr {log10($v0)}]
-                    set v1 [expr {log10($v1)}]
-                    set min [expr {log10($min)}]
-                    set max [expr {log10($max)}]
-                }
-
-                if {$pix > $pix0} {
-                    set delta [expr {$v1-$v0}]
-                } else {
-                    set delta [expr {$v0-$v1}]
-                }
-                set min [expr {$min-$delta}]
-                set max [expr {$max-$delta}]
-                if {$log} {
-                    set min [expr {pow(10.0,$min)}]
-                    set max [expr {pow(10.0,$max)}]
-                }
-                $g axis configure $axis -min $min -max $max
-
-                # move axis, don't edit on release
-                set _axis(move) 1
-            }
-        }
-        release {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"_axis release axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-
-            if {!$_axis(moved)} {
-                # small movement? then treat as click -- pop up axis editor
-                set dx [expr {abs($x-$_axis(click-x))}]
-                set dy [expr {abs($y-$_axis(click-y))}]
-                if {$dx < 2 && $dy < 2} {
-                    _axis edit $axis
-                }
-            } else {
-                # one last movement
-                _axis drag $axis $x $y
-            }
-            catch {unset _axis}
-        }
-        edit {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"_axis edit axis\""
-            }
-            set axis [lindex $args 0]
-            set _axisPopup(current) $axis
-
-            # apply last value when deactivating
-            $itk_component(hull).axes configure -deactivatecommand \
-                [itcl::code $this _axis changed $axis focus]
-
-            # fix axis label controls...
-            set label [$itk_component(plot) axis cget $axis -title]
-            $inner.label delete 0 end
-            $inner.label insert end $label
-            bind $inner.label <Return> \
-                [itcl::code $this _axis changed $axis label]
-            bind $inner.label <KP_Enter> \
-                [itcl::code $this _axis changed $axis label]
-            bind $inner.label <FocusOut> \
-                [itcl::code $this _axis changed $axis label]
-
-            # fix min/max controls...
-            foreach {min max} [$itk_component(plot) axis limits $axis] break
-            $inner.min delete 0 end
-            $inner.min insert end $min
-            bind $inner.min <Return> \
-                [itcl::code $this _axis changed $axis min]
-            bind $inner.min <KP_Enter> \
-                [itcl::code $this _axis changed $axis min]
-            bind $inner.min <FocusOut> \
-                [itcl::code $this _axis changed $axis min]
-
-            $inner.max delete 0 end
-            $inner.max insert end $max
-            bind $inner.max <Return> \
-                [itcl::code $this _axis changed $axis max]
-            bind $inner.max <KP_Enter> \
-                [itcl::code $this _axis changed $axis max]
-            bind $inner.max <FocusOut> \
-                [itcl::code $this _axis changed $axis max]
-
-            # fix format control...
-            set fmts [$inner.format choices get -value]
-            set i [lsearch -exact $fmts $_axisPopup(format-$axis)]
-            if {$i < 0} { set i 0 }  ;# use Auto choice
-            $inner.format value [$inner.format choices get -label $i]
-
-            bind $inner.format <<Value>> \
-                [itcl::code $this _axis changed $axis format]
-
-            # fix scale control...
-            if {[$itk_component(plot) axis cget $axis -logscale]} {
-                set _axisPopup(scale) "log"
-                $inner.format configure -state disabled
-            } else {
-                set _axisPopup(scale) "linear"
-                $inner.format configure -state normal
-            }
-            $inner.scales.linear configure \
-                -command [itcl::code $this _axis changed $axis scale]
-            $inner.scales.log configure \
-                -command [itcl::code $this _axis changed $axis scale]
-
-            #
-            # Figure out where the window should pop up.
-            #
-            set x [winfo rootx $itk_component(plot)]
-            set y [winfo rooty $itk_component(plot)]
-            set w [winfo width $itk_component(plot)]
-            set h [winfo height $itk_component(plot)]
-            foreach {x0 y0 pw ph} [$itk_component(plot) extents plotarea] break
-            switch -glob -- $axis {
-                x {
-                    set x [expr {round($x + $x0+0.5*$pw)}]
-                    set y [expr {round($y + $y0+$ph + 0.5*($h-$y0-$ph))}]
-                    set dir "above"
-                }
-                x* {
-                    set x [expr {round($x + $x0+0.5*$pw)}]
-                    set dir "below"
-                    set allx [$itk_component(plot) x2axis use]
-                    set max [llength $allx]
-                    set i [lsearch -exact $allx $axis]
-                    set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-                }
-                y {
-                    set x [expr {round($x + 0.5*$x0)}]
-                    set y [expr {round($y + $y0+0.5*$ph)}]
-                    set dir "right"
-                }
-                y* {
-                    set y [expr {round($y + $y0+0.5*$ph)}]
-                    set dir "left"
-                    set ally [$itk_component(plot) y2axis use]
-                    set max [llength $ally]
-                    set i [lsearch -exact $ally $axis]
-                    set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-                    set x [expr {round($x+$x0+$pw + ($i+0.5)*($w-$x0-$pw)/double($max))}]
-                }
-            }
-            $itk_component(hull).axes activate @$x,$y $dir
-        }
-        changed {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"_axis changed axis what\""
-            }
-            set axis [lindex $args 0]
-            set what [lindex $args 1]
-            if {$what == "focus"} {
-                set what [focus]
-                if {[winfo exists $what]} {
-                    set what [winfo name $what]
-                }
-            }
-
-            switch -- $what {
-                label {
-                    set val [$inner.label get]
-                    $itk_component(plot) axis configure $axis -title $val
-                }
-                min {
-                    set val [$inner.min get]
-                    if {![string is double -strict $val]} {
-                        Rappture::Tooltip::cue $inner.min "Must be a number"
-                        bell
-                        return
-                    }
-
-                    set max [lindex [$itk_component(plot) axis limits $axis] 1]
-                    if {$val >= $max} {
-                        Rappture::Tooltip::cue $inner.min "Must be <= max ($max)"
-                        bell
-                        return
-                    }
-                    catch {
-                        # can fail in log mode
-                        $itk_component(plot) axis configure $axis -min $val
-                    }
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.min delete 0 end
-                    $inner.min insert end $min
-                }
-                max {
-                    set val [$inner.max get]
-                    if {![string is double -strict $val]} {
-                        Rappture::Tooltip::cue $inner.max "Should be a number"
-                        bell
-                        return
-                    }
-
-                    set min [lindex [$itk_component(plot) axis limits $axis] 0]
-                    if {$val <= $min} {
-                        Rappture::Tooltip::cue $inner.max "Must be >= min ($min)"
-                        bell
-                        return
-                    }
-                    catch {
-                        # can fail in log mode
-                        $itk_component(plot) axis configure $axis -max $val
-                    }
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.max delete 0 end
-                    $inner.max insert end $max
-                }
-                format {
-                    set fmt [$inner.format translate [$inner.format value]]
-                    set _axisPopup(format-$axis) $fmt
-
-                    # force a refresh
-                    $itk_component(plot) axis configure $axis -min \
-                        [$itk_component(plot) axis cget $axis -min]
-                }
-                scale {
-                    _axis scale $axis $_axisPopup(scale)
-
-                    if {$_axisPopup(scale) == "log"} {
-                        $inner.format configure -state disabled
-                    } else {
-                        $inner.format configure -state normal
-                    }
-
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.min delete 0 end
-                    $inner.min insert end $min
-                    $inner.max delete 0 end
-                    $inner.max insert end $max
-                }
-                default {
-                    # be lenient so we can handle the "focus" case
-                }
-            }
-        }
-        format {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"_axis format axis widget value\""
-            }
-            set axis [lindex $args 0]
-            set value [lindex $args 2]
-
-            if {[$itk_component(plot) axis cget $axis -logscale]} {
-                set fmt "%.6g"
-            } else {
-                set fmt $_axisPopup(format-$axis)
-            }
-            return [format $fmt $value]
-        }
-        scale {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"_axis scale axis type\""
-            }
-            set axis [lindex $args 0]
-            set type [lindex $args 1]
-
-            if {$type == "log"} {
-                catch {$itk_component(plot) axis configure $axis -logscale 1}
-                # leave format alone in log mode
-                $itk_component(plot) axis configure $axis -command ""
-            } else {
-                catch {$itk_component(plot) axis configure $axis -logscale 0}
-                # use special formatting for linear mode
-                $itk_component(plot) axis configure $axis -command \
-                    [itcl::code $this _axis format $axis]
-            }
-        }
-        default {
-            error "bad option \"$option\": should be changed, edit, hilite, or format"
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _getLineMarkerOptions <style>
-#
-# Used internally to create a list of configuration options specific to the
-# axis line marker.  The input is a list of name value pairs.  Options that
-# are not recognized are ignored.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::_getLineMarkerOptions {style} {
-    array set lineOptions {
-        "-color"  "-outline"
-        "-dashes" "-dashes"
-        "-linecolor" "-foreground"
-        "-linewidth" "-borderwidth"
-    }
-    set options {}
-    foreach {name value} $style {
-        if { [info exists lineOptions($name)] } {
-            lappend options $lineOptions($name) $value
-        }
-    }
-    return $options
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getTextMarkerOptions <style>
-#
-# Used internally to create a list of configuration options specific to the
-# axis text marker.  The input is a list of name value pairs.  Options that
-# are not recognized are ignored.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::_getTextMarkerOptions {style} {
-    array set textOptions {
-        "-color"  "-outline"
-        "-textcolor"  "-outline"
-        "-font"   "-font"
-        "-xoffset" "-xoffset"
-        "-yoffset" "-yoffset"
-        "-anchor" "-anchor"
-        "-rotate" "-rotate"
-    }
-    set options {}
-    foreach {name value} $style {
-        if { [info exists textOptions($name)] } {
-            lappend options $textOptions($name) $value
-        }
-    }
-    return $options
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getAxes <dataobj>
-#
-# Used internally to figure out the axes used to plot the given
-# <dataobj>.  Returns a list of the form {x y}, where x is the
-# x-axis name (x, x2, x3, etc.), and y is the y-axis name.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BarchartResult::_getAxes {dataobj} {
-    # rebuild if needed, so we know about the axes
-    if {[$_dispatcher ispending !rebuild]} {
-        $_dispatcher cancel !rebuild
-        $_dispatcher event -now !rebuild
-    }
-
-    # what is the x axis?  x? x2? x3? ...
-    set xlabel [$dataobj hints xlabel]
-    if {[info exists _label2axis(x-$xlabel)]} {
-        set mapx $_label2axis(x-$xlabel)
-    } else {
-        set mapx "x"
-    }
-
-    # what is the y axis?  y? y2? y3? ...
-    set ylabel [$dataobj hints ylabel]
-    if {[info exists _label2axis(y-$ylabel)]} {
-        set mapy $_label2axis(y-$ylabel)
-    } else {
-        set mapy "y"
-    }
-
-    return [list $mapx $mapy]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -gridcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::BarchartResult::gridcolor {
-    if {"" == $itk_option(-gridcolor)} {
-        $itk_component(plot) grid off
-    } else {
-        $itk_component(plot) grid configure -color $itk_option(-gridcolor)
-        $itk_component(plot) grid on
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -autocolors
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::BarchartResult::autocolors {
-    foreach c $itk_option(-autocolors) {
-        if {[catch {winfo rgb $itk_component(hull) $c}]} {
-            error "bad color \"$c\""
-        }
-    }
-    if {$_autoColorI >= [llength $itk_option(-autocolors)]} {
-        set _autoColorI 0
-    }
-}
-
-itcl::body Rappture::BarchartResult::_enterMarker { g name x y text } {
-    _leaveMarker $g $name
-    set id [$g marker create text \
-                -coords [list $x $y] \
-                -yoffset -1 \
-                -anchor s \
-                -text $text]
-    set _markers($name) $id
-}
-
-itcl::body Rappture::BarchartResult::_leaveMarker { g name } {
-    if { [info exists _markers($name)] } {
-        set id $_markers($name)
-        $g marker delete $id
-        unset _markers($name)
-    }
-}
-
-itcl::body Rappture::BarchartResult::_formatTickLabel { w value } {
-    # Determine the element name from the value
-
-    set index [expr round($value)]
-    if { $index != $value } {
-        return $value
-    }
-    return [lindex  $_tickLabels [expr $index - 1]]
-    if { $label == "" } {
-        return $value
-    }
-    return $label
-}
-
-#
-# ResetLegend --
-#
-itcl::body Rappture::BarchartResult::ResetLegend {} {
-    set g $itk_component(plot)
-    update idletasks
-    $itk_component(legend) reset [$g element show]
-}
Index: trunk/gui/scripts/booleanentry.tcl
===================================================================
--- trunk/gui/scripts/booleanentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,197 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: BooleanEntry - widget for entering boolean values
-#
-#  This widget represents a <boolean> entry on a control panel.
-#  It is used to enter yes/no or on/off values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::BooleanEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _newValue {}
-    protected method _log {}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-}
-
-itk::usual BooleanEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::BooleanEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    itk_component add -protected vframe {
-        frame $itk_interior.vframe
-    }
-
-    # if the control has an icon, plug it in
-    set icon [string trim [$_owner xml get $path.about.icon]]
-    if {$icon != ""} {
-        itk_component add icon {
-            set icon [image create photo -data $icon]
-            set w [image width $icon]
-            set h [image height $icon]
-            canvas $itk_component(vframe).icon -height $h -width $w -borderwidth 0 -highlightthickness 0
-        } {
-            usual
-            ignore -highlightthickness -highlightbackground -highlightcolor
-        }
-        set c $itk_component(icon)
-        $c create image [expr {0.5*$w}] [expr {0.5*$h}] \
-            -anchor center -image $icon
-        pack $itk_component(icon) -fill x -side left
-    }
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    itk_component add switch {
-        Rappture::Switch $itk_component(vframe).switch \
-            -interactcommand [itcl::code $this _log]
-    }
-    set color [string trim [$_owner xml get $path.about.color]]
-    if {$color != ""} {
-        $itk_component(switch) configure -oncolor $color
-    }
-
-    bind $itk_component(switch) <<Value>> [itcl::code $this _newValue]
-    pack $itk_component(switch) -fill x -side left
-    pack $itk_component(vframe) -side left -expand yes -fill both
-    eval itk_initialize $args
-
-    #
-    # Assign the default value to this widget, if there is one.
-    #
-    set str [string trim [$_owner xml get $path.default]]
-    if {"" != $str} {
-        $itk_component(switch) value $str
-    } else {
-        $itk_component(switch) value off
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BooleanEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [string trim [lindex $args 0]]
-        $itk_component(switch) value $newval
-        event generate $itk_component(hull) <<Value>>
-        return $newval
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    return [$itk_component(switch) value]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BooleanEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {"" == $label} {
-        set label "Boolean"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BooleanEntry::tooltip {} {
-    set str [string trim [$_owner xml get $_path.about.description]]
-    append str "\n\nClick to turn on/off"
-    return $str
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _newValue
-#
-# Invoked automatically whenever the value in the gauge changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BooleanEntry::_newValue {} {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _log
-#
-# Used internally to send info to the logging mechanism.  Calls the
-# Rappture::Logger mechanism to log the change to this input.
-# ----------------------------------------------------------------------
-itcl::body Rappture::BooleanEntry::_log {} {
-    Rappture::Logger::log input $_path [$itk_component(switch) value]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::BooleanEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(switch) configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/bugreport.tcl
===================================================================
--- trunk/gui/scripts/bugreport.tcl	(revision 6716)
+++ 	(revision )
@@ -1,715 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  UTILITY: bugreport
-#
-#  This redefines the usual Tcl bgerror command to install a nicer
-#  looking bug handler.  Bug reports can be submitted back to a
-#  HUBzero-based site as support tickets.  Additional information
-#  can be obtained by defining procedures as bugreport::instrumented
-#  proc (captures entrance/exit from proc) and by calling
-#  bugreport::remark with extra info along the way.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-option add *BugReport*Label.font {Helvetica -12} startupFile
-option add *BugReport*banner*foreground white startupFile
-option add *BugReport*banner*background #a9a9a9 startupFile
-option add *BugReport*banner*highlightBackground #a9a9a9 startupFile
-option add *BugReport*banner.title.font {Helvetica -18 bold} startupFile
-option add *BugReport*xmit*wrapLength 3i startupFile
-option add *BugReport*expl.width 50 startupFile
-option add *BugReport*expl.font {Helvetica -12} startupFile
-option add *BugReport*expl.boldFont {Helvetica -12 bold} startupFile
-option add *BugReport*comments.l.font {Helvetica -12 italic} startupFile
-option add *BugReport*comments.info.text.font {Helvetica -12} startupFile
-option add *BugReport*details*font {Courier -12} startupFile
-
-namespace eval Rappture::bugreport {
-    # details from the current trouble report, which user may decide to submit
-    variable details
-
-    # status from bugreport::instrumented/remark in case a bug occurs
-    variable extraStack ""
-    variable extraInfo ""
-
-    # assume that if there's a problem launching a job, we should know it
-    variable reportJobFailures 1
-
-    # submit these kinds of tickets by default
-    variable settings
-    set settings(user) $::tcl_platform(user)
-    set settings(type) "automatic"
-    set settings(group) ""
-    set settings(category) "Rappture"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: install
-#
-# Called once in the main program to install this bug reporting
-# facility.  Any unexpected errors after this call will be handled
-# by this mechanism.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::install {} {
-    ::proc ::bgerror {err} { ::Rappture::bugreport::activate $err }
-    # Load tls early to prevent error in tls::initlib and [pwd]
-    package require http
-    package require tls
-}
-
-# ----------------------------------------------------------------------
-# USAGE: activate <error>
-#
-# Used internally to pop up the bug handler whenver a bug is
-# encountered.  Tells the user that there is a bug and logs the
-# problem, so it can be fixed.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::activate {err} {
-    global env errorInfo
-    variable details
-    variable settings
-
-    if {"@SHOWDETAILS" == $err} {
-        pack propagate .bugreport yes
-        pack forget .bugreport.expl
-        pack forget .bugreport.xmit
-        pack forget .bugreport.done
-        pack forget .bugreport.cntls.show
-        pack .bugreport.cntls -after .bugreport.banner -side bottom -fill x
-        pack .bugreport.details -after .bugreport.banner \
-            -expand yes -fill both -padx 8 -pady 8
-        pack .bugreport.comments -after .bugreport.details \
-            -expand yes -fill both -padx 8 -pady {0 8}
-
-        update idletasks
-        set w [winfo reqwidth .bugreport]
-        set h [winfo reqheight .bugreport]
-
-        set x [winfo rootx .main]
-        set y [winfo rooty .main]
-
-        set mw [winfo width .main]
-        if { $mw == 1 } {
-            set mw [winfo reqwidth .main]
-        }
-        set mh [winfo height .main]
-        if { $mh == 1 } {
-            set mh [winfo reqwidth .main]
-        }
-        if { $mw > $w } {
-            set x [expr { $x + (($mw-$w)/2) }]
-        }
-        if { $mh > $h } {
-            set y [expr { $y + (($mh-$h)/2) }]
-        }
-        wm geometry .bugreport +$x+$y
-        raise .bugreport
-        return
-    }
-
-    # gather details so we can submit trouble reports later
-    # do this now, before we do anything with "catch" down below
-    # that might mask the errorInfo
-    register $err
-
-    pack propagate .bugreport yes
-    pack forget .bugreport.details
-    pack forget .bugreport.xmit
-    pack forget .bugreport.done
-    pack .bugreport.cntls.show -side right
-    pack .bugreport.cntls -after .bugreport.banner -side bottom -fill x
-    pack .bugreport.expl -after .bugreport.banner \
-        -expand yes -fill both -padx 8 -pady 8
-    pack .bugreport.comments -after .bugreport.expl \
-        -expand yes -fill both -padx 8 -pady {0 8}
-
-    .bugreport.expl configure -state normal
-    .bugreport.expl delete 1.0 end
-
-    set url [Rappture::Tool::resources -huburl]
-    if {"" != $url} {
-        .bugreport.expl insert end "Something went wrong with this tool.  Help us understand what happened by submitting a trouble report, so we can fix the problem.  If you continue having trouble with this tool, please close it and restart."
-        .bugreport.cntls.send configure -state normal
-        focus .bugreport.cntls.send
-    } else {
-        .bugreport.expl insert end "Something went wrong with this tool.  We would ask you to submit a trouble report about the error, but we can't tell what hub it should be submitted to.  If you continue having trouble with this tool, please close it and restart."
-        pack forget .bugreport.comments
-        .bugreport.cntls.send configure -state disabled
-        focus .bugreport.cntls.ok
-    }
-    fixTextHeight .bugreport.expl
-    .bugreport.expl configure -state disabled
-
-    .bugreport.details.info.text configure -state normal
-    .bugreport.details.info.text delete 1.0 end
-    .bugreport.details.info.text insert end "    USER: $settings(user)\n"
-    .bugreport.details.info.text insert end "HOSTNAME: $details(hostname)\n"
-    .bugreport.details.info.text insert end "PLATFORM: $details(platform)\n"
-    .bugreport.details.info.text insert end "CATEGORY: $details(category)\n"
-    .bugreport.details.info.text insert end "    TOOL: $details(referrer)\n"
-    .bugreport.details.info.text insert end " SESSION: $details(session)\n"
-    .bugreport.details.info.text insert end " SUMMARY: $details(summary)\n"
-    .bugreport.details.info.text insert end "---------\n"
-    .bugreport.details.info.text insert end $details(stackTrace)
-    .bugreport.details.info.text configure -state disabled
-
-    set w [winfo reqwidth .bugreport]
-    set h [winfo reqheight .bugreport]
-
-    set x [winfo rootx .main]
-    set y [winfo rooty .main]
-
-    set mw [winfo width .main]
-    if { $mw == 1 } {
-        set mw [winfo reqwidth .main]
-    }
-    set mh [winfo height .main]
-    if { $mh == 1 } {
-        set mh [winfo reqwidth .main]
-    }
-
-    if { $mw > $w } {
-        set x [expr { $x + (($mw-$w)/2) }]
-    }
-    if { $mh > $h } {
-        set y [expr { $y + (($mh-$h)/2) }]
-    }
-
-    wm geometry .bugreport +$x+$y
-    wm deiconify .bugreport
-    raise .bugreport
-
-    catch {grab set .bugreport}
-    update
-}
-
-# ----------------------------------------------------------------------
-# USAGE: deactivate
-#
-# Used internally to take down the bug handler dialog.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::deactivate {} {
-    grab release .bugreport
-    wm withdraw .bugreport
-
-    # reset the grab in case it's hosed
-    Rappture::grab::reset
-}
-
-# ----------------------------------------------------------------------
-# USAGE: instrumented <what> <name> <arglist> <body>
-#
-# Used instead of the usual Tcl "proc" or itcl::body to define a
-# procedure that will automatically register information about its
-# execution in the bugreport mechanism.  The <what> parameter should
-# be either "proc" or "itcl::body" or something like that.  When the
-# procedure starts, it pushes its call information onto the stack,
-# then invokes the procedure body, then adds information about the
-# return code.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::instrumented {what name arglist body} {
-    set avals ""
-    foreach term $arglist {
-        set aname [lindex $term 0]
-        append avals "\$$aname "
-    }
-    uplevel [list $what $name $arglist [format {
-        Rappture::bugreport::remark -enter "PROC %s: %s"
-        set __status [catch {%s} __result]
-        Rappture::bugreport::remark -leave "PROC %s: code($__status) => $__result"
-        switch -- $__status {
-            0 - 2 {
-                return $__result
-            }
-            3 {
-                set __result "invoked \"break\" outside of a loop"
-            }
-            4 {
-                set __result "invoked \"continue\" outside of a loop"
-            }
-        }
-        error $__result $::errorInfo
-    } $name $avals $body $name]]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: remark ?-enter|-leave? <message>
-#
-# Adds the <message> to the current "extraInfo" being kept about the
-# program.  This adds useful debugging info to the report that gets
-# sent back when an unexpected error is trapped.  The -enter and -leave
-# options are used when a bugreport::instrumented proc starts/exits to
-# change the indent level for future messages.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::remark {args} {
-    variable extraStack
-    variable extraInfo
-
-    if {[llength $args] > 1} {
-        set option [lindex $args 0]
-        set args [lrange $args 1 end]
-        switch -- $option {
-            -enter {
-                if {[llength $args] != 1} {
-                    error "wrong # args: should be \"remark -enter message\""
-                }
-                set mesg [lindex $args 0]
-                if {[llength $extraStack] == 0} {
-                    set extraInfo ""
-                }
-                append extraInfo [remark -indent ">> $mesg"]
-                set extraStack [linsert $extraStack 0 $mesg]
-                return
-            }
-            -leave {
-                if {[llength $args] != 1} {
-                    error "wrong # args: should be \"remark -leave message\""
-                }
-                set mesg [lindex $args 0]
-                set extraStack [lrange $extraStack 1 end]
-                append extraInfo [remark -indent "<< $mesg"]
-                return
-            }
-            -indent {
-                if {[llength $args] != 1} {
-                    error "wrong # args: should be \"remark -indent message\""
-                }
-            }
-            default {
-                error "bad option \"$option\": should be -enter, -leave, -indent"
-            }
-        }
-    }
-    set mesg [lindex $args 0]
-    set nlevel [llength $extraStack]
-    set indent [string repeat { } [expr {2*$nlevel}]]
-    foreach line [split $mesg \n] {
-        append extraInfo "$indent$line\n"
-        set prefix "   "
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: sanitize <string> ?<replacement>?
-#
-# Removes any sensitive information in the bug report.  This is useful
-# for things such as passwords that should be scrubbed out before any
-# ticket is filed.  Replaces the <string> with an optional <replacement>
-# string (or ******** by default).  This is usually called in some sort
-# of "catch" before forwarding the error on to the usual bgerror routine.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::sanitize {str {repl ********}} {
-    global errorInfo
-    variable extraInfo
-
-    set map [list $str $repl]
-    set errorInfo [string map $map $errorInfo]
-    set extraInfo [string map $map $extraInfo]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: attach <name> <string>
-#
-# Removes any sensitive information in the bug report.  This is useful
-# for things such as passwords that should be scrubbed out before any
-# ticket is filed.  Replaces the <string> with an optional <replacement>
-# string (or ******** by default).  This is usually called in some sort
-# of "catch" before forwarding the error on to the usual bgerror routine.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::attach {str {repl ********}} {
-    global errorInfo
-    variable extraInfo
-
-    set map [list $str $repl]
-    set errorInfo [string map $map $errorInfo]
-    set extraInfo [string map $map $extraInfo]
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: submit
-#
-# Takes details currently stored in the panel and registers them
-# as a support ticket on the hosting hub site.  Pops up a panel
-# during the process and informs the user of the result.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::submit {} {
-    set info [.bugreport.details.info.text get 1.0 end]
-
-    pack propagate .bugreport no
-    pack forget .bugreport.details
-    pack forget .bugreport.expl
-    pack forget .bugreport.comments
-    pack forget .bugreport.cntls
-    pack .bugreport.xmit -after .bugreport.banner -padx 8 -pady 8
-    .bugreport.xmit.title configure -text "Sending trouble report to [Rappture::Tool::resources -hubname]..."
-
-    # send off the trouble report...
-    .bugreport.xmit.icon start
-    set status [catch send result]
-    .bugreport.xmit.icon stop
-
-    pack propagate .bugreport yes
-    pack forget .bugreport.xmit
-    pack .bugreport.expl -after .bugreport.banner -padx 8 -pady 8
-    .bugreport.expl configure -state normal
-    .bugreport.expl delete 1.0 end
-
-    # handle the result
-    if {$status != 0} {
-        # add error to the details field, so we can see it with magic clicks
-        .bugreport.details.info.text configure -state normal
-        .bugreport.details.info.text insert 1.0 "Ticket submission failed:\n$result\n-----\n"
-        .bugreport.details.info.text configure -state disabled
-
-        .bugreport.expl insert end "Oops! Ticket submission failed:\n$result\n\nIf you want to report the original problem, you can file your own trouble report by going to the web site and clicking on the \"Help\" or \"Support\" link on the main navigation bar.  If you continue having trouble with this tool, please close it and restart."
-    } elseif {[regexp {Ticket #([0-9]*) +\((.*?)\) +([0-9]+) +times} $result match ticket extra times]} {
-        .bugreport.expl insert end "This problem has been reported as " "" "Ticket #$ticket" bold " in our system." ""
-        if {[string is integer $times] && $times > 1} {
-            .bugreport.expl insert end "  This particular problem has been reported $times times."
-        }
-        .bugreport.expl insert end "\n\nIf you continue having trouble with this tool, please close it and restart.  Thanks for reporting the problem and helping us improve things!"
-    } else {
-        .bugreport.expl insert end "This problem has been reported.  Here is the response from the hub, which may contain information about your ticket:\n" "" $result bold "\n\nIf you continue having trouble with this tool, please close it and restart.  Thanks for reporting the problem and helping us improve things!" ""
-    }
-    fixTextHeight .bugreport.expl
-    .bugreport.expl configure -state disabled
-    pack .bugreport.done -side bottom -padx 8 -pady 8
-    focus .bugreport.done
-}
-
-# ----------------------------------------------------------------------
-# USAGE: register <err>
-#
-# Low-level function used to capture information about a bug report
-# prior to calling "send", which actually sends the ticket.  We usually
-# let the user preview the information and decide whether or not to
-# send the ticket.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::register {err} {
-    global errorInfo tcl_platform
-    variable details
-    variable settings
-    variable extraInfo
-
-    #
-    # Figure out exactly what we'll send if the bug report is
-    # submitted, so we can show the user.
-    #
-    set stackTrace "$err\n---------\n$errorInfo\n---------\n$extraInfo"
-    if {![regexp {^([^\n]+)\n} $stackTrace match summary]} {
-        if {[string length $stackTrace] == 0} {
-            set summary "Unexpected error from Rappture"
-        } else {
-            set summary $stackTrace
-        }
-    }
-    if {[string length $summary] > 200} {
-        set summary "[string range $summary 0 200]..."
-    }
-    if {[string match {Problem launching job*} $summary]} {
-        append summary " (in tool \"[Rappture::Tool::resources -appname]\")"
-        set category "Tools"
-    } else {
-        set category $settings(category)
-    }
-
-    # make sure that the stack trace isn't too long
-    set toolong 20000
-    if {[string length $stackTrace] > $toolong} {
-        #
-        # If this came from "Problem launching job", then it will have
-        # a "== RAPPTURE INPUT ==" part somewhere in the middle.  Try
-        # to show the first part, this middle part, and the very last
-        # part, cutting out whatever we have to in the middle.
-        #
-        if {[regexp -indices {\n== RAPPTURE INPUT ==\n} $stackTrace match]} {
-            foreach {smid0 smid1} $match break
-            set quarter [expr {$toolong/4}]
-            set s0 $quarter
-            set smid0 [expr {$smid0-$quarter}]
-            set smid1 [expr {$smid1+$quarter}]
-            set s1 [expr {[string length $stackTrace]-$quarter}]
-
-            if {$smid0 < $s0} {
-                # first part is short -- truncate last part
-                set stackTrace "[string range $stackTrace 0 $smid1]\n...\n[string range $stackTrace [expr {[string length $stackTrace]-($toolong-$smid1)}] end]"
-            } elseif {$smid1 > $s1} {
-                # last part is short -- truncate first part
-                set tailsize [expr {[string length $stackTrace]-$smid0}]
-                set stackTrace "[string range $stackTrace 0 [expr {$toolong-$tailsize}]]\n...\n[string range $stackTrace $smid0 end]"
-            } else {
-                # rappture input line is right about in the middle
-                set stackTrace "[string range $stackTrace 0 $s0]\n...\n[string range $stackTrace $smid0 $smid1]\n...\n[string range $stackTrace $s1 end]"
-            }
-        } else {
-            # no Rappture input -- just show first part and last part
-            set half [expr {$toolong/2}]
-            set stackTrace "[string range $stackTrace 0 $half]\n...\n[string range $stackTrace [expr {[string length $stackTrace]-$half}] end]"
-        }
-    }
-
-    set details(summary) $summary
-    set details(category) $category
-    set details(stackTrace) $stackTrace
-    set details(hostname) [info hostname]
-    set details(session) [Rappture::Tool::resources -session]
-    set details(referrer) [Rappture::Tool::resources -appname]
-    set details(platform) [array get tcl_platform]
-
-    Rappture::Logger::log oops! $summary
-}
-
-# ----------------------------------------------------------------------
-# USAGE: attachment <string>
-#
-# Low-level function used to capture information about a bug report
-# prior to calling "send", which actually sends the ticket.  We usually
-# let the user preview the information and decide whether or not to
-# send the ticket.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::attachment { string } {
-    variable details
-    set details(attachment) $string
-}
-
-# ----------------------------------------------------------------------
-# USAGE: send
-#
-# Low-level function used to send bug reports back to the hub site.
-# Error details gathered by a previous call to "register" are sent
-# along as a support ticket.  Returns a string of the following form,
-# representing details about the new or existing ticket:
-#   Ticket #XX (XXXXXX) XX times
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::send {} {
-    variable details
-    variable settings
-
-    package require http
-    package require tls
-    http::register https 443 [list ::tls::socket -tls1 0 -ssl2 0 -ssl3 0]
-
-
-    set report $details(stackTrace)
-    set cmts [string trim [.bugreport.comments.info.text get 1.0 end]]
-    if {[string length $cmts] > 0} {
-        set report "$cmts\n\n[string repeat = 72]\n$report"
-    }
-    set toolFile ""
-    if { [info exists details(attachment)] } {
-        set toolFile "/tmp/tool[pid].xml"
-        set f [open $toolFile "w"]
-        puts $f $details(attachment)
-        close $f
-        unset details(attachment)
-    }
-    set query [http::formatQuery \
-        option com_support \
-        controller tickets \
-        upload $toolFile \
-        task create \
-        no_html 1 \
-        report $report \
-        sesstoken $details(session) \
-        hostname $details(hostname) \
-        os $details(platform) \
-        category $details(category) \
-        summary $details(summary) \
-        referrer $details(referrer) \
-        login $settings(user) \
-        group $settings(group) \
-        type $settings(type) \
-    ]
-    set url [Rappture::Tool::resources -huburl]
-    if { $url == "" } {
-        set url "http://hubzero.org"
-    }
-    if {[string index $url end] == "/"} {
-        append url "index.php"
-    } else {
-        append url "/index.php"
-    }
-
-    set token [http::geturl $url -query $query -timeout 60000]
-
-    if {[http::ncode $token] != 200} {
-        error [http::code $token]
-    }
-    upvar #0 $token rval
-    set info $rval(body)
-    http::cleanup $token
-
-    if { $toolFile != "" } {
-        file delete $toolFile
-    }
-    if {[regexp {Ticket #[0-9]* +\(.*?\) +[0-9]+ +times} $info match]} {
-        return $match
-    }
-    error "Report received, but ticket may not have been filed.  Here's the result...\n$info"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: fixTextHeight <widget>
-#
-# Used internally to adjust the height of a text widget so it is just
-# tall enough to show the info within it.
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::fixTextHeight {widget} {
-    #
-    # HACK ALERT!  In Tk8.5, we can count display lines directly.
-    #   But for earlier versions, we have to cook up something
-    #   similar.
-    #
-    if {[catch {$widget count -displaylines 1.0 end} h] == 0 && $h > 0} {
-        $widget configure -height $h
-    } else {
-        for {set h 1} {$h < 15} {incr h} {
-            $widget configure -height $h
-            $widget see 1.0
-            update idletasks
-            if {"" != [$widget bbox end-1char]} {
-                break
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: shouldReport jobfailures <boolean>
-# USAGE: shouldReport for ?oops|jobs?
-#
-# Used internally to determine whether or not this system should
-# automatically report errors back to the hosting hub.  Returns 1
-# if the tool should, and 0 otherwise.  The decision is made based
-# on whether this is a current tool in production, whether it is
-# being tested in a workspace, and whether the tool commonly generates
-# problems (by pilot error in its input deck).
-# ----------------------------------------------------------------------
-proc Rappture::bugreport::shouldReport {option value} {
-    global env
-
-    switch -- $option {
-        jobfailures {
-            variable reportJobFailures
-            if {![string is boolean $value]} {
-                error "bad value \"$value\": should be boolean"
-            }
-            set reportJobFailures $value
-        }
-        for {
-            # is it being run within a workspace?
-            set appname [Rappture::Tool::resources -appname]
-            if {[string match {[Ww]orkspace*} $appname]} {
-                return 0
-            }
-            set url [Rappture::Tool::resources -huburl]
-            if { $url == "" } {
-                return 0
-            }
-            # if this is a problem launching a job and the tool
-            # expects this, then don't bother with automatic reports.
-            variable reportJobFailures
-            if {"jobs" == $value && !$reportJobFailures} {
-                return 0
-            }
-
-            # this is a real problem -- report it!
-            return 1
-        }
-        default {
-            error "bad option \"$option\": should be jobfailures or for"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Build the bug reporting dialog
-# ----------------------------------------------------------------------
-toplevel .bugreport -class BugReport -borderwidth 1 -relief solid
-wm overrideredirect .bugreport 1
-wm withdraw .bugreport
-
-frame .bugreport.banner -background #a9a9a9
-pack .bugreport.banner -side top -fill x
-label .bugreport.banner.icon -image [Rappture::icon alert]
-pack .bugreport.banner.icon -side left -padx 2 -pady 2
-label .bugreport.banner.title -text "Oops! Internal Error"
-pack .bugreport.banner.title -side left -padx {0 8} -pady 2
-
-# add these frustration bindings in case the "Dismiss" button is off screen
-bind .bugreport.banner.icon <Double-ButtonPress-1> \
-    Rappture::bugreport::deactivate
-bind .bugreport.banner.title <Double-ButtonPress-1> \
-    Rappture::bugreport::deactivate
-bind .bugreport <KeyPress-Escape> \
-    Rappture::bugreport::deactivate
-
-set bg [.bugreport cget -background]
-text .bugreport.expl -borderwidth 0 -highlightthickness 0 -background $bg \
-    -height 3 -wrap word
-.bugreport.expl tag configure bold \
-    -font [option get .bugreport.expl boldFont Font]
-#
-# HACK ALERT!  We have problems with fixTextHeight working correctly
-#   on Windows for Tk8.4 and earlier.  To make it work properly, we
-#   add the binding below.  At some point, we'll ditch 8.4 and we can
-#   use the new "count -displaylines" option in Tk8.5.
-#
-bind .bugreport.expl <Map> {Rappture::bugreport::fixTextHeight %W}
-
-frame .bugreport.comments
-label .bugreport.comments.l -text "What were you doing just before this error?" -anchor w
-pack .bugreport.comments.l -side top -anchor w
-Rappture::Scroller .bugreport.comments.info -xscrollmode none -yscrollmode auto
-text .bugreport.comments.info.text -width 30 -height 3 -wrap word
-.bugreport.comments.info contents .bugreport.comments.info.text
-bind .bugreport.comments.info.text <ButtonPress> {focus %W}
-pack .bugreport.comments.info -expand yes -fill both
-
-frame .bugreport.cntls
-pack .bugreport.cntls -side bottom -fill x
-button .bugreport.cntls.ok -text "Ignore" -command {
-    Rappture::bugreport::deactivate
-}
-pack .bugreport.cntls.ok -side left -padx {4 20} -pady 8
-button .bugreport.cntls.send -text "Send Trouble Report" -command {
-    Rappture::bugreport::submit
-}
-pack .bugreport.cntls.send -side right -padx 4 -pady 8
-
-button .bugreport.cntls.show -text "Show Details..." \
-    -command {Rappture::bugreport::activate @SHOWDETAILS}
-pack .bugreport.cntls.show -side right
-
-
-frame .bugreport.details
-Rappture::Scroller .bugreport.details.info -xscrollmode auto -yscrollmode auto
-text .bugreport.details.info.text -width 50 -height 15 -wrap none
-.bugreport.details.info contents .bugreport.details.info.text
-pack .bugreport.details.info -expand yes -fill both
-
-frame .bugreport.xmit
-Rappture::Animicon .bugreport.xmit.icon -images {
-    circle-ball1 circle-ball2 circle-ball3 circle-ball4
-    circle-ball5 circle-ball6 circle-ball7 circle-ball8
-}
-pack .bugreport.xmit.icon -side left
-label .bugreport.xmit.title -anchor w
-pack .bugreport.xmit.title -side left -expand yes -fill x
-
-button .bugreport.done -text "Done" \
-    -command Rappture::bugreport::deactivate
-
-# this binding keeps the bugreport window on top
-bind BugReportOnTop <ButtonPress> {
-    wm deiconify %W
-    raise %W
-}
-set btags [bindtags .bugreport]
-bindtags .bugreport [linsert $btags 0 BugReportOnTop]
-
Index: trunk/gui/scripts/choiceentry.tcl
===================================================================
--- trunk/gui/scripts/choiceentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,315 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: ChoiceEntry - widget for entering a choice of strings
-#
-#  This widget represents a <choice> entry on a control panel.
-#  It is used to choose one of several mutually-exclusive strings.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::ChoiceEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-    destructor { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _rebuild {}
-    protected method _newValue {}
-    protected method _tooltip {}
-    protected method _log {}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-    private variable _str2val     ;# maps option label => option value
-}
-
-itk::usual ChoiceEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    itk_component add choice {
-        Rappture::Combobox $itk_interior.choice -editable no \
-            -interactcommand [itcl::code $this _log]
-    }
-    pack $itk_component(choice) -expand yes -fill both
-    bind $itk_component(choice) <<Value>> [itcl::code $this _newValue]
-
-    eval itk_initialize $args
-
-    _rebuild
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::destructor {} {
-    $_owner notify remove $this
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [lindex $args 0]
-        if {[info exists _str2val($newval)]} {
-            # this is a label -- use it directly
-            $itk_component(choice) value $newval
-            set newval $_str2val($newval)  ;# report the actual value
-        } else {
-            # this is a value -- search for corresponding label
-            foreach str [array names _str2val] {
-                if {$_str2val($str) eq $newval} {
-                    $itk_component(choice) value $str
-                    break
-                }
-            }
-        }
-        return $newval
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    set str [$itk_component(choice) value]
-    if {[info exists _str2val($str)]} {
-        return $_str2val($str)
-    }
-    return $str
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {"" == $label} {
-        set label "Choice"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::tooltip {} {
-    # query tooltip on-demand based on current choice
-    return "@[itcl::code $this _tooltip]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _rebuild
-#
-# Used internally to rebuild the contents of this choice widget
-# whenever something that it depends on changes.  Scans through the
-# information in the XML spec and builds a list of choices for the
-# widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::_rebuild {} {
-    # get rid of any existing choices
-    $itk_component(choice) choices delete 0 end
-    catch {unset _str2val}
-
-    #
-    # Plug in the various options for the choice.
-    #
-    set max 10
-    foreach cname [$_owner xml children -type option $_path] {
-        set path [string trim [$_owner xml get $_path.$cname.path]]
-        if {"" != $path} {
-            # look for the input element controlling this path
-            set found 0
-            foreach cntl [Rappture::entities [$_owner xml object] "input"] {
-                set len [string length $cntl]
-                if {[string equal -length $len $cntl $path]} {
-                    set found 1
-                    break
-                }
-            }
-            if {$found} {
-                #
-                # Choice comes from a list of matching entities at
-                # a particular XML path.  Use the <label> as a template
-                # for each item on the path.
-                #
-                $_owner notify add $this $cntl [itcl::code $this _rebuild]
-
-                set label \
-                    [string trim [$_owner xml get $_path.$cname.about.label]]
-                if {"" == $label} {
-                    set label "%type #%n"
-                }
-
-                set ppath [Rappture::LibraryObj::path2list $path]
-                set leading [join [lrange $ppath 0 end-1] .]
-                set tail [lindex $ppath end]
-                set n 1
-                foreach ccname [$_owner xml children $leading] {
-                    if {[string match $tail $ccname]} {
-                        set subst(%n) $n
-                        set subst(%type) [$_owner xml element -as type $leading.$ccname]
-                        set subst(%id) [$_owner xml element -as id $leading.$ccname]
-                        foreach detail [$_owner xml children $leading.$ccname] {
-                            set subst(%$detail) \
-                                [$_owner xml get $leading.$ccname.$detail]
-                        }
-                        set str [string map [array get subst] $label]
-                        $itk_component(choice) choices insert end \
-                            $leading.$ccname $str
-                        incr n
-                    }
-                }
-                $itk_component(choice) value ""
-            } else {
-                puts "can't find controlling entity for path \"$path\""
-            }
-        } else {
-            #
-            # Choice is an ordinary LABEL.
-            # Add the label as-is into the list of choices.
-            #
-            set val [string trim [$_owner xml get $_path.$cname.value]]
-            set str [string trim [$_owner xml get $_path.$cname.about.label]]
-            if {"" == $val} {
-                set val $str
-            }
-            if {"" != $str} {
-                set _str2val($str) $val
-                $itk_component(choice) choices insert end $_path.$cname $str
-                set len [string length $str]
-                if {$len > $max} { set max $len }
-            }
-        }
-    }
-    $itk_component(choice) configure -width $max
-
-    #
-    # Assign the default value to this widget, if there is one.
-    #
-    set defval [string trim [$_owner xml get $_path.default]]
-    if {"" != $defval} {
-        if {[info exists _str2val($defval)]} {
-            $itk_component(choice) value $defval
-        } else {
-            foreach str [array names _str2val] {
-                if {$_str2val($str) == $defval} {
-                    $itk_component(choice) value $str
-                    break
-                }
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _newValue
-#
-# Invoked automatically whenever the value in the choice changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::_newValue {} {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _tooltip
-#
-# Returns the tooltip for this widget, given the current choice in
-# the selector.  This is normally called by the Rappture::Tooltip
-# facility whenever it is about to pop up a tooltip for this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::_tooltip {} {
-    set tip [string trim [$_owner xml get $_path.about.description]]
-
-    # get the description for the current choice, if there is one
-    set str [$itk_component(choice) value]
-    set path [$itk_component(choice) translate $str]
-    set desc ""
-    if {$path != ""} {
-        set desc [string trim [$_owner xml get $path.about.description]]
-    }
-
-    if {[string length $str] > 0 && [string length $desc] > 0} {
-        append tip "\n\n$str:\n$desc"
-    }
-    return $tip
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _log
-#
-# Used internally to send info to the logging mechanism.  Calls the
-# Rappture::Logger mechanism to log the change to this input.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ChoiceEntry::_log {} {
-    Rappture::Logger::log input $_path [$itk_component(choice) value]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::ChoiceEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(choice) configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/cloud.tcl
===================================================================
--- trunk/gui/scripts/cloud.tcl	(revision 6716)
+++ 	(revision )
@@ -1,287 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: cloud - represents the mesh for a cloud of points
-#
-#  This object represents the mesh for a cloud of points in an XML
-#  description of a device.  It simplifies the process of extracting
-#  data that represent the mesh.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-
-namespace eval Rappture { # forward declaration }
-
-itcl::class Rappture::Cloud {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method points {}
-    public method units { axis }
-    public method label { axis }
-    public method vtkdata {}
-    public method dimensions {}
-    public method limits {which}
-    public method hints {{key ""}}
-    public method numpoints {} {
-        return $_numPoints
-    }
-    public method isvalid {} {
-        return $_isValid
-    }
-
-    public proc fetch {xmlobj path}
-    public proc release {obj}
-
-    private variable _xmlobj "";        # ref to XML obj with device data
-    private variable _cloud "";         # lib obj representing this cloud
-    private variable _units "" ;        # system of units for x, y, z
-    private variable _axis2label;       #
-    private variable _axis2units;       #
-    private variable _limits;           # limits x, y, z
-    private variable _numPoints 0
-    private variable _vtkdata ""
-    private variable _points ""
-    private variable _dim 0
-    private variable _isValid 0;        # Indicates if the data is valid.
-
-    private common _xp2obj ;            # Used for fetch/release ref counting
-    private common _obj2ref ;           # Used for fetch/release ref counting
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::Cloud::fetch <xmlobj> <path>
-#
-# Clients use this instead of a constructor to fetch the Cloud for
-# a particular <path> in the <xmlobj>.  When the client is done with
-# the cloud, he calls "release" to decrement the reference count.
-# When the cloud is no longer needed, it is cleaned up automatically.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Cloud::fetch {xmlobj path} {
-    set handle "$xmlobj|$path"
-    if {[info exists _xp2obj($handle)]} {
-        set obj $_xp2obj($handle)
-        incr _obj2ref($obj)
-        return $obj
-    }
-
-    set obj [Rappture::Cloud ::#auto $xmlobj $path]
-    set _xp2obj($handle) $obj
-    set _obj2ref($obj) 1
-    return $obj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::Cloud::release <obj>
-#
-# Clients call this when they're no longer using a Cloud fetched
-# previously by the "fetch" proc.  This decrements the reference
-# count for the cloud and destroys the object when it is no longer
-# in use.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Cloud::release {obj} {
-    if {[info exists _obj2ref($obj)]} {
-        incr _obj2ref($obj) -1
-        if {$_obj2ref($obj) <= 0} {
-            unset _obj2ref($obj)
-            foreach handle [array names _xp2obj] {
-                if {$_xp2obj($handle) == $obj} {
-                    unset _xp2obj($handle)
-                }
-            }
-            itcl::delete object $obj
-        }
-    } else {
-        error "can't find reference count for $obj"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Cloud::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be Rappture::library"
-    }
-    set _xmlobj $xmlobj
-    set _cloud [$xmlobj element -as object $path]
-
-    set _units [$_cloud get units]
-    set first [lindex $_units 0]
-    set list {}
-    foreach u $_units axis { x y z } {
-        if { $u != "" } {
-            set _axis2units($axis) $u
-        } else {
-            set _axis2units($axis) $first
-        }
-        lappend list $_axis2units($axis)
-    }
-    set _units $list
-    foreach label [$_cloud get labels] axis { x y z } {
-        if { $label != "" } {
-            set _axis2label($axis) $label
-        } else {
-            set _axis2label($axis) [string toupper $axis]
-        }
-    }
-
-    set _numPoints 0
-    set _points {}
-    foreach line [split [$xmlobj get $path.points] \n] {
-        if {"" == [string trim $line]} {
-            continue
-        }
-
-        if {[llength $line] > 3} {
-            puts stderr "ERROR: Too many coordinates in cloud points list"
-            return
-        }
-
-        # make sure we have x,y,z
-        while {[llength $line] < 3} {
-            lappend line "0"
-        }
-
-        # Extract each point and add it to the points list
-        foreach {x y z} $line break
-        foreach axis {x y z} {
-            # Units on point coordinates are NOT supported
-            set value [set $axis]
-            # Update limits
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) [list $value $value]
-            } else {
-                foreach { min max } $_limits($axis) break
-                if {$value < $min} {
-                    set min $value
-                }
-                if {$value > $max} {
-                    set max $value
-                }
-                set _limits($axis) [list $min $max]
-            }
-        }
-        append _points "$x $y $z\n"
-        incr _numPoints
-    }
-    append out "DATASET POLYDATA\n"
-    append out "POINTS $_numPoints double\n"
-    append out $_points
-    set _vtkdata $out
-    if { $_numPoints == 0 } {
-        return
-    }
-    set _dim 0
-    foreach { xmin xmax } $_limits(x) break
-    if { $xmax > $xmin } {
-        incr _dim
-    }
-    foreach { ymin ymax } $_limits(y) break
-    if { $ymax > $ymin } {
-        incr _dim
-    }
-    foreach { zmin zmax } $_limits(z) break
-    if { $zmax > $zmin } {
-        incr _dim
-    }
-    set _isValid 1
-    puts stderr "WARNING: The <cloud> element is deprecated.  Please use an unstructured <mesh> instead."
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Cloud::destructor {} {
-    # don't destroy the _xmlobj! we don't own it!
-    itcl::delete object $_cloud
-}
-
-# ----------------------------------------------------------------------
-# USAGE: points
-#
-# Returns a string containing the points for this mesh.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Cloud::points {} {
-    return $_points
-}
-
-# ----------------------------------------------------------------------
-# USAGE: dimensions
-#
-# Returns the number of dimensions for this object: 1, 2, or 3.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Cloud::dimensions {} {
-    return $_dim
-}
-
-# ----------------------------------------------------------------------
-# USAGE: limits x|y|z
-#
-# Returns the {min max} values for the limits of the specified axis.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Cloud::limits { axis } {
-    if { ![info exists _limits($axis)] } {
-        error "bad axis \"$axis\": should be x, y, z"
-    }
-    return $_limits($axis)
-}
-
-#
-# units --
-#
-#       Returns the units of the given axis.
-#
-itcl::body Rappture::Cloud::units { axis } {
-    if { ![info exists _axis2units($axis)] } {
-        return ""
-    }
-    return $_axis2units($axis)
-}
-
-#
-# label --
-#
-#       Returns the label of the given axis.
-#
-itcl::body Rappture::Cloud::label { axis } {
-    if { ![info exists _axis2label($axis)] } {
-        return ""
-    }
-    return $_axis2label($axis)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this field.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Cloud::hints {{keyword ""}} {
-    foreach key {label color units} {
-        set str [$_cloud get $key]
-        if {"" != $str} {
-            set hints($key) $str
-        }
-    }
-
-    if {$keyword != ""} {
-        if {[info exists hints($keyword)]} {
-            return $hints($keyword)
-        }
-        return ""
-    }
-    return [array get hints]
-}
-
-itcl::body Rappture::Cloud::vtkdata {} {
-    return $_vtkdata
-}
Index: trunk/gui/scripts/color.tcl
===================================================================
--- trunk/gui/scripts/color.tcl	(revision 6716)
+++ 	(revision )
@@ -1,227 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  UTILITY: color
-#
-#  This file contains various utility functions for manipulating
-#  color values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-namespace eval Rappture::color { # forward declaration }
-
-# ---------------------------------------------------------------------
-# USAGE: brightness <color> <fraction>
-#
-# Used to brighten or dim a Tk <color> value by some +/- <fraction> in
-# the range 0-1.  Returns another color in the same hue, but with
-# different brighness.
-# ----------------------------------------------------------------------
-proc Rappture::color::brightness {color frac} {
-    foreach {h s v} [Rappture::color::RGBtoHSV $color] { break }
-    set v [expr {$v+$frac}]
-
-    # if frac overflows the value, pass changes along to saturation
-    if {$v < 0} {
-        set s [expr {$s+$v}]
-        if {$s < 0} { set s 0 }
-        set v 0
-    }
-    if {$v > 1} {
-        set s [expr {$s-($v-1)}]
-        if {$s < 0} { set s 0 }
-        set v 1
-    }
-
-    return [Rappture::color::HSVtoRGB $h $s $v]
-}
-
-# ---------------------------------------------------------------------
-# USAGE: brightness_min <color> <min>
-#
-# Used to make sure a color is not too dim.  If the value is less
-# than the <min>, then it is capped at that value.  That way, the
-# return color shows up against black.
-# ----------------------------------------------------------------------
-proc Rappture::color::brightness_min {color min} {
-    foreach {h s v} [Rappture::color::RGBtoHSV $color] { break }
-    if {$v < $min} {
-        set v $min
-    }
-    return [Rappture::color::HSVtoRGB $h $s $v]
-}
-
-# ---------------------------------------------------------------------
-# USAGE: brightness_max <color> <max>
-#
-# Used to make sure a color is not too dim.  If the value is less
-# than the <min>, then it is capped at that value.  That way, the
-# return color shows up against black.
-# ----------------------------------------------------------------------
-proc Rappture::color::brightness_max {color max} {
-    foreach {h s v} [Rappture::color::RGBtoHSV $color] { break }
-    if {$v > $max} {
-        set v $max
-    }
-    return [Rappture::color::HSVtoRGB $h $s $v]
-}
-
-# ---------------------------------------------------------------------
-# USAGE: RGBtoHSV <color>
-#
-# Used to convert a Tk <color> value to hue, saturation, value
-# components.  Returns a list of the form {h s v}.
-# ----------------------------------------------------------------------
-proc Rappture::color::RGBtoHSV {color} {
-    #
-    # If the colors are exhausted sometimes winfo can fail with a
-    # division by zero.  Catch it to avoid problems.
-    #
-    if { [catch {winfo rgb . $color} status] != 0 } {
-        set s 0
-        set v 0
-        set h 0
-        return [list $h $s $v]
-    }
-    foreach {r g b} $status {}
-    set min [expr {($r < $g) ? $r : $g}]
-    set min [expr {($b < $min) ? $b : $min}]
-    set max [expr {($r > $g) ? $r : $g}]
-    set max [expr {($b > $max) ? $b : $max}]
-
-    set v [expr {$max/65535.0}]
-
-    set delta [expr {$max-$min}]
-
-    if { $delta == 0 } {
-        # delta=0 => gray color
-        set s 0
-        set v [expr {$r/65535.0}]
-        set h 0
-        return [list $h $s $v]
-    }
- 
-    if {$max > 0} {
-        set s [expr {$delta/double($max)}]
-    } else {
-        # r=g=b=0  =>  s=0, v undefined
-        set s 0
-        set v 0
-        set h 0
-        return [list $h $s $v]
-    }
-
-    if {$r == $max} {
-        set h [expr {($g - $b)/double($delta)}]
-    } elseif {$g == $max} {
-        set h [expr {2 + ($b - $r)/double($delta)}]
-    } else {
-        set h [expr {4 + ($r - $g)/double($delta)}]
-    }
-    set h [expr {$h*1.04719756667}] ;# *60 degrees
-    if {$h < 0} {
-        set h [expr {$h+6.2831854}]
-    }
-    return [list $h $s $v]
-}
-
-# ---------------------------------------------------------------------
-# USAGE: HSVtoRGB <color>
-#
-# Used to convert hue, saturation, value for a color to its
-# equivalent RGB form.  Returns a prompt Tk color of the form
-# #RRGGBB.
-# ----------------------------------------------------------------------
-proc Rappture::color::HSVtoRGB {h s v} {
-    if {$s == 0} {
-        set v [expr round(255*$v)]
-        set r $v
-        set g $v
-        set b $v
-    } else {
-        if {$h >= 6.28318} {set h [expr $h-6.28318]}
-        set h [expr $h/1.0472]
-        set f [expr $h-floor($h)]
-        set p [expr round(255*$v*(1.0-$s))]
-        set q [expr round(255*$v*(1.0-$s*$f))]
-        set t [expr round(255*$v*(1.0-$s*(1.0-$f)))]
-        set v [expr round(255*$v)]
-
-        switch [expr int($h)] {
-            0 {set r $v; set g $t; set b $p}
-            1 {set r $q; set g $v; set b $p}
-            2 {set r $p; set g $v; set b $t}
-            3 {set r $p; set g $q; set b $v}
-            4 {set r $t; set g $p; set b $v}
-            5 {set r $v; set g $p; set b $q}
-        }
-    }
-    return [format "#%.2x%.2x%.2x" $r $g $b]
-}
-
-# ---------------------------------------------------------------------
-# USAGE: wave2RGB <wavelength>
-#
-# Given a visible wavelength in nm, returns a Tk color of the form
-# #RRGGBB. Returns black for nonvisible wavelengths.  Based on code from
-# Dan Bruton (astro@tamu.edu) http://www.physics.sfasu.edu/astro/color/spectra.html
-# ----------------------------------------------------------------------
-
-proc Rappture::color::wave2RGB {wl} {
-
-    # strip off any units
-    set wl [string trimright $wl "nm"]
-
-    if {$wl < 380 || $wl > 780} {
-        return black
-    }
-    set gamma 0.8
-    set r 0.0
-    set g 0.0
-    set b 0.0
-    if {$wl <= 440} {
-        set r [expr (440.0 - $wl) / 60.0]
-        set b 1.0
-    } elseif {$wl <= 490} {
-        set g [expr ($wl - 440.0) / 50.0]
-        set b 1.0
-    } elseif {$wl <= 510} {
-        set g 1.0
-        set b [expr (510.0 - $wl) / 20.0]
-    } elseif {$wl <= 580} {
-        set g 1.0
-        set r [expr ($wl - 510.0) / 70.0]
-    } elseif {$wl <= 645} {
-        set r 1.0
-        set g [expr (645.0 - $wl) / 65.0]
-    } else {
-        set r 1.0
-    }
-
-    if {$wl > 700} {
-        set sss [expr 0.3 + 0.7 * (780.0 - $wl) / 80.0]
-    } elseif {$wl < 420} {
-        set sss [expr 0.3 + 0.7 * ($wl - 380.0) / 40.0]
-    } else {
-        set sss 1.0
-    }
-    set r [expr int(255.0 * pow(($sss * $r), $gamma))]
-    set g [expr int(255.0 * pow(($sss * $g), $gamma))]
-    set b [expr int(255.0 * pow(($sss * $b), $gamma))]
-    return [format "#%.2X%.2X%.2X" $r $g $b]
-}
-
-# Returns a list containing three decimal values in the range 0 to 65535,
-# which are the red, green, and blue intensities that correspond to color
-# in the window given by window. Color may be specified in any of the forms
-# acceptable for a color option.
-proc Rappture::color::RGB {color} {
-    if {[string match "*nm" $color]} {
-        set color [Rappture::color::wave2RGB [string trimright $color "nm"]]
-    }
-    return [winfo rgb . $color]
-}
Index: trunk/gui/scripts/combobox.tcl
===================================================================
--- trunk/gui/scripts/combobox.tcl	(revision 6716)
+++ trunk/gui/scripts/combobox.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: combobox - entry widget with a drop-down list of values
@@ -10,8 +9,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -24,7 +20,5 @@
 option add *Combobox.textBackground white widgetDefault
 option add *Combobox.textForeground black widgetDefault
-option add *Combobox.disabledBackground white widgetDefault
-option add *Combobox.disabledForeground gray widgetDefault
-option add *Combobox.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
+option add *Combobox.font -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
 
 itcl::class Rappture::Combobox {
@@ -32,21 +26,14 @@
 
     itk_option define -editable editable Editable ""
-    itk_option define -state state State "normal"
     itk_option define -width width Width 0
-    itk_option define -disabledbackground disabledBackground DisabledBackground ""
-    itk_option define -disabledforeground disabledForeground DisabledForeground ""
-    itk_option define -interactcommand interactCommand InteractCommand ""
 
     constructor {args} { # defined below }
 
     public method value {args}
-    public method translate {value {defValue ""}}
-    public method label {value}
-    public method current {}
+    public method translate {value}
     public method choices {option args}
 
     protected method _entry {option}
     protected method _dropdown {option}
-    protected method _fixState {}
 
     blt::bitmap define ComboboxArrow {
@@ -56,8 +43,6 @@
            0xfe, 0x7c, 0x38, 0x10};
     }
-    private variable _value2label
-    private variable _label2value
-}
-
+}
+                                                                                
 itk::usual Combobox {
     keep -cursor -font
@@ -136,5 +121,5 @@
         }
 
-        after 10 [list catch [list event generate $itk_component(hull) <<Value>>]]
+        event generate $itk_component(hull) <<Value>>
     } elseif {[llength $args] != 0} {
         error "wrong # args: should be \"value ?newval?\""
@@ -151,41 +136,11 @@
 # method returns the corresponding value.  Otherwise, it returns "".
 # ----------------------------------------------------------------------
-itcl::body Rappture::Combobox::translate {value {defValue ""}} {
+itcl::body Rappture::Combobox::translate {value} {
     foreach {val label} [choices get -both] {
-        if {$label eq $value} {
+        if {$label == $value} {
             return $val
         }
     }
-    return $defValue
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label <value>
-#
-# Clients use this to translate a value to a label.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combobox::label { myValue } {
-    foreach {val label} [choices get -both] {
-        if {$myValue == $val} {
-            return $label
-        }
-    }
     return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current
-#
-# Clients use this to retrieve a label from the entry widget and return
-# its value, if one exists. If no value exists for the label, then the
-# label is returned.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combobox::current {} {
-    set raw [$itk_component(entry) get]
-    set value [translate $raw "badValue"]
-    if { $value ne "badValue" } {
-        return $value
-    }
-    return $raw
 }
 
@@ -219,13 +174,10 @@
     switch -- $option {
         apply {
-            if {$itk_option(-editable) && $itk_option(-state) == "normal"} {
+            if {$itk_option(-editable)} {
                 event generate $itk_component(hull) <<Value>>
-                if {[string length $itk_option(-interactcommand)] > 0} {
-                    uplevel #0 $itk_option(-interactcommand)
-                }
             }
         }
         click {
-            if {!$itk_option(-editable) && $itk_option(-state) == "normal"} {
+            if {!$itk_option(-editable)} {
                 $itk_component(button) configure -relief sunken
                 update idletasks; after 100
@@ -268,56 +220,11 @@
         }
         select {
-            set newval [$itk_component(ddlist) current -label]
-            set val [$itk_component(entry) get]
-            if {$newval ne "" && $newval ne $val} {
-                value $newval
-                if {[string length $itk_option(-interactcommand)] > 0} {
-                    uplevel #0 $itk_option(-interactcommand)
-                }
+            set val [$itk_component(ddlist) current -label]
+            if {"" != $val} {
+                value $val
             }
         }
         default {
             error "bad option \"$option\": should be post, unpost, select"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixState
-#
-# Used internally to fix the widget state when the -editable/-state
-# options change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combobox::_fixState {} {
-    if {$itk_option(-state) == "normal"} {
-        $itk_component(button) configure -state normal
-        $itk_component(entry) configure \
-            -background $itk_option(-textbackground) \
-            -foreground $itk_option(-textforeground) \
-            -disabledbackground $itk_option(-textbackground) \
-            -disabledforeground $itk_option(-textforeground)
-    } else {
-        $itk_component(button) configure -state disabled
-        $itk_component(entry) configure \
-            -background $itk_option(-disabledbackground) \
-            -foreground $itk_option(-disabledforeground) \
-            -disabledbackground $itk_option(-disabledbackground) \
-            -disabledforeground $itk_option(-disabledforeground)
-    }
-
-    if {$itk_option(-editable)} {
-        if {$itk_option(-state) == "normal"} {
-            $itk_component(entry) configure -state normal
-        } else {
-            $itk_component(entry) configure -state disabled
-        }
-    } else {
-        $itk_component(entry) configure -state disabled
-    }
-
-    if {!$itk_option(-editable) || $itk_option(-state) != "normal"} {
-        # can't keep focus here -- move it along to the next widget
-        if {[focus] == $itk_component(entry)} {
-            focus [tk_focusNext [focus]]
         }
     }
@@ -331,15 +238,11 @@
         error "bad value \"$itk_option(-editable)\": should be boolean"
     }
-    _fixState
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Combobox::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    _fixState
-}
+    if {$itk_option(-editable)} {
+        $itk_component(entry) configure -state normal
+    } else {
+        $itk_component(entry) configure -state disabled
+        if {[focus] == $itk_component(entry)} {
+            focus [tk_focusNext [focus]]
+        }
+    }
+}
Index: trunk/gui/scripts/combochecks.tcl
===================================================================
--- trunk/gui/scripts/combochecks.tcl	(revision 6716)
+++ 	(revision )
@@ -1,346 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: combochecks - like a combobox, but items with checkboxes
-#
-#  This widget looks a lot like a combobox, but has a drop-down list
-#  of checkbox items.  The list of checked items is shown in the
-#  entry area as a comma-separated list.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Combochecks.borderWidth 2 widgetDefault
-option add *Combochecks.relief sunken widgetDefault
-option add *Combochecks.width 10 widgetDefault
-option add *Combochecks.editable yes widgetDefault
-option add *Combochecks.textBackground white widgetDefault
-option add *Combochecks.textForeground black widgetDefault
-option add *Combochecks.disabledBackground white widgetDefault
-option add *Combochecks.disabledForeground gray widgetDefault
-option add *Combochecks.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Combochecks {
-    inherit itk::Widget
-
-    itk_option define -editable editable Editable ""
-    itk_option define -state state State "normal"
-    itk_option define -width width Width 0
-    itk_option define -disabledbackground disabledBackground DisabledBackground ""
-    itk_option define -disabledforeground disabledForeground DisabledForeground ""
-    itk_option define -interactcommand interactCommand InteractCommand ""
-
-    constructor {args} { # defined below }
-
-    public method value {args}
-    public method translate {value {defValue ""}}
-    public method label {value}
-    public method choices {option args}
-
-    protected method _entry {option}
-    protected method _dropdown {option}
-    protected method _fixState {}
-
-    blt::bitmap define CombochecksArrow {
-        #define arrow_width 8
-        #define arrow_height 4
-        static unsigned char arrow_bits[] = {
-           0xfe, 0x7c, 0x38, 0x10};
-    }
-    private variable _value2label
-    private variable _label2value
-}
-
-itk::usual Combochecks {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combochecks::constructor {args} {
-    itk_option add hull.borderwidth hull.relief
-
-    itk_component add button {
-        button $itk_interior.btn -bitmap CombochecksArrow -padx 0 \
-            -borderwidth 1 -relief raised -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness -highlightbackground -highlightcolor
-        ignore -borderwidth -relief
-    }
-    pack $itk_component(button) -side right -fill y
-
-    itk_component add entry {
-        entry $itk_interior.entry -borderwidth 0 -relief flat -state disabled
-    } {
-        usual
-        keep -width
-        rename -highlightbackground -textbackground textBackground Background
-        rename -background -textbackground textBackground Background
-        rename -foreground -textforeground textForeground Foreground
-        rename -disabledbackground -textbackground textBackground Background
-        rename -disabledforeground -textforeground textForeground Foreground
-        ignore -borderwidth -relief
-    }
-    pack $itk_component(entry) -side left -expand yes -fill both
-
-    bind $itk_component(entry) <KeyPress-Return> \
-        [itcl::code $this _entry apply]
-    bind $itk_component(entry) <ButtonPress> \
-        [itcl::code $this _entry click]
-
-    itk_component add ddlist {
-        Rappture::Dropdownchecks $itk_component(button).ddlist \
-            -postcommand [itcl::code $this _dropdown post] \
-            -unpostcommand [itcl::code $this _dropdown unpost] \
-    }
-
-    bind $itk_component(ddlist) <<DropdownchecksSelect>> \
-        [itcl::code $this _dropdown select]
-
-    $itk_component(button) configure -command \
-        [list $itk_component(ddlist) post $itk_component(hull) left]
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combochecks::value {args} {
-    if {[llength $args] == 1} {
-        set newval [lindex $args 0]
-
-        # FIXME: not sure if I need to update the ddlist just in case
-        # user calls value() without manipulating the ddlist
-        $itk_component(ddlist) reset
-        foreach part $newval {
-            set oldpart $part
-            set part [translate $part]
-            if {[string compare $part ""] == 0} {
-                # part could not be translated to a component
-                error "bad value \"$oldpart\": should be one of \"[join [choices get -label] {, }]\""
-            }
-            $itk_component(ddlist) state $part 1
-        }
-
-        $itk_component(entry) configure -state normal
-        $itk_component(entry) delete 0 end
-        $itk_component(entry) insert end [join $newval {, }]
-        if {!$itk_option(-editable)} {
-            $itk_component(entry) configure -state disabled
-        }
-
-        after 10 [list catch \
-            [list event generate $itk_component(hull) <<Value>>]]
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?newval?\""
-    }
-    return [$itk_component(entry) get]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: translate <value>
-#
-# Clients use this to translate a value from the entry part of the
-# combobox to one of the underlying values in the combobox.  If the
-# <value> string matches one of the labels for the choices, this
-# method returns the corresponding value.  Otherwise, it returns "".
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combochecks::translate {value {defValue ""}} {
-    foreach {val label} [choices get -both] {
-        if {$label eq $value} {
-            return $val
-        }
-    }
-    return $defValue
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label <value>
-#
-# Clients use this to translate a value to a label.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combochecks::label { myValue } {
-    foreach {val label} [choices get -both] {
-        if {$myValue == $val} {
-            return $label
-        }
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: choices insert <pos> ?<value1> <label1> ...?
-# USAGE: choices delete <first> ?<last>?
-# USAGE: choices get ?-value|-label|-both? ?<index>?
-# USAGE: choices state <value> ?on|off?
-# USAGE: choices index <value>
-#
-# Clients use this to manipulate the list of choices in the drop-down
-# list.  Each choice is represented by a (computer-friendly) value
-# and its corresponding (human-friendly) label.  The "get" option
-# returns information about options on the list, including the value,
-# the label, or both.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combochecks::choices {option args} {
-    eval $itk_component(ddlist) $option $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _entry apply
-# USAGE: _entry click
-#
-# Used internally to handle the entry widget for this combobox.  The
-# click option is invoked when the user click on the entry widget and
-# performs a post operation on the dropdown list. The apply option
-# is invoked when the user presses the Return key to set the value of
-# the entry widget or selects a value. It generates a Value signal.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combochecks::_entry {option} {
-    switch -- $option {
-        apply {
-            if {$itk_option(-editable) && $itk_option(-state) == "normal"} {
-                event generate $itk_component(hull) <<Value>>
-                if {[string length $itk_option(-interactcommand)] > 0} {
-                    uplevel #0 $itk_option(-interactcommand)
-                }
-            }
-        }
-        click {
-            if {!$itk_option(-editable) && $itk_option(-state) == "normal"} {
-                $itk_component(button) configure -relief sunken
-                update idletasks; after 100
-                $itk_component(button) configure -relief raised
-
-                $itk_component(ddlist) post $itk_component(hull) left
-            }
-        }
-        default {
-            error "bad option \"$option\": should be apply, click"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _dropdown post
-# USAGE: _dropdown unpost
-# USAGE: _dropdown select
-#
-# Used internally to handle the dropdown list for this combobox.  The
-# post/unpost options are invoked when the list is posted or unposted
-# to manage the relief of the controlling button.  The select option
-# is invoked whenever there is a selection from the list, to assign
-# the value back to the entry.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combochecks::_dropdown {option} {
-    switch -- $option {
-        post {
-#            set value [$itk_component(entry) get]
-#            set i [$itk_component(ddlist) index -label $value]
-#            if {$i >= 0} {
-#                $itk_component(ddlist) select clear 0 end
-#                $itk_component(ddlist) select set $i
-#            }
-        }
-        unpost {
-            if {$itk_option(-editable)} {
-                focus $itk_component(entry)
-            }
-        }
-        select {
-            set newval [$itk_component(ddlist) current -label]
-            set val [$itk_component(entry) get]
-            if {$newval eq ""} {
-                # all options are unchecked, use the old val
-                # wrap val (from entry) in a list to protect embedded whitespace
-                value [list $val]
-            } elseif {$newval ne $val} {
-                # new value selected, update the widget
-                value $newval
-                if {[string length $itk_option(-interactcommand)] > 0} {
-                    uplevel #0 $itk_option(-interactcommand)
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be post, unpost, select"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixState
-#
-# Used internally to fix the widget state when the -editable/-state
-# options change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Combochecks::_fixState {} {
-    if {$itk_option(-state) == "normal"} {
-        $itk_component(button) configure -state normal
-        $itk_component(entry) configure \
-            -background $itk_option(-textbackground) \
-            -foreground $itk_option(-textforeground) \
-            -disabledbackground $itk_option(-textbackground) \
-            -disabledforeground $itk_option(-textforeground)
-    } else {
-        $itk_component(button) configure -state disabled
-        $itk_component(entry) configure \
-            -background $itk_option(-disabledbackground) \
-            -foreground $itk_option(-disabledforeground) \
-            -disabledbackground $itk_option(-disabledbackground) \
-            -disabledforeground $itk_option(-disabledforeground)
-    }
-
-    if {$itk_option(-editable)} {
-        if {$itk_option(-state) == "normal"} {
-            $itk_component(entry) configure -state normal
-        } else {
-            $itk_component(entry) configure -state disabled
-        }
-    } else {
-        $itk_component(entry) configure -state disabled
-    }
-
-    if {!$itk_option(-editable) || $itk_option(-state) != "normal"} {
-        # can't keep focus here -- move it along to the next widget
-        if {[focus] == $itk_component(entry)} {
-            focus [tk_focusNext [focus]]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -editable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Combochecks::editable {
-    if {![string is boolean -strict $itk_option(-editable)]} {
-        error "bad value \"$itk_option(-editable)\": should be boolean"
-    }
-    _fixState
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Combochecks::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    _fixState
-}
Index: trunk/gui/scripts/controlOwner.tcl
===================================================================
--- trunk/gui/scripts/controlOwner.tcl	(revision 6716)
+++ 	(revision )
@@ -1,560 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: owner - manages Rappture controls
-#
-#  This object represents an entity managing Rappture controls.
-#  It is typically a Tool, a DeviceEditor, or some other large entity
-#  that manages a Rappture XML tree.  All controlling widgets are
-#  registered with an owner, and the owner propagates notifications
-#  out to clients who have an interest in a particular control.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-
-itcl::class Rappture::ControlOwner {
-    constructor {owner} { # defined below }
-
-    public method xml {args}
-
-    public method load {newobj}
-    public method widgetfor {path args}
-    public method valuefor {path args}
-    public method dependenciesfor {path args}
-    public method ownerfor {path {skip ""}}
-    public method changed {path}
-    public method regularize {path}
-    public method notify {option owner args}
-    public method sync {}
-    public method tool {}
-
-    protected method _slave {option args}
-
-    protected variable _owner ""     ;# ControlOwner containing this one
-    protected variable _path ""      ;# paths within are relative to this
-    protected variable _slaves ""    ;# this owner has these slaves
-    protected variable _xmlobj ""    ;# Rappture XML description
-    private variable _path2widget    ;# maps path => widget on this page
-    private variable _path2controls  ;# maps path => panel containing widget
-    private variable _owner2paths    ;# for notify: maps owner => interests
-    private variable _type2curpath   ;# maps type(path) => path's current value
-    private variable _callbacks      ;# for notify: maps owner/path => callback
-    private variable _dependencies   ;# maps path => other paths dep on this
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::constructor {owner} {
-    if {"" != $owner} {
-        set parts [split $owner @]
-        set _owner [lindex $parts 0]
-        set _path [lindex $parts 1]
-        $_owner _slave add $this
-    }
-
-    # we are adding this so notes can be used
-    # in coordination with loaders inside the load function
-    array set _type2curpath {
-        drawing all
-        choice current
-        boolean current
-        image current
-        integer current
-        loader current
-        multichoice current
-        note contents
-        number current
-        periodicelement current
-        string current
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: xml <subcommand> ?<arg> <arg> ...?
-# USAGE: xml object
-#
-# Used by clients to manipulate the underlying XML data for this
-# tool.  The <subcommand> can be any operation supported by a
-# Rappture::library object.  Clients can also request the XML object
-# directly by using the "object" subcommand.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::xml {args} {
-    if {"object" == $args} {
-        return $_xmlobj
-    }
-    return [eval $_xmlobj $args]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: widgetfor <path> ?<widget>?
-#
-# Used by embedded widgets such as a Controls panel to register the
-# various controls associated with this page.  That way, this
-# ControlOwner knows what widgets to look at when syncing itself
-# to the underlying XML data.
-#
-# There can only be one widget per path, since the control owner will
-# later query the widgets for current values.  If there is already an
-# existing widget registered for the <path>, then it will be deleted
-# and the new <widget> will take its place.  If the caller doesn't
-# want to replace an existing widget, it should check before calling
-# this method and make sure that the return value is "".
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::widgetfor {path args} {
-    # if this is a query operation, then look for the path
-    if {[llength $args] == 0} {
-        set owner [ownerfor $path]
-        if {$owner ne $this && $owner ne ""} {
-            return [$owner widgetfor $path]
-        }
-        if {[info exists _path2widget($path)]} {
-            return $_path2widget($path)
-        }
-        return ""
-    }
-
-    # otherwise, associate the path with the given widget
-    set widget [lindex $args 0]
-    if {$widget ne ""} {
-        # is there already a widget registered for this path?
-        if {[info exists _path2widget($path)]} {
-            # delete old widget and replace
-            set panel $_path2controls($path)
-            $panel delete $path
-            set _path2controls($path) ""
-        }
-
-        # register the new widget for the path
-        set _path2widget($path) $widget
-
-        # look up the containing panel and store it too
-        set w [winfo parent $widget]
-        while {$w ne ""} {
-            if {[string match *Controls [winfo class $w]]} {
-                set _path2controls($path) $w
-                break
-            }
-            set w [winfo parent $w]
-        }
-    } else {
-        # empty name => forget about this widget
-        catch {unset _path2widget($path)}
-        catch {unset _path2controls($path)}
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: valuefor <path> ?<newValue>?
-#
-# Used by embedded widgets such as a Loader to query or set the
-# value of another control.  With no extra args, it returns the
-# value of the widget at the <path> in the XML.  Otherwise, it
-# sets the value of the widget to <newValue>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::valuefor {path args} {
-    set owner [ownerfor $path]
-
-    # if this is a query operation, then look for the path
-    if {[llength $args] == 0} {
-        if {$owner != $this && $owner != ""} {
-            return [$owner valuefor $path]
-        }
-        if {[info exists _path2widget($path)]} {
-            return [$_path2widget($path) value]
-        }
-        # can't find the path? try removing the prefix for this owner
-        set plen [string length $_path]
-        if {[string equal -length $plen $_path $path]} {
-            set relpath [string range $path [expr {$plen+1}] end]
-            if {[info exists _path2widget($relpath)]} {
-                return [$_path2widget($relpath) value]
-            }
-        }
-        return ""
-    }
-
-    # otherwise, set the value
-    if {$owner != $this && $owner != ""} {
-        return [eval $owner valuefor $path $args]
-    }
-    if {[llength $args] > 1} {
-        error "wrong # args: should be \"valuefor path ?newValue?\""
-    }
-
-    if {[info exists _path2widget($path)]} {
-        $_path2widget($path) value [lindex $args 0]
-    } else {
-        error "bad path \"$path\": should be one of [join [lsort [array names _path2widget]] {, }]"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: dependenciesfor <path> ?<path>...?
-#
-# Used by embedded widgets such as a Controls panel to register the
-# various controls that are dependent on another one.  If only one
-# path is specified, then this method returns all known dependencies
-# for the specified <path>.  Otherwise, the additional <path>'s are
-# noted as being dependent on the first <path>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::dependenciesfor {path args} {
-    if {"" != $_owner} {
-        #
-        # Keep all dependencies at the highest level.
-        # That way, a structure can come and go, but the
-        # dependencies remain fixed in the topmost tool.
-        #
-        set plen [string length $_path]
-        if {"" != $_path && ![string equal -length $plen $_path $path]} {
-            set path $_path.$path
-        }
-        return [eval $_owner dependenciesfor $path $args]
-    }
-
-    # if this is a query operation, then look for the path
-    if {[llength $args] == 0} {
-        if {[info exists _dependencies($path)]} {
-            return $_dependencies($path)
-        }
-        return ""
-    }
-
-    # add new dependencies
-    if {![info exists _dependencies($path)]} {
-        set _dependencies($path) ""
-    }
-    foreach dpath $args {
-        set i [lsearch -exact $_dependencies($path) $dpath]
-        if {$i < 0} {
-            lappend _dependencies($path) $dpath
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ownerfor <path> ?<skip>?
-#
-# Returns the ControlOwner that directly controls the specified <path>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::ownerfor {path {skip ""}} {
-    if {[info exists _path2widget($path)]} {
-        return $this
-    }
-
-    # can't find the path? try removing the prefix for this owner
-    set plen [string length $_path]
-    if {[string equal -length $plen $_path $path]} {
-        set relpath [string range $path [expr {$plen+1}] end]
-        if {[info exists _path2widget($relpath)]} {
-            return $this
-        }
-    }
-
-    # couldn't find this path?  then check all subordinates
-    foreach slave $_slaves {
-        if {$slave == $skip} {
-            continue  ;# skip this slave if it's already been searched
-        }
-        set rval [$slave ownerfor $path $this]
-        if {"" != $rval} {
-            return $rval
-        }
-    }
-
-    # check the owner as a last resort
-    if {"" != $_owner && $_owner != $skip} {
-        set rval [$_owner ownerfor $path $this]
-        if {"" != $rval} {
-            return $rval
-        }
-    }
-
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load <xmlobj>
-#
-# Loads the contents of a Rappture <xmlobj> into the controls
-# associated with this tool.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::load {newobj} {
-    if {![Rappture::library isvalid $newobj]} {
-        error "\"$newobj\" is not a Rappture::library"
-    }
-    foreach path [array names _path2widget] {
-        # the following elements do not accept "current" tags, skip them
-        set type [[tool] xml element -as type $path]
-        if {[lsearch {group separator control} $type] >= 0} {
-            continue
-        }
-
-        set type [[tool] xml element -as type $path]
-        if {[info exists _type2curpath($type)]} {
-            if { $_type2curpath($type) == "all" } {
-                set currentpath $path
-            } else {
-                set currentpath $path.$_type2curpath($type)
-            }
-        } else {
-            # default incase i forgot an input type in _type2curpath
-            set currentpath $path.current
-        }
-
-        # copy new value to the XML tree
-        # also copy to the widget associated with the tree
-        #
-        # we only copy the values if they existed in newobj
-        # so we don't overwrite values that were set in previous loads.
-        # this is needed for when the users specify copy.from and copy.to
-        # in a loader. in this case, _path2widget holds a list of all
-        # widgets. if there are two loaders loading two different widgets,
-        # and each loader uses the copy from/to functionality,
-        # the second load could wipe out the values set in the first load
-        # because on the second load, the copied paths from the first load no
-        # longer exist in newobj and blanks are copied to the paths
-        # in [tool] xml set by the first loader. the solution is to check
-        # newobj and see if the path exists. if the path exists, then we copy
-        # it over to [tool] xml, otherwise we ignore it.
-        if {"" != [$newobj element -as type $currentpath]} {
-            [tool] xml copy $currentpath from $newobj $currentpath
-            set val [$newobj get $currentpath]
-            if {[string length $val] > 0
-                  || [llength [$newobj children $currentpath]] == 0} {
-                $_path2widget($path) value $val
-            } else {
-                set obj [$newobj element -as object $currentpath]
-                $_path2widget($path) value $obj
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: changed <path>
-#
-# Invoked automatically by the various widgets associated with this
-# tool whenever their value changes.  Sends notifications to any
-# client that has registered an interest via "notify add".
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::changed {path} {
-    if {"" != $_owner} {
-        set plen [string length $_path]
-        if {"" != $_path && ![string equal -length $plen $_path $path]} {
-            set path $_path.$path
-        }
-        $_owner changed $path
-    } else {
-        # send out any callback notifications
-        foreach owner [array names _owner2paths] {
-            foreach pattern $_owner2paths($owner) {
-                if {[string match $pattern $path]} {
-                    uplevel #0 $_callbacks($owner/$pattern)
-                    break
-                }
-            }
-        }
-
-        # find the control panel for each dependency, and tell it
-        # to update its layout.
-        foreach cpath [dependenciesfor $path] {
-            set wv [widgetfor $cpath]
-            while {"" != $wv} {
-                set wv [winfo parent $wv]
-                if {[winfo class $wv] == "Controls"} {
-                    $wv refresh
-                    break
-                }
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: regularize <path>
-#
-# Clients use this to get a full, regularized path for the specified
-# <path>, which may be relative to the current owner.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::regularize {path} {
-    set owner [ownerfor $path]
-    if {$owner != $this && $owner != ""} {
-        return [$owner regularize $path]
-    }
-    set rpath ""
-    if {"" != $_xmlobj} {
-        set rpath [$_xmlobj element -as path $path]
-
-        # can't find the path? try removing the prefix for this owner
-        if {"" == $rpath} {
-            set plen [string length $_path]
-            if {[string equal -length $plen $_path $path]} {
-                set relpath [string range $path [expr {$plen+2}] end]
-                set rpath [$_xmlobj element -as path $relpath]
-            }
-        }
-
-        if {"" != $rpath && "" != $_path} {
-            # return a full name for the path
-            set rpath "$_path.$rpath"
-        }
-    }
-    return $rpath
-}
-
-# ----------------------------------------------------------------------
-# USAGE: notify add <owner> <path> <callback>
-# USAGE: notify info ?<owner>? ?<path>?
-# USAGE: notify remove <owner> ?<path> ...?
-#
-# Clients use this to request notifications about changes to a
-# particular <path> for a control under this tool.  Whenever the
-# value associated with <path> changes, the client identified by
-# <owner> is sent a message by invoking its <callback> routine.
-#
-# Notifications can be silenced by calling the "notify remove"
-# function.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::notify {option args} {
-    switch -- $option {
-        add {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"notify add owner path callback\""
-            }
-            set owner [lindex $args 0]
-            set path [lindex $args 1]
-            set cb [lindex $args 2]
-
-            if {[info exists _owner2paths($owner)]} {
-                set plist $_owner2paths($owner)
-            } else {
-                set plist ""
-            }
-
-            set i [lsearch -exact $plist $path]
-            if {$i < 0} { lappend _owner2paths($owner) $path }
-            set _callbacks($owner/$path) $cb
-        }
-        info {
-            if {[llength $args] == 0} {
-                # no args? then return all owners
-                return [array names _owner2paths]
-            } else {
-                set owner [lindex $args 0]
-                if {[info exists _owner2paths($owner)]} {
-                    set plist $_owner2paths($owner)
-                } else {
-                    set plist ""
-                }
-                if {[llength $args] == 1} {
-                    # 1 arg? then return paths for this owner
-                    return $plist
-                } elseif {[llength $args] == 2} {
-                    # 2 args? then return callback for this path
-                    set path [lindex $args 1]
-                    if {[info exists _callbacks($owner/$path)]} {
-                        return $_callbacks($owner/$path)
-                    }
-                    return ""
-                } else {
-                    error "wrong # args: should be \"notify info ?owner? ?path?\""
-                }
-            }
-        }
-        remove {
-            if {[llength $args] < 1} {
-                error "wrong # args: should be \"notify remove owner ?path ...?\""
-            }
-            set owner [lindex $args 0]
-
-            if {[llength $args] == 1} {
-                # no args? then delete all paths for this owner
-                if {[info exists _owner2paths($owner)]} {
-                    set plist $_owner2paths($owner)
-                } else {
-                    set plist ""
-                }
-            } else {
-                set plist [lrange $args 1 end]
-            }
-
-            # forget about the callback for each path
-            foreach path $plist {
-                catch {unset _callbacks($owner/$path)}
-
-                if {[info exists _owner2paths($owner)]} {
-                    set i [lsearch -exact $_owner2paths($owner) $path]
-                    if {$i >= 0} {
-                        set _owner2paths($owner) \
-                            [lreplace $_owner2paths($owner) $i $i]
-                    }
-                }
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: sync
-#
-# Used by descendents such as a Controls panel to register the
-# various controls associated with this page.  That way, this
-# ControlOwner knows what widgets to look at when syncing itself
-# to the underlying XML data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::sync {} {
-    # sync all of the widgets under control of this owner
-    if {"" != $_xmlobj} {
-        foreach path [lsort [array names _path2widget]] {
-            set type [$_xmlobj element -as type $path]
-            if {[lsearch {group separator control note} $type] >= 0} {
-                continue
-            }
-            $_xmlobj put $path.current [$_path2widget($path) value]
-        }
-    }
-
-    # sync all subordinate slaves as well
-    foreach slave $_slaves {
-        $slave sync
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tool
-#
-# Clients use this to figure out which tool is associated with
-# this object.  If there is no parent ControlOwner, then this
-# must be the top-level tool.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::tool {} {
-    if {"" != $_owner} {
-        return [$_owner tool]
-    }
-    return $this
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _slave add <newobj>...
-#
-# Used internally to register the parent-child relationship whenever
-# one ControlOwner is registered to another.  When the parent syncs,
-# it causes all of its children to sync.  When a name is being
-# resolved, it is resolved locally first, then up to the parent for
-# further resolution.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ControlOwner::_slave {option args} {
-    switch -- $option {
-        add {
-            eval lappend _slaves $args
-        }
-        default {
-            error "bad option \"$option\": should be add"
-        }
-    }
-}
Index: trunk/gui/scripts/controls.tcl
===================================================================
--- trunk/gui/scripts/controls.tcl	(revision 6716)
+++ 	(revision )
@@ -1,949 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: controls - a container for various Rappture controls
-#
-#  This widget is a smart frame acting as a container for controls.
-#  Controls are added to this panel, and the panel itself decides
-#  how to arrange them given available space.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Controls.padding 4 widgetDefault
-option add *Controls.labelFont \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Controls {
-    inherit itk::Widget
-
-    itk_option define -layout layout Layout ""
-    itk_option define -padding padding Padding 0
-
-    constructor {owner args} { # defined below }
-    destructor { # defined below }
-
-    public method insert {pos path}
-    public method delete {first {last ""}}
-    public method index {name}
-    public method control {args}
-    public method refresh {}
-
-    protected method _layout {}
-    protected method _monitor {name state}
-    protected method _controlChanged {name}
-    protected method _controlValue {path {units ""}}
-    protected method _formatLabel {str}
-    protected method _changeTabs {{why -program}}
-    protected method _resize {}
-
-    private variable _owner ""       ;# controls belong to this owner
-    private variable _tabs ""        ;# optional tabset for groups
-    private variable _frame ""       ;# pack controls into this frame
-    private variable _counter 0      ;# counter for control names
-    private variable _dispatcher ""  ;# dispatcher for !events
-    private variable _controls ""    ;# list of known controls
-    private variable _showing ""     ;# list of enabled (showing) controls
-    private variable _name2info      ;# maps control name => info
-    private variable _scheme ""      ;# layout scheme (tabs/vert/horz/sentence)
-    private variable _sentenceparts  ;# info for layout scheme "sentence:"
-}
-
-itk::usual Controls {
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::constructor {owner args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !layout
-    $_dispatcher dispatch $this !layout "[itcl::code $this _layout]; list"
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this _resize]; list"
-
-    set _owner $owner
-
-    Rappture::Scroller $itk_interior.sc -xscrollmode none -yscrollmode auto
-    pack $itk_interior.sc -expand yes -fill both
-    set f [$itk_interior.sc contents frame]
-
-    set _tabs [blt::tabset $f.tabs -borderwidth 0 -relief flat \
-        -side top -tearoff 0 -samewidth 0 -highlightthickness 0 \
-        -selectbackground $itk_option(-background) \
-        -selectcommand [itcl::code $this _changeTabs -user]]
-    pack $_tabs -expand yes -fill both
-
-    set _frame [frame $_tabs.inner]
-    pack $_frame -expand yes -fill both
-
-    #
-    # Put this frame in whenever the control frame is empty.
-    # It forces the size to contract back now when controls are deleted.
-    #
-    frame $_frame.empty -width 1 -height 1
-
-    #
-    # Set up a binding that all inserted widgets will use so that
-    # we can monitor their size changes.
-    #
-    bind Controls-$this <Configure> \
-        [list $_dispatcher event -idle !resize]
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::destructor {} {
-    delete 0 end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: insert <pos> <path>
-#
-# Clients use this to insert a control into this panel.  The control
-# is inserted into the list at position <pos>, which can be an integer
-# starting from 0 or the keyword "end".  Information about the control
-# is taken from the specified <path>.
-#
-# Returns a name that can be used to identify the control in other
-# methods.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::insert {pos path} {
-    if {$pos ne "end" && ![string is integer $pos]} {
-        set pos [index $pos]
-    }
-
-    incr _counter
-    set name "control$_counter"
-    set path [$_owner xml element -as path $path]
-
-    set _name2info($name-path) $path
-    set _name2info($name-id) [$_owner xml element -as id $path]
-    set _name2info($name-label) ""
-    set _name2info($name-type) ""
-    set _name2info($name-value) [set w $_frame.v$name]
-    set _name2info($name-enable) "yes"
-    set _name2info($name-disablestyle) "greyout"
-
-    set type [$_owner xml element -as type $path]
-    set _name2info($name-type) $type
-    switch -- $type {
-        choice {
-            Rappture::ChoiceEntry $w $_owner $path
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        filechoice {
-            Rappture::FileChoiceEntry $w $_owner $path
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        filelist {
-            Rappture::FileListEntry $w $_owner $path
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        group {
-            Rappture::GroupEntry $w $_owner $path
-        }
-        loader {
-            Rappture::Loader $w $_owner $path -tool [$_owner tool]
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        multichoice {
-            Rappture::MultiChoiceEntry $w $_owner $path
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        number {
-            Rappture::NumberEntry $w $_owner $path
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        integer {
-            Rappture::IntegerEntry $w $_owner $path
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        boolean {
-            Rappture::BooleanEntry $w $_owner $path
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        string {
-            Rappture::TextEntry $w $_owner $path
-            bind $w <<Final>> [itcl::code $this _controlChanged $name]
-        }
-        drawing {
-            Rappture::DrawingEntry $w $_owner $path
-        }
-        map {
-            Rappture::MapEntry $w $_owner $path
-        }
-        image {
-            Rappture::ImageEntry $w $_owner $path
-        }
-        control {
-            set label [string trim [$_owner xml get $path.label]]
-            if {"" == $label} {
-                set label "Simulate"
-            }
-            set service [string trim [$_owner xml get $path.service]]
-            button $w -text $label -command [list $service run]
-        }
-        separator {
-            frame $w -class Separator -height 10
-        }
-        note {
-            Rappture::Note $w $_owner $path
-        }
-        periodicelement {
-            Rappture::PeriodicElementEntry $w $_owner $path
-            bind $w <<Value>> [itcl::code $this _controlChanged $name]
-        }
-        default {
-            error "don't know how to add control type \"$type\""
-        }
-    }
-
-    #
-    # If this element has an <enable> expression, then register
-    # its controlling widget here.
-    #
-    set disablestyle [string trim [$_owner xml get $path.about.disablestyle]]
-    if { $disablestyle != "" } {
-        set _name2info($name-disablestyle) $disablestyle
-    }
-    #
-    # If this element has an <enable> expression, then register
-    # its controlling widget here.
-    #
-    set enable [string trim [$_owner xml get $path.about.enable]]
-    if {"" == $enable} {
-        set enable yes
-    }
-    if {![string is boolean $enable]} {
-        set re {([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\))(\.([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\)))*(:[-a-zA-Z0-9/]+)?}
-        set rest $enable
-        set enable ""
-        set deps ""
-        while {1} {
-            if {[regexp -indices $re $rest match]} {
-                foreach {s0 s1} $match break
-
-                if {[string index $rest [expr {$s0-1}]] == "\""} {
-                    # string in ""'s? then leave it alone
-                    append enable [string range $rest 0 [expr {$s0-1}]]
-                    set rest [string range $rest $s0 end]
-                    if {[regexp -indices {[^\"]+\"} $rest match]} {
-                        foreach {s0 s1} $match break
-                        append enable [string range $rest $s0 $s1]
-                        set rest [string range $rest [expr {$s1+1}] end]
-                    } else {
-                        puts stderr "WARNING: mismatched quote in enable condition for $path"
-                        puts stderr "   expr: [string trim [$_owner xml get $path.about.enable]]"
-                        set rest ""
-                    }
-                } else {
-                    #
-                    # This is a symbol which should be substituted
-                    # it can be either:
-                    #   input.foo.bar
-                    #   input.foo.bar:units
-                    #
-                    set cpath [string range $rest $s0 $s1]
-                    set parts [split $cpath :]
-                    set ccpath [lindex $parts 0]
-                    set units [lindex $parts 1]
-
-                    # make sure we have the standard path notation
-                    set stdpath [$_owner regularize $ccpath]
-                    if {"" == $stdpath} {
-                        puts stderr "WARNING: don't recognize parameter $cpath in <enable> expression for $path.  This may be buried in a structure that is not yet loaded."
-                        set stdpath $ccpath
-                    }
-                    # substitute [_controlValue ...] call in place of path
-                    append enable [string range $rest 0 [expr {$s0-1}]]
-                    append enable [format {[_controlValue %s %s]} $stdpath $units]
-                    lappend deps $stdpath
-                    set rest [string range $rest [expr {$s1+1}] end]
-                }
-            } else {
-                append enable $rest
-                break
-            }
-        }
-
-        foreach cpath $deps {
-            $_owner dependenciesfor $cpath $path
-        }
-    }
-    set _name2info($name-enable) $enable
-    $_owner widgetfor $path $w
-
-    if {[lsearch {control group drawing map separator note} $type] < 0} {
-        # make a label for this control
-        set label [$w label]
-        if {$label ne ""} {
-            set _name2info($name-label) $_frame.l$name
-            set font [option get $itk_component(hull) labelFont Font]
-            label $_name2info($name-label) -text [_formatLabel $label] \
-                -font $font
-        }
-
-        # register the tooltip for this control
-        set tip [$w tooltip]
-        if {$tip ne ""} {
-            Rappture::Tooltip::for $w $tip -log $path
-
-            # add the tooltip to the label too, if there is one
-            if {$_name2info($name-label) ne ""} {
-                Rappture::Tooltip::for $_name2info($name-label) $tip -log $path
-            }
-        }
-    }
-
-    # insert the new control onto the known list
-    set _controls [linsert $_controls $pos $name]
-    _monitor $name on
-
-    # now that we have a new control, we should fix the layout
-    $_dispatcher event -idle !layout
-    _controlChanged $name
-
-    return $name
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete <first> ?<last>?
-#
-# Clients use this to delete one or more controls from this widget.
-# The <first> and <last> represent the integer index of the desired
-# control.  You can use the "index" method to convert a control name to
-# its integer index.  If only <first> is specified, then that one
-# control is deleted.  If <last> is specified, then all controls in the
-# range <first> to <last> are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::delete {first {last ""}} {
-    if {$last == ""} {
-        set last $first
-    }
-    if {![string is integer $first]} {
-        set first [index $first]
-    }
-    if {![string is integer $last]} {
-        set last [index $last]
-    }
-
-    foreach name [lrange $_controls $first $last] {
-        _monitor $name off
-
-        if {"" != $_name2info($name-label)} {
-            destroy $_name2info($name-label)
-        }
-        if {"" != $_name2info($name-value)} {
-            destroy $_name2info($name-value)
-        }
-        $_owner widgetfor $_name2info($name-path) ""
-        array unset _name2info $name-*
-    }
-    set _controls [lreplace $_controls $first $last]
-
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# USAGE: index <name>|<path>|@n|end
-#
-# Clients use this to convert a control <name> into its corresponding
-# integer index.  Returns an error if the <name> is not recognized.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::index {val} {
-    set i [lsearch $_controls $val]
-    if {$i >= 0} {
-        return $i
-    }
-    if {[regexp {^@([0-9]+)$} $val match i]} {
-        return $i
-    }
-    if {$val eq "end"} {
-        return [expr {[llength $_controls]-1}]
-    }
-
-    # treat as a path name and search for this path
-    foreach name $_controls {
-        if {$_name2info($name-path) eq $val} {
-            set i [lsearch $_controls $name]
-            if {$i >= 0} {
-                return $i
-            }
-        }
-    }
-
-    error "bad control name \"$name\": should be @int or \"end\" or path name or one of [join [lsort $_controls] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: control ?-label|-value|-path|-enable? ?<name>|@n?
-#
-# Clients use this to get information about controls.  With no args, it
-# returns a list of all control names.  Otherwise, it returns the frame
-# associated with a control name.  The -label option requests the label
-# widget instead of the value widget.  The -path option requests the
-# path within the XML that the control affects.  The -enable option
-# requests the enabling condition for this control.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::control {args} {
-    if {[llength $args] == 0} {
-        return $_controls
-    }
-    Rappture::getopts args params {
-        flag switch -value default
-        flag switch -label
-        flag switch -path
-        flag switch -enable
-        flag switch -disablestyle
-    }
-    if {[llength $args] == 0} {
-        error "missing control name"
-    }
-    set i [index [lindex $args 0]]
-    set name [lindex $_controls $i]
-
-    set opt $params(switch)
-    return $_name2info($name$opt)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: refresh
-#
-# Clients use this to refresh the layout of the control panel
-# whenever a widget within the panel changes visibility state.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::refresh {} {
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _layout
-#
-# Used internally to fix the layout of controls whenever controls
-# are added or deleted, or when the control arrangement changes.
-# There are a lot of heuristics here trying to achieve a "good"
-# arrangement of controls.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::_layout {} {
-    #
-    # Clear any existing layout
-    #
-    foreach {rmax cmax} [grid size $_frame] break
-    for {set r 0} {$r < $rmax} {incr r} {
-        grid rowconfigure $_frame $r -weight 0 -minsize 0
-    }
-    grid rowconfigure $_frame 99 -weight 0
-
-    for {set c 0} {$c < $cmax} {incr c} {
-        grid columnconfigure $_frame $c -weight 0 -minsize 0
-    }
-
-    foreach name $_controls {
-        foreach elem {label value} {
-            set w $_name2info($name-$elem)
-            if {$w ne "" && [winfo exists $w]} {
-                grid forget $w
-            }
-        }
-    }
-    grid forget $_frame.empty
-
-    if {[$_tabs size] > 0} {
-        $_tabs delete 0 end
-    }
-
-    #
-    # Decide which widgets should be shown and which should be hidden.
-    #
-    set hidden ""
-    set showing ""
-    foreach name $_controls {
-        set show 1
-        set cond $_name2info($name-enable)
-        if {[string is boolean $cond] && !$cond} {
-            # hard-coded "off" -- ignore completely
-
-            # When the "enable" of a control is hardcoded "off", "0", etc., it
-            # means to hide the control. This is used by bandstrlab to add
-            # invisible parameters to a structure.  The value of the parameter
-            # is used by other widgets with enable statements.
-
-            # The proper method for doing this is to add a
-            #   <disablestyle>hide<disablestyle>
-            # tag to the about section of the control.
-
-        } elseif {[catch {expr $cond} show] == 0} {
-            set type $_name2info($name-type)
-            set disablestyle $_name2info($name-disablestyle)
-            set lwidget $_name2info($name-label)
-            set vwidget $_name2info($name-value)
-            if {[lsearch -exact {group image structure} $type] >= 0 ||
-                $disablestyle == "hide" } {
-                if {$show ne "" && $show} {
-                    lappend showing $name
-                } else {
-                    lappend hidden $name
-                }
-            } else {
-                # show other objects, but enable/disable them
-                lappend showing $name
-                if {$show ne "" && $show} {
-                    catch {$vwidget configure -state normal}
-                    if {[winfo exists $lwidget]} {
-                        $lwidget configure -foreground \
-                            [lindex [$lwidget configure -foreground] 3]
-                    }
-                } else {
-                    catch {$vwidget configure -state disabled}
-                    if {[winfo exists $lwidget]} {
-                        $lwidget configure -foreground gray
-                    }
-                }
-            }
-        } else {
-            bgerror "Error in <enable> expression for \"$_name2info($name-path)\":\n  $show"
-        }
-    }
-
-    # store the showing tabs in the object so it can be used in _changeTabs
-    set _showing $showing
-
-    #
-    # Decide on a layout scheme:
-    #   default ...... tabs for groups of groups; vertical otherwise
-    #   tabs ......... tabbed notebook
-    #   vertical ..... "label: value" down in rows
-    #   horizontal ... "label: value" across columns
-    #   sentence ..... text with embedded widgets
-    #
-    set _scheme $itk_option(-layout)
-    if {$_scheme eq "" || $_scheme eq "tabs"} {
-        if {[llength $showing] < 2} {
-            set _scheme "vertical"
-        } else {
-            set _scheme "tabs"
-            foreach name $showing {
-                set w $_name2info($name-value)
-                if {[winfo class $w] ne "GroupEntry"} {
-                    # something other than a group? then fall back on vertical
-                    set _scheme "vertical"
-                    break
-                }
-            }
-        }
-    }
-
-    # if the layout is "sentence:..." then create new parts
-    if {[string match {sentence:*} $itk_option(-layout)]
-        && [array size _sentenceparts] == 0} {
-        set n 0
-        set font [option get $itk_component(hull) labelFont Font]
-        set str [string range $itk_option(-layout) 9 end]
-        while {[regexp -indices {\$\{([a-zA-Z0-9_]+)\}} $str match name]} {
-            foreach {s0 s1} $name break
-            set name [string range $str $s0 $s1]
-
-            # create a label for the string before the substitution
-            foreach {s0 s1} $match break
-            set prefix [string trim [string range $str 0 [expr {$s0-1}]]]
-            if {$prefix ne ""} {
-                set lname $_frame.sentence[incr n]
-                label $lname -text $prefix -font $font
-                lappend _sentenceparts(all) $lname
-                lappend _sentenceparts(fragments) $lname
-            }
-
-            # add the widget for the substitution part
-            set found ""
-            foreach c $_controls {
-                if {$_name2info($c-id) eq $name} {
-                    set found $c
-                    break
-                }
-            }
-            if {$found ne ""} {
-                lappend _sentenceparts(all) $_name2info($found-value)
-            } else {
-                puts stderr "WARNING: name \"$name\" in sentence layout \"$itk_option(-layout)\" not recognized"
-            }
-
-            set str [string range $str [expr {$s1+1}] end]
-        }
-
-        # create a label for any trailing string
-        set str [string trim $str]
-        if {$str ne ""} {
-            set lname $_frame.sentence[incr n]
-            label $lname -text $str -font $font
-            lappend _sentenceparts(all) $lname
-            lappend _sentenceparts(fragments) $lname
-        }
-    }
-
-    switch -glob -- $_scheme {
-        tabs {
-            #
-            # SCHEME: tabs
-            # put a series of groups into a tabbed notebook
-            #
-
-            # stop covering up the tabset and put the _frame inside the tabs
-            pack forget $_frame
-            $_tabs configure -width 0 -height 0
-
-            set gn 1
-            foreach name $showing {
-                set wv $_name2info($name-value)
-                $wv configure -heading no
-                set label [$wv component heading cget -text]
-                if {"" == $label} {
-                    set label "Group #$gn"
-                }
-                set _name2info($name-label) $label
-                $_tabs insert end $name -text $label \
-                    -activebackground $itk_option(-background) \
-                    -window $_frame -fill both
-                incr gn
-            }
-
-            # compute the overall size
-            # BE CAREFUL: do this after setting "-heading no" above
-            $_dispatcher event -now !resize
-
-            grid columnconfigure $_frame 0 -weight 1
-            grid rowconfigure $_frame 0 -weight 1
-
-            $_tabs select 0; _changeTabs
-        }
-
-        vertical {
-            #
-            # SCHEME: vertical
-            # simple "Label: Value" layout
-            #
-            if {[$_tabs size] > 0} {
-                $_tabs delete 0 end
-            }
-            pack $_frame -expand yes -fill both
-            $_tabs configure -width [winfo reqwidth $_frame] \
-                -height [winfo reqheight $_frame]
-
-            set expand 0  ;# most controls float to top
-            set row 0
-            foreach name $showing {
-                set wl $_name2info($name-label)
-                if {$wl != "" && [winfo exists $wl]} {
-                    grid $wl -row $row -column 0 -sticky e
-                }
-
-                set wv $_name2info($name-value)
-                if {$wv ne "" && [winfo exists $wv]} {
-                    if {$wl != ""} {
-                        grid $wv -row $row -column 1 -sticky ew
-                    } else {
-                        grid $wv -row $row -column 0 -columnspan 2 -sticky ew
-                    }
-
-                    grid rowconfigure $_frame $row -weight 0
-
-                    switch -- [winfo class $wv] {
-                        TextEntry {
-                            if {[regexp {[0-9]+x[0-9]+} [$wv size]]} {
-                                grid $wl -sticky ne -pady 4
-                                grid $wv -sticky nsew
-                                grid rowconfigure $_frame $row -weight 1
-                                grid columnconfigure $_frame 1 -weight 1
-                                set expand 1
-                            }
-                        }
-                        GroupEntry {
-                            $wv configure -heading yes
-
-                            #
-                            # Scan through all children in this group
-                            # and see if any demand more space.  If the
-                            # group contains a structure or a note, then
-                            # make sure that the group itself is set to
-                            # expand/fill.
-                            #
-                            set queue [winfo children $wv]
-                            set expandgroup 0
-                            while {[llength $queue] > 0} {
-                                set w [lindex $queue 0]
-                                set queue [lrange $queue 1 end]
-                                set c [winfo class $w]
-                                if {[lsearch {DeviceEditor Note} $c] >= 0} {
-                                    set expandgroup 1
-                                    break
-                                }
-                                eval lappend queue [winfo children $w]
-                            }
-                            if {$expandgroup} {
-                                set expand 1
-                                grid $wv -sticky nsew
-                                grid rowconfigure $_frame $row -weight 1
-                            }
-                        }
-                        Note {
-                            grid $wv -sticky nsew
-                            grid rowconfigure $_frame $row -weight 1
-                            set expand 1
-                        }
-                    }
-                    grid columnconfigure $_frame 1 -weight 1
-                }
-
-                incr row
-                grid rowconfigure $_frame $row -minsize $itk_option(-padding)
-                incr row
-            }
-            grid $_frame.empty -row $row
-
-            #
-            # If there are any hidden items, then make the bottom of
-            # this form fill up any extra space, so the form floats
-            # to the top.  Otherwise, it will jitter around as the
-            # hidden items come and go.
-            #
-            if {[llength $hidden] > 0 && !$expand} {
-                grid rowconfigure $_frame 99 -weight 1
-            } else {
-                grid rowconfigure $_frame 99 -weight 0
-            }
-        }
-
-        horizontal {
-            #
-            # SCHEME: horizontal
-            # lay out left to right
-            #
-            if {[$_tabs size] > 0} {
-                $_tabs delete 0 end
-            }
-            pack $_frame -expand yes -fill both
-            $_tabs configure -width [winfo reqwidth $_frame] \
-                -height [winfo reqheight $_frame]
-
-            set col 0
-            set pad [expr {$itk_option(-padding)/2}]
-            foreach name $showing {
-                set wl $_name2info($name-label)
-                if {$wl != "" && [winfo exists $wl]} {
-                    grid $wl -row 0 -column $col -sticky e -padx $pad
-                    incr col
-                }
-
-                set wv $_name2info($name-value)
-                if {$wv != "" && [winfo exists $wv]} {
-                    grid $wv -row 0 -column $col -sticky ew -padx $pad
-                    grid columnconfigure $_frame $col -weight 0
-                    incr col
-                }
-            }
-        }
-
-        sentence:* {
-            #
-            # SCHEME: sentence
-            # lay out left to right with sentence parts: "( [x] , [y] )"
-            #
-            if {[$_tabs size] > 0} {
-                $_tabs delete 0 end
-            }
-            pack $_frame -expand yes -fill both
-            $_tabs configure -width [winfo reqwidth $_frame] \
-                -height [winfo reqheight $_frame]
-
-            set col 0
-            set pad [expr {$itk_option(-padding)/2}]
-            foreach widget $_sentenceparts(all) {
-                grid $widget -row 0 -column $col -padx $pad
-                incr col
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _monitor <name> <state>
-#
-# Used internally to add/remove bindings that cause the widget
-# associated with <name> to notify this controls widget of size
-# changes.  Whenever there is a size change, this controls widget
-# should fix its layout.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::_monitor {name state} {
-    set tag "Controls-$this"
-    set wv $_name2info($name-value)
-    if {[catch {bindtags $wv} btags]} {
-        return
-    }
-    set i [lsearch $btags $tag]
-
-    if {$state} {
-        if {$i < 0} {
-            bindtags $wv [linsert $btags 0 $tag]
-        }
-    } else {
-        if {$i >= 0} {
-            bindtags $wv [lreplace $btags $i $i]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _controlChanged <name>
-#
-# Invoked automatically whenever the value for a control changes.
-# Sends a notification along to the tool controlling this panel.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::_controlChanged {name} {
-    set path $_name2info($name-path)
-
-    #
-    # Let the owner know that this control changed.
-    #
-    if {"" != $_owner} {
-        $_owner changed $path
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _controlValue <path> ?<units>?
-#
-# Used internally to get the value of a control with the specified
-# <path>.  Returns the current value for the control.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::_controlValue {path {units ""}} {
-    if {"" != $_owner} {
-        set val [$_owner valuefor $path]
-        if {"" != $units} {
-            set val [Rappture::Units::convert $val -to $units -units off]
-        }
-        return $val
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _formatLabel <string>
-#
-# Used internally to format a label <string>.  Trims any excess
-# white space and adds a ":" to the end.  That way, all labels
-# have a uniform look.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::_formatLabel {str} {
-    set str [string trim $str]
-    if {"" != $str && [string index $str end] != ":"} {
-        append str ":"
-    }
-    return $str
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _changeTabs ?-user|-program?
-#
-# Used internally to change tabs when the user clicks on a tab
-# in the "tabs" layout mode.  This mode is used when the widget
-# contains nothing but groups, as a compact way of representing
-# the groups.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::_changeTabs {{why -program}} {
-    set i [$_tabs index select]
-    # we use _showing here instead of _controls because sometimes tabs
-    # are disabled, and the index of the choosen tab always matches
-    # _showing, even if tabs are disabled.
-    set name [lindex $_showing $i]
-    if {$name ne ""} {
-        foreach w [grid slaves $_frame] {
-            grid forget $w
-        }
-
-        set wv $_name2info($name-value)
-        grid $wv -row 0 -column 0 -sticky nsew
-
-        $_tabs tab configure [$_tabs get $i] -window $_frame
-
-        if {$why eq "-user"} {
-            Rappture::Logger::log group $_name2info($name-path)
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _resize
-#
-# Used internally to resize the widget when its contents change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Controls::_resize {} {
-    switch -glob -- $_scheme {
-        tabs {
-            # in "tabs" mode, the overall size is the largest for all pages
-            set maxw 0
-            set maxh 0
-            update idletasks
-            foreach name $_controls {
-                set wv $_name2info($name-value)
-                set w [winfo reqwidth $wv]
-                if {$w > $maxw} { set maxw $w }
-                set h [winfo reqheight $wv]
-                if {$h > $maxh} { set maxh $h }
-            }
-
-            # Turn off propagation temporarily so that we don't keep
-            # recursing back into this routine when we change the frame's
-            # dimensions below.
-            grid propagate $_frame no
-
-            $_frame configure -width $maxw -height $maxh
-
-            # Turn progagation back on so that the parent widget recognizes
-            # when the widget changes size or is unpacked.
-            grid propagate $_frame yes
-        }
-        vertical - horizontal - sentence* {
-            # in other modes, just use normal size propagation
-            grid propagate $_frame yes
-        }
-        default {
-            error "bad layout scheme \"$_scheme\""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -padding
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Controls::padding {
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -layout
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Controls::layout {
-    # clear any existing sentence parts
-    if {[array size _sentenceparts] > 0} {
-        foreach part $_sentenceparts(fragments) {
-            destroy $part
-        }
-        catch {unset _sentenceparts}
-    }
-
-    if {![regexp {^(|horizontal|vertical|tabs|sentence:.+)$} $itk_option(-layout)]} {
-        puts "ERROR: bad layout option \"$itk_option(-layout)\" -- should be horizontal, vertical, tabs or sentence:..."
-        set itk_option(-layout) ""
-    }
-
-    # recompute the layout at some point
-    $_dispatcher event -idle !layout
-}
Index: trunk/gui/scripts/coverflow.tcl
===================================================================
--- trunk/gui/scripts/coverflow.tcl	(revision 6716)
+++ 	(revision )
@@ -1,624 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Coverflow - browse through a series of images
-#
-#  This widget works like the coverflow browser on iOS.  It presents
-#  a series of images with one in the center and others off to the
-#  sides.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Coverflow.width 5i widgetDefault
-option add *Coverflow.height 2i widgetDefault
-option add *Coverflow.background black widgetDefault
-option add *Coverflow.padding 20 widgetDefault
-option add *Coverflow.spacing 40 widgetDefault
-option add *Coverflow.font {Helvetica 10} widgetDefault
-option add *Coverflow.fontColor white widgetDefault
-
-itcl::class Rappture::Coverflow {
-    inherit itk::Widget
-
-    itk_option define -selectcommand selectCommand SelectCommand ""
-    itk_option define -padding padding Padding 0
-    itk_option define -spacing spacing Spacing 0
-    itk_option define -font font Font ""
-    itk_option define -fontcolor fontColor Foreground ""
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method insert {where args}
-    public method itemconfigure {index args}
-    public method delete {args}
-    public method get {index args}
-    public method size {}
-    public method select {index args}
-
-    private method _itemForIndex {index}
-    private method _redraw {args}
-    private method _rescale {tid height}
-    private method _event {type x y}
-
-    private variable _dispatcher ""  ;# dispatcher for !events
-    private variable _tweener ""     ;# used for animations
-    private variable _items ""       ;# list of tag names for items
-    private variable _data           ;# data for coverflow items
-    private variable _counter 0      ;# for generating unique item IDs
-    private variable _current ""     ;# currently selected item
-    private variable _click ""       ;# click point from last _event call
-}
-
-itk::usual Rappture::Coverflow {
-    keep -background -cursor
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::constructor {args} {
-    itk_option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    # create a dispatcher for events
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !redraw
-    $_dispatcher dispatch $this !redraw [itcl::code $this _redraw]
-
-    # create a tweener for animations
-    set _tweener [Rappture::Tweener ::#auto -duration 300 \
-        -command [list $_dispatcher event -idle !redraw -position %v] \
-        -finalize [list $_dispatcher event -idle !redraw]]
-
-    itk_component add area {
-        canvas $itk_interior.area
-    } {
-        keep -background -borderwidth -relief
-    }
-    pack $itk_component(area) -side left -expand yes -fill both
-
-    bind $itk_component(area) <Configure> \
-        [list $_dispatcher event -idle !redraw]
-
-    bind $itk_component(area) <ButtonPress> \
-        [itcl::code $this _event click %x %y]
-    bind $itk_component(area) <B1-Motion> \
-        [itcl::code $this _event drag %x %y]
-    bind $itk_component(area) <ButtonRelease> \
-        [itcl::code $this _event release %x %y]
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::destructor {} {
-    itcl::delete object $_tweener
-}
-
-# ----------------------------------------------------------------------
-# USAGE: insert <index> <image> ?-option <value>...?
-#
-# Inserts a new image into the coverflow at the position <index>, which
-# is an integer starting from 0 at the left, or the keyword "end" for
-# the right.  The remaining arguments are configuration options:
-#
-#   -tag ....... unique tag name for this item
-#   -text ...... text displayed beneath the image when selected
-#   -data ...... data sent to the callback command
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::insert {where imh args} {
-    array set params $args
-    if {[info exists params(-tag)]} {
-        set tid $params(-tag)
-        unset params(-tag)
-    } else {
-        set tid "item[incr _counter]"
-    }
-
-    if {[info exists _data($tid-text)]} {
-        error "item \"$tid\" already exists -- tags must be unique"
-    }
-    set _items [linsert $_items $where $tid]
-    set _data($tid-image) $imh
-    set _data($tid-scaled) [image create photo]
-    set _data($tid-lastupdate) ""
-    set _data($tid-text) ""
-    set _data($tid-data) ""
-
-    eval itemconfigure $tid [array get params]
-
-    if {$_current eq ""} {
-        select $tid
-    }
-
-    # return the tag name for this new item
-    return $tid
-}
-
-# ----------------------------------------------------------------------
-# USAGE: itemconfigure <indexOrTag> -option <value> ...
-#
-# Used to modify an existing item.  The <indexOrTag> can be an integer
-# index for the item or a -tag name given when the item was created.
-# The remaining -option/value pairs are used to modify the values
-# associated with the item.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::itemconfigure {index args} {
-    set n [_itemForIndex $index]
-    if {$n eq ""} {
-        error "bad index \"$index\": should be integer or -tag name"
-    }
-    set tid [lindex $_items $n]
-
-    # store the new data and then redraw
-    foreach {key val} $args {
-        if {[info exists _data($tid$key)]} {
-            set _data($tid$key) $val
-
-            # make sure we redraw the flow at some point
-            $_dispatcher event -idle !redraw
-        } else {
-            error "bad option \"$key\": should be -text, -data"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<indexOrTag> <indexOrTag>...?
-# USAGE: delete all
-#
-# Deletes one or more entries from this listbox.  With the "all"
-# keyword, it deletes all entries in the listbox.  Otherwise, it
-# deletes one or more entries as specified.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::delete {args} {
-    if {$args eq "all"} {
-        set args $_items
-    }
-    foreach index $args {
-        set n [_itemForIndex $index]
-        if {$n ne ""} {
-            set tid [lindex $_items $n]
-            set _items [lreplace $_items $n $n]
-
-            image delete $_data($tid-scaled)
-            unset _data($tid-image)
-            unset _data($tid-scaled)
-            unset _data($tid-lastupdate)
-            unset _data($tid-text)
-            unset _data($tid-data)
-
-            # if this item was selected, then clear that
-            if {$tid eq $_current} {
-                if {$n < [llength $_items]} {
-                    set _current [lindex $_items $n]
-                } else {
-                    set _current [lindex $_items end]
-                }
-            }
-
-            # make sure we redraw the list at some point
-            $_dispatcher event -idle !redraw
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get <indexOrTag> ?-option -option...?
-#
-# Used to query information about an item.  With no extra args, it
-# returns the tag with an entry, or "" if the entry is not recognized.
-# If additional -option values are specified, then data values are
-# returned for the requested options.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::get {index args} {
-    set n [_itemForIndex $index]
-    if {$n eq ""} {
-        return ""
-    }
-    if {[llength $args] == 0} {
-        return [lindex $_items $n]
-    }
-
-    set vlist ""
-    foreach option $args {
-        if {[info exists _data($tid$option)]} {
-            lappend vlist $_data($tid$option)
-        } else {
-            error "invalid option \"$option\""
-        }
-    }
-    return $vlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: size
-#
-# Returns the number of items in the listbox.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::size {} {
-    return [llength $_items]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: select <indexOrTag> ?-animate on|off?
-#
-# Makes the given item the "current" item in the coverflow.  This is
-# the item that is shown front-and-center.  If this was not already
-# the current item, then the -selectcommand is invoked with information
-# related to the selected item.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::select {index args} {
-    set n [_itemForIndex $index]
-    if {$n eq ""} {
-        error "bad index \"$index\": should be integer or -tag name"
-    }
-    set tid [lindex $_items $n]
-    if {$tid eq ""} {
-        error "bad index \"$index\": index out of range"
-    }
-
-    set animate on
-    array set params $args
-    if {[info exists params(-animate)]} {
-        set animate $params(-animate)
-    }
-
-    if {$_current ne $tid} {
-        set from [lsearch -exact $_items $_current]
-        set _current $tid
-
-        # invoke the callback to react to this selection
-        if {$itk_option(-selectcommand) ne ""} {
-            set arglist $_data($tid-image)
-            foreach opt {-text -data} {
-                lappend arglist $opt $_data($tid$opt)
-            }
-            uplevel #0 $itk_option(-selectcommand) $arglist
-        }
-
-        # animate the motion and redraw the current choice
-        if {$from >= 0 && $animate} {
-            $_tweener configure -from $from -to $n
-            $_tweener go -restart
-        } else {
-            $_dispatcher event -idle !redraw
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _itemForIndex <indexOrTag>
-#
-# Converts the given <indexOrTag> to a valid entry name.  If the
-# <indexOrTag> is an integer, then it is interpreted as an index
-# in the range 0 to the size of the list.  Otherwise, it is treated
-# as a -tag name that may have been used when creating the item.
-#
-# Returns an integer index or "" if the item is not recognized.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::_itemForIndex {index} {
-    if {[string is integer -strict $index]} {
-        return $index
-    }
-    if {$index eq "end"} {
-        return [llength $_items]
-    }
-    set n [lsearch -exact $_items $index]
-    if {$n >= 0} {
-        return $n
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw ?-position <float>?
-#
-# Used internally to redraw all items in the list after it has changed.
-# With no args, it draws the current state with the selected image
-# shown in the middle.  The -position specifies an index, but perhaps
-# with a fractional part.  An index like 2.3 is drawn with the center
-# between images 2 and 3 -- about 1/3 of the way through the animation.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::_redraw {args} {
-    set c $itk_component(area)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    $c delete all
-
-    if {$w == 1 && $h == 1} {
-        # just starting up -- forget it
-        return
-    }
-
-    # get the desired position from the args or the current position
-    set pos [lsearch $_items $_current]
-
-    array set params $args
-    if {[info exists params(-position)]} {
-        set pos $params(-position)
-    }
-
-    if {$pos < 0} { set pos 0 }
-    if {$pos >= [llength $_items]-1} { set pos [expr {[llength $_items]-1}] }
-
-    # does any image have text?  if so, make room for it along the bottom
-    set textht 0
-    foreach tid $_items {
-        if {$_data($tid-text) ne ""} {
-            set textht [font metrics $itk_option(-font) -linespace]
-            break
-        }
-    }
-
-    # figure out the height of the covers and their midpoint
-    set ih [expr {$h-2*$itk_option(-padding)-$textht}]
-    set y0 [expr {($h-$textht)/2}]
-
-    #
-    # If the position is an integer, then that image is centered
-    # in the current view.  Otherwise, we're between two images.
-    #
-    set xmid [expr {$w/2}]
-    set spacing $itk_option(-spacing)
-    set shadow 0.8
-    set shorten 0.8
-    set len 0.3
-
-    if {abs($pos-round($pos)) < 0.05} {
-        # one image right in the middle
-        set lpos [expr {round($pos)}]
-        set rpos $lpos
-
-        # find the x-coord for the left/right sides of that image
-        set tid [lindex $_items $lpos]
-        set origw [image width $_data($tid-image)]
-        set origh [image height $_data($tid-image)]
-        set iw [expr {$ih*$origw/$origh}]
-        set lx [expr {$xmid-$iw/2}]
-        set rx [expr {$xmid+$iw/2}]
-    } else {
-        # between images -- pos and pos+1
-        set lpos [expr {round(floor($pos))}]
-        set rpos [expr {$lpos+1}]
-
-        set llen [expr {$len + (1-$len)*($rpos-$pos)}]
-        set lside [expr {$shorten + (1-$shorten)*($rpos-$pos)}]
-        set lshadow [expr {$shadow*($pos-$lpos)}]
-        set rlen [expr {$len + (1-$len)*($pos-$lpos)}]
-        set rside [expr {$shorten + (1-$shorten)*($pos-$lpos)}]
-        set rshadow [expr {$shadow*($rpos-$pos)}]
-
-        # find the x-coord for the left/right sides of the two images
-        set tid [lindex $_items $lpos]
-        set origw [image width $_data($tid-image)]
-        set origh [image height $_data($tid-image)]
-        set iw0 [expr {$ih*$origw/$origh}]
-        set lx0 [expr {$xmid-$iw0/2}]
-        set rx0 [expr {$xmid+$iw0/2}]
-
-        set tid [lindex $_items $rpos]
-        set origw [image width $_data($tid-image)]
-        set origh [image height $_data($tid-image)]
-        set iw1 [expr {$ih*$origw/$origh}]
-        set lx1 [expr {$xmid-$iw1/2}]
-        set rx1 [expr {$xmid+$iw1/2}]
-
-        set lx [expr {($lx1-$lx0+$spacing)*($rpos-$pos) + $lx0-$spacing}]
-        set rx [expr {($rx1-$rx0-$spacing)*($pos-$lpos) + $rx0+$spacing}]
-    }
-
-    # scan through all images and update their scaling
-    # use -lastupdate to avoid scaling if we're in the same state
-    for {set i 0} {$i < [llength $_items]} {incr i} {
-        set tid [lindex $_items $i]
-        if {$i < $lpos} {
-            set state "left $ih"
-            if {$_data($tid-lastupdate) ne $state} {
-                _rescale $tid $ih
-                squeezer -side right -shadow $shadow -shorten $len \
-                    $_data($tid-scaled) $_data($tid-scaled)
-                set _data($tid-lastupdate) $state
-            }
-        } elseif {$i > $rpos} {
-            set state "right $ih"
-            if {$_data($tid-lastupdate) ne $state} {
-                _rescale $tid $ih
-                squeezer -side left -shadow $shadow -shorten $len \
-                    $_data($tid-scaled) $_data($tid-scaled)
-                set _data($tid-lastupdate) $state
-            }
-        } elseif {$i == $lpos && $i == $rpos} {
-            set state "center $ih"
-            if {$_data($tid-lastupdate) ne $state} {
-                _rescale $tid $ih
-                set _data($tid-lastupdate) $state
-            }
-        } elseif {$i == $lpos} {
-            set state "left $ih ~ $llen"
-            if {$_data($tid-lastupdate) ne $state} {
-                _rescale $tid $ih
-                squeezer -side right -shadow $lshadow -shorten $llen \
-                    -amount $lside $_data($tid-scaled) $_data($tid-scaled)
-                set _data($tid-lastupdate) $state
-            }
-        } elseif {$i == $rpos} {
-            set state "right $ih ~ $rlen"
-            if {$_data($tid-lastupdate) ne $state} {
-                _rescale $tid $ih
-                squeezer -side left -shadow $rshadow -shorten $rlen \
-                    -amount $rside $_data($tid-scaled) $_data($tid-scaled)
-                set _data($tid-lastupdate) $state
-            }
-        }
-    }
-
-    #
-    # Figure out the positions of the various images to the left,
-    # to the right, and in the middle.  Build up a list of items
-    # to draw.
-    #
-    set tiles ""
-
-    # start at left and lay down tiles toward the middle
-    set numOnLeft [expr {round(floor($lx/$spacing))+1}]
-    set i [expr {$lpos-$numOnLeft}]
-    if {$i < 0} { set i 0 }
-    set x0 [expr {$lx - ($lpos-$i)*$spacing}]
-    while {$i < $lpos} {
-        lappend tiles $i $x0 w
-        set x0 [expr {$x0+$spacing}]
-        incr i
-    }
-
-    # start at right and lay down tiles toward the middle
-    set numOnRight [expr {round(floor(($w-$rx)/$spacing))+1}]
-    set i [expr {$rpos+$numOnRight}]
-    if {$i >= [llength $_items]} { set i [expr {[llength $_items]-1}] }
-    set x0 [expr {$rx + ($i-$rpos)*$spacing}]
-    while {$i > $rpos} {
-        lappend tiles $i $x0 e
-        set x0 [expr {$x0-$spacing}]
-        incr i -1
-    }
-
-    # lay down the center image or images
-    if {$lpos == $rpos} {
-        # just one image in the middle
-        lappend tiles $lpos $xmid c
-    } else {
-        # two tiles in a transition
-        if {$llen > $rlen} {
-            lappend tiles $rpos $rx e $lpos $lx w
-        } else {
-            lappend tiles $lpos $lx w $rpos $rx e
-        }
-    }
-
-    # run through the list and draw all items
-    foreach {i x anchor} $tiles {
-        set tid [lindex $_items $i]
-        $c create image $x $y0 -anchor $anchor \
-            -image $_data($tid-scaled) -tags "item$i"
-    }
-
-    # if there is a single center image, show its text
-    if {$lpos == $rpos} {
-        set tid [lindex $_items $lpos]
-        if {$_data($tid-text) ne ""} {
-            $c create text $xmid [expr {$h-$itk_option(-padding)/2}] \
-                -anchor s -text $_data($tid-text) \
-                -font $itk_option(-font) -fill $itk_option(-fontcolor)
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _rescale <tid> <height>
-#
-# Used internally to rescale a single image (associated with item ID
-# tid) to the specified <height>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::_rescale {tid ht} {
-    set iw [image width $_data($tid-image)]
-    set ih [image height $_data($tid-image)]
-    set wd [expr {$ht*$iw/$ih}]
-    $_data($tid-scaled) configure -width $wd -height $ht
-    blt::winop resample $_data($tid-image) $_data($tid-scaled) box
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _event <type> <x> <y>
-#
-# Called whenever the user clicks or interacts with the coverflow.
-# The event <type> is something like "click" or "drag".
-# ----------------------------------------------------------------------
-itcl::body Rappture::Coverflow::_event {type x y} {
-    set c $itk_component(area)
-    switch -- $type {
-        click {
-            set _click [list $x $y]
-        }
-        drag {
-            if {$_click ne "" && $_current ne ""} {
-                foreach {x0 y0} $_click break
-                set delta [expr {double($x-$x0)/$itk_option(-spacing)}]
-                set pos [lsearch -exact $_items $_current]
-                set newpos [expr {$pos+$delta}]
-                $_dispatcher event -idle !redraw -position $newpos
-
-                if {![regexp {dragged} $_click]} {
-                    lappend _click dragged
-                }
-            }
-        }
-        release {
-            if {$_click ne ""} {
-                foreach {x0 y0} $_click break
-                if {abs($x-$x0) > 3 || abs($y-$y0) > 3} {
-                    # one last drag event
-                    _event drag $x $y
-                }
-
-                if {[regexp {dragged} $_click]} {
-                    # adjust the current selection to the current pos
-                    set delta [expr {double($x-$x0)/$itk_option(-spacing)}]
-                    set pos [lsearch -exact $_items $_current]
-                    set newpos [expr {round($pos+$delta)}]
-                    if {$newpos < 0} {set newpos 0}
-                    set max [expr {[llength $_items]-1}]
-                    if {$newpos > $max} {set newpos $max}
-
-                    select $newpos -animate off
-
-                    # select may not change, so do one last proper draw
-                    $_dispatcher event -idle !redraw -position $newpos
-
-                    set _click ""
-                    return
-                }
-            }
-
-            # click in place -- see what image we clicked on
-            set found ""
-            foreach id [$c find overlapping $x $y $x $y] {
-                if {[regexp {item([0-9]+)} [$c gettags $id] match index]} {
-                    set found $index
-                }
-                # keep searching for top-most item in stack
-            }
-            if {$found ne ""} {
-                select $found
-            }
-            set _click ""
-        }
-        default {
-            error "bad option \"$type\": should be click, drag, release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTIONS
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Coverflow::padding {
-    $_dispatcher event -idle !redraw
-}
-itcl::configbody Rappture::Coverflow::spacing {
-    $_dispatcher event -idle !redraw
-}
-itcl::configbody Rappture::Coverflow::font {
-    $_dispatcher event -idle !redraw
-}
-itcl::configbody Rappture::Coverflow::fontcolor {
-    $_dispatcher event -idle !redraw
-}
Index: trunk/gui/scripts/curve.tcl
===================================================================
--- trunk/gui/scripts/curve.tcl	(revision 6716)
+++ trunk/gui/scripts/curve.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: curve - extracts data from an XML description of a field
@@ -10,44 +9,27 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itcl
 package require BLT
 
-namespace eval Rappture {
-    # forward declaration
-}
+namespace eval Rappture { # forward declaration }
 
 itcl::class Rappture::Curve {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
+    constructor {libobj path} { # defined below }
+    destructor { # defined below }
 
     public method components {{pattern *}}
-    public method mesh {cname }
-    public method values { cname }
-    public method limits {which}
+    public method vectors {{what -overall}}
+    public method controls {option args}
     public method hints {{key ""}}
-    public method xmarkers {}
-    public method ymarkers {}
-    public method xErrorValues { cname }
-    public method yErrorValues { cname }
 
     protected method _build {}
 
-    private variable _xmlobj ""  ;      # ref to lib obj with curve data
-    private variable _curve ""   ;      # lib obj representing this curve
-    private variable _comp2xy    ;      # maps component name => x,y vectors
-    private variable _hints      ;      # cache of hints stored in XML
+    private variable _libobj ""  ;# ref to lib obj with curve data
+    private variable _curve ""   ;# lib obj representing this curve
+    private variable _comp2vecs  ;# maps component name => x,y vectors
 
-    private variable _xmarkers "";      # list of {x,label,options} triplets.
-    private variable _ymarkers "";      # list of {y,label,options} triplets.
-    private common _counter 0    ;      # counter for unique vector names
+    private common _counter 0    ;# counter for unique vector names
 }
 
@@ -55,10 +37,11 @@
 # CONSTRUCTOR
 # ----------------------------------------------------------------------
-itcl::body Rappture::Curve::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be LibraryObj"
+itcl::body Rappture::Curve::constructor {libobj path} {
+    if {![Rappture::Library::valid $libobj]} {
+        error "bad value \"$libobj\": should be LibraryObj"
     }
-    set _xmlobj $xmlobj
-    set _curve [$xmlobj element -as object $path]
+    set _libobj $libobj
+    set _curve [$libobj get -object $path]
+
     # build up vectors for various components of the curve
     _build
@@ -70,8 +53,8 @@
 itcl::body Rappture::Curve::destructor {} {
     itcl::delete object $_curve
-    # don't destroy the _xmlobj! we don't own it!
+    # don't destroy the _libobj! we don't own it!
 
-    foreach name [array names _comp2xy] {
-        eval blt::vector destroy $_comp2xy($name)
+    foreach name [array names _comp2vecs] {
+        eval blt::vector destroy $_comp2vecs($name)
     }
 }
@@ -86,5 +69,5 @@
 itcl::body Rappture::Curve::components {{pattern *}} {
     set rlist ""
-    foreach name [array names _comp2xy] {
+    foreach name [array names _comp2vecs] {
         if {[string match $pattern $name]} {
             lappend rlist $name
@@ -95,126 +78,15 @@
 
 # ----------------------------------------------------------------------
-# USAGE: mesh ?<name>?
+# USAGE: vectors ?<name>?
 #
-# Returns the xvec for the specified curve component <name>.
+# Returns a list {xvec yvec} for the specified curve component <name>.
 # If the name is not specified, then it returns the vectors for the
 # overall curve (sum of all components).
 # ----------------------------------------------------------------------
-itcl::body Rappture::Curve::mesh {cname} {
-    if {[info exists _comp2xy($cname)]} {
-        return [lindex $_comp2xy($cname) 0]  ;# return xv
+itcl::body Rappture::Curve::vectors {{what -overall}} {
+    if {[info exists _comp2vecs($what)]} {
+        return $_comp2vecs($what)
     }
-    error "bad component \"$cname\": should be one of [join [lsort [array names _comp2xy]] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: values ?<name>?
-#
-# Returns the yvec for the specified curve component <name>.
-# If the name is not specified, then it returns the vectors for the
-# overall curve (sum of all components).
-# ----------------------------------------------------------------------
-itcl::body Rappture::Curve::values {cname} {
-    if {[info exists _comp2xy($cname)]} {
-        return [lindex $_comp2xy($cname) 1]  ;# return yv
-    }
-    error "bad component \"$cname\": should be one of [join [lsort [array names _comp2xy]] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: xErrorValues <name>
-#
-# Returns the xvec for the specified curve component <name>.
-# If the name is not specified, then it returns the vectors for the
-# overall curve (sum of all components).
-# ----------------------------------------------------------------------
-itcl::body Rappture::Curve::xErrorValues { cname } {
-    if {[info exists _comp2xy($cname)]} {
-        return [lindex $_comp2xy($cname) 2]  ;# return xev
-    }
-    error "unknown component \"$cname\": should be one of [join [lsort [array names _comp2xy]] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: yErrorValues <name>
-#
-# Returns the xvec for the specified curve component <name>.
-# If the name is not specified, then it returns the vectors for the
-# overall curve (sum of all components).
-# ----------------------------------------------------------------------
-itcl::body Rappture::Curve::yErrorValues { cname } {
-    if {[info exists _comp2xy($cname)]} {
-        return [lindex $_comp2xy($cname) 3]  ;# return yev
-    }
-    error "unknown component \"$cname\": should be one of [join [lsort [array names _comp2xy]] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: limits x|xlin|xlog|y|ylin|ylog
-#
-# Returns the {min max} limits for the specified axis.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Curve::limits {which} {
-    set min ""
-    set max ""
-    switch -- $which {
-        x - xlin { set pos 0; set log 0; set axis xaxis }
-        xlog { set pos 0; set log 1; set axis xaxis }
-        y - ylin - v - vlin { set pos 1; set log 0; set axis yaxis }
-        ylog - vlog { set pos 1; set log 1; set axis yaxis }
-        default {
-            error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
-        }
-    }
-
-    blt::vector tmp zero
-    foreach comp [array names _comp2xy] {
-        set vname [lindex $_comp2xy($comp) $pos]
-        $vname variable vec
-
-        if {$log} {
-            # on a log scale, use abs value and ignore 0's
-            $vname dup tmp
-            $vname dup zero
-            zero expr {tmp == 0}            ;# find the 0's
-            tmp expr {abs(tmp)}             ;# get the abs value
-            tmp expr {tmp + zero*max(tmp)}  ;# replace 0's with abs max
-            set vmin [blt::vector expr min(tmp)]
-            set vmax [blt::vector expr max(tmp)]
-        } else {
-            set vmin $vec(min)
-            set vmax $vec(max)
-        }
-
-        if {"" == $min} {
-            set min $vmin
-        } elseif {$vmin < $min} {
-            set min $vmin
-        }
-        if {"" == $max} {
-            set max $vmax
-        } elseif {$vmax > $max} {
-            set max $vmax
-        }
-    }
-    blt::vector destroy tmp zero
-
-    set val [$_curve get $axis.min]
-    if {"" != $val && "" != $min} {
-        if {$val > $min} {
-            # tool specified this min -- don't go any lower
-            set min $val
-        }
-    }
-
-    set val [$_curve get $axis.max]
-    if {"" != $val && "" != $max} {
-        if {$val < $max} {
-            # tool specified this max -- don't go any higher
-            set max $val
-        }
-    }
-
-    return [list $min $max]
+    error "bad option \"$what\": should be [join [lsort [array names _comp2vecs]] {, }]"
 }
 
@@ -227,53 +99,28 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Curve::hints {{keyword ""}} {
-    if {![info exists _hints]} {
-        foreach {key path} {
-            color   about.color
-            group   about.group
-            label   about.label
-            style   about.style
-            type    about.type
-            xdesc   xaxis.description
-            xlabel  xaxis.label
-            xmax    xaxis.max
-            xmin    xaxis.min
-            xscale  xaxis.scale
-            xticks  xaxis.ticklabels
-            xunits  xaxis.units
-            ydesc   yaxis.description
-            ylabel  yaxis.label
-            ymax    yaxis.max
-            ymin    yaxis.min
-            yscale  yaxis.scale
-            yticks  yaxis.ticklabels
-            yunits  yaxis.units
-        } {
-            set str [$_curve get $path]
-            if {"" != $str} {
-                set _hints($key) $str
-            }
+    foreach {key path} {
+        label   label
+        color   color
+        color   style
+        xlabel  xaxis.label
+        xunits  xaxis.units
+        xscale  xaxis.scale
+        ylabel  yaxis.label
+        yunits  yaxis.units
+        yscale  yaxis.scale
+    } {
+        set str [$_curve get $path]
+        if {"" != $str} {
+            set hints($key) $str
         }
-        if {[info exists _hints(xlabel)] && "" != $_hints(xlabel)
-              && [info exists _hints(xunits)] && "" != $_hints(xunits)} {
-            set _hints(xlabel) "$_hints(xlabel) ($_hints(xunits))"
-        }
-        if {[info exists _hints(ylabel)] && "" != $_hints(ylabel)
-              && [info exists _hints(yunits)] && "" != $_hints(yunits)} {
-            set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))"
-        }
+    }
 
-        if {[info exists _hints(group)] && [info exists _hints(label)]} {
-            # pop-up help for each curve
-            set _hints(tooltip) $_hints(label)
-        }
-        set _hints(xmlobj) $_xmlobj
-    }
     if {$keyword != ""} {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
+        if {[info exists hints($keyword)]} {
+            return $hints($keyword)
         }
         return ""
     }
-    return [array get _hints]
+    return [array get hints]
 }
 
@@ -288,8 +135,8 @@
 itcl::body Rappture::Curve::_build {} {
     # discard any existing data
-    foreach name [array names _comp2xy] {
-        eval blt::vector destroy $_comp2xy($name)
+    foreach name [array names _comp2vecs] {
+        eval blt::vector destroy $_comp2vecs($name)
     }
-    catch {unset _comp2xy}
+    catch {unset _comp2vecs}
 
     #
@@ -297,70 +144,26 @@
     # vectors for each part.
     #
-    foreach cname [$_curve children -type component] {
-        set xv [blt::vector create \#auto]
-        set yv [blt::vector create \#auto]
-        set xev [blt::vector create \#auto]
-        set yev [blt::vector create \#auto]
+    set max [$_curve get -count component]
+    for {set i 0} {$i < $max} {incr i} {
+        set xv ""
+        set yv ""
 
-        set xydata [$_curve get $cname.xy]
-        if { "" != $xydata} {
-            set tmp [blt::vector create \#auto]
-            $tmp set $xydata
-            $tmp split $xv $yv
-            blt::vector destroy $tmp
-        } else {
-            $xv set [$_curve get $cname.xvector]
-            $yv set [$_curve get $cname.yvector]
+        set xydata [$_curve get component$i.xy]
+        if {"" != $xydata} {
+            set xv [blt::vector create x$_counter]
+            set yv [blt::vector create y$_counter]
+
+            foreach line [split $xydata \n] {
+                if {[scan $line {%g %g} xval yval] == 2} {
+                    $xv append $xval
+                    $yv append $yval
+                }
+            }
         }
-        if { (([$xv length] == 0) && ([$yv length] == 0)) ||
-             ([$xv length] != [$yv length]) } {
-            # FIXME: need to show an error about improper data.
-            blt::vector destroy $xv $yv
-            set xv ""; set yv ""
-            continue;
+
+        if {$xv != "" && $yv != ""} {
+            set _comp2vecs(component$i) [list $xv $yv]
+            incr _counter
         }
-        $xev set [$_curve get "$cname.xerrorbars"]
-        $yev set [$_curve get "$cname.yerrorbars"]
-        set _comp2xy($cname) [list $xv $yv $xev $yev]
-        incr _counter
-    }
-
-    # Creates lists of x and y marker data.
-    set _xmarkers {}
-    set _ymarkers {}
-    foreach cname [$_curve children -type "marker" xaxis] {
-        set at     [$_curve get "xaxis.$cname.at"]
-        set label  [$_curve get "xaxis.$cname.label"]
-        set styles [$_curve get "xaxis.$cname.style"]
-        set data [list $at $label $styles]
-        lappend _xmarkers $data
-    }
-    foreach cname [$_curve children -type "marker" yaxis] {
-        set at     [$_curve get "yaxis.$cname.at"]
-        set label  [$_curve get "yaxis.$cname.label"]
-        set styles [$_curve get "yaxis.$cname.style"]
-        set data [list $at $label $styles]
-        lappend _ymarkers $data
     }
 }
-
-# ----------------------------------------------------------------------
-# USAGE: xmarkers
-#
-# Returns the list of settings for each marker on the x-axis.
-# If no markers have been specified the empty string is returned.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Curve::xmarkers {} {
-    return $_xmarkers;
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ymarkers
-#
-# Returns the list of settings for each marker on the y-axis.
-# If no markers have been specified the empty string is returned.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Curve::ymarkers {} {
-    return $_ymarkers;
-}
-
Index: trunk/gui/scripts/datatable.tcl
===================================================================
--- trunk/gui/scripts/datatable.tcl	(revision 6716)
+++ 	(revision )
@@ -1,155 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: datatable - extracts data from an XML description of a field
-#
-#  This object represents a datatable of data in an XML description of
-#  simulator output.  A datatable is similar to a field, but a field is
-#  a quantity versus position in device.  A datatable is any quantity
-#  versus any other quantity.  This class simplifies the process of
-#  extracting data vectors that represent the datatable.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture {
-    # forward declaration
-}
-
-itcl::class Rappture::DataTable {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method components {{pattern *}}
-    public method values {}
-    public method columns {}
-    public method hints {{key ""}}
-
-    protected method Build {}
-    private variable _xmlobj ""  ;      # ref to lib obj with datatable data
-    private variable _datatable "";     # lib obj representing this datatable
-    private variable _columns ""
-    private variable _hints      ;      # cache of hints stored in XML
-    private variable _tree ""
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTable::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be LibraryObj"
-    }
-    set _xmlobj $xmlobj
-    set _datatable [$xmlobj element -as object $path]
-
-    # build up vectors for various components of the datatable
-    Build
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTable::destructor {} {
-    itcl::delete object $_datatable
-    blt::tree destroy $_tree
-}
-
-# ----------------------------------------------------------------------
-# USAGE: values
-#
-# Returns the values for the datatable as a BLT tree.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTable::values {} {
-    return $_tree
-}
-
-# ----------------------------------------------------------------------
-# USAGE: columns
-#
-# Returns the columns of the datatable in order.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTable::columns {} {
-    return $_columns
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this datatable.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTable::hints {{keyword ""}} {
-    if {![info exists _hints]} {
-        foreach {key path} {
-            group   about.group
-            label   about.label
-            color   about.color
-            style   about.style
-        } {
-            set str [$_datatable get $path]
-            if {"" != $str} {
-                set _hints($key) $str
-            }
-        }
-    }
-    set _hints(xmlobj) $_xmlobj
-    if { $keyword != "" } {
-        if { [info exists _hints($keyword)] } {
-            return $_hints($keyword)
-        }
-        return ""
-    }
-    return [array get _hints]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Build
-#
-# Used internally to build up the vector representation for the
-# datatable when the object is first constructed, or whenever the datatable
-# data changes.  Discards any existing vectors and builds everything
-# from scratch.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTable::Build {} {
-    # Discard any existing data
-    if { $_tree != "" } {
-        blt::tree destroy $_tree
-        set _tree ""
-    }
-    set _columns {}
-
-    # Sniff for column information: label, descriptions, and style
-    foreach cname [$_datatable children -type "column"] {
-        set label        [$_datatable get "$cname.label"]
-        set description  [$_datatable get "$cname.description"]
-        set style        [$_datatable get "$cname.style"]
-        lappend _columns $label $description $style
-    }
-    set csvdata [$_datatable get csv]
-    set _tree [blt::tree create]
-    if {"" != $csvdata} {
-        set csvlist [blt::csv -data $csvdata]
-        foreach row $csvlist {
-            set child [$_tree insert 0]
-            set c 0
-            foreach value $row {label description style} $_columns {
-                if { $label == "" } {
-                    set label "$c"
-                }
-                $_tree set $child $label $value
-                incr c
-            }
-        }
-    }
-}
Index: trunk/gui/scripts/datatableresult.tcl
===================================================================
--- trunk/gui/scripts/datatableresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,364 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: datatableresult - X/Y plot in a ResultSet
-#
-#  This widget is an X/Y plot, meant to view line graphs produced
-#  as output from the run of a Rappture tool.  Use the "add" and
-#  "delete" methods to control the dataobjs showing on the plot.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *DataTableResult.width 3i widgetDefault
-option add *DataTableResult.height 3i widgetDefault
-option add *DataTableResult.gridColor #d9d9d9 widgetDefault
-option add *DataTableResult.activeColor blue widgetDefault
-option add *DataTableResult.dimColor gray widgetDefault
-option add *DataTableResult.controlBackground gray widgetDefault
-option add *DataTableResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-option add *DataTableResult*Balloon*Entry.background white widgetDefault
-
-itk::usual TreeView {
-    keep -foreground -cursor
-}
-
-itcl::class Rappture::DataTableResult {
-    inherit itk::Widget
-
-    itk_option define -gridcolor gridColor GridColor ""
-    itk_option define -activecolor activeColor ActiveColor ""
-    itk_option define -dimcolor dimColor DimColor ""
-
-    private variable _tree ""
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args} {
-        # Do nothing
-    }
-    public method snap { w h }
-    public method tooltip { desc x y }
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method download {option args}
-
-    protected method Rebuild {}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-    private variable _dlist ""     ;# list of dataobj objects
-    private variable _dataobj2color  ;# maps dataobj => plotting color
-    private variable _dataobj2width  ;# maps dataobj => line width
-    private variable _dataobj2dashes ;# maps dataobj => BLT -dashes list
-    private variable _dataobj2raise  ;# maps dataobj => raise flag 0/1
-    private variable _raised    "";
-    common _downloadPopup          ;# download options from popup
-}
-
-itk::usual DataTableResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTableResult::constructor {args} {
-    if { [catch {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    array set _downloadPopup {
-        format csv
-    }
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    set _tree [blt::tree create]
-    Rappture::Scroller $itk_interior.scroller \
-        -xscrollmode auto -yscrollmode auto
-
-    itk_component add treeview {
-        blt::treeview $itk_interior.scroller.tv -borderwidth 1 \
-            -highlightthickness 0 -tree $_tree
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    $itk_component(treeview) style textbox lowered -background grey95
-    $itk_component(treeview) style textbox raised -background white
-    $itk_interior.scroller contents $itk_component(treeview)
-    pack $itk_interior.scroller -fill both -expand yes
-    eval itk_initialize $args
-    } err] != 0} {
-        puts stderr errs=$err
-    }
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTableResult::destructor {} {
-    if { $_tree != "" } {
-        blt::tree destroy $_tree
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a dataobj to the plot.  The optional <settings>
-# are used to configure the plot.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTableResult::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -type "line"
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-    if { $params(-raise) } {
-        set _raised $dataobj
-    }
-    lappend _dlist $dataobj
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTableResult::get {} {
-    return $_dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTableResult::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-    # delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        if { $dataobj == $_raised } {
-            set _raised ""
-        }
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            set changed 1
-        }
-    }
-    set _raised [lindex $_dlist 0]
-    # If anything changed, then rebuild the table
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTableResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            set popup .datatableresultdownload
-            if {![winfo exists .datatableresultdownload]} {
-                # if we haven't created the popup yet, do it now
-                Rappture::Balloon $popup \
-                    -title "[Rappture::filexfer::label downloadWord] as..."
-                set inner [$popup component inner]
-                label $inner.summary -text "" -anchor w
-                pack $inner.summary -side top
-                radiobutton $inner.datatable \
-                    -text "Data as Comma-Separated Values" \
-                    -variable Rappture::DataTableResult::_downloadPopup(format) \
-                    -value csv
-                pack $inner.datatable -anchor w
-                button $inner.go -text [Rappture::filexfer::label download] \
-                    -command [lindex $args 0]
-                pack $inner.go -pady 4
-            } else {
-                set inner [$popup component inner]
-            }
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:"
-            update idletasks ;# fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .datatableresultdownload
-            if {[winfo exists .datatableresultdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                csv {
-                    # reverse the objects so the selected data appears on top
-                    set dlist ""
-                    foreach dataobj [get] {
-                        set dlist [linsert $dlist 0 $dataobj]
-                    }
-
-                    # generate the comma-separated value data for these objects
-                    set csvdata ""
-                    foreach dataobj $dlist {
-                        append csvdata "[string repeat - 60]\n"
-                        append csvdata " [$dataobj hints label]\n"
-                        if {[info exists _dataobj2desc($dataobj)]
-                            && [llength [split $_dataobj2desc($dataobj) \n]] > 1} {
-                            set indent "for:"
-                            foreach line [split $_dataobj2desc($dataobj) \n] {
-                                append csvdata " $indent $line\n"
-                                set indent "    "
-                            }
-                        }
-                        append csvdata "[string repeat - 60]\n"
-
-                        append csvdata "[$dataobj hints xlabel], [$dataobj hints ylabel]\n"
-                        set first 1
-                        foreach comp [$dataobj components] {
-                            if {!$first} {
-                                # blank line between components
-                                append csvdata "\n"
-                            }
-                            set xv [$dataobj mesh $comp]
-                            set yv [$dataobj values $comp]
-                            foreach x [$xv values] y [$yv values] {
-                                append csvdata [format "%20.15g, %20.15g\n" $x $y]
-                            }
-                            set first 0
-                        }
-                        append csvdata "\n"
-                    }
-                    return [list .txt $csvdata]
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DataTableResult::Rebuild {} {
-    eval $_tree delete [$_tree children 0]
-
-    foreach dataobj $_dlist {
-        scan $dataobj "::dataTable%d" suffix
-        incr suffix
-
-        set newtree [$dataobj values]
-        # Copy the data object's tree onto our tree.
-        set dest [$_tree firstchild 0]
-        foreach src [$newtree children 0] {
-            if { $dest == -1 } {
-                set dest [$_tree insert 0]
-            }
-            foreach {name value} [$newtree get $src] {
-                set label "$name \#$suffix"
-                $_tree set $dest $label $value
-                set labels($label) 1
-            }
-            set dest [$_tree nextsibling $dest]
-        }
-    }
-    foreach col [$itk_component(treeview) column names] {
-        if { [string match "BLT TreeView*" $col] } {
-            continue
-        }
-        $itk_component(treeview) column delete $col
-    }
-    $itk_component(treeview) column configure treeView -hide yes
-    set dataobj [lindex $_dlist 0]
-    if { $dataobj != "" } {
-        foreach { label description style } [$dataobj columns] {
-            foreach c [lsort -dictionary [array names labels $label*]] {
-                eval $itk_component(treeview) column insert end [list $c] $style
-                $itk_component(treeview) column bind $c <Enter> \
-                    [itcl::code $this tooltip $description %X %Y]
-                $itk_component(treeview) column bind $c <Leave> \
-                    { Rappture::Tooltip::tooltip cancel }
-            }
-        }
-    }
-    if { [llength $_dlist] == 1 } {
-        foreach { label description style } [$dataobj columns] {
-            foreach c [lsort -dictionary [array names labels $label*]] {
-                $itk_component(treeview) column configure $c -text $label
-            }
-        }
-    }
-    if { $_raised != "" } {
-        foreach c [$itk_component(treeview) column names] {
-            $itk_component(treeview) column configure $c -style lowered
-        }
-        scan $_raised "::dataTable%d" suffix
-        incr suffix
-        foreach { label description style } [$_raised columns] {
-            set c "$label \#$suffix"
-            $itk_component(treeview) column configure $c -style raised
-        }
-    }
-}
-
-itcl::body Rappture::DataTableResult::snap { w h } {
-    set g $itk_component(plot)
-    if { $w <= 0 || $h <= 0 } {
-        set w [winfo width $g]
-        set h [winfo height $g]
-    }
-    set img [image create picture -width $w -height $h]
-    $g snap $img -width $w -height $h
-    return $img
-}
-
-itcl::body Rappture::DataTableResult::tooltip { description x y } {
-    Rappture::Tooltip::text $itk_component(treeview) $description
-    Rappture::Tooltip::tooltip pending $itk_component(treeview) @$x,$y
-}
Index: trunk/gui/scripts/deviceEditor.tcl
===================================================================
--- trunk/gui/scripts/deviceEditor.tcl	(revision 6716)
+++ 	(revision )
@@ -1,222 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: deviceEditor - general-purpose device editor
-#
-#  This widget takes a <structure> description and chooses a specific
-#  editor appropriate for the contents of the structure.  If the
-#  <structure> contains a molecule, then it chooses a MoleculeViewer.
-#  If it contains a 1D device, then it chooses a deviceViewer1D.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *DeviceEditor.autoCleanUp yes widgetDefault
-
-itcl::class Rappture::DeviceEditor {
-    inherit itk::Widget Rappture::ControlOwner
-
-    itk_option define -autocleanup autoCleanUp AutoCleanUp 1
-
-    constructor {owner args} {
-        Rappture::ControlOwner::constructor $owner
-    } {
-        # defined below
-    }
-    public method value {args}
-    public method download {option args}
-    public method add {dataobj {settings ""}}
-    public method delete {args}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method snap {w h}
-
-    protected method _redraw {}
-    protected method _type {xmlobj}
-
-    private variable _current ""  ;# active device editor
-
-    public common _molvisHosts ""
-
-    public proc setMolvisServer {namelist} {
-        if {[regexp {^[a-zA-Z0-9\.]+:[0-9]+(,[a-zA-Z0-9\.]+:[0-9]+)*$} $namelist match]} {
-            set _molvisHosts $namelist
-        } else {
-            error "bad visualization server address \"$namelist\": should be host:port,host:port,..."
-        }
-    }
-}
-
-itk::usual DeviceEditor {
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceEditor::constructor {owner args} {
-    itk_component add top {
-        frame $itk_interior.top
-    }
-    pack $itk_component(top) -fill x
-
-    eval itk_initialize $args
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceEditor::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$_xmlobj != ""} {
-            if {$itk_option(-autocleanup)} {
-                # delete any existing object
-                itcl::delete object $_xmlobj
-            }
-            set _xmlobj ""
-        }
-
-        set newval [lindex $args 0]
-        if {$newval != ""} {
-            if {$onlycheck} {
-                return
-            }
-            if {![Rappture::library isvalid $newval]} {
-                error "bad value \"$newval\": should be Rappture::Library"
-            }
-            set _xmlobj $newval
-        }
-        _redraw
-        $_current configure -device $_xmlobj
-        event generate $itk_component(hull) <<Value>>
-
-    } elseif {[llength $args] == 0} {
-        sync  ;# querying -- must sync controls with the value
-    } else {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-    return $_xmlobj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot. Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise. Only
-# -brightness and -raise do anything.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceEditor::add {dataobj {settings ""}} {
-    set _xmlobj $dataobj
-    if {"" == $_current} {    # Make sure viewer instance exists
-        _redraw
-    }
-    eval $_current add $dataobj [list $settings]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj> <dataobj> ...?
-#
-# Clients use this to delete a dataobj from the plot. If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceEditor::delete {args} {
-    if {"" != $_current} {
-        eval $_current delete $args
-        set _xmlobj [lindex [$_current get] end]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceEditor::download {option args} {
-    if {"" != $_current} {
-        return [eval $_current download $option $args]
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Used internally to load new device data into the appropriate
-# editor.  If the editor needs to be created, it is created and
-# activated within this widget.  Then, the data is loaded into
-# the editor.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceEditor::_redraw {} {
-    if {$_current != ""} {
-        $_current configure -device ""
-        set _current ""
-    }
-    switch -- [_type $_xmlobj] {
-        molecule {
-            if { ![winfo exists $itk_component(hull).mol] } {
-                catch {
-                    destroy $itk_component(hull).dev
-                }
-                Rappture::MolvisViewer $itk_component(hull).mol
-                pack $itk_component(hull).mol -expand yes -fill both
-            }
-            set _current $itk_component(hull).mol
-        }
-        device1D {
-            if { ![winfo exists $itk_component(hull).dev] } {
-                catch {
-                    destroy $itk_component(hull).mol
-                }
-                Rappture::DeviceViewer1D $itk_component(hull).dev $this
-                pack $itk_component(hull).dev -expand yes -fill both
-            }
-            set _current $itk_component(hull).dev
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _type <xmlobj>
-#
-# Used internally to determine the type of the device data stored
-# within the <xmlobj>.  Returns a name such as "molecule" or
-# "device1D" indicating the type of editor that should be used to
-# display the data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceEditor::_type {xmlobj} {
-    if {$xmlobj == ""} {
-        return ""
-    }
-    if {[llength [$xmlobj children -type molecule components]] > 0} {
-        return "molecule"
-    }
-    return "device1D"
-}
-
-itcl::body Rappture::DeviceEditor::snap { w h } {
-    return [$_current snap $w $h]
-}
Index: trunk/gui/scripts/deviceLayout1D.tcl
===================================================================
--- trunk/gui/scripts/deviceLayout1D.tcl	(revision 6716)
+++ trunk/gui/scripts/deviceLayout1D.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: deviceLayout1D - visualizer for 1D device geometries
@@ -10,18 +9,15 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
 package require BLT
 
-option add *DeviceLayout1D.width 3.5i widgetDefault
+option add *DeviceLayout1D.width 4i widgetDefault
 option add *DeviceLayout1D.deviceSize 0.25i widgetDefault
 option add *DeviceLayout1D.deviceOutline black widgetDefault
 option add *DeviceLayout1D.annotate all widgetDefault
 option add *DeviceLayout1D.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
+    -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
 
 itcl::class Rappture::DeviceLayout1D {
@@ -29,6 +25,6 @@
 
     itk_option define -font font Font ""
+    itk_option define -library library Library ""
     itk_option define -device device Device ""
-    itk_option define -width width Width 0
     itk_option define -devicesize deviceSize DeviceSize 0
     itk_option define -deviceoutline deviceOutline DeviceOutline ""
@@ -44,5 +40,5 @@
     protected method _redraw {}
     protected method _drawLayer {index x0 x1}
-    protected method _drawIcon {index x0 x1 imh}
+    protected method _drawMolecule {index x0 x1}
     protected method _drawAnnotation {index x0 x1}
     protected method _mater2color {mater}
@@ -51,23 +47,25 @@
     private variable _sizes         ;# maps size name => pixels
 
+    private variable _library ""    ;# LibraryObj for library information
     private variable _device ""     ;# LibraryObj for device representation
     private variable _slabs ""      ;# list of node names for slabs in device
     private variable _z0 ""         ;# list parallel to _slabs with z0
                                     ;#   coord for lhs of each slab
-    private variable _z1 ""         ;# list parallel to _slabs with z1
-                                    ;#   coord for rhs of each slab
+    private variable _zthick ""     ;# list parallel to _slabs with thickness
+                                    ;#   for each slab
     private variable _maters ""     ;# list parallel to _slabs with material
                                     ;#   for each slab
-    private variable _colors ""     ;# list parallel to _slabs with color
-                                    ;#   for each slab
 
     private variable _controls      ;# maps control path => status on/off
 
-    private variable _icons         ;# maps icon data => image handle
-}
-
+    private common _icons
+    set _icons(molecule) [image create photo -file \
+        [file join $Rappture::installdir scripts images molecule.gif]]
+}
+                                                                                
 itk::usual DeviceLayout1D {
     keep -background -cursor
-    keep -device -deviceoutline -devicesize
+    keep -library -device
+    keep -deviceoutline -devicesize
     keep -selectbackground -selectforeground -selectborderwidth
     keep -width
@@ -84,4 +82,5 @@
     $_dispatcher dispatch $this !redraw "[itcl::code $this _redraw]; list"
 
+    itk_option add hull.width
     pack propagate $itk_component(hull) no
 
@@ -93,12 +92,9 @@
         ignore -highlightthickness -highlightbackground -highlightcolor
     }
-    pack $itk_component(area) -expand yes -fill both
+    pack $itk_component(area) -fill both
     bind $itk_component(area) <Configure> \
         [list $_dispatcher event -idle !redraw]
 
     eval itk_initialize $args
-
-    set _sizes(header) 1
-    set _sizes(bararea) 1
 }
 
@@ -116,5 +112,5 @@
     }
     set zmin [lindex $_z0 0]
-    set zmax [lindex $_z1 end]
+    set zmax [lindex $_z0 end]
     return [list $zmin $zmax]
 }
@@ -140,6 +136,6 @@
 #
 # Clients use this to add hints about the controls that should be
-# added to the layout area.  Common paths are components.slab#.material
-# and components.slab#.thickness.
+# added to the layout area.  Common paths are recipe.slab#.material
+# and recipe.slab#.thickness.
 # ----------------------------------------------------------------------
 itcl::body Rappture::DeviceLayout1D::controls {option args} {
@@ -169,56 +165,25 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::DeviceLayout1D::_layout {} {
-    #
-    # First, recompute the overall width/height of this widget...
-    #
-    # requested minimum size
-    set wmax [winfo pixels $itk_component(hull) $itk_option(-width)]
-    if {$wmax <= 0} { set wmax 100 }
-
-    # size of an ordinary material bar:
-    set hmax [expr {$_sizes(bar)+$_sizes(bar45)+2}]
-
-    # add the maximum size of any embedded icons:
-    if {$_device != ""} {
-        foreach nn [$_device children components] {
-            set icon [$_device get components.$nn.about.icon]
-            if {"" != $icon} {
-                if {[info exists _icons($icon)]} {
-                    set imh $_icons($icon)
-                } else {
-                    set imh [image create photo -data $icon]
-                    set _icons($icon) $imh
-                }
-
-                set w [image width $_icons($icon)]
-                if {$w > $wmax} {
-                    set wmax $w
-                }
-
-                set h [image height $_icons($icon)]
-                if {$h > $hmax} {
-                    set hmax $h
-                }
-            }
-        }
-    }
-    set _sizes(bararea) $hmax
+    # first, recompute the overall height of this widget
+    set h [expr {$_sizes(bar)+$_sizes(bar45)+20}]
 
     set fnt $itk_option(-font)
-    # see if any of the slabs has a material
-    foreach m $_maters {
-        if {"" != $m} {
-            set extra [expr {1.5*[font metrics $fnt -linespace]}]
-            set hmax [expr {$hmax+$extra}]
-            break
-        }
+    if {[regexp {\.material} [array names _controls]]} {
+        # one of the slabs has its material displayed
+        set extra [expr {1.2*[font metrics $fnt -linespace]}] 
+        set h [expr {$h+$extra}]
+    }
+    if {[regexp {\.thickness} [array names _controls]]} {
+        # one of the slabs has its thickness displayed
+        set extra [expr {1.2*[font metrics $fnt -linespace]}] 
+        set h [expr {$h+$extra}]
     }
 
     # see if any of the slabs has a label
     if {$_device != ""} {
-        foreach nn [$_device children components] {
-            if {"" != [$_device get components.$nn.about.label]} {
-                set extra [expr {1.2*[font metrics $fnt -linespace]}]
-                set hmax [expr {$hmax+$extra}]
+        foreach nn [$_device get -children recipe] {
+            if {"" != [$_device get recipe.$nn.label]} {
+                set extra [expr {1.2*[font metrics $fnt -linespace]}] 
+                set h [expr {$h+$extra}]
                 break
             }
@@ -226,57 +191,35 @@
     }
 
-    set oldw [component hull cget -width]
+    # a little extra height for the molecule image
+    if {[$_device get -exists recipe.molecule]} {
+        set h [expr {$h+15}]
+    }
+
     set oldh [component hull cget -height]
-    if {$wmax != $oldw || $hmax != $oldh} {
-        component hull configure -width $wmax -height $hmax
+    if {$h != $oldh} {
+        component hull configure -height $h
         $_dispatcher event -idle !redraw
     }
-    set _sizes(header) [expr {$hmax - $_sizes(bararea)}]
 
     # next, scan through the device and compute layer positions
     set slabs ""
     set z0 ""
-    set z1 ""
+    set zthick ""
     set maters ""
-    set colors ""
-
+
+    set z 0
     if {$_device != ""} {
-        # get the default system of units
-        set units [set defunits [$_device get units]]
-        if {$units == "arbitrary" || $units == ""} {
-            set defunits "m"
-            set units "um"
-        }
-
-        foreach nn [$_device children components] {
+        foreach nn [$_device get -children recipe] {
             switch -glob -- $nn {
-                box* {
-                    # get x-coord for each corner
-                    set c0 [$_device get components.$nn.corner0]
-                    regsub -all , $c0 { } c0
-                    set c0 [lindex $c0 0]
-                    set c0 [Rappture::Units::convert $c0 \
-                        -context $defunits -to $units -units off]
-
-                    set c1 [$_device get components.$nn.corner1]
-                    regsub -all , $c1 { } c1
-                    set c1 [lindex $c1 0]
-                    set c1 [Rappture::Units::convert $c1 \
-                        -context $defunits -to $units -units off]
-
-                    lappend slabs components.$nn
-                    lappend z0 $c0
-                    lappend z1 $c1
-
-                    set m [$_device get components.$nn.material]
-                    lappend maters $m
-
-                    if {"" != $m} {
-                        set c [_mater2color $m]
-                    } else {
-                        set c [$_device get components.$nn.about.color]
-                    }
-                    if {"" == $c} { set c gray }
-                    lappend colors $c
+                slab* - molecule* {
+                    set tval [$_device get recipe.$nn.thickness]
+                    set tval [Rappture::Units::convert $tval \
+                        -context um -to um -units off]
+                    lappend slabs recipe.$nn
+                    lappend z0 $z
+                    lappend zthick $tval
+                    lappend maters [$_device get recipe.$nn.material]
+
+                    set z [expr {$z+$tval}]
                 }
                 default {
@@ -286,15 +229,14 @@
         }
     }
+    lappend z0 $z
 
     # something change? then store new layout and redraw
     if {![string equal $z0 $_z0]
-          || ![string equal $z1 $_z1]
-          || ![string equal $maters $_maters]
-          || ![string equal $colors $_colors]} {
+          || ![string equal $zthick $_zthick]
+          || ![string equal $maters $_maters]} {
         set _slabs $slabs
         set _z0 $z0
-        set _z1 $z1
+        set _zthick $zthick
         set _maters $maters
-        set _colors $colors
 
         $_dispatcher event -idle !redraw
@@ -312,4 +254,7 @@
 
     # clean up images and delete all other items
+    foreach item [$c find withtag image] {
+        image delete [$c itemcget $item -image]
+    }
     $c delete all
 
@@ -319,28 +264,36 @@
     set x1 [expr {$x0 + $w}]
 
-    set zmax [lindex $_z1 end]
+    set zmax [lindex $_z0 end]
     set xx0 $x0
     set xx1 $x1
 
+    set drewslab 0
     for {set i 0} {$i < [llength $_slabs]} {incr i} {
         set name [lindex $_slabs $i]
-        set z0 [lindex $_z0 $i]
-        set z1 [lindex $_z1 $i]
-        set xx0 [expr {double($z0)/$zmax * ($x1-$x0) + $x0}]
-        set xx1 [expr {double($z1)/$zmax * ($x1-$x0) + $x0}]
-
-        set icon [$_device get $name.about.icon]
-        if {"" != $icon} {
-            if {[info exists _icons($icon)]} {
-                set imh $_icons($icon)
-            } else {
-                set imh [image create photo -data $icon]
-                set _icons($icon) $imh
+        if {[regexp {slab[0-9]*$} $name]} {
+            set z0 [lindex $_z0 $i]
+            set zthick [lindex $_zthick $i]
+            set xx0 [expr {double($z0)/$zmax * ($x1-$x0) + $x0}]
+            set xx1 [expr {double($z0+$zthick)/$zmax * ($x1-$x0) + $x0}]
+            _drawLayer $i $xx0 $xx1
+            _drawAnnotation $i $xx0 $xx1
+            set drewslab 1
+        } else {
+            if {$drewslab} {
+                _drawLayer cap $xx0 $xx1  ;# draw the end cap
+                set drewslab 0
             }
-            _drawIcon $i $xx0 $xx1 $imh
-        } else {
-            _drawLayer $i $xx0 $xx1
-        }
-        _drawAnnotation $i $xx0 $xx1
+            if {[regexp {molecule[0-9]*$} $name]} {
+                set z0 [lindex $_z0 $i]
+                set zthick [lindex $_zthick $i]
+                set xx0 [expr {double($z0)/$zmax * ($x1-$x0) + $x0}]
+                set xx1 [expr {double($z0+$zthick)/$zmax * ($x1-$x0) + $x0}]
+                _drawMolecule $i $xx0 $xx1
+                _drawAnnotation $i $xx0 $xx1
+            }
+        }
+    }
+    if {[llength $_slabs] > 0} {
+        _drawLayer cap $xx0 $xx1  ;# draw the end cap
     }
 }
@@ -355,8 +308,11 @@
 itcl::body Rappture::DeviceLayout1D::_drawLayer {index x0 x1} {
     set c $itk_component(area)
-    set h [expr {$_sizes(header) + $_sizes(bararea) - 1}]
-
-    set bsize [expr {$_sizes(bar)+$_sizes(bar45)+2}]
-    set y0 [expr {$h - 0.5*$_sizes(bararea) + 0.5*$bsize}]
+    set h [expr {[winfo height $c]-1}]
+    # a little extra height for the molecule image
+    if {[$_device get -exists recipe.molecule]} {
+        set h [expr {$h-15}]
+    }
+
+    set y0 $h
     set y0p [expr {$y0-$_sizes(bar45)}]
     set y1p [expr {$y0-$_sizes(bar)}]
@@ -368,6 +324,12 @@
     set lcolor $itk_option(-deviceoutline)
 
-    if {$index < [llength $_slabs]} {
-        set fcolor [lindex $_colors $index]
+    if {$index == "cap"} {
+        #
+        # Draw the outline around the end cap
+        #
+        $c create line $x1 $y0  $x1 $y1p  $x1p $y1 -fill $lcolor
+
+    } elseif {$index < [llength $_slabs]} {
+        set fcolor [_mater2color [lindex $_maters $index]]
 
         #
@@ -385,37 +347,39 @@
             -outline $lcolor -fill $fcolor
         $c create line $x0 $y1p  $x1 $y1p -fill $lcolor
-
-        #
-        # Draw the outline around the end cap
-        #
-        $c create line $x1 $y0  $x1 $y1p  $x1p $y1 -fill $lcolor
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _drawIcon <index> <x0> <x1> <imh>
-#
-# Used internally within _redraw to draw a material layer that is
-# represented by an icon.  The layer sits at <index> within the slab
-# list into the active area.  The layer is drawn between coordinates
-# <x0> and <x1> on the canvas.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceLayout1D::_drawIcon {index x0 x1 imh} {
+    }
+}
+
+# ----------------------------------------------------------------------
+# USAGE: _drawMolecule <index> <x0> <x1>
+#
+# Used internally within _redraw to draw one molecule layer at the
+# <index> within the slab list into the active area.  The layer is
+# drawn between coordinates <x0> and <x1> on the canvas.
+# ----------------------------------------------------------------------
+itcl::body Rappture::DeviceLayout1D::_drawMolecule {index x0 x1} {
     set c $itk_component(area)
-    set h [expr {$_sizes(header) + $_sizes(bararea) - 1}]
-
-    set bsize [expr {$_sizes(bar)+$_sizes(bar45)+2}]
-    set y0 [expr {$h - 0.5*$_sizes(bararea) + 0.5*$bsize}]
+    set h [expr {[winfo height $c]-1}]
+    # a little extra height for the molecule image
+    if {[$_device get -exists recipe.molecule]} {
+        set h [expr {$h-15}]
+    }
+
+    set y0 $h
     set y0p [expr {$y0-$_sizes(bar45)}]
     set y1p [expr {$y0-$_sizes(bar)}]
     set y1 [expr {$y1p-$_sizes(bar45)}]
     set x0p [expr {$x0+$_sizes(bar45)}]
-    set x1p [expr {$x1+$_sizes(bar45)}]
-
-    set xx0 [expr {0.5*($x0+$x0p)}]
-    set xx1 [expr {0.5*($x1+$x1p)}]
+
+    set x [expr {0.5*($x0+$x0p)}]
     set y [expr {0.5*($y0+$y0p) + 0.5*($y1-$y0p)}]
 
-    $c create image [expr {0.5*($xx0+$xx1)}] $y -anchor c -image $imh
+    set w [image width $_icons(molecule)]
+    set h [image height $_icons(molecule)]
+    set dx [expr {round($x1-$x0)}]
+    set dy [expr {round(double($x1-$x0)/$w*$h)}]
+    set imh [image create photo -width $dx -height $dy]
+    blt::winop resample $_icons(molecule) $imh
+
+    $c create image $x $y -anchor w -image $imh -tags image
 }
 
@@ -429,6 +393,13 @@
 itcl::body Rappture::DeviceLayout1D::_drawAnnotation {index x0 x1} {
     set c $itk_component(area)
-
-    set ytop [expr {$_sizes(header)+1}]
+    set h [expr {[winfo height $c]-1}]
+    # a little extra height for the molecule image
+    if {[$_device get -exists recipe.molecule]} {
+        set h [expr {$h-15}]
+    }
+
+    set y0 $h
+    set y1 [expr {$y0-$_sizes(bar)-$_sizes(bar45)}]
+
     set x0p [expr {$x0+$_sizes(bar45)}]
     set x1p [expr {$x1+$_sizes(bar45)}]
@@ -437,6 +408,23 @@
     set fnt $itk_option(-font)
     set lh [font metrics $fnt -linespace]
-    set ymid [expr {$ytop-2-0.5*$lh}]
-    set y [expr {$ytop-4}]
+    set ymid [expr {$y1-2-0.5*$lh}]
+    set y [expr {$y1-2}]
+
+    #
+    # If there's a .thickness control for this slab, draw it here.
+    #
+    set elem [lindex $_slabs $index]
+    set path "device.$elem.thickness"
+    if {[info exists _controls($path)] && $_controls($path)} {
+        set zthick [lindex $_zthick $index]
+        set zthick [Rappture::Units::convert $zthick -context um -to um]
+
+        $c create line $x0p $y $x0p [expr {$y-$lh}]
+        $c create line $x1p $y $x1p [expr {$y-$lh}]
+
+        $c create line $x0p $ymid $x1p $ymid -arrow both
+        $c create text $xmid [expr {$ymid-2}] -anchor s -text $zthick
+        set y [expr {$y-2.0*$lh}]
+    }
 
     #
@@ -444,14 +432,14 @@
     #
     set elem [lindex $_slabs $index]
-    set mater [lindex $_maters $index]
-    if {"" != $mater} {
-        set x $x1p
-        $c create rectangle [expr {$x-10}] [expr {$y-14}] \
-            [expr {$x-0}] [expr {$y-4}] \
-            -outline black -fill [_mater2color $mater]
-        set x [expr {$x-12}]
-        $c create text $x [expr {$y-7}] -anchor e \
+    set path "device.$elem.material"
+    if {[info exists _controls($path)] && $_controls($path)} {
+        set mater [lindex $_maters $index]
+        set w [expr {12+[font measure $fnt $mater]}]
+        set x [expr {$x1p - 0.5*($x1p-$x0p-$w)}]
+        $c create rectangle [expr {$x-10}] [expr {$y-10}] \
+            $x $y -outline black -fill [_mater2color $mater]
+        $c create text [expr {$x-12}] [expr {$y-5}] -anchor e \
             -text $mater
-        set y [expr {$y-1.5*$lh}]
+        set y [expr {$y-1.2*$lh}]
     }
 
@@ -460,6 +448,7 @@
     #
     if {"" != $_device} {
-        set label [$_device get $elem.about.label]
+        set label [$_device get "$elem.label"]
         if {"" != $label} {
+            set y [expr {$y-0.5*$lh}]
             $c create text [expr {0.5*($x0p+$x1p)}] $y -anchor s \
                 -text $label
@@ -475,8 +464,9 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::DeviceLayout1D::_mater2color {mater} {
-    set lib [Rappture::library standard]
-    set color [$lib get materials.($mater).color]
-    if {$color != ""} {
-        return $color
+    if {$_library != ""} {
+        set color [$_library get materials.$mater.color]
+        if {$color != ""} {
+            return $color
+        }
     }
     return gray
@@ -491,4 +481,20 @@
 itcl::configbody Rappture::DeviceLayout1D::font {
     $_dispatcher event -idle !layout
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -library
+#
+# Set to the Rappture::Library object representing the library with
+# material properties and other info.
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::DeviceLayout1D::library {
+    if {$itk_option(-library) != ""} {
+        if {![Rappture::Library::valid $itk_option(-library)]} {
+            error "bad value \"$itk_option(-library)\": should be Rappture::Library"
+        }
+    }
+    set _library $itk_option(-library)
+    $_dispatcher event -idle !redraw
 }
 
@@ -502,24 +508,10 @@
 itcl::configbody Rappture::DeviceLayout1D::device {
     if {$itk_option(-device) != ""} {
-        if {![Rappture::library isvalid $itk_option(-device)]} {
+        if {![Rappture::Library::valid $itk_option(-device)]} {
             error "bad value \"$itk_option(-device)\": should be Rappture::Library"
         }
     }
     set _device $itk_option(-device)
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -width
-#
-# Sets the minimum overall width of the widget.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::DeviceLayout1D::width {
-    if {[catch {
-          winfo pixels $itk_component(hull) $itk_option(-width)
-      } pixels]} {
-        error "bad screen distance \"$itk_option(-width)\""
-    }
-    $_dispatcher event -idle !layout
+    $_dispatcher event -idle !redraw
 }
 
Index: trunk/gui/scripts/deviceViewer1D.tcl
===================================================================
--- trunk/gui/scripts/deviceViewer1D.tcl	(revision 6716)
+++ trunk/gui/scripts/deviceViewer1D.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: deviceViewer1D - visualizer for 1D device geometries
@@ -11,18 +10,14 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
-package require Img
 package require BLT
 
+option add *DeviceViewer1D.width 4i widgetDefault
+option add *DeviceViewer1D.height 4i widgetDefault
 option add *DeviceViewer1D.padding 4 widgetDefault
 option add *DeviceViewer1D.deviceSize 0.25i widgetDefault
 option add *DeviceViewer1D.deviceOutline black widgetDefault
-option add *DeviceViewer1D*graph.width 3i widgetDefault
-option add *DeviceViewer1D*graph.height 2i widgetDefault
 
 itcl::class Rappture::DeviceViewer1D {
@@ -30,20 +25,13 @@
 
     itk_option define -device device Device ""
-
-    constructor {owner args} { # defined below }
+    itk_option define -tool tool Tool ""
+
+    constructor {args} { # defined below }
     destructor { # defined below }
 
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method parameters {title args} { # do nothing }
-
     public method controls {option args}
-    public method download {option args}
-
-    protected method _loadDevice {}
-    protected method _loadParameters {frame path}
-    protected method _changeTabs {{why -program}}
-    protected method _fixSize {}
+                                                                                
+    protected method _fixTabs {}
+    protected method _changeTabs {}
     protected method _fixAxes {}
     protected method _align {}
@@ -54,14 +42,12 @@
     protected method _controlSet {widget libObj path}
 
-    private variable _owner ""      ;# thing managing this control
-    private variable _dlist ""      ;# list of dataobj objects
-    private variable _dobj2raise    ;# maps dataobj => raise flag
-    private variable _device ""     ;# XML library with <structure>
+    private variable _device ""     ;# LibraryObj for device rep
+    private variable _tool ""       ;# LibraryObj for tool parameters
     private variable _tab2fields    ;# maps tab name => list of fields
-    private variable _field2parm    ;# maps field path => parameter name
     private variable _units ""      ;# units for field being edited
+    private variable _restrict ""   ;# restriction expr for field being edited
     private variable _marker        ;# marker currently being edited
 }
-
+                                                                                
 itk::usual DeviceViewer1D {
 }
@@ -70,7 +56,6 @@
 # CONSTRUCTOR
 # ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::constructor {owner args} {
-    set _owner $owner
-
+itcl::body Rappture::DeviceViewer1D::constructor {args} {
+    itk_option add hull.width hull.height
     pack propagate $itk_component(hull) no
 
@@ -78,5 +63,5 @@
         blt::tabset $itk_interior.tabs -borderwidth 0 -relief flat \
             -side bottom -tearoff 0 \
-            -selectcommand [itcl::code $this _changeTabs -user]
+            -selectcommand [itcl::code $this _changeTabs]
     } {
         keep -activebackground -activeforeground
@@ -84,7 +69,6 @@
         rename -highlightbackground -background background Background
         keep -highlightcolor -highlightthickness
+        keep -selectbackground -selectforeground
         keep -tabbackground -tabforeground
-        rename -selectbackground -background background Background
-        rename -selectforeground -foreground foreground Foreground
     }
     pack $itk_component(tabs) -expand yes -fill both
@@ -94,8 +78,8 @@
     }
 
-    itk_component add top {
-        frame $itk_component(inner).top
-    }
-    pack $itk_component(top) -fill x
+    itk_component add ambient {
+        frame $itk_component(inner).ambient
+    }
+    pack $itk_component(ambient) -side top -fill x
 
     itk_component add layout {
@@ -106,5 +90,6 @@
     itk_component add graph {
         blt::graph $itk_component(inner).graph \
-            -highlightthickness 0 -plotpadx 0 -plotpady 0
+            -highlightthickness 0 -plotpadx 0 -plotpady 0 \
+            -width 3i -height 3i
     } {
         keep -background -foreground -cursor -font
@@ -114,6 +99,6 @@
 
     bind $itk_component(graph) <Configure> "
-        [list after cancel [list catch [itcl::code $this _align]]]
-        [list after 100 [list catch [itcl::code $this _align]]]
+        after cancel [itcl::code $this _fixAxes]
+        after idle [itcl::code $this _fixAxes]
     "
 
@@ -131,7 +116,4 @@
 
     eval itk_initialize $args
-
-    after cancel [list catch [itcl::code $this _fixSize]]
-    after idle [list catch [itcl::code $this _fixSize]]
 }
 
@@ -146,158 +128,49 @@
     after cancel [list catch [itcl::code $this _fixAxes]]
     after cancel [list catch [itcl::code $this _align]]
-    after cancel [list catch [itcl::code $this _loadDevice]]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise. Only
-# -brightness and -raise do anything.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    set pos [lsearch -exact $_dlist $dataobj]
-
-    if {$pos < 0} {
-        if {![Rappture::library isvalid $dataobj]} {
-            error "bad value \"$dataobj\": should be Rappture::library object"
-        }
-
-        lappend _dlist $dataobj
-        set _dobj2raise($dataobj) $params(-raise)
-
-        after cancel [list catch [itcl::code $this _loadDevice]]
-        after idle [list catch [itcl::code $this _loadDevice]]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-    foreach obj $dlist {
-        if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} {
-            set i [lsearch -exact $dlist $obj]
-            if {$i >= 0} {
-                set dlist [lreplace $dlist $i $i]
-                lappend dlist $obj
-            }
-        }
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj> <dataobj> ...?
-#
-# Clients use this to delete a dataobj from the plot. If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            catch {unset _dobj2raise($dataobj)}
-            set changed 1
-        }
-    }
-
-    # if anything changed, then rebuild the plot
-    if {$changed} {
-        after cancel [list catch [itcl::code $this _loadDevice]]
-        after idle [list catch [itcl::code $this _loadDevice]]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: controls insert <pos> <xmlobj> <path>
+}
+
+# ----------------------------------------------------------------------
+# USAGE: controls add <parameter>
+# USAGE: controls remove <parameter>|all
 #
 # Clients use this to add a control to the internal panels of this
-# widget.  Such controls are usually placed at the top of the widget,
-# but if possible, they are integrated directly onto the device
-# layout or the field area.
+# widget.  If the <parameter> is ambient*, then the control is added
+# to the top, so it goes along with the layout of the device.  If
+# it is device.field*, then it goes in one of the field panels.
 # ----------------------------------------------------------------------
 itcl::body Rappture::DeviceViewer1D::controls {option args} {
     switch -- $option {
-        insert {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"controls insert pos xmlobj path\""
+        add {
+            if {[llength $args] != 1} {
+                error "wrong # args: should be \"controls add parameter\""
             }
-            set pos [lindex $args 0]
-            set xmlobj [lindex $args 1]
-            set path [lindex $args 2]
-            if {[string match *structure.parameters* $path]} {
-            } elseif {[string match structure.components* $path]} {
-                $itk_component(layout) controls insert $pos $xmlobj $path
+            set path [lindex $args 0]
+            if {[string match device.field* $path]} {
+            } elseif {[string match device.recipe* $path]} {
+                $itk_component(layout) controls add $path
+            } else {
+                _controlCreate $itk_component(ambient) $_tool $path
             }
         }
+        remove {
+            error "not yet implemented"
+        }
         default {
-            error "bad option \"$option\": should be insert"
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            # no controls for this download yet
-            return ""
-        }
-        now {
-            return ""  ;# not implemented yet!
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _loadDevice
+            error "bad option \"$option\": should be add or remove"
+        }
+    }
+}
+
+# ----------------------------------------------------------------------
+# USAGE: _fixTabs
 #
 # Used internally to search for fields and create corresponding
 # tabs whenever a device is installed into this viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::_loadDevice {} {
-    set _device [lindex [get] end]
-
+#
+# If there are no tabs, then the widget is packed so that it appears
+# directly.  Otherwise, the interior reconfigured and assigned to
+# the current tab.
+# ----------------------------------------------------------------------
+itcl::body Rappture::DeviceViewer1D::_fixTabs {} {
     #
     # Release any info left over from the last device.
@@ -307,9 +180,4 @@
     }
     catch {unset _tab2fields}
-    catch {unset _field2parm}
-
-    if {[winfo exists $itk_component(top).cntls]} {
-        $itk_component(top).cntls delete 0 end
-    }
 
     #
@@ -318,12 +186,14 @@
     #
     if {$_device != ""} {
-        foreach nn [$_device children fields] {
-            set name [$_device get fields.$nn.about.label]
-            if {$name == ""} {
-                set name $nn
+        foreach nn [$_device get -children] {
+            if {[string match field* $nn]} {
+                set name [$_device get $nn.label]
+                if {$name == ""} {
+                    set name $nn
+                }
+
+                set fobj [Rappture::Field ::#auto $_device $_device $nn]
+                lappend _tab2fields($name) $fobj
             }
-
-            set fobj [Rappture::Field ::#auto $_device fields.$nn]
-            lappend _tab2fields($name) $fobj
         }
     }
@@ -336,7 +206,7 @@
     if {[llength $tabs] <= 0} {
         #
-        # No fields?  Then we don't need to bother with tabs.
-        # Just pack the inner frame directly.  If there are no
-        # fields, get rid of the graph.
+        # No fields or one field?  Then we don't need to bother
+        # with tabs.  Just pack the inner frame directly.  If
+        # there are no fields, get rid of the graph.
         #
         pack $itk_component(inner) -expand yes -fill both
@@ -357,24 +227,8 @@
 
         foreach name $tabs {
-            $itk_component(tabs) insert end $name \
-                -activebackground $itk_option(-background)
+            $itk_component(tabs) insert end $name
         }
         $itk_component(tabs) select 0
     }
-
-    #
-    # Scan through and look for any parameters in the <structure>.
-    # Register any parameters associated with fields, so we can
-    # add them as active controls whenever we install new fields.
-    # Create controls for any remaining parameters, so the user
-    # can see that there's something to adjust.
-    #
-    if {$_device != ""} {
-        _loadParameters $itk_component(top) parameters
-    }
-
-    #
-    # Install the first tab
-    #
     _changeTabs
 
@@ -385,77 +239,13 @@
     $itk_component(graph) configure \
         -rightmargin [$itk_component(layout) extents bar3D]
-
-    after cancel [list catch [itcl::code $this _fixSize]]
-    after idle [list catch [itcl::code $this _fixSize]]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _loadParameters <frame> <path>
-#
-# Used internally in _loadDevice to load child parameters at the
-# specified <path> into the <frame>.  If any of the children are
-# groups, then this is called recursively to fill in the group
-# children.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::_loadParameters {frame path} {
-    foreach cname [$_device children $path] {
-        set handled 0
-        set type [$_device element -as type $path.$cname]
-        if {$type == "about"} {
-            continue
-        }
-        if {$type == "number"} {
-            set name [$_device element -as id $path.$cname]
-
-            # look for a field that uses this parameter
-            set found ""
-            foreach fname [$_device children fields] {
-                foreach comp [$_device children fields.$fname] {
-                    set v [$_device get fields.$fname.$comp.constant]
-                    if {[string equal $v $name]} {
-                        set found "fields.$fname.$comp"
-                        break
-                    }
-                }
-                if {"" != $found} break
-            }
-
-            if {"" != $found} {
-                set _field2parm($found) $name
-                set handled 1
-            }
-        }
-
-        #
-        # Any parameter that was not handled above should be handled
-        # here, by adding it to a control panel above the device
-        # layout area.
-        #
-        if {!$handled} {
-            if {![winfo exists $frame.cntls]} {
-                Rappture::Controls $frame.cntls $_owner
-                pack $frame.cntls -expand yes -fill both
-            }
-            $frame.cntls insert end $path.$cname
-
-            #
-            # If this is a group, then we must add its children
-            # recursively.
-            #
-            if {$type == "group"} {
-                set gr [$frame.cntls control -value end]
-                _loadParameters [$gr component inner] $path.$cname
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _changeTabs ?-user|-program?
+}
+
+# ----------------------------------------------------------------------
+# USAGE: _changeTabs
 #
 # Used internally to change the field being displayed whenever a new
 # tab is selected.
 # ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::_changeTabs {{why -program}} {
+itcl::body Rappture::DeviceViewer1D::_changeTabs {} {
     set graph $itk_component(graph)
 
@@ -473,8 +263,4 @@
     }
 
-    if {$why eq "-user"} {
-        Rappture::Logger::log device1D -field $name
-    }
-
     #
     # Update the graph to show the current field.
@@ -484,22 +270,10 @@
 
     foreach {zmin zmax} [$itk_component(layout) limits] { break }
-    if {$zmin != "" && $zmin < $zmax} {
-        $graph axis configure x -min $zmin -max $zmax
-    }
-
-    if {$_device != ""} {
-        set units [$_device get units]
-        if {$units != "arbitrary"} {
-            $graph axis configure x -hide no -title "Position ($units)"
-        } else {
-            $graph axis configure x -hide yes
-        }
-    } else {
-        $graph axis configure x -hide no -title "Position"
-    }
-    $graph axis configure x -checklimits no
+    if {$zmax > $zmin} {
+        $graph axis configure x -min $zmin -max $zmax -title "Position (um)"
+    }
 
     # turn on auto limits
-    $graph axis configure y -min "" -max "" -checklimits no
+    $graph axis configure y -min "" -max ""
 
     set flist ""
@@ -521,4 +295,10 @@
         }
 
+        if {[info exists hints(restrict)]} {
+            set _restrict $hints(restrict)
+        } else {
+            set _restrict ""
+        }
+
         if {[info exists hints(scale)]
               && [string match log* $hints(scale)]} {
@@ -529,15 +309,7 @@
 
         foreach comp [$fobj components] {
-            # can only handle 1D meshes here
-            if {[$fobj components -dimensions $comp] != "1D"} {
-                continue
-            }
-
             set elem "elem[incr n]"
-            set xv [$fobj mesh $comp]
-            set yv [$fobj values $comp]
-
-            $graph element create $elem -x $xv -y $yv \
-                -color black -symbol "" -linewidth 2
+            foreach {xv yv} [$fobj vectors $comp] { break }
+            $graph element create $elem -x $xv -y $yv -symbol "" -linewidth 2
 
             if {[info exists hints(color)]} {
@@ -546,15 +318,12 @@
 
             foreach {path x y val} [$fobj controls get $comp] {
-                if {$path != ""} {
-                    set id "control[incr n]"
-                    $graph marker create text -coords [list $x $y] \
-                        -text $val -anchor s -name $id -background ""
-                    $graph marker bind $id <Enter> \
-                        [itcl::code $this _marker enter $id]
-                    $graph marker bind $id <Leave> \
-                        [itcl::code $this _marker leave $id]
-                    $graph marker bind $id <ButtonPress> \
-                        [itcl::code $this _marker edit $id $fobj/$path]
-                }
+                $graph marker create text -coords [list $x $y] \
+                    -text $val -anchor s -name $comp.$x
+                $graph marker bind $comp.$x <Enter> \
+                    [itcl::code $this _marker enter $comp.$x]
+                $graph marker bind $comp.$x <Leave> \
+                    [itcl::code $this _marker leave $comp.$x]
+                $graph marker bind $comp.$x <ButtonPress> \
+                    [itcl::code $this _marker edit $comp.$x $fobj/$path]
             }
         }
@@ -562,21 +331,6 @@
 
     # let the widget settle, then fix the axes to "nice" values
-    after cancel [list catch [itcl::code $this _fixAxes]]
-    after 100 [list catch [itcl::code $this _fixAxes]]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Used internally to fix the overall size of this widget based on
-# the various parts inside.  Sets the requested width/height of the
-# widget so that it is big enough to display the device and its
-# fields.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceViewer1D::_fixSize {} {
-    update idletasks
-    set w [winfo reqwidth $itk_component(tabs)]
-    set h [winfo reqheight $itk_component(tabs)]
-    component hull configure -width $w -height $h
+    after cancel [itcl::code $this _fixAxes]
+    after 20 [itcl::code $this _fixAxes]
 }
 
@@ -590,9 +344,4 @@
 itcl::body Rappture::DeviceViewer1D::_fixAxes {} {
     set graph $itk_component(graph)
-    if {![winfo ismapped $graph]} {
-        after cancel [list catch [itcl::code $this _fixAxes]]
-        after 100 [list catch [itcl::code $this _fixAxes]]
-        return
-    }
 
     #
@@ -604,5 +353,4 @@
     #
     set log [$graph axis cget y -logscale]
-    $graph axis configure y -min "" -max ""
     foreach {min max} [$graph axis limits y] { break }
 
@@ -688,21 +436,7 @@
         enter {
             $itk_component(graph) marker configure $name -background #e5e5e5
-            #
-            # BE CAREFUL:  Need an update here to force the graph to
-            #   refresh itself or else a subsequent click on the
-            #   marker will ignore the text that was recently changed,
-            #   and fail to generate a <ButtonPress> event!
-            #
-            update idletasks
         }
         leave {
             $itk_component(graph) marker configure $name -background ""
-            #
-            # BE CAREFUL:  Need an update here to force the graph to
-            #   refresh itself or else a subsequent click on the
-            #   marker will ignore the text that was recently changed,
-            #   and fail to generate a <ButtonPress> event!
-            #
-            update idletasks
         }
         edit {
@@ -740,13 +474,18 @@
                     bell
                     Rappture::Tooltip::cue $itk_component(geditor) $result
-                    Rappture::Logger::log warning $_marker(path) $result
                     return 0
                 }
-            }
-            if {[catch {$_marker(fobj) controls validate $_marker(path) $name} result]} {
-                bell
-                Rappture::Tooltip::cue $itk_component(geditor) $result
-                Rappture::Logger::log warning $_marker(path) $result
-                return 0
+                if {"" != $_restrict
+                      && [catch {Rappture::Units::convert $result \
+                        -context $_units -to $_units -units off} value] == 0} {
+
+                    set rexpr $_restrict
+                    regsub -all value $rexpr {$value} rexpr
+                    if {[catch {expr $rexpr} result] == 0 && !$result} {
+                        bell
+                        Rappture::Tooltip::cue $itk_component(geditor) "Should satisfy the condition: $_restrict"
+                        return 0
+                    }
+                }
             }
             return 1
@@ -761,7 +500,5 @@
 
             $_marker(fobj) controls put $_marker(path) $value
-            $_owner changed $_marker(path)
             event generate $itk_component(hull) <<Edit>>
-            Rappture::Logger::log input $_marker(path) $value
 
             _changeTabs
@@ -779,8 +516,9 @@
 itcl::body Rappture::DeviceViewer1D::_controlCreate {container libObj path} {
     set presets ""
-    foreach pre [$libObj children -type preset $path] {
+    set npre [$libObj get -count $path.preset]
+    for {set i 0} {$i < $npre} {incr i} {
         lappend presets \
-            [$libObj get $path.$pre.value] \
-            [$libObj get $path.$pre.label]
+            [$libObj get $path.preset$i.value] \
+            [$libObj get $path.preset$i.label]
     }
 
@@ -801,5 +539,5 @@
 
     # create the widget
-    $type $w -units $units -presets $presets -log $path
+    $type $w -units $units -presets $presets
     pack $w -side top -anchor w
     bind $w <<Value>> [itcl::code $this _controlSet $w $libObj $path]
@@ -868,13 +606,25 @@
 itcl::configbody Rappture::DeviceViewer1D::device {
     if {$itk_option(-device) != ""} {
-        if {![Rappture::library isvalid $itk_option(-device)]} {
+        if {![Rappture::Library::valid $itk_option(-device)]} {
             error "bad value \"$itk_option(-device)\": should be Rappture::Library"
         }
     }
-
-    delete
-    if {"" != $itk_option(-device)} {
-        add $itk_option(-device)
-    }
-    _loadDevice
-}
+    set _device $itk_option(-device)
+    _fixTabs
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -tool
+#
+# Set to the Rappture::Library object containing tool parameters.
+# Needed only if controls are added to the widget, so the controls
+# can update the tool parameters.
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::DeviceViewer1D::tool {
+    if {$itk_option(-tool) != ""} {
+        if {![Rappture::Library::valid $itk_option(-tool)]} {
+            error "bad value \"$itk_option(-tool)\": should be Rappture::Library"
+        }
+    }
+    set _tool $itk_option(-tool)
+}
Index: trunk/gui/scripts/deviceresult.tcl
===================================================================
--- trunk/gui/scripts/deviceresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,128 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: DeviceResult - output for <structure>
-#
-#  This widget is used to show <structure> output.  It is similar
-#  to a DeviceEditor, but does not allow editing.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *DeviceResult.width 4i widgetDefault
-option add *DeviceResult.height 4i widgetDefault
-option add *DeviceResult.font \
-    -*-courier-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::DeviceResult {
-    inherit itk::Widget
-
-    constructor {args} { # defined below }
-
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} { # do nothing }
-    public method download {option args}
-
-    private variable _dataobj ""  ;# data object currently being displayed
-}
-
-itk::usual DeviceResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceResult::constructor {args} {
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add viewer {
-        # turn off auto-cleanup -- resultset swaps results in and out
-        Rappture::DeviceEditor $itk_interior.dev "" -autocleanup no
-    }
-    pack $itk_component(viewer) -expand yes -fill both
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  If the optional
-# <settings> are specified, then the are applied to the data.  Allowed
-# settings are -color and -brightness, -width, -linestyle and -raise.
-# (Many of these are ignored.)
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceResult::add {dataobj {settings ""}} {
-    array set params {
-        -color ""
-        -brightness ""
-        -width ""
-        -linestyle ""
-        -raise ""
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    eval $itk_component(viewer) add $dataobj [list $settings]
-
-    set _dataobj $dataobj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceResult::get {} {
-    return $_dataobj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceResult::delete {args} {
-    eval $itk_component(viewer) delete $args
-    set _dataobj ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all dataobjs--even those not showing on the screen.
-# Because of this, the limits are appropriate for all dataobjs as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceResult::scale {args} {
-    # nothing to do for structures
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DeviceResult::download {option args} {
-    return [eval $itk_component(viewer) download $option $args]
-}
Index: trunk/gui/scripts/diffview.tcl
===================================================================
--- trunk/gui/scripts/diffview.tcl	(revision 6716)
+++ 	(revision )
@@ -1,121 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  WIDGET: diffview - view differences between two strings
-#
-#  These are the class bindings for the Diffview widget.  The widget
-#  itself is implemented in C code, but this file customizes the
-#  behavior of the widget by adding default bindings.  It is loaded
-#  when the widget initializes itself.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-namespace eval Rappture { # forward declaration }
-
-# ----------------------------------------------------------------------
-# Code for "usual" itk options
-# ----------------------------------------------------------------------
-if {[catch {package require Itk}] == 0} {
-    itk::usual Diffview {
-        keep -background -foreground -cursor
-        keep -addedbackground -addedforeground
-        keep -deletedbackground -deletedforeground -overstrike
-        keep -changedbackground -changedforeground
-        keep -highlightcolor -highlightthickness
-        rename -highlightbackground -background background Background
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# Key navigation
-# ----------------------------------------------------------------------
-bind Diffview <Key-Up> {
-    %W yview scroll -1 units
-}
-bind Diffview <Control-Key-Up> {
-    %W yview scroll -1 pages
-}
-bind Diffview <Key-Prior> {
-    %W yview scroll -1 pages
-}
-
-bind Diffview <Key-Down> {
-    %W yview scroll 1 units
-}
-bind Diffview <Control-Key-Down> {
-    %W yview scroll 1 pages
-}
-bind Diffview <Key-Next> {
-    %W yview scroll 1 pages
-}
-
-bind Diffview <Key-Left> {
-    %W xview scroll -1 units
-}
-bind Diffview <Control-Key-Left> {
-    %W xview scroll -1 pages
-}
-
-bind Diffview <Key-Right> {
-    %W xview scroll 1 units
-}
-bind Diffview <Control-Key-Right> {
-    %W xview scroll 1 pages
-}
-
-# ----------------------------------------------------------------------
-# Click/drag for fast scanning
-# ----------------------------------------------------------------------
-bind Diffview <ButtonPress-2> {
-    %W scan mark %x %y
-}
-bind Diffview <B2-Motion> {
-    %W scan dragto %x %y
-}
-
-# ----------------------------------------------------------------------
-# MouseWheel bindings
-# ----------------------------------------------------------------------
-switch -- [tk windowingsystem] {
-    classic - aqua {
-        bind Diffview <MouseWheel> {
-            %W yview scroll [expr {-(%D)}] units
-        }
-        bind Diffview <Option-MouseWheel> {
-            %W yview scroll [expr {-10*(%D)}] units
-        }
-        bind Diffview <Shift-MouseWheel> {
-            %W xview scroll [expr {-(%D)}] units
-        }
-        bind Diffview <Shift-Option-MouseWheel> {
-            %W xview scroll [expr {-10*(%D)}] units
-        }
-    }
-    x11 {
-        # support for mousewheels on Linux comes from buttons 4/5
-        bind Diffview <4> {
-            if {!$tk_strictMotif} {
-                %W yview scroll -5 units
-            }
-        }
-        bind Diffview <5> {
-            if {!$tk_strictMotif} {
-                %W yview scroll 5 units
-            }
-        }
-
-        # in case anyone generates a <MouseWheel> event
-        bind Diffview <MouseWheel> {
-            %W yview scroll [expr {-(%D/120)*4}] units
-        }
-    }
-    default {
-        bind Diffview <MouseWheel> {
-            %W yview scroll [expr {-(%D/120)*4}] units
-        }
-    }
-}
Index: trunk/gui/scripts/dispatcher.tcl
===================================================================
--- trunk/gui/scripts/dispatcher.tcl	(revision 6716)
+++ trunk/gui/scripts/dispatcher.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: dispatcher - central notification mechanism
@@ -14,8 +13,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itcl
@@ -46,5 +42,5 @@
     private variable _extraargs      ;# extra args for dispatch calls
 }
-
+                                                                                
 # ----------------------------------------------------------------------
 # CONSTRUCTOR
@@ -53,5 +49,5 @@
     # nothing to do
 }
-
+                                                                                
 # ----------------------------------------------------------------------
 # DESTRUCTOR
@@ -225,5 +221,4 @@
 # ----------------------------------------------------------------------
 # USAGE: cancel ?!event ...?
-#        cancel all
 #
 # Used to cancel any event notifications pending for the specified
@@ -232,13 +227,7 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::DispatchObj::cancel {args} {
-    if { $args == "all" } {
-        foreach event [array names _event2clients] {
-            after cancel [itcl::code $this _send $event all @extra]
-        }
-        return
-    }
     foreach event $args {
         if {![info exists _event2clients($event)]} {
-            error "bad event \"$event\": should be [join [lsort [array names _event2clients]] {, }]"
+            error "bad event \"$str\": should be [join [lsort [array names _event2clients]] {, }]"
         }
         after cancel [itcl::code $this _send $event all @extra]
Index: trunk/gui/scripts/drawing.tcl
===================================================================
--- trunk/gui/scripts/drawing.tcl	(revision 6716)
+++ 	(revision )
@@ -1,261 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: drawing - 3D drawing of data
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture {
-    # forward declaration
-}
-
-itcl::class Rappture::Drawing {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method label { elem }
-    public method type { elem }
-    public method style { elem }
-    public method shape { elem }
-    public method values { elem }
-    public method data { elem }
-    public method hints {{keyword ""}}
-    public method components { args }
-
-    private variable _drawing
-    private variable _xmlobj
-    private variable _styles
-    private variable _shapes
-    private variable _labels
-    private variable _types
-    private variable _data
-    private variable _hints
-    private variable _units
-}
-
-# ----------------------------------------------------------------------
-# Constructor
-# ----------------------------------------------------------------------
-itcl::body Rappture::Drawing::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be Rappture::library"
-    }
-    set _xmlobj $xmlobj
-    set _drawing [$xmlobj element -as object $path]
-    set _units [$_drawing get units]
-
-    set xunits [$xmlobj get units]
-    if {"" == $xunits || "arbitrary" == $xunits} {
-        set xunits "um"
-    }
-    # determine the overall size of the device
-    foreach elem [$_xmlobj children $path] {
-        switch -glob -- $elem {
-            # polygon is deprecated in favor of polydata
-            polygon* - polydata* {
-                set _data($elem) [$_xmlobj get $path.$elem.vtk]
-                set _data($elem) [string trim $_data($elem)]
-                set _styles($elem) [$_xmlobj get $path.$elem.about.style]
-                set _labels($elem) [$_xmlobj get $path.$elem.about.label]
-                set _types($elem) polydata
-            }
-            glyphs* {
-                set _data($elem) [$_xmlobj get $path.$elem.vtk]
-                set _data($elem) [string trim $_data($elem)]
-                set _styles($elem) [$_xmlobj get $path.$elem.about.style]
-                set _labels($elem) [$_xmlobj get $path.$elem.about.label]
-                set _shapes($elem) [$_xmlobj get $path.$elem.about.shape]
-                set _types($elem) glyphs
-            }
-            molecule* {
-                set pdbdata [$_xmlobj get $path.$elem.pdb]
-                if { $pdbdata != "" } {
-                    set contents [Rappture::PdbToVtk $pdbdata]
-                } else {
-                    set contents [$_xmlobj get $path.$elem.vtk]
-                }
-                set _data($elem) [string trim $contents]
-                set _styles($elem) [$_xmlobj get $path.$elem.about.style]
-                set _labels($elem) [$_xmlobj get $path.$elem.about.label]
-                set _types($elem) molecule
-            }
-        }
-    }
-    foreach {key path} {
-        camera  about.camera
-        color   about.color
-        group   about.group
-        label   about.label
-        type    about.type
-        xdesc   xaxis.description
-        ydesc   yaxis.description
-        zdesc   zaxis.description
-        xlabel  xaxis.label
-        ylabel  yaxis.label
-        zlabel  zaxis.label
-        xscale  xaxis.scale
-        yscale  yaxis.scale
-        zscale  zaxis.scale
-        xunits  xaxis.units
-        yunits  yaxis.units
-        zunits  zaxis.units
-        xmin    xaxis.min
-        xmax    xaxis.max
-        ymin    yaxis.min
-        ymax    yaxis.max
-        zmin    zaxis.min
-        zmax    zaxis.max
-    } {
-        set str [$_drawing get $path]
-        if {"" != $str} {
-            set _hints($key) $str
-        }
-    }
-    foreach {key path} {
-        toolid          tool.id
-        toolname        tool.name
-        toolcommand     tool.execute
-        tooltitle       tool.title
-        toolrevision    tool.version.application.revision
-    } {
-        set str [$_xmlobj get $path]
-        if { "" != $str } {
-            set _hints($key) $str
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Destructor
-# ----------------------------------------------------------------------
-itcl::body Rappture::Drawing::destructor {} {
-    # empty
-}
-
-#
-# label --
-#
-#       Returns the label of the named drawing element.
-#
-itcl::body Rappture::Drawing::label { elem } {
-    if { [info exists _labels($elem)] } {
-        return $_labels($elem)
-    }
-    return ""
-}
-
-#
-# type --
-#
-#       Returns the type of the named drawing element.
-#
-itcl::body Rappture::Drawing::type { elem } {
-    if { [info exists _types($elem)] } {
-        return $_types($elem)
-    }
-    return ""
-}
-
-#
-# style --
-#
-#       Returns the style string of the named drawing element.
-#
-itcl::body Rappture::Drawing::style { elem } {
-    if { [info exists _styles($elem)] } {
-        return $_styles($elem)
-    }
-    return ""
-}
-
-#
-# shape --
-#
-#       Returns the shape of the glyphs in the drawing element.
-#
-itcl::body Rappture::Drawing::shape { elem } {
-    set shape ""
-    if { [info exists _shapes($elem)] } {
-        return $_shapes($elem)
-    }
-    switch -- $shape {
-        arrow - cone - cube - cylinder - dodecahedron -
-        icosahedron - line - octahedron - sphere - tetrahedron  {
-            return $shape
-        }
-        default {
-            puts stderr "unknown glyph shape \"$shape\""
-        }
-    }
-    return ""
-}
-
-#
-# data --
-#
-#       Returns the data of the named drawing element.
-#
-itcl::body Rappture::Drawing::data { elem } {
-    if { [info exists _data($elem)] } {
-        return $_data($elem)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# method values
-#       Returns a base64 encoded, gzipped Tcl list that represents the
-#       Tcl command and data to recreate the uniform rectangular grid
-#       on the nanovis server.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Drawing::values { elem } {
-    if { [info exists _data($elem)] } {
-        return $_data($elem)
-    }
-    return ""
-}
-
-itcl::body Rappture::Drawing::components { args } {
-    return [array names _data]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this curve.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Drawing::hints { {keyword ""} } {
-    if 0 {
-    if {[info exists _hints(xlabel)] && "" != $_hints(xlabel)
-        && [info exists _hints(xunits)] && "" != $_hints(xunits)} {
-        set _hints(xlabel) "$_hints(xlabel) ($_hints(xunits))"
-    }
-    if {[info exists _hints(ylabel)] && "" != $_hints(ylabel)
-        && [info exists _hints(yunits)] && "" != $_hints(yunits)} {
-        set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))"
-    }
-    }
-    if {[info exists _hints(group)] && [info exists _hints(label)]} {
-        # pop-up help for each curve
-        set _hints(tooltip) $_hints(label)
-    }
-    if {$keyword != ""} {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
-        }
-        return ""
-    }
-    return [array get _hints]
-}
Index: trunk/gui/scripts/drawingentry.tcl
===================================================================
--- trunk/gui/scripts/drawingentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1151 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: DrawingEntry - widget for entering numeric values
-#
-#  This widget represents a <number> entry on a control panel.
-#  It is used to enter numeric values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require Img
-
-itcl::class Rappture::DrawingEntry {
-    inherit itk::Widget
-    itk_option define -state state State "normal"
-
-    private variable _dispatcher ""
-    private variable _path
-    private variable _owner
-    private variable _monitoring ""
-    private variable _xmlobj ""
-
-    # slave interpreter where all substituted variables are stored
-    private variable _parser ""
-
-    # unique counter for popup names
-    private common _popupnum 0
-
-    private variable _canvasHeight 0
-    private variable _canvasWidth 0
-    private variable _cpath2popup
-    private variable _takedown ""
-    private variable _cname2id
-    private variable _cname2image
-    private variable _name2path
-    private variable _name2map
-    private variable _drawingHeight 0
-    private variable _drawingWidth 0
-    private variable _showing ""
-    private variable _xAspect 0
-    private variable _xMin 0
-    private variable _xOffset 0
-    private variable _xScale 1.0
-    private variable _yAspect 0
-    private variable _yMin 0
-    private variable _yOffset 0
-    private variable _yScale 1.0
-    private variable _cursor ""
-
-    constructor {owner path args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method value { args }
-    public method label {}
-    public method tooltip {}
-
-    private method Activate { tag }
-    private method AdjustDrawingArea { xAspect yAspect }
-    private method Deactivate { tag }
-    private method Highlight { tag }
-    private method Invoke { name x y }
-    private method ParseBackground {}
-    private method ParseDescription {}
-    private method ParseGrid { cpath cname }
-    private method ParseHotspot { cpath cname }
-    private method ParseLine { cpath cname }
-    private method ParseOval { cpath cname }
-    private method ParsePicture { cpath cname }
-    private method ParsePolygon { cpath cname }
-    private method ParseRectangle { cpath cname }
-    private method ParseScreenCoordinates { values }
-    private method ParseText { cpath cname }
-    private method Redraw {}
-    private method ScreenCoords { coords }
-    private method ScreenX { x }
-    private method ScreenY { y }
-    private method UpdateSubstitutions {}
-    private method XmlGet { path }
-    private method XmlGetSubst { path }
-    private method Hotspot { option cname item args }
-}
-
-itk::usual DrawingEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::DrawingEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _path $path
-    set _owner $owner
-    set _xmlobj [$_owner xml object]
-
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !redraw
-    $_dispatcher dispatch $this !redraw "[itcl::code $this Redraw]; list"
-
-    #
-    # Display the current drawing.
-    #
-    itk_component add drawing {
-        canvas $itk_interior.canvas -background white -relief sunken -bd 1 \
-            -width 400 -height 300
-    } {
-        ignore -background
-    }
-    pack $itk_component(drawing) -expand yes -fill both
-    bind $itk_component(drawing) <Configure> \
-        [itcl::code $_dispatcher event -idle !redraw]
-
-    # scan through all variables and attach notifications for changes
-    set subs [$_xmlobj children -as path -type variable $_path.substitutions]
-    foreach cpath $subs {
-        set map ""
-        set name ""
-        set path ""
-        foreach elem [$_xmlobj children $cpath] {
-            switch -glob -- $elem {
-                "name*" {
-                    set name [XmlGet $cpath.$elem]
-                }
-                "path*" {
-                    set path [XmlGet $cpath.$elem]
-                }
-                "map*" {
-                    set from [XmlGet $cpath.$elem.from]
-                    set to [XmlGet $cpath.$elem.to]
-                    lappend map $from $to
-                }
-            }
-        }
-        if {$name eq ""} {
-            puts stderr "no name defined for substitution variable \"$cpath\""
-            continue
-        }
-        if {[info exists _name2path($name)]} {
-            puts stderr "substitution variable \"$name\" already defined"
-            continue
-        }
-        set _name2path($name) $path
-        if {$path eq ""} {
-            puts stderr "no path defined for substitution variable \"$cpath\""
-            continue
-        }
-        set _name2map($name) $map
-
-        # keep track of controls built for each variable (see below)
-        set controls($path) unused
-
-        # whenever variable changes, update drawing to report new values
-        if {[lsearch $_monitoring $path] < 0} {
-            $_owner notify add $this $path \
-                [itcl::code $_dispatcher event -idle !redraw]
-            lappend _monitoring $path
-        }
-    }
-
-    # find all embedded controls and build a popup for each hotspot
-    set hotspots [$_xmlobj children -type hotspot -as path $_path.components]
-    foreach cpath $hotspots {
-        set listOfControls [$_xmlobj children -type controls $cpath]
-        if {[llength $listOfControls] > 0} {
-            set popup .drawingentrypopup[incr _popupnum]
-            Rappture::Balloon $popup -title "Change values..."
-            set inner [$popup component inner]
-            Rappture::Controls $inner.controls $_owner
-            pack $inner.controls -fill both -expand yes
-            set _cpath2popup($cpath) $popup
-
-            # Add control widgets to this popup.
-            # NOTE: if the widget exists elsewhere, it is deleted at this
-            #   point and "sucked in" to the popup.
-            foreach cname $listOfControls {
-                set cntlpath [XmlGetSubst $cpath.$cname]
-                $inner.controls insert end $cntlpath
-            }
-        }
-    }
-    set c $itk_component(drawing)
-    set texts [$_xmlobj children -type text -as path $_path.components]
-    foreach cpath $texts {
-        set popup ""
-        set mode [XmlGetSubst $cpath.hotspot]
-        if {$mode eq "off"} {
-            # no popup if hotspot is turned off
-            continue
-        }
-
-        # easiest way to parse embedded variables is to create a hotspot item
-        set id [$c create hotspot 0 0 -text [XmlGet $cpath.text]]
-        foreach varName [Rappture::hotspot variables $c $id] {
-            if {[info exists _name2path($varName)]} {
-                set cntlpath $_name2path($varName)
-
-                if {$controls($cntlpath) ne "unused"} {
-                    puts stderr "WARNING: drawing variable \"$varName\" is used in two hotspots, but will appear in only one of them."
-                    continue
-                }
-                set controls($cntlpath) "--"
-
-                if {$popup eq ""} {
-                    # create the popup for this item, if we haven't already
-                    set popup .drawingentrypopup[incr _popupnum]
-                    Rappture::Balloon $popup -title "Change values..."
-                    set inner [$popup component inner]
-                    Rappture::Controls $inner.controls $_owner
-                    pack $inner.controls -fill both -expand yes
-                }
-
-                # Add the control widget for this variable to this popup.
-                # NOTE: if the widget exists elsewhere, it is deleted at this
-                #   point and "sucked in" to the popup.
-                set inner [$popup component inner]
-                $inner.controls insert end $cntlpath
-                set _cpath2popup($cntlpath) $popup
-            } else {
-                puts stderr "unknown variable \"$varName\" in drawing item at $cpath"
-            }
-        }
-        $c delete $id
-    }
-
-    # create a parser to manage substitions of variable values
-    set _parser [interp create -safe]
-
-    eval itk_initialize $args
-
-    # initialize the drawing at some point
-    $_dispatcher event -idle !redraw
-}
-
-itcl::body Rappture::DrawingEntry::destructor {} {
-    # stop monitoring controls for value changes
-    foreach cpath $_monitoring {
-        $_owner notify remove $this $cpath
-    }
-
-    # tear down the value subsitution parser
-    if {$_parser != ""} {
-        $_parser delete
-    }
-}
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DrawingEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {$label eq ""} {
-        set label "Drawing"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DrawingEntry::tooltip {} {
-    set str [$_xmlobj get $_path.about.description]
-    return [string trim $str]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::DrawingEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-}
-
-itcl::body Rappture::DrawingEntry::Redraw {} {
-    # If a popup is pending, redraw signals a value change; take it down
-    if {$_takedown ne ""} {
-        $_takedown deactivate
-        set _takedown ""
-    }
-
-    # Remove exists canvas items and hints
-    $itk_component(drawing) delete all
-
-    # Delete any images that we created.
-    foreach name [array names _cname2image] {
-        image delete $_cname2image($name)
-    }
-    array unset _cname2id
-    array unset _cname2image
-
-    # Recompute the size of the canvas/drawing area
-    set _canvasWidth [winfo width $itk_component(drawing)]
-    if { $_canvasWidth < 2 } {
-        set _canvasWidth [winfo reqwidth $itk_component(drawing)]
-    }
-    set _canvasHeight [winfo height $itk_component(drawing)]
-    if { $_canvasHeight < 2 } {
-        set _canvasHeight [winfo reqheight $itk_component(drawing)]
-    }
-    set _drawingWidth $_canvasWidth
-    set _drawingHeight $_canvasHeight
-    set _xOffset 0
-    set _yOffset 0
-    # By default, the screen coordinates are 0 to 1
-    ParseScreenCoordinates "0 0 1 1"
-    ParseDescription
-}
-
-#
-# ParseDescription --
-#
-itcl::body Rappture::DrawingEntry::ParseDescription {} {
-    ParseBackground
-    UpdateSubstitutions
-    foreach cname [$_xmlobj children $_path.components] {
-        switch -glob -- $cname {
-            "line*" {
-                ParseLine $_path.components.$cname $cname
-            }
-            "grid*" {
-                ParseGrid $_path.components.$cname $cname
-            }
-            "text*" {
-                ParseText $_path.components.$cname $cname
-            }
-            "picture*" {
-                ParsePicture $_path.components.$cname $cname
-            }
-            "rectangle*" {
-                ParseRectangle $_path.components.$cname $cname
-            }
-            "oval*" {
-                ParseOval $_path.components.$cname $cname
-            }
-            "polygon*" {
-                ParsePolygon $_path.components.$cname $cname
-            }
-            "hotspot*" {
-                ParseHotspot $_path.components.$cname $cname
-            }
-        }
-    }
-}
-
-#
-# ParseGrid --
-#
-itcl::body Rappture::DrawingEntry::ParseGrid { cpath cname } {
-    array set attr2option {
-        "linewidth"     "-width"
-        "arrow"         "-arrow"
-        "dash"          "-dash"
-        "color"         "-fill"
-    }
-    # Set default options first and then let tool.xml override them.
-    array set options {
-        -arrow          none
-        -width          0
-        -fill           black
-        -dash           ""
-    }
-    # Coords
-    set xcoords [XmlGetSubst $cpath.xcoords]
-    set ycoords [XmlGetSubst $cpath.ycoords]
-    if { $ycoords == "" } {
-        set ycoords "0 1"
-        set ymax 1
-        set ymin 0
-    } else {
-        set list {}
-        set ymax -10000
-        set ymin 10000
-        foreach c $ycoords {
-            set y [ScreenY $c]
-            if { $y > $ymax } {
-                set ymax $y
-            }
-            if { $y < $ymin } {
-                set ymin $y
-            }
-            lappend list $y
-        }
-        set ycoords $list
-    }
-    if { $xcoords == "" } {
-        set xcoords "0 1"
-        set xmax 1
-        set xmin 0
-    } else {
-        set list {}
-        set xmax -10000
-        set xmin 10000
-        foreach c $xcoords {
-            set x [ScreenX $c]
-            if { $x > $xmax } {
-                set xmax $x
-            }
-            if { $x < $xmin } {
-                set xmin $x
-            }
-            lappend list $x
-        }
-        set xcoords $list
-    }
-
-    set list {}
-    foreach attr [$_xmlobj children $cpath] {
-        if { [info exists attr2option($attr)] } {
-            set option $attr2option($attr)
-            set value [XmlGetSubst $cpath.$attr]
-            set options($option) $value
-        }
-    }
-    set options(-tags) $cname
-    foreach y $ycoords {
-        lappend ids \
-            [eval $itk_component(drawing) create line $xmin $y $xmax $y \
-                 [array get options]]
-    }
-    foreach x $xcoords {
-        lappend ids \
-            [eval $itk_component(drawing) create line $x $ymin $x $ymax \
-                 [array get options]]
-    }
-    set _cname2id($cname) $ids
-}
-
-#
-# ParseHotspot --
-#
-itcl::body Rappture::DrawingEntry::ParseHotspot { cpath cname } {
-    array set attr2option {
-        "color"  "-fill"
-        "anchor" "-anchor"
-    }
-
-    # Set default options first and then let tool.xml override them.
-    array set options {
-        -fill red
-        -anchor c
-    }
-    foreach attr [$_xmlobj children $cpath] {
-        if { [info exists attr2option($attr)] } {
-            set option $attr2option($attr)
-            set value [XmlGetSubst $cpath.$attr]
-            set options($option) $value
-        }
-    }
-    # Coordinates
-    set coords [XmlGetSubst $cpath.coords]
-    if {$coords eq ""} {
-        set coords "0 0 1 1"
-    }
-    set c $itk_component(drawing)
-    foreach {x1 y1} [ScreenCoords $coords] break
-    set id [$itk_component(drawing) create image $x1 $y1]
-    array unset options -fill
-    set options(-tags) $cname
-    set options(-image) [Rappture::icon hotspot_normal]
-    eval $c itemconfigure $id [array get options]
-    set _cname2id($cname) $id
-    $c bind $id <Enter> [itcl::code $this Activate $cname]
-    $c bind $id <Leave> [itcl::code $this Deactivate $cname]
-    set bbox [$c bbox $id]
-    set y1 [lindex $bbox 1]
-    $c bind $id <ButtonPress-1> [itcl::code $this Invoke $cpath $x1 $y1]
-}
-
-#
-# ParseLine --
-#
-itcl::body Rappture::DrawingEntry::ParseLine { cpath cname } {
-    array set attr2option {
-        "linewidth"     "-width"
-        "arrow"         "-arrow"
-        "dash"          "-dash"
-        "color"         "-fill"
-    }
-    # Set default options first and then let tool.xml override them.
-    array set options {
-        -arrow          none
-        -width          0
-        -fill           black
-        -dash           ""
-    }
-    # Coords
-    set coords [XmlGetSubst $cpath.coords]
-    if {$coords eq ""} {
-        set coords "0 0"
-    }
-    set coords [ScreenCoords $coords]
-
-    set list {}
-    foreach attr [$_xmlobj children $cpath] {
-        if { [info exists attr2option($attr)] } {
-            set option $attr2option($attr)
-            set value [XmlGetSubst $cpath.$attr]
-            set options($option) $value
-        }
-    }
-    set options(-tags) $cname
-    set id [eval $itk_component(drawing) create line $coords]
-    set _cname2id($cname) $id
-    eval $itk_component(drawing) itemconfigure $id [array get options]
-}
-
-#
-# ParseOval --
-#
-itcl::body Rappture::DrawingEntry::ParseOval { cpath cname } {
-    array set attr2option {
-        "outline"       "-outline"
-        "fill"          "-fill"
-        "linewidth"     "-width"
-    }
-
-    # Set default options first and then let tool.xml override them.
-    array set options {
-        -fill blue
-        -width 1
-        -outline black
-    }
-    foreach attr [$_xmlobj children $cpath] {
-        if { [info exists attr2option($attr)] } {
-            set option $attr2option($attr)
-            set value [XmlGetSubst $cpath.$attr]
-            set options($option) $value
-        }
-    }
-    # Coordinates
-    set coords [XmlGetSubst $cpath.coords]
-    if {$coords eq ""} {
-        set coords "0 0 1 1"
-    }
-    foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break
-    set id [$itk_component(drawing) create oval $x1 $y1 $x2 $y2]
-    set _cname2id($cname) $id
-    eval $itk_component(drawing) itemconfigure $id [array get options]
-}
-
-#
-# ParsePicture --
-#
-itcl::body Rappture::DrawingEntry::ParsePicture { cpath cname } {
-    array set attr2option {
-        "anchor"        "-anchor"
-    }
-
-    # Set default options first and then let tool.xml override them.
-    array set options {
-        -anchor nw
-    }
-    foreach attr [$_xmlobj children $cpath] {
-        if { [info exists attr2option($attr)] } {
-            set option $attr2option($attr)
-            set value [XmlGetSubst $cpath.$attr]
-            set options($option) $value
-        }
-    }
-    set contents [string trim [XmlGetSubst $cpath.contents]]
-    set img ""
-    if { [string compare -length 7 $contents "file://"] == 0 } {
-        set fileName [string range $contents 7 end]
-        set path $fileName
-        # find the file on a search path
-        if { [file pathtype $path] != "absolute" } {
-            set dir [[$_owner tool] installdir]
-            set searchlist [list $dir [file join $dir docs]]
-            foreach dir $searchlist {
-                if {[file readable [file join $dir $fileName]]} {
-                    set path [file join $dir $fileName]
-                    break
-                }
-            }
-        }
-        if { [file exists $path] } {
-            set img [image create photo -file $path]
-        } else {
-            puts stderr "WARNING: can't find picture contents \"$path\""
-        }
-    } elseif { [string compare -length 7 $contents "http://"] == 0 } {
-        puts stderr  "don't know how to handle http"
-        return
-    } elseif { $contents != "" } {
-        set img [image create photo -data $contents]
-    }
-    if {$img == ""} {
-        return
-    }
-    # Coordinates
-    set coords [XmlGetSubst $cpath.coords]
-    if { [llength $coords] == 2 } {
-        foreach { x1 y1 } [ScreenCoords $coords] break
-        set w [XmlGetSubst $cpath.width]
-        if { $w == "" || ![string is double $w] || $w <= 0.0 } {
-            set width [expr [image width $img] / 4]
-        } else {
-            set width [expr int([ScreenX $w] - [ScreenX 0])]
-        }
-        set h [XmlGetSubst $cpath.height]
-        if { $h == "" || ![string is double $h] || $h <= 0.0 } {
-            set height [expr [image height $img] / 4]
-        } else {
-            set height [expr int([ScreenY $h] - [ScreenY 0])]
-        }
-        if { $width != [image width $img] || $height != [image height $img] } {
-            set dst [image create photo -width $width -height $height]
-            blt::winop resample $img $dst box
-            image delete $img
-            set img $dst
-        }
-    } elseif { [llength $coords] == 4 } {
-        foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break
-        if { $x1 > $x2 } {
-            set tmp $x1
-            set x1 $x2
-            set x2 $tmp
-        }
-        if { $y1 > $y2 } {
-            set tmp $x1
-            set x1 $x2
-            set x2 $tmp
-        }
-        set width [expr {int($x2 - $x1 + 1)}]
-        set height [expr {int($y2 - $y1 + 1)}]
-        if { $width != [image width $img] || $height != [image height $img] } {
-            set dst [image create photo -width $width -height $height]
-            blt::winop resample $img $dst box
-            image delete $img
-            set img $dst
-        }
-    } else {
-        set width [expr [image width $img] / 4]
-        set height [expr [image height $img] / 4]
-         set dst [image create photo -width $width -height $height]
-        blt::winop resample $img $dst box
-        image delete $img
-        set img $dst
-        set x1 0
-        set y1 0
-    }
-    set options(-tags) $cname
-    set options(-image) $img
-    set id [$itk_component(drawing) create image $x1 $y1]
-    set _cname2image($cname) $img
-    set _cname2id($cname) $id
-    eval $itk_component(drawing) itemconfigure $id [array get options]
-}
-
-
-itcl::body Rappture::DrawingEntry::ParsePolygon { cpath cname } {
-    array set attr2option {
-        "outline"       "-outline"
-        "color"         "-fill"
-        "fill"          "-fill"
-        "linewidth"     "-width"
-    }
-    # Set default options first and then let tool.xml override them.
-    array set options {
-        -width          1
-        -fill           blue
-        -outline        black
-    }
-
-    # Coords
-    set coords [XmlGetSubst $cpath.coords]
-    if {$coords eq ""} {
-        set coords "0 0"
-    }
-    set coords [ScreenCoords $coords]
-
-    set list {}
-    foreach attr [$_xmlobj children $cpath] {
-        if { [info exists attr2option($attr)] } {
-            set option $attr2option($attr)
-            set value [XmlGetSubst $cpath.$attr]
-            set options($option) $value
-        }
-    }
-    set options(-tags) $cname
-    set id [eval $itk_component(drawing) create polygon $coords]
-    set _cname2id($cname) $id
-    eval $itk_component(drawing) itemconfigure $id [array get options]
-}
-
-#
-# ParseRectangle --
-#
-itcl::body Rappture::DrawingEntry::ParseRectangle { cpath cname } {
-    array set attr2option {
-        "outline"       "-outline"
-        "fill"          "-fill"
-        "linewidth"     "-width"
-    }
-
-    # Set default options first and then let tool.xml override them.
-    array set options {
-        -fill blue
-        -width 1
-        -outline black
-    }
-    foreach attr [$_xmlobj children $cpath] {
-        if { [info exists attr2option($attr)] } {
-            set option $attr2option($attr)
-            set value [XmlGetSubst $cpath.$attr]
-            set options($option) $value
-        }
-    }
-    # Coordinates
-    set coords [XmlGetSubst $cpath.coords]
-    if {$coords eq ""} {
-        set coords "0 0 1 1"
-    }
-    foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break
-    set id [$itk_component(drawing) create rectangle $x1 $y1 $x2 $y2]
-    set _cname2id($cname) $id
-    eval $itk_component(drawing) itemconfigure $id [array get options]
-}
-
-#
-# ParseText --
-#
-itcl::body Rappture::DrawingEntry::ParseText { cpath cname } {
-    array set attr2option {
-        "font"          "-font"
-        "color"         "-foreground"
-        "valuecolor"    "-valueforeground"
-        "fill"          "-background"
-        "text"          "-text"
-        "anchor"        "-anchor"
-    }
-
-    # Set default options first and then let tool.xml override them.
-    array set options {
-        -font {Arial -14}
-        -valuefont {Arial -14}
-        -valueforeground blue3
-        -text {}
-        -fill {}
-        -anchor c
-    }
-    foreach attr [$_xmlobj children $cpath] {
-        if { [info exists attr2option($attr)] } {
-            set option $attr2option($attr)
-            if { $attr == "text" } {
-                set value [XmlGet $cpath.$attr]
-            } else {
-                set value [XmlGetSubst $cpath.$attr]
-            }
-            set options($option) $value
-        }
-    }
-    # Coords
-    set coords [XmlGetSubst $cpath.coords]
-    if {$coords eq ""} {
-        set coords "0 0"
-    }
-    foreach {x0 y0} [ScreenCoords $coords] break
-
-    set hotspot [XmlGetSubst $cpath.hotspot]
-    if {$hotspot eq ""} {
-        # assume inline by default
-        set hotspot "inline"
-    } elseif {[lsearch {inline off} $hotspot] < 0} {
-        puts stderr "WARNING: bad hotspot value \"$hotspot\": should be inline or off"
-    }
-
-    if {$hotspot eq "inline"} {
-        set options(-showicons) 1
-    }
-    set c $itk_component(drawing)
-    set options(-tags) $cname
-    set options(-image) [Rappture::icon hotspot_normal]
-    set options(-activeimage) [Rappture::icon hotspot_active]
-    set id [$c create hotspot $x0 $y0]
-    set _cname2id($cname) $id
-    set options(-interp) $_parser
-    eval $c itemconfigure $id [array get options]
-
-    if {$hotspot eq "inline"} {
-        $c bind $id <Enter> \
-            [itcl::code $this Hotspot activate $cname $id %x %y]
-        $c bind $id <Motion> \
-            [itcl::code $this Hotspot activate $cname $id %x %y]
-        $c bind $id <Leave> \
-            [itcl::code $this Hotspot deactivate $cname $id]
-        $c bind $id <ButtonRelease-1> \
-            [itcl::code $this Hotspot invoke $cname $id %x %y]
-    }
-}
-
-
-itcl::body Rappture::DrawingEntry::Hotspot { option cname item args } {
-    set c $itk_component(drawing)
-
-    # see what variable (if any) that we're touching within the text
-    set varName ""
-    if {[llength $args] >= 2} {
-        foreach {x y} $args break
-        foreach {varName x0 y0 x1 y1} [Rappture::hotspot identify $c $item $x $y] break
-    }
-
-    switch -- $option {
-        activate {
-            if {$varName ne ""} {
-                set active [$c itemcget $item -activevalue]
-                if {$varName ne $active} {
-                    $c itemconfigure $item -activevalue $varName
-                }
-                $itk_component(drawing) configure -cursor center_ptr
-
-                # put up a tooltip for this item
-                set cpath $_name2path($varName)
-                set tip [XmlGet $cpath.about.description]
-                if {$tip ne ""} {
-                    set x [expr {[winfo rootx $c]+$x0+10}]
-                    set y [expr {[winfo rooty $c]+$y1}]
-                    set tag "$c-[string map {. ""} $cpath]"
-                    Rappture::Tooltip::text $tag $tip -log $cpath
-                    Rappture::Tooltip::tooltip pending $tag @$x,$y
-                }
-            } else {
-                $c itemconfigure $item -activevalue ""
-                $itk_component(drawing) configure -cursor ""
-                Rappture::Tooltip::tooltip cancel
-            }
-        }
-        deactivate {
-            $c itemconfigure $item -activevalue ""
-            $itk_component(drawing) configure -cursor ""
-            Rappture::Tooltip::tooltip cancel
-        }
-        invoke {
-            if {$varName ne ""} {
-                set x [expr {($x0+$x1)/2}]
-                Invoke $_name2path($varName) $x $y0
-            }
-        }
-        default {
-            error "bad option \"$option\": should be activate, deactivate, invoke"
-        }
-    }
-}
-
-
-itcl::body Rappture::DrawingEntry::ScreenX { x } {
-    return [expr {($x - $_xMin)*$_xScale + $_xOffset}]
-}
-
-itcl::body Rappture::DrawingEntry::ScreenY { y } {
-    return [expr {($y - $_yMin)*$_yScale + $_yOffset}]
-}
-
-itcl::body Rappture::DrawingEntry::ScreenCoords { coords } {
-    set list {}
-    foreach {x y} $coords {
-        lappend list [ScreenX $x] [ScreenY $y]
-    }
-    return $list
-}
-
-itcl::body Rappture::DrawingEntry::AdjustDrawingArea { xAspect yAspect } {
-    set _drawingWidth $_canvasWidth
-    set _drawingHeight $_canvasHeight
-    if { $xAspect <= 0 || $yAspect <= 0 } {
-        return
-    }
-    set current [expr double($_canvasWidth) / double($_canvasHeight)]
-    set wanted [expr double($xAspect) / double($yAspect)]
-    if { $current > $wanted } {
-        set sw [ expr int($_canvasWidth * $wanted)]
-        if { $sw < 1 } {
-            set sw 1
-        }
-        set _xOffset [expr $_canvasWidth - $sw]
-        set _drawingWidth $sw
-    } else {
-        set sh [expr int($_canvasHeight / $wanted)]
-        if { $sh < 1 }  {
-            set sh 1
-        }
-        set _xOffset [expr $_canvasHeight - $sh]
-        set _drawingHeight $sh
-    }
-}
-
-#
-#      <background>
-#       <!-- background color of the drawing canvas (default white) -->
-#       <color>black</color>
-#       <!-- coordinate system:  x0 y0 ?at screenx screeny? x1 y1
-#                                ?at screenx screeny?
-#            The screenx/screeny values are optional, so you can also say
-#            something like "-.1 0 1.1 1" as you had in your example.
-#            This lets you put the origin at a specific point on screen,
-#            and also define the directions of the axes.  We still compute
-#            the overall bounding box.  In the example below, the bounding
-#            box goes from -1,1 in the upper-left corner to 1,-1 in the
-#            lower right.
-#       -->
-#       <coordinates>0 0 at 50% 50% 1 1 at 100% 100%</coordinates>
-
-#       <!-- aspect ratio:  scales coordinate system so that pixels may not
-#            be square.  A coordinate system like the one above implies a
-#            square drawing area, since x and y both go from -1 to 1.  But
-#            if you set the aspect to 2:1, you'll get something twice as
-#            wide as it is tall.  This effectively says that x goes from
-#            -1 to 1 in a certain distance, but y goes from -1 to 1 in half
-#            that screen distance.  Default is whatever aspect is defined
-#            by the coordinates.  If x goes 0-3 and y goes 0-1, then the
-#            drawing (without any other aspect ratio) would be 3x wide and
-#            1x tall.  The aspect ratio could be used to force it to be
-#            square instead by setting "1 1" instead.  In that case, x goes
-#            0-3 over the width, and y goes 0-1 over the same screen distance
-#            along the height.
-#       -->
-#       <aspect>2 1</aspect>
-#     </background>
-#
-
-itcl::body Rappture::DrawingEntry::ParseScreenCoordinates { values } {
-    set bad ""
-    foreach point {1 2} {
-        set xvals($point) [lindex $values 0]
-        if {![string is double -strict $xvals($point)]} {
-            set bad "missing background coordinate point $point in \"$values\""
-            break
-        }
-
-        set yvals($point) [lindex $values 1]
-        if {![string is double -strict $yvals($point)]} {
-            set bad "missing background coordinate point $point in \"$values\""
-            break
-        }
-        set values [lrange $values 2 end]
-
-        # each corner point can be place anywhere from 0% to 100%
-        if {[lindex $values 0] eq "at"} {
-            if {[regexp {^([0-9]+)%$} [lindex $values 1] match xpcnt]
-              && [regexp {^([0-9]+)%$} [lindex $values 2] match ypcnt]} {
-                set wherex($point) [expr {0.01*$xpcnt}]
-                set wherey($point) [expr {0.01*$ypcnt}]
-                set values [lrange $values 3 end]
-            } else {
-                set bad "expected \"at XX% YY%\" but got \"$values\""; break
-            }
-        } else {
-            set wherex($point) [expr {($point == 1) ? 0 : 1}]
-            set wherey($point) [expr {($point == 1) ? 0 : 1}]
-        }
-    }
-    if {$bad eq "" && $wherex(1) == $wherex(2)} {
-        set bad [format "drawing background limits have x points both at %d%%" [expr {round($wherex(1)*100)}]]
-    }
-    if {$bad eq "" && $wherey(1) == $wherey(2)} {
-        set bad [format "drawing background limits have y points both at %d%%" [expr {round($wherex(1)*100)}]]
-    }
-
-    if {$bad eq "" && $xvals(1) == $xvals(2)} {
-        set bad "drawing background coordinates have 0 range in x"
-    }
-    if {$bad eq "" && $yvals(1) == $yvals(2)} {
-        set bad "drawing background coordinates have 0 range in y"
-    }
-    if {$bad eq "" && [llength $values] > 0} {
-        set bad "extra coordinates \"$values\""
-    }
-
-    if {$bad ne ""} {
-        puts stderr "WARNING: $bad"
-        puts stderr "assuming default \"0 0 1 1\" coordinates"
-        array set xvals {1 0 2 1}
-        array set yvals {1 0 2 1}
-        array set wherex {1 0 2 1}
-        array set wherey {1 0 2 1}
-    }
-
-    # compute min/scale for each axis based on the input values
-    if {$wherex(1) < $wherex(2)} {
-        set min 1; set max 2
-    } else {
-        set min 2; set max 1
-    }
-
-    set slope [expr {double($xvals($max)-$xvals($min))
-                      / ($wherex($max)-$wherex($min))}]
-    set _xMin [expr {-$wherex($min)*$slope + $xvals($min)}]
-    set xmax [expr {(1-$wherex($max))*$slope + $xvals($max)}]
-    set _xScale [expr {[winfo width $itk_component(drawing)]/($xmax-$_xMin)}]
-
-    if {$wherey(1) < $wherey(2)} {
-        set min 1; set max 2
-    } else {
-        set min 2; set max 1
-    }
-
-    set slope [expr {double($yvals($max)-$yvals($min))
-                      / ($wherey($max)-$wherey($min))}]
-    set _yMin [expr {-$wherey($min)*$slope + $yvals($min)}]
-    set ymax [expr {(1-$wherey($max))*$slope + $yvals($max)}]
-    set _yScale [expr {[winfo height $itk_component(drawing)]/($ymax-$_yMin)}]
-}
-
-itcl::body Rappture::DrawingEntry::ParseBackground {} {
-    foreach elem [$_xmlobj children $_path.background] {
-        switch -- $elem {
-            "color" {
-                #  Background color of the drawing canvas (default white)
-                set value [XmlGet $_path.background.$elem]
-                $itk_component(drawing) configure -background $value
-            }
-            "aspect" {
-                set value [XmlGet $_path.background.$elem]
-                foreach { xAspect yAspect } $value break
-                AdjustDrawingArea $xAspect $yAspect
-            }
-            "coords" - "coordinates" {
-                set value [XmlGet $_path.background.$elem]
-                ParseScreenCoordinates $value
-            }
-            "width" {
-                set width [XmlGet $_path.background.$elem]
-                $itk_component(drawing) configure -width $width
-            }
-            "height" {
-                set height [XmlGet $_path.background.$elem]
-                $itk_component(drawing) configure -height $height
-            }
-            default {
-                puts stderr "WARNING: don't understand \"$elem\" in $_path"
-            }
-        }
-    }
-}
-
-#
-# Invoke --
-#
-itcl::body Rappture::DrawingEntry::Invoke {cpath x y} {
-    if {![info exists _cpath2popup($cpath)]} {
-        puts stderr "WARNING: no controls for hotspot at $cpath"
-        return
-    }
-    set popup $_cpath2popup($cpath)
-
-    # if this popup has only one control, watch for it to change and
-    # take it down automatically
-    set inner [$popup component inner]
-    set n [expr {[$inner.controls index end]+1}]
-    if {$n == 1} {
-        set _takedown $popup
-    } else {
-        set _takedown ""
-    }
-
-    # Activate the popup and call for the output.
-    set rootx [winfo rootx $itk_component(drawing)]
-    set rooty [winfo rooty $itk_component(drawing)]
-
-    set x [expr {round($x + $rootx)}]
-    set y [expr {round($y + $rooty)}]
-    $popup activate @$x,$y above
-}
-
-#
-# Activate --
-#
-itcl::body Rappture::DrawingEntry::Activate { cname } {
-    $itk_component(drawing) configure -cursor center_ptr
-    $itk_component(drawing) itemconfigure $_cname2id($cname) \
-        -image [Rappture::icon hotspot_active]
-}
-
-#
-# Deactivate --
-#
-itcl::body Rappture::DrawingEntry::Deactivate { cname } {
-    $itk_component(drawing) configure -cursor ""
-    $itk_component(drawing) itemconfigure $_cname2id($cname) \
-        -image [Rappture::icon hotspot_normal]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::DrawingEntry::value {args} {
-    # Redraw if there's a new library object.
-    if { [llength $args] > 0 } {
-        set libobj [lindex $args 0]
-        if { $libobj != "" } {
-            $_dispatcher event -idle !redraw
-        }
-    }
-    return ""
-}
-
-itcl::body Rappture::DrawingEntry::UpdateSubstitutions {} {
-    # Load parser with the variables representing the substitution
-    foreach name [array names _name2path] {
-        set path $_name2path($name)
-        set w [$_owner widgetfor $path]
-        if {$w ne ""} {
-            set value [$w value]
-        } else {
-            set value ""
-        }
-        if {$_name2map($name) ne ""} {
-            set value [string map $_name2map($name) $value]
-        }
-        $_parser eval [list set $name $value]
-    }
-}
-
-itcl::body Rappture::DrawingEntry::XmlGet { path } {
-    set value [$_xmlobj get $path]
-    return [string trim $value]
-}
-
-itcl::body Rappture::DrawingEntry::XmlGetSubst { path } {
-    set value [$_xmlobj get $path]
-    if {$_parser == ""} {
-        return [string trim $value]
-    }
-    return [string trim [$_parser eval [list subst -nocommands $value]]]
-}
Index: trunk/gui/scripts/dropdown.tcl
===================================================================
--- trunk/gui/scripts/dropdown.tcl	(revision 6716)
+++ trunk/gui/scripts/dropdown.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: dropdown - base class for drop-down panels
@@ -9,8 +8,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -19,5 +15,5 @@
 option add *Dropdown.outline black widgetDefault
 option add *Dropdown.borderwidth 1 widgetDefault
-option add *Dropdown.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
+option add *Dropdown.font -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
 
 itcl::class Rappture::Dropdown {
@@ -85,5 +81,5 @@
     set h [winfo height $itk_component(hull)]
     set sw [winfo screenwidth $itk_component(hull)]
-    set sh [winfo screenheight $itk_component(hull)]
+    set sh [winfo screenwidth $itk_component(hull)]
 
     if {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} {
Index: trunk/gui/scripts/dropdownchecks.tcl
===================================================================
--- trunk/gui/scripts/dropdownchecks.tcl	(revision 6716)
+++ 	(revision )
@@ -1,450 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: dropdownchecks - drop-down list of checkbox items
-#
-#  This is the drop-down for the Combochecks widget, which maintains
-#  a list of options.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *Dropdownchecks.textBackground white widgetDefault
-option add *Dropdownchecks.foreground black widgetDefault
-option add *Dropdownchecks.outline black widgetDefault
-option add *Dropdownchecks.borderwidth 1 widgetDefault
-option add *Dropdownchecks.relief flat widgetDefault
-option add *Dropdownchecks.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Dropdownchecks {
-    inherit Rappture::Dropdown
-
-    itk_option define -font font Font ""
-    itk_option define -foreground foreground Foreground ""
-
-    constructor {args} { # defined below }
-
-    public method insert {pos args}
-    public method delete {first {last ""}}
-    public method index {args}
-    public method get {args}
-    public method size {}
-    public method state {value {newval ""}}
-    public method reset {}
-    public method current {{what -value}}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-    private variable _values ""     ;# values for all elems in list
-    private variable _labels ""     ;# labels for each of the _values
-    private variable _states        ;# maps list item => on/off state
-    private variable _layout        ;# layout parameters for drawing
-
-    protected method _redraw {args}
-    protected method _layout {args}
-    protected method _adjust {{widget ""}}
-    protected method _react {x y}
-}
-
-itk::usual Dropdownchecks {
-    keep -background -outline -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !redraw
-    $_dispatcher dispatch $this !redraw [itcl::code $this _redraw]
-    $_dispatcher register !layout
-    $_dispatcher dispatch $this !layout [itcl::code $this _layout]
-
-    itk_component add scroller {
-        Rappture::Scroller $itk_interior.sc \
-            -xscrollmode off -yscrollmode auto
-    }
-    pack $itk_component(scroller) -expand yes -fill both
-
-    itk_component add list {
-        canvas $itk_component(scroller).list \
-            -highlightthickness 0 -width 3i -height 1.5i
-    } {
-        usual
-        rename -background -textbackground textBackground Background
-        ignore -highlightthickness -highlightbackground -highlightcolor
-        keep -relief
-    }
-    $itk_component(scroller) contents $itk_component(list)
-
-    # add bindings so the listbox can react to selections
-    bind RapptureDropdownchecks-$this <ButtonRelease-1> \
-        [itcl::code $this _react %x %y]
-    bind RapptureDropdownchecks-$this <KeyPress-Escape> \
-        [itcl::code $this unpost]
-
-    set btags [bindtags $itk_component(list)]
-    set i [lsearch $btags [winfo class $itk_component(list)]]
-    set btags [lreplace $btags $i $i RapptureDropdownchecks-$this]
-    bindtags $itk_component(list) $btags
-
-    eval itk_initialize $args
-
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# USAGE: insert <pos> ?<value1> <label1> <value2> <label2> ...?
-#
-# Inserts one or more values into this drop-down list.  Each value
-# has a keyword (computer-friendly value) and a label (human-friendly
-# value).  The labels appear in the listbox.  If the label is "--",
-# then the value is used as the label.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::insert {pos args} {
-    if {"end" == $pos} {
-        set pos [llength $_values]
-    } elseif {![string is integer -strict $pos]} {
-        error "bad index \"$pos\": should be integer or \"end\""
-    }
-
-    if {[llength $args] == 1} {
-        set args [lindex $args 0]
-    }
-    if {[llength $args] % 2 != 0} {
-        error "wrong # args: should be \"insert pos ?value label ...?\""
-    }
-
-    foreach {val label} $args {
-        if {$label == "--"} {
-            set label $val
-        }
-        set _values [linsert $_values $pos $val]
-        set _labels [linsert $_labels $pos $label]
-        set _states($val) 0
-        incr pos
-    }
-    $_dispatcher event -idle !redraw
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete <first> ?<last>?
-#
-# Deletes one or more values from this drop-down list.  The indices
-# <first> and <last> should be integers from 0 or the keyword "end".
-# All values in the specified range are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::delete {first {last ""}} {
-    if {$last == ""} {
-        set last $first
-    }
-    if {![regexp {^[0-9]+|end$} $first]} {
-        error "bad index \"$first\": should be integer or \"end\""
-    }
-    if {![regexp {^[0-9]+|end$} $last]} {
-        error "bad index \"$last\": should be integer or \"end\""
-    }
-
-    foreach val [lrange $_values $first $last] {
-        unset _states($val)
-    }
-    set _values [lreplace $_values $first $last]
-    set _labels [lreplace $_labels $first $last]
-
-    $_dispatcher event -idle !redraw
-}
-
-# ----------------------------------------------------------------------
-# USAGE: index ?-value|-label? <value>
-#
-# Returns the integer index for the position of the specified <value>
-# in the list.  Returns -1 if the value is not recognized.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::index {args} {
-    set format -value
-    set first [lindex $args 0]
-    if {$first == "-value" || $first == "-label"} {
-        set format $first
-        set args [lrange $args 1 end]
-    } elseif {[llength $args] > 1} {
-        error "bad option \"$first\": should be -value or -label"
-    }
-    if {[llength $args] != 1} {
-        error "wrong # args: should be \"index ?-value? ?-label? string\""
-    }
-    set value [lindex $args 0]
-
-    switch -- $format {
-        -value { return [lsearch -exact $_values $value] }
-        -label { return [lsearch -exact $_labels $value] }
-    }
-    return -1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-value|-label|-both? ?<index>?
-#
-# Queries one or more values from the drop-down list.  With no args,
-# it returns a list of all values and labels in the list.  If the
-# index is specified, then it returns the value or label (or both)
-# for the specified index.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::get {args} {
-    set format -both
-    set first [lindex $args 0]
-    if {[string index $first 0] == "-"} {
-        set choices {-value -label -both}
-        if {[lsearch $choices $first] < 0} {
-            error "bad option \"$first\": should be [join [lsort $choices] {, }]"
-        }
-        set format $first
-        set args [lrange $args 1 end]
-    }
-
-    # return the whole list or just a single value
-    if {[llength $args] > 1} {
-        error "wrong # args: should be \"get ?-value|-label|-both? ?index?\""
-    }
-    if {[llength $args] == 0} {
-        set vlist $_values
-        set llist $_labels
-        set op lappend
-    } else {
-        set i [lindex $args 0]
-        set vlist [list [lindex $_values $i]]
-        set llist [list [lindex $_labels $i]]
-        set op set
-    }
-
-    # scan through and build up the return list
-    set rlist ""
-    foreach v $vlist l $llist {
-        switch -- $format {
-            -value { $op rlist $v }
-            -label { $op rlist $l }
-            -both  { lappend rlist $v $l }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: size
-#
-# Returns the number of choices in this list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::size {} {
-    return [llength $_values]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: state <value> ?on|off?
-#
-# Used to query or set the state for the underlying values of the
-# listbox.  The <value> is the value associated with a label option.
-# With no other arg, it returns the current state for that value.
-# Otherwise, it sets the state for that value.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::state {val {newval ""}} {
-    if {$newval eq ""} {
-        if {[info exists _states($val)]} {
-            return $_states($val)
-        }
-        return ""
-    }
-
-    if {[info exists _states($val)]} {
-        if {$newval} {
-            set img [Rappture::icon cbon]
-        } else {
-            set img [Rappture::icon cboff]
-        }
-        $itk_component(list) itemconfigure box-$val -image $img
-        set _states($val) $newval
-    } else {
-        error "bad value \"$val\": should be one of [join $_values {, }]"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Resets the state of all checkboxes back to 0 (unchecked).
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::reset {} {
-    foreach val $_values {
-        set _states($val) 0
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current ?-value|-label|-both?
-#
-# Clients use this to query the current selections from the listbox/canvas.
-# Returns a list of values, labels, or list of lists of both, according
-# to the option.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::current {{what -value}} {
-    set rlist ""
-    set l  [llength $_values]
-    for {set i 0} {$i < $l} {incr i} {
-        set val [lindex $_values $i]
-        if {$_states($val)} {
-            switch -- $what {
-                -value { lappend rlist [lindex $_values $i] }
-                -label { lappend rlist [lindex $_labels $i] }
-                -both  { lappend rlist [list [lindex $_values $i] \
-                                             [lindex $_labels $i]] }
-                default {
-                    error "bad option \"$what\": should be -value, -label, -both"
-                }
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _layout ?<eventData>?
-#
-# Used internally to recompute layout parameters whenever the font
-# changes.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::_layout {args} {
-    # figure out the sizes of the checkboxes
-    set wmax 0
-    set hmax 0
-    foreach icon {cbon cboff} {
-        set img [Rappture::icon $icon]
-        set w [image width $img]
-        if {$w > $wmax} {set wmax $w}
-        set h [image height $img]
-        if {$h > $hmax} {set hmax $h}
-    }
-    incr wmax 2
-
-    set fnt $itk_option(-font)
-    set lineh [expr {[font metrics $fnt -linespace]+2}]
-
-    if {$hmax > $lineh} {
-        set lineh $hmax
-    }
-
-    set _layout(boxwidth) $wmax
-    set _layout(lineh) $lineh
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw ?<eventData>?
-#
-# Used internally to redraw the items in the list whenever new items
-# are added or removed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::_redraw {args} {
-    set c $itk_component(list)
-    $c delete all
-
-    set fg $itk_option(-foreground)
-
-    if {[$_dispatcher ispending !layout]} {
-        $_dispatcher event -now !layout
-    }
-
-    set y 0
-    set _layout(ypos) ""
-    for {set i 0} {$i < [llength $_values]} {incr i} {
-        set x0 2
-        set val [lindex $_values $i]
-        set label [lindex $_labels $i]
-
-        if {$_states($val)} {
-            set img [Rappture::icon cbon]
-        } else {
-            set img [Rappture::icon cboff]
-        }
-
-        set ymid [expr {$y + $_layout(lineh)/2}]
-        $c create image $x0 $ymid -anchor w -image $img -tags box-$val
-        incr x0 $_layout(lineh)
-        $c create text $x0 $ymid -anchor w -text $label -fill $fg
-
-        lappend _layout(ypos) [incr y $_layout(lineh)]
-    }
-
-    # fix the overall size for scrolling
-    foreach {x0 y0 x1 y1} [$c bbox all] break
-    $c configure -scrollregion [list 0 0 $x1 $y1]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _adjust ?<widget>?
-#
-# This method is invoked each time the dropdown is posted to adjust
-# its size and contents.  If the <widget> is specified, it is the
-# controlling widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::_adjust {{widget ""}} {
-    chain $widget
-
-    set c $itk_component(list)
-    set lineh $_layout(lineh)
-
-    foreach {x0 y0 x1 y1} [$c bbox all] break
-    set maxw [expr {$x1+2}]
-
-    set maxh [expr {10*$lineh + 2*[$c cget -borderwidth] + 2}]
-
-    if {$widget != ""} {
-        if {$maxw < [winfo width $widget]} { set maxw [winfo width $widget] }
-    }
-    $c configure -width $maxw -height $maxh
-
-    if {$widget != ""} {
-        set y [expr {[winfo rooty $widget]+[winfo height $widget]}]
-        set screenh [winfo screenheight $widget]
-        set lines [expr {round(floor(double($screenh-$y)/$lineh))}]
-        if {[llength $_labels] < $lines} {
-            set lines [llength $_labels]
-        }
-        set maxh [expr {[lindex $_layout(ypos) [expr {$lines-1}]]+2}]
-        $c configure -height $maxh
-    }
-
-    focus $c
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _react <x> <y>
-#
-# Invoked automatically when the user has selected something from
-# the listbox.  Unposts the drop-down and generates an event letting
-# the client know that the selection has changed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Dropdownchecks::_react {x y} {
-    if {$x >= 0 && $x <= [winfo width $itk_component(hull)]
-          && $y >= 0 && $y <= [winfo height $itk_component(hull)]} {
-
-        set x [$itk_component(list) canvasx $x]
-        set y [$itk_component(list) canvasy $y]
-
-        for {set i 0} {$i < [llength $_values]} {incr i} {
-            if {$y < [lindex $_layout(ypos) $i]} {
-                set val [lindex $_values $i]
-                if {$_states($val)} {
-                    state $val 0
-                } else {
-                    state $val 1
-                }
-                break
-            }
-        }
-        event generate $itk_component(hull) <<DropdownchecksSelect>>
-    } else {
-        unpost
-    }
-}
Index: trunk/gui/scripts/dropdownlist.tcl
===================================================================
--- trunk/gui/scripts/dropdownlist.tcl	(revision 6716)
+++ trunk/gui/scripts/dropdownlist.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: dropdownlist - drop-down list of items
@@ -8,8 +7,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -20,5 +16,5 @@
 option add *Dropdownlist.relief flat widgetDefault
 option add *Dropdownlist.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
+    -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
 
 itcl::class Rappture::Dropdownlist {
@@ -70,5 +66,5 @@
 
     # add bindings so the listbox can react to selections
-    bind RapptureDropdownlist-$this <ButtonRelease-1> [itcl::code $this _react]
+    bind RapptureDropdownlist-$this <ButtonRelease> [itcl::code $this _react]
     bind RapptureDropdownlist-$this <KeyPress-Return> [itcl::code $this _react]
     bind RapptureDropdownlist-$this <KeyPress-space> [itcl::code $this _react]
@@ -139,5 +135,4 @@
     set _values [lreplace $_values $first $last]
     set _labels [lreplace $_labels $first $last]
-    $itk_component(list) delete $first $last
 }
 
@@ -278,5 +273,5 @@
         if {$maxw < [winfo width $widget]} { set maxw [winfo width $widget] }
     }
-    set avg [font measure $fnt "n"]
+    set avg [font measure $fnt "x"]
     $itk_component(list) configure -width [expr {round($maxw/double($avg))+1}]
 
Index: trunk/gui/scripts/editor.tcl
===================================================================
--- trunk/gui/scripts/editor.tcl	(revision 6716)
+++ trunk/gui/scripts/editor.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: editor - pop-up editor for little bits of text
@@ -28,8 +27,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -59,5 +55,5 @@
     protected variable _loc   ;# array of editor location parameters
 }
-
+                                                                                
 itk::usual Editor {
     keep -cursor -font
@@ -89,6 +85,4 @@
     bind $itk_component(editor) <KeyPress-Return> \
         [itcl::code $this deactivate]
-    bind $itk_component(editor) <KP_Enter> \
-        [itcl::code $this deactivate]
     bind $itk_component(editor) <KeyPress-Escape> \
         [itcl::code $this deactivate -abort]
@@ -96,21 +90,4 @@
         [itcl::code $this _click %X %Y]
 
-    itk_component add emenu {
-        menu $itk_component(editor).menu -tearoff 0
-    } {
-        usual
-        ignore -tearoff
-        ignore -background -foreground
-    }
-    $itk_component(emenu) add command -label "Cut" -accelerator "^X" \
-        -command [list event generate $itk_component(editor) <<Cut>>]
-    $itk_component(emenu) add command -label "Copy" -accelerator "^C" \
-        -command [list event generate $itk_component(editor) <<Copy>>]
-    $itk_component(emenu) add command -label "Paste" -accelerator "^V" \
-        -command [list event generate $itk_component(editor) <<Paste>>]
-    bind $itk_component(editor) <<PopupMenu>> {
-        tk_popup %W.menu %X %Y
-    }
-
     eval itk_initialize $args
 }
@@ -126,7 +103,4 @@
 itcl::body Rappture::Editor::activate {} {
     set e $itk_component(editor)
-    if {[winfo ismapped $e]} {
-        return  ;# already mapped -- nothing to do
-    }
 
     set info ""
@@ -165,5 +139,5 @@
     wm deiconify $itk_component(hull)
     raise $itk_component(hull)
-    focus -force $itk_component(editor)
+    focus $itk_component(editor)
 
     # try to grab the pointer, and keep trying...
@@ -259,8 +233,4 @@
     if {[winfo containing $x $y] != $itk_component(editor)} {
         deactivate
-    } else {
-        # make sure the editor has keyboard focus!
-        # it loses focus sometimes during cut/copy/paste operations
-        focus -force $itk_component(editor)
     }
 }
@@ -286,13 +256,9 @@
     set h [expr {[font metrics $fnt -linespace]+4}]
     set h [expr {($h < $_loc(h)) ? $_loc(h) : $h}]
-    if {$h+$_loc(y) >= [winfo screenheight $e]} {
-        set h [expr {[winfo screenheight $e]-$_loc(y)}]
-    }
-    # Temporary fix to prevent Opps. Don't deal with negative dimensions.
-    if { $w <= 0 || $h <= 0 } {
-        wm geometry $itk_component(hull) "+$_loc(x)+$_loc(y)"
-    } else {
-        wm geometry $itk_component(hull) "${w}x${h}+$_loc(x)+$_loc(y)"
-    }
+    if {$h+$_loc(y) >= [winfo screenwidth $e]} {
+        set h [expr {[winfo screenwidth $e]-$_loc(y)}]
+    }
+
+    wm geometry $itk_component(hull) "${w}x${h}+$_loc(x)+$_loc(y)"
 }
 
Index: trunk/gui/scripts/energyLevels.tcl
===================================================================
--- trunk/gui/scripts/energyLevels.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1037 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: EnergyLevels - visualizer for discrete energy levels
-#
-#  This widget is a simple visualizer for a set of quantized energy
-#  levels, as you might find for a molecule or a quantum well.  It
-#  takes the Rappture XML representation for a <table> and extracts
-#  values from the "energy" column, then plots those energies on a
-#  graph.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *EnergyLevels.width 4i widgetDefault
-option add *EnergyLevels.height 4i widgetDefault
-option add *EnergyLevels.padding 4 widgetDefault
-option add *EnergyLevels.controlBackground gray widgetDefault
-option add *EnergyLevels.shadeColor gray widgetDefault
-option add *EnergyLevels.levelColor black widgetDefault
-option add *EnergyLevels.levelTextForeground black widgetDefault
-option add *EnergyLevels.levelTextBackground white widgetDefault
-
-option add *EnergyLevels.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::EnergyLevels {
-    inherit itk::Widget
-
-    itk_option define -padding padding Padding 0
-    itk_option define -shadecolor shadeColor ShadeColor ""
-    itk_option define -levelcolor levelColor LevelColor ""
-    itk_option define -leveltextforeground levelTextForeground Foreground ""
-    itk_option define -leveltextbackground levelTextBackground Background ""
-
-    constructor {args} { # defined below }
-
-    public proc columns {table}
-
-    public method add {table {settings ""}}
-    public method delete {args}
-    public method get {}
-    public method scale {args}
-    public method download {args} {}
-    public method parameters {title args} { # do nothing }
-
-    protected method _redraw {{what all}}
-    protected method _zoom {option args}
-    protected method _view {midE delE}
-    protected method _hilite {option args}
-    protected method _getLayout {}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-
-    private variable _dlist ""     ;# list of data objects
-    private variable _dobj2color   ;# maps data obj => color option
-    private variable _dobj2raise   ;# maps data obj => raise option
-    private variable _dobj2desc    ;# maps data obj => description
-    private variable _dobj2cols    ;# maps data obj => column names
-    private variable _emin ""      ;# autoscale min for energy
-    private variable _emax ""      ;# autoscale max for energy
-    private variable _eviewmin ""  ;# min for "zoom" view
-    private variable _eviewmax ""  ;# max for "zoom" view
-    private variable _edefmin ""   ;# min for default "zoom" view
-    private variable _edefmax ""   ;# max for default "zoom" view
-    private variable _ehomo ""     ;# energy of HOMO level in topmost dataset
-    private variable _lhomo ""     ;# label for HOMO level
-    private variable _elumo ""     ;# energy of LUMO level in topmost dataset
-    private variable _llumo ""     ;# label for LUMO level
-    private variable _hilite ""    ;# item currently highlighted
-    common _downloadPopup          ;# download options from popup
-}
-
-itk::usual EnergyLevels {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !redraw
-    $_dispatcher dispatch $this !redraw "[itcl::code $this _redraw all]; list"
-    $_dispatcher register !zoom
-    $_dispatcher dispatch $this !zoom "[itcl::code $this _redraw zoom]; list"
-
-    array set _downloadPopup {
-        format csv
-    }
-
-    itk_option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add controls {
-        frame $itk_interior.cntls
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    pack $itk_component(controls) -side right -fill y
-
-    itk_component add reset {
-        button $itk_component(controls).reset \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -bitmap [Rappture::icon reset] \
-            -command [itcl::code $this _zoom reset]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground Background }
-    pack $itk_component(reset) -padx 4 -pady 4
-    Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $itk_component(controls).zin \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -bitmap [Rappture::icon zoomin] \
-            -command [itcl::code $this _zoom in]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground Background
-    }
-    pack $itk_component(zoomin) -padx 4 -pady 4
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $itk_component(controls).zout \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -bitmap [Rappture::icon zoomout] \
-            -command [itcl::code $this _zoom out]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground Background
-    }
-    pack $itk_component(zoomout) -padx 4 -pady 4
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    #
-    # Add label for the title.
-    #
-    itk_component add title {
-        label $itk_interior.title
-    }
-    pack $itk_component(title) -side top
-
-    #
-    # Add graph showing levels
-    #
-    itk_component add graph {
-        canvas $itk_interior.graph -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(graph) -expand yes -fill both
-
-    bind $itk_component(graph) <Configure> \
-        [list $_dispatcher event -idle !redraw]
-
-    bind $itk_component(graph) <ButtonPress-1> \
-        [itcl::code $this _zoom at %x %y]
-    bind $itk_component(graph) <B1-Motion> \
-        [itcl::code $this _zoom at %x %y]
-
-    bind $itk_component(graph) <Motion> \
-        [itcl::code $this _hilite brush %x %y]
-    bind $itk_component(graph) <Leave> \
-        [itcl::code $this _hilite hide]
-
-    bind $itk_component(graph) <KeyPress-Up> \
-        [itcl::code $this _zoom nudge 1]
-    bind $itk_component(graph) <KeyPress-Right> \
-        [itcl::code $this _zoom nudge 1]
-    bind $itk_component(graph) <KeyPress-plus> \
-        [itcl::code $this _zoom nudge 1]
-
-    bind $itk_component(graph) <KeyPress-Down> \
-        [itcl::code $this _zoom nudge -1]
-    bind $itk_component(graph) <KeyPress-Left> \
-        [itcl::code $this _zoom nudge -1]
-    bind $itk_component(graph) <KeyPress-minus> \
-        [itcl::code $this _zoom nudge -1]
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: columns <table>
-#
-# Clients use this to scan a <table> XML object and see if it contains
-# columns for energy levels.  If so, it returns a list of two column
-# names: {labels energies}.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::columns {dataobj} {
-    set names [$dataobj columns -component]
-    set epos [lsearch -exact $names column(levels)]
-    if {$epos >= 0} {
-        set units [$dataobj columns -units $epos]
-        if {![string match energy* [Rappture::Units::description $units]]} {
-            set epos -1
-        }
-    }
-
-    # can't find column named "levels"? then look for column with energies
-    if {$epos < 0} {
-        set index 0
-        foreach units [$dataobj columns -units] {
-            if {[string match energy* [Rappture::Units::description $units]]} {
-                if {$epos >= 0} {
-                    # more than one energy column -- bail out
-                    set epos -1
-                    break
-                }
-                set epos $index
-            }
-            incr index
-        }
-    }
-
-    # look for a column with labels
-    set lpos -1
-    set index 0
-    foreach units [$dataobj columns -units] {
-        if {"" == $units} {
-            set vals [$dataobj values -column $index]
-            if {$lpos != $epos} {
-                set lpos $index
-                break
-            }
-        }
-        incr index
-    }
-
-    if {$epos >= 0 || $lpos >= 0} {
-        return [list [lindex $names $lpos] [lindex $names $epos]]
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::add {dataobj {settings ""}} {
-    #
-    # Make sure this table contains energy levels.
-    #
-    set cols [Rappture::EnergyLevels::columns $dataobj]
-    if {"" == $cols} {
-        error "table \"$dataobj\" does not contain energy levels"
-    }
-
-    #
-    # Scan through the settings and resolve all values.
-    #
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    # convert -linestyle to BLT -dashes
-    switch -- $params(-linestyle) {
-        dashed { set params(-linestyle) {4 4} }
-        dotted { set params(-linestyle) {2 4} }
-        default { set params(-linestyle) {} }
-    }
-
-    # if -brightness is set, then update the color
-    if {$params(-brightness) != 0} {
-        set params(-color) [Rappture::color::brightness \
-            $params(-color) $params(-brightness)]
-    }
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) blue
-    }
-
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-        set _dobj2color($dataobj) $params(-color)
-        set _dobj2raise($dataobj) $params(-raise)
-        set _dobj2desc($dataobj) $params(-description)
-
-        foreach {lcol ecol} $cols break
-        set _dobj2cols($dataobj-label) $lcol
-        set _dobj2cols($dataobj-energy) $ecol
-
-        $_dispatcher event -idle !redraw
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified data objs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            catch {unset _dobj2color($dataobj)}
-            catch {unset _dobj2raise($dataobj)}
-            catch {unset _dobj2desc($dataobj)}
-            catch {unset _dobj2cols($dataobj-label)}
-            catch {unset _dobj2cols($dataobj-energy)}
-            set changed 1
-        }
-    }
-
-    # if anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !redraw
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-    foreach obj $dlist {
-        if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} {
-            set i [lsearch -exact $dlist $obj]
-            if {$i >= 0} {
-                set dlist [lreplace $dlist $i $i]
-                lappend dlist $obj
-            }
-        }
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all dataobjs--even those not showing on the screen.
-# Because of this, the limits are appropriate for all data as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::scale {args} {
-    set _emin ""
-    set _emax ""
-    foreach obj $args {
-        if {![info exists _dobj2cols($obj-energy)]} {
-            # don't recognize this object? then ignore it
-            continue
-        }
-        foreach {min max} [$obj limits $_dobj2cols($obj-energy)] break
-
-        if {"" != $min && "" != $max} {
-            if {"" == $_emin} {
-                set _emin $min
-                set _emax $max
-            } else {
-                if {$min < $_emin} { set _emin $min }
-                if {$max > $_emax} { set _emax $max }
-            }
-        }
-    }
-
-    if {"" != $_emin && $_emin == $_emax} {
-        set _emin [expr {$_emin-0.1}]
-        set _emax [expr {$_emax+0.1}]
-    }
-
-    set _eviewmin ""  ;# reset zoom view
-    set _eviewmax ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            set popup .energyresultdownload
-            if {![winfo exists .energyresultdownload]} {
-                # if we haven't created the popup yet, do it now
-                Rappture::Balloon $popup \
-                    -title "[Rappture::filexfer::label downloadWord] as..."
-                set inner [$popup component inner]
-                label $inner.summary -text "" -anchor w
-                pack $inner.summary -side top
-                radiobutton $inner.csv -text "Data as Comma-Separated Values" \
-                    -variable Rappture::EnergyLevels::_downloadPopup(format) \
-                    -value csv
-                pack $inner.csv -anchor w
-                radiobutton $inner.pdf -text "Image as PDF/PostScript" \
-                    -variable Rappture::EnergyLevels::_downloadPopup(format) \
-                    -value pdf
-                pack $inner.pdf -anchor w
-                button $inner.go -text [Rappture::filexfer::label download] \
-                    -command [lindex $args 0]
-                pack $inner.go -pady 4
-            } else {
-                set inner [$popup component inner]
-            }
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:"
-            update idletasks ;# fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .energyresultdownload
-            if {[winfo exists .energyresultdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-              csv {
-                # reverse the objects so the selected data appears on top
-                set dlist ""
-                foreach dataobj [get] {
-                    set dlist [linsert $dlist 0 $dataobj]
-                }
-                # generate the comma-separated value data for these objects
-                set csvdata ""
-                foreach dataobj $dlist {
-                    append csvdata "[string repeat - 60]\n"
-                    append csvdata " [$dataobj hints label]\n"
-                    if {[info exists _dobj2desc($dataobj)]
-                          && [llength [split $_dobj2desc($dataobj) \n]] > 1} {
-                        set indent "for:"
-                        foreach line [split $_dobj2desc($dataobj) \n] {
-                            append csvdata " $indent $line\n"
-                            set indent "    "
-                        }
-                    }
-                    append csvdata "[string repeat - 60]\n"
-
-                    set ecol $_dobj2cols($dataobj-energy)
-                    set units [$dataobj columns -units $ecol]
-                    foreach eval [$dataobj values -column $ecol] {
-                        append csvdata [format "%20.15g $units\n" $eval]
-                    }
-                    append csvdata "\n"
-                }
-                return [list .txt $csvdata]
-              }
-              pdf {
-                set psdata [$itk_component(graph) postscript]
-
-                set cmds {
-                    set fout "energy[pid].pdf"
-                    exec ps2pdf - $fout << $psdata
-
-                    set fid [open $fout r]
-                    fconfigure $fid -translation binary -encoding binary
-                    set pdfdata [read $fid]
-                    close $fid
-
-                    file delete -force $fout
-                }
-                if {[catch $cmds result] == 0} {
-                    return [list .pdf $pdfdata]
-                }
-                return [list .ps $psdata]
-              }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Used internally to load a list of energy levels from a <table> within
-# the data objects.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::_redraw {{what all}} {
-    # scale data now, if we haven't already
-    if {"" == $_emin || "" == $_emax} {
-        eval scale $_dlist
-    }
-
-    set dlist [get]
-    set topdobj [lindex $dlist end]
-    _getLayout
-
-    #
-    # Redraw the overall layout
-    #
-    if {$what == "all"} {
-        $c delete all
-        if {[llength $dlist] == 0} {
-            return
-        }
-
-        #
-        # Scan through all data objects and plot them in order from
-        # the bottom up.
-        #
-        set e2y [expr {($yzoom1-$yzoom0)/($_emax-$_emin)}]
-
-        set title ""
-        set dataobj ""
-        foreach dataobj $dlist {
-            if {"" == $title} {
-                set title [$dataobj hints label]
-            }
-
-            set ecol $_dobj2cols($dataobj-energy)
-            set color $_dobj2color($dataobj)
-            if {"" == $color} {
-                set color $itk_option(-levelcolor)
-            }
-            set color [Rappture::color::brightness $color 0.7]
-
-            foreach eval [$dataobj values -column $ecol] {
-                set y [expr {($eval-$_emin)*$e2y + $yzoom0}]
-                $c create line $xx0 $y $xx1 $y -fill $color -width 1
-            }
-        }
-
-        #
-        # Scan through the data and look for HOMO/LUMO levels.
-        # Set the default view to the energy just above and
-        # just below the HOMO/LUMO levels.
-        #
-        set _edefmin [expr {0.4*($_emax-$_emin) + $_emin}]
-        set _edefmax [expr {0.6*($_emax-$_emin) + $_emin}]
-
-        set nlumo -1
-        set nhomo -1
-
-        set dataobj [lindex $dlist end]
-        if {"" != $dataobj} {
-            set lcol $_dobj2cols($dataobj-label)
-            set ecol $_dobj2cols($dataobj-energy)
-            set units [$dataobj columns -units $ecol]
-
-            set n 0
-            foreach eval [$dataobj values -column $ecol] \
-                    lval [$dataobj values -column $lcol] {
-
-                if {[string equal -nocase $lval "HOMO"]} {
-                    set nhomo $n
-                    set _lhomo $lval
-                    set nlumo [expr {$n+1}]
-                    set _llumo "LUMO"
-                } elseif {[string equal -nocase $lval "Ground State"]} {
-                    set nhomo $n
-                    set _lhomo $lval
-                    set nlumo [expr {$n+1}]
-                    set _llumo "1st Excited State"
-                } elseif {[string equal -nocase $lval "LUMO"]
-                      || [string equal -nocase $lval "1st Excited State"]} {
-                    set nlumo $n
-                    set _llumo $lval
-                }
-                incr n
-            }
-
-            if {$nhomo >= 0 && $nlumo >= 0} {
-                set elist [$dataobj values -column $ecol]
-                set _ehomo [lindex $elist $nhomo]
-                set _elumo [lindex $elist $nlumo]
-                if {"" != $_elumo && "" != $_ehomo} {
-                    set gap [expr {$_elumo - $_ehomo}]
-                    set _edefmin [expr {$_ehomo - 0.3*$gap}]
-                    set _edefmax [expr {$_elumo + 0.3*$gap}]
-
-                    set y [expr {($_ehomo-$_emin)*$e2y + $yzoom0}]
-                    set id [$c create rectangle $xx0 $y $xx1 $y0 \
-                        -stipple [Rappture::icon rdiag] \
-                        -outline "" -fill $itk_option(-shadecolor)]
-                    $c lower $id
-                }
-            }
-        }
-        if {"" == $_eviewmin || "" == $_eviewmax} {
-            set _eviewmin $_edefmin
-            set _eviewmax $_edefmax
-        }
-
-        if {"" != $title} {
-            pack $itk_component(title) -side top -before $c
-            $itk_component(title) configure -text $title
-        } else {
-            pack forget $itk_component(title)
-        }
-
-        # draw the lines for the "zoom" view (fixed up below)
-        set color $itk_option(-foreground)
-        $c create line $x0 $yzoom0 $x1 $yzoom0 -fill $color -tags zmin
-        $c create line $x0 $yzoom0 $x1 $yzoom0 -fill $color -tags zmax
-
-        $c create line $x1 $yzoom0 $x2 $yzoom0 -fill $color -tags zoomup
-        $c create line $x1 $yzoom0 $x2 $yzoom1 -fill $color -tags zoomdn
-
-        $c create line $x2 $yzoom0 $x3 $yzoom0 -fill $color
-        $c create line $x2 $yzoom1 $x3 $yzoom1 -fill $color
-    }
-
-    #
-    # Redraw the "zoom" area on the right side
-    #
-    if {$what == "zoom" || $what == "all"} {
-        set e2y [expr {($yzoom1-$yzoom0)/($_emax-$_emin)}]
-
-        set y [expr {($_eviewmin-$_emin)*$e2y + $yzoom0}]
-        $c coords zmin $x0 $y $x1 $y
-        $c coords zoomup $x1 $y $x2 $yzoom0
-
-        set y [expr {($_eviewmax-$_emin)*$e2y + $yzoom0}]
-        $c coords zmax $x0 $y $x1 $y
-        $c coords zoomdn $x1 $y $x2 $yzoom1
-
-        # redraw all levels in the current view
-        $c delete zlevels zlabels
-
-        set e2y [expr {($yzoom1-$yzoom0)/($_eviewmax-$_eviewmin)}]
-        foreach dataobj $dlist {
-            set ecol $_dobj2cols($dataobj-energy)
-            set color $_dobj2color($dataobj)
-            if {"" == $color} {
-                set color $itk_option(-levelcolor)
-            }
-
-            set n 0
-            foreach eval [$dataobj values -column $ecol] {
-                set y [expr {($eval-$_eviewmin)*$e2y + $yzoom0}]
-                if {$y >= $y1 && $y <= $y0} {
-                    set id [$c create line $xx2 $y $xx3 $y \
-                        -fill $color -width 1 \
-                        -tags [list zlevels $dataobj-$n]]
-                }
-                incr n
-            }
-        }
-
-        if {"" != $topdobj && "" != $_ehomo && "" != $_elumo} {
-            set ecol $_dobj2cols($topdobj-energy)
-            set units [$topdobj columns -units $ecol]
-
-            set yy0 [expr {($_ehomo-$_eviewmin)*$e2y + $yzoom0}]
-            set yy1 [expr {($_elumo-$_eviewmin)*$e2y + $yzoom0}]
-
-            set textht [font metrics $itk_option(-font) -linespace]
-            if {$yy0-$yy1 >= 1.5*$textht} {
-                $c create line [expr {$x3-10}] $yy0 [expr {$x3-10}] $yy1 \
-                    -arrow both -fill $itk_option(-foreground) \
-                    -tags zlabels
-                $c create text [expr {$x3-15}] [expr {0.5*($yy0+$yy1)}] \
-                    -anchor e -text "Eg = [expr {$_elumo-$_ehomo}] $units" \
-                    -tags zlabels
-
-                # label the HOMO level
-                set tid [$c create text [expr {0.5*($x2+$x3)}] $yy0 -anchor c \
-                    -text "$_lhomo = $_ehomo $units" \
-                    -fill $itk_option(-leveltextforeground) \
-                    -tags zlabels]
-
-                foreach {xb0 yb0 xb1 yb1} [$c bbox $tid] break
-                set tid2 [$c create rectangle \
-                    [expr {$xb0-1}] [expr {$yb0-1}] \
-                    [expr {$xb1+1}] [expr {$yb1+1}] \
-                    -outline $itk_option(-leveltextforeground) \
-                    -fill $itk_option(-leveltextbackground) \
-                    -tags zlabels]
-                $c lower $tid2 $tid
-
-                # label the LUMO level
-                set tid [$c create text [expr {0.5*($x2+$x3)}] $yy1 -anchor c \
-                    -text "$_llumo = $_elumo $units" \
-                    -fill $itk_option(-leveltextforeground) \
-                    -tags zlabels]
-
-                foreach {xb0 yb0 xb1 yb1} [$c bbox $tid] break
-                set tid2 [$c create rectangle \
-                    [expr {$xb0-1}] [expr {$yb0-1}] \
-                    [expr {$xb1+1}] [expr {$yb1+1}] \
-                    -outline $itk_option(-leveltextforeground) \
-                    -fill $itk_option(-leveltextbackground) \
-                    -tags zlabels]
-                $c lower $tid2 $tid
-            }
-
-            if {$yy0 < $y0} {
-                set id [$c create rectangle $xx2 $yy0 $xx3 $y0 \
-                    -stipple [Rappture::icon rdiag] \
-                    -outline "" -fill $itk_option(-shadecolor) \
-                    -tags zlabels]
-                $c lower $id
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _zoom in
-# USAGE: _zoom out
-# USAGE: _zoom reset
-# USAGE: _zoom at <x> <y>
-# USAGE: _zoom nudge <dir>
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::_zoom {option args} {
-    switch -- $option {
-        in {
-            set midE [expr {0.5*($_eviewmax + $_eviewmin)}]
-            set delE [expr {0.8*($_eviewmax - $_eviewmin)}]
-            _view $midE $delE
-        }
-        out {
-            set midE [expr {0.5*($_eviewmax + $_eviewmin)}]
-            set delE [expr {1.25*($_eviewmax - $_eviewmin)}]
-            _view $midE $delE
-        }
-        reset {
-            set _eviewmin $_edefmin
-            set _eviewmax $_edefmax
-            $_dispatcher event -idle !zoom
-        }
-        at {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"_zoom at x y\""
-            }
-            set x [lindex $args 0]
-            set y [lindex $args 1]
-
-            _getLayout
-            set y2e [expr {($_emax-$_emin)/($yzoom1-$yzoom0)}]
-
-            if {$x > $x1} {
-                return
-            }
-            set midE [expr {($y-$yzoom0)*$y2e + $_emin}]
-            set delE [expr {$_eviewmax - $_eviewmin}]
-            _view $midE $delE
-        }
-        nudge {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"_zoom nudge dir\""
-            }
-            set dir [lindex $args 0]
-
-            set midE [expr {0.5*($_eviewmax + $_eviewmin)}]
-            set delE [expr {$_eviewmax - $_eviewmin}]
-            set midE [expr {$midE + $dir*0.25*$delE}]
-            _view $midE $delE
-        }
-    }
-    focus $itk_component(graph)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _view <midE> <delE>
-#
-# Called automatically when the user clicks/drags on the left side
-# of the widget where energy levels are displayed.  Sets the zoom
-# view so that it's centered on the <y> coordinate.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::_view {midE delE} {
-    if {$delE > $_emax-$_emin} {
-        set delE [expr {$_emax - $_emin}]
-    }
-    if {$midE - 0.5*$delE < $_emin} {
-        set _eviewmin $_emin
-        set _eviewmax [expr {$_eviewmin+$delE}]
-    } elseif {$midE + 0.5*$delE > $_emax} {
-        set _eviewmax $_emax
-        set _eviewmin [expr {$_eviewmax-$delE}]
-    } else {
-        set _eviewmin [expr {$midE - 0.5*$delE}]
-        set _eviewmax [expr {$midE + 0.5*$delE}]
-    }
-    $_dispatcher event -idle !zoom
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _hilite brush <x> <y>
-# USAGE: _hilite show <dataobj> <level>
-# USAGE: _hilite hide
-#
-# Used internally to highlight energy levels in the zoom view and
-# show their associated energy.  The "brush" operation is called
-# as the mouse moves in the zoom view, to see if the <x>,<y>
-# coordinate is touching a level.  The show/hide operations are
-# then used to show/hide level info.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::_hilite {option args} {
-    switch -- $option {
-        brush {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"_hilite brush x y\""
-            }
-            set x [lindex $args 0]
-            set y [lindex $args 1]
-
-            _getLayout
-            if {$x < $x2 || $x > $x3} {
-                return   ;# pointer must be in "zoom" area
-            }
-
-            set c $itk_component(graph)
-            set id [$c find withtag current]
-
-            # touching a line? then find the level and show its info
-            if {"" != $id} {
-                set e2y [expr {($yzoom1-$yzoom0)/($_eviewmax-$_eviewmin)}]
-
-                # put the dataobj list in order according to -raise options
-                set dlist $_dlist
-                foreach obj $dlist {
-                    if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} {
-                        set i [lsearch -exact $dlist $obj]
-                        if {$i >= 0} {
-                            set dlist [lreplace $dlist $i $i]
-                            lappend dlist $obj
-                        }
-                    }
-                }
-
-                set found 0
-                foreach dataobj $dlist {
-                    set ecol $_dobj2cols($dataobj-energy)
-                    set n 0
-                    foreach eval [$dataobj values -column $ecol] {
-                        set ylevel [expr {($eval-$_eviewmin)*$e2y + $yzoom0}]
-                        if {$y >= $ylevel-3 && $y <= $ylevel+3} {
-                            set found 1
-                            break
-                        }
-                        incr n
-                    }
-                    if {$found} break
-                }
-                if {$found} {
-                    _hilite show $dataobj $n
-                } else {
-                    _hilite hide
-                }
-            } else {
-                _hilite hide
-            }
-        }
-        show {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"_hilite show dataobj level\""
-            }
-            set dataobj [lindex $args 0]
-            set level [lindex $args 1]
-
-            if {$_hilite == "$dataobj $level"} {
-                return
-            }
-            _hilite hide
-
-            set lcol $_dobj2cols($dataobj-label)
-            set lval [lindex [$dataobj values -column $lcol] $level]
-            set ecol $_dobj2cols($dataobj-energy)
-            set eval [lindex [$dataobj values -column $ecol] $level]
-            set units [$dataobj columns -units $ecol]
-
-            if {$eval == $_ehomo || $eval == $_elumo} {
-                $itk_component(graph) itemconfigure $dataobj-$level -width 2
-                set _hilite "$dataobj $level"
-                # don't pop up info for the HOMO/LUMO levels
-                return
-            }
-
-            _getLayout
-            set e2y [expr {($yzoom1-$yzoom0)/($_eviewmax-$_eviewmin)}]
-            set y [expr {($eval-$_eviewmin)*$e2y + $yzoom0}]
-
-            set tid [$c create text [expr {0.5*($x2+$x3)}] $y -anchor c \
-                -text "$lval = $eval $units" \
-                -fill $itk_option(-leveltextforeground) \
-                -tags hilite]
-
-            foreach {x0 y0 x1 y1} [$c bbox $tid] break
-            set tid2 [$c create rectangle \
-                [expr {$x0-1}] [expr {$y0-1}] \
-                [expr {$x1+1}] [expr {$y1+1}] \
-                -outline $itk_option(-leveltextforeground) \
-                -fill $itk_option(-leveltextbackground) \
-                -tags hilite]
-            $c lower $tid2 $tid
-
-            $c itemconfigure $dataobj-$level -width 2
-            set _hilite "$dataobj $level"
-        }
-        hide {
-            if {"" != $_hilite} {
-                $itk_component(graph) delete hilite
-                $itk_component(graph) itemconfigure zlevels -width 1
-                set _hilite ""
-            }
-        }
-        default {
-            error "bad option \"$option\": should be brush, show, hide"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getLayout
-#
-# Used internally to compute a series of variables used when redrawing
-# the widget.  Creates the variables with the proper values in the
-# calling context.
-# ----------------------------------------------------------------------
-itcl::body Rappture::EnergyLevels::_getLayout {} {
-    upvar c c
-    set c $itk_component(graph)
-
-    upvar w w
-    set w [winfo width $c]
-
-    upvar h h
-    set h [winfo height $c]
-
-    #
-    # Measure the size of a typical label and use that to size
-    # the left/right portions.  If the label is too big, leave
-    # at least a little room for the labels.
-    #
-    set size [font measure $itk_option(-font) "$_llumo = X.XXXXXXe-XX eV"]
-    set size [expr {$size + 6*$itk_option(-padding)}]
-
-    set textht [font metrics $itk_option(-font) -linespace]
-    set ypad [expr {int(0.5*($textht + 6))}]
-
-    if {$size > $w-20} {
-        set size [expr {$w-20}]
-    } elseif {$size < 0.66*$w} {
-        set size [expr {0.66*$w}]
-    }
-    set xm [expr {$w - $size}]
-
-    upvar x0 x0
-    set x0 $itk_option(-padding)
-
-    upvar x1 x1
-    set x1 [expr {$xm - $itk_option(-padding)}]
-
-    upvar x2 x2
-    set x2 [expr {$xm + $itk_option(-padding)}]
-
-    upvar x3 x3
-    set x3 [expr {$w - $itk_option(-padding)}]
-
-
-    upvar xx0 xx0
-    set xx0 [expr {$x0 + $itk_option(-padding)}]
-
-    upvar xx1 xx1
-    set xx1 [expr {$x1 - $itk_option(-padding)}]
-
-    upvar xx2 xx2
-    set xx2 [expr {$x2 + $itk_option(-padding)}]
-
-    upvar xx3 xx3
-    set xx3 [expr {$x3 - $itk_option(-padding)}]
-
-
-    upvar y0 y0
-    set y0 [expr {$h - $itk_option(-padding)}]
-
-    upvar yzoom0 yzoom0
-    set yzoom0 [expr {$y0 - $ypad}]
-
-    upvar y1 y1
-    set y1 $itk_option(-padding)
-
-    upvar yzoom1 yzoom1
-    set yzoom1 [expr {$y1 + $ypad}]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -levelColor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::EnergyLevels::levelcolor {
-    $_dispatcher event -idle !redraw
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -leveltextforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::EnergyLevels::leveltextforeground {
-    $_dispatcher event -idle !redraw
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -leveltextbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::EnergyLevels::leveltextbackground {
-    $_dispatcher event -idle !redraw
-}
Index: trunk/gui/scripts/field.tcl
===================================================================
--- trunk/gui/scripts/field.tcl	(revision 6716)
+++ trunk/gui/scripts/field.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: field - extracts data from an XML description of a field
@@ -8,157 +7,34 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
-
-# TODO:
-#    Vector field limits are wrong: need to compute magnitude limits and
-#    component-wise limits.
-
-#
-# Possible field dataset types:
-#
-# 1D Datasets
-#       1D              A field contained in a structure
-# 2D Datasets
-#       vtk             (range of z-axis is zero).
-#       unirect2d       (deprecated)
-#       cloud           (x,y point coordinates) (deprecated)
-#       mesh
-# 3D Datasets
-#       vtk
-#       unirect3d       (deprecated)
-#       cloud           (x,y,z coordinates) (deprecated)
-#       mesh
-#       dx              (FIXME: make dx-to-vtk converter work)
-#       ucd             (AVS ucd format)
-#
-# Viewers:
-#       Format     Dim  Description                   Viewer          Server
-#       1D          1   structure field               DeviceViewer1D  N/A
-#       vtk         2   vtk file data.                contour         vtkvis
-#       vtk         3   vtk file data.                isosurface      vtkvis
-#       mesh        2   points-on-mesh                heightmap       vtkvis
-#       mesh        3   points-on-mesh                isosurface      vtkvis
-#       dx          3   DX                            volume          nanovis
-#       unirect2d   2   unirect2d + extents > 1 flow  flow            nanovis
-#       unirect3d   3   unirect3d + extents > 1 flow  flow            nanovis
-#
-# With <views>, can specify which viewer for specific datasets.  So it's OK
-# for the same dataset to be viewed in more than one way.
-#  o Any 2D dataset can be viewed as a contour/heightmap.
-#  o Any 3D dataset can be viewed as a isosurface.
-#  o Any 2D dataset with vector data can be streamlines or flow.
-#  o Any 3D uniform rectilinear dataset can be viewed as a volume.
-#  o Any 3D dataset with vector data can be streamlines or flow.
-#
-# Need <views> to properly do things like qdot: volume with a polydata
-# transparent shell.  The view will combine the two objects <field> and
-# <drawing> (??) into a single viewer.
-#
 package require Itcl
 package require BLT
 
-namespace eval Rappture {
-    # forward declaration
-}
+namespace eval Rappture { # forward declaration }
 
 itcl::class Rappture::Field {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method blob { cname }
-    public method components {args}
+    constructor {devobj libobj path} { # defined below }
+    destructor { # defined below }
+
+    public method components {{pattern *}}
+    public method vectors {{what -overall}}
     public method controls {option args}
-    public method fieldinfo { fname } {
-        lappend out $_fld2Label($fname)
-        lappend out $_fld2Units($fname)
-        lappend out $_fld2Components($fname)
-        return $out
-    }
-    public method fieldlimits {}
-    public method fieldnames { cname } {
-        if { ![info exists _comp2fldName($cname)] } {
-            return ""
-        }
-        return $_comp2fldName($cname)
-    }
-    public method flowhints { cname }
     public method hints {{key ""}}
-    public method isvalid {} {
-        return $_isValid
-    }
-    public method limits {axis}
-    public method mesh {{cname -overall}}
-    public method numComponents {cname}
-    public method style { cname }
-    public method type {}
-    public method valueLimits { cname }
-    public method values { cname }
-    public method viewer {} {
-        return $_viewer
-    }
-    public method vtkdata {cname}
-    public method xErrorValues { cname } {
-    }
-    public method yErrorValues { cname } {
-    }
-
-    protected method Build {}
-    protected method _getValue {expr}
-    protected method GetAssociation { cname }
-    protected method GetTypeAndSize { cname }
-    protected method ReadVtkDataSet { cname contents }
-
-    private method AvsToVtk { cname contents }
-    private method DicomToVtk { cname contents }
-    private method BuildPointsOnMesh { cname }
-    private method InitHints {}
-    private method VerifyVtkDataSet { contents }
-    private method VectorLimits { vector vectorsize {comp -1} }
-    private method VtkDataSetToXy { dataset }
-
-    protected variable _dim 0;          # Dimension of the mesh
-
-    private variable _xmlobj "";        # ref to XML obj with field data
-    private variable _path "";          # Path of this object in the XML
-    private variable _field "";         # This field element as XML obj
-
-    private variable _type "";          # Field type: e.g. file type
-    private variable _hints;            # Hints array
-    private variable _limits;           # maps axis name => {z0 z1} limits
-    private variable _units "";         # system of units for this field
-    private variable _viewer "";        # Hints which viewer to use
-    private variable _isValid 0;        # Indicates if the field contains
-                                        # valid data.
-    private variable _isValidComponent; # Array of valid components found
-    private variable _zmax 0;           # length of the device (1D only)
-
-    private variable _fld2Components;   # field name => number of components
-    private variable _fld2Label;        # field name => label
-    private variable _fld2Units;        # field name => units
-
-    private variable _comp2fldName;     # cname => field names.
-    private variable _comp2type;        # cname => type (e.g. "vectors")
-    private variable _comp2size;        # cname => # of components in element
-    private variable _comp2assoc;       # cname => association (e.g. pointdata)
-    private variable _comp2dims;        # cname => dimensionality
-    private variable _comp2xy;          # cname => x,y vectors
-    private variable _comp2vtk;         # cname => vtk file data
-    private variable _comp2dx;          # cname => OpenDX data
-    private variable _comp2style;       # cname => style settings
-    private variable _comp2cntls;       # cname => x,y control points (1D only)
-    private variable _comp2limits;      # cname => List of axis, min/max list
-    private variable _comp2flowhints;   # cname => Rappture::FlowHints obj
-    private variable _comp2mesh;        # list: mesh obj, BLT vector of values
-                                        # valid for cloud,mesh,unirect2d
-    private common _alwaysConvertDX 0;  # If set, convert DX and store as VTK,
-                                        # even if viewer is nanovis/flowvis
-    private common _counter 0;          # counter for unique vector names
+
+    protected method _build {}
+
+    private variable _device ""  ;# ref to lib obj with device data
+    private variable _libobj ""  ;# ref to lib obj with field data
+
+    private variable _units ""   ;# system of units for this field
+    private variable _limits     ;# maps slab name => {z0 z1} limits
+    private variable _zmax 0     ;# length of the device
+
+    private variable _field ""   ;# lib obj representing this field
+    private variable _comp2vecs  ;# maps component name => x,y vectors
+    private variable _comp2cntls ;# maps component name => x,y control points
+
+    private common _counter 0    ;# counter for unique vector names
 }
 
@@ -166,36 +42,31 @@
 # CONSTRUCTOR
 # ----------------------------------------------------------------------
-itcl::body Rappture::Field::constructor {xmlobj path} {
-    package require vtk
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be Rappture::library"
-    }
-    set _xmlobj $xmlobj
-    set _path $path
-    set _field [$xmlobj element -as object $path]
+itcl::body Rappture::Field::constructor {devobj libobj path} {
+    if {![Rappture::Library::valid $devobj]} {
+        error "bad value \"$devobj\": should be LibraryObj"
+    }
+    if {![Rappture::Library::valid $libobj]} {
+        error "bad value \"$libobj\": should be LibraryObj"
+    }
+    set _device $devobj
+    set _libobj $libobj
+    set _field [$libobj get -object $path]
     set _units [$_field get units]
-
-    set xunits [$xmlobj get units]
-    if {"" == $xunits || "arbitrary" == $xunits} {
-        set xunits "um"
-    }
 
     # determine the overall size of the device
     set z0 [set z1 0]
-    foreach elem [$_xmlobj children components] {
+    foreach elem [$_device get -children recipe] {
         switch -glob -- $elem {
-            box* {
+            slab* - molecule* {
                 if {![regexp {[0-9]$} $elem]} {
                     set elem "${elem}0"
                 }
-                set z0 [$_xmlobj get components.$elem.corner0]
-                set z0 [Rappture::Units::convert $z0 \
-                    -context $xunits -to $xunits -units off]
-
-                set z1 [$_xmlobj get components.$elem.corner1]
-                set z1 [Rappture::Units::convert $z1 \
-                    -context $xunits -to $xunits -units off]
-
+                set tval [$_device get recipe.$elem.thickness]
+                set tval [Rappture::Units::convert $tval \
+                    -context um -to um -units off]
+                set z1 [expr {$z0+$tval}]
                 set _limits($elem) [list $z0 $z1]
+
+                set z0 $z1
             }
         }
@@ -204,6 +75,5 @@
 
     # build up vectors for various components of the field
-    Build
-    InitHints
+    _build
 }
 
@@ -213,78 +83,23 @@
 itcl::body Rappture::Field::destructor {} {
     itcl::delete object $_field
-    # don't destroy the _xmlobj! we don't own it!
-
-    foreach name [array names _comp2xy] {
-        eval blt::vector destroy $_comp2xy($name)
-    }
-    foreach name [array names _comp2flowhints] {
-        itcl::delete object $_comp2flowhints($name)
-    }
-    foreach name [array names _comp2mesh] {
-        # Data is in the form of a mesh and a vector.
-        foreach { mesh vector } $_comp2mesh($name) break
-        # Release the mesh (may be shared)
-        set class [$mesh info class]
-        ${class}::release $mesh
-        # Destroy the vector
-        blt::vector destroy $vector
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: components ?-name|-dimensions|-style? ?<pattern>?
-#
-# Returns a list of names or types for the various components of
-# this field.  If the optional glob-style <pattern> is specified,
-# then it returns only the components with names matching the pattern.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::components {args} {
-    Rappture::getopts args params {
-        flag what -name default
-        flag what -dimensions
-        flag what -style
-        flag what -particles
-        flag what -flow
-        flag what -box
-    }
-
-    set pattern *
-    if {[llength $args] > 0} {
-        set pattern [lindex $args 0]
-        set args [lrange $args 1 end]
-    }
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"components ?switches? ?pattern?\""
-    }
-
-    # There's only one dimension of the field.  Components can't have
-    # different dimensions in the same field.  They would by definition be
-    # using different meshes and viewers.
-    if { $params(what) == "-dimensions" } {
-        return "${_dim}D"
-    }
-    # BE CAREFUL: return component names in proper order
+    # don't destroy the _device! we don't own it!
+
+    foreach name [array names _comp2vecs] {
+        eval blt::vector destroy $_comp2vecs($name)
+    }
+}
+
+# ----------------------------------------------------------------------
+# USAGE: components ?<pattern>?
+#
+# Returns a list of names for the various components of this field.
+# If the optional glob-style <pattern> is specified, then it returns
+# only the component names matching the pattern.
+# ----------------------------------------------------------------------
+itcl::body Rappture::Field::components {{pattern *}} {
     set rlist ""
-    set components {}
-    # First compile a list of valid components that match the pattern
-    foreach cname [$_field children -type component] {
-        if { ![info exists _isValidComponent($cname)] } {
-            continue
-        }
-        if { [string match $pattern $cname] } {
-            lappend components $cname
-        }
-    }
-    # Now handle the tests.
-    switch -- $params(what) {
-        -name {
-            set rlist $components
-        }
-        -style {
-            foreach cname $components {
-                if { [info exists _comp2style($cname)] } {
-                    lappend rlist $_comp2style($cname)
-                }
-            }
+    foreach name [array names _comp2vecs] {
+        if {[string match $pattern $name]} {
+            lappend rlist $name
         }
     }
@@ -293,254 +108,19 @@
 
 # ----------------------------------------------------------------------
-# USAGE: mesh ?<name>?
-#
-# For 1D data (curve), returns a BLT vector of x values for the field
-# component <name>.  Otherwise, this method is unused.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::mesh {{cname -overall}} {
-    if {$cname == "-overall" || $cname == "component0"} {
-        set cname [lindex [components -name] 0]
-    }
-    if {[info exists _comp2xy($cname)]} {
-        return [lindex $_comp2xy($cname) 0]  ;# return xv
-    }
-    if {[info exists _comp2vtk($cname)]} {
-        error "method \"mesh\" is not implemented for VTK file data"
-    }
-    if {[info exists _comp2dx($cname)]} {
-        error "method \"mesh\" is not implemented for DX file data"
-    }
-    if {[info exists _comp2mesh($cname)]} {
-        error "method \"mesh\" is not implemented for Rappture::Mesh"
-    }
-    error "can't get field mesh: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: values ?<name>?
-#
-# For 1D data (curve), returns a BLT vector of field values (y coords)
-# for the field component <name>.  Otherwise, this method is unused.
-# The number of elements in the vector should be a multiple of the
-# return value of [numComponents]
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::values {cname} {
-    if {$cname == "component0"} {
-        set cname "component"
-    }
-    if {[info exists _comp2xy($cname)]} {
-        return [lindex $_comp2xy($cname) 1]  ;# return yv
-    }
-    if {[info exists _comp2vtk($cname)]} {
-        error "method \"values\" is not implemented for VTK file data"
-    }
-    if {[info exists _comp2dx($cname)]} {
-        error "method \"values\" is not implemented for DX file data"
-    }
-    if {[info exists _comp2mesh($cname)]} {
-        return [lindex $_comp2mesh($cname) 1] ;# return vector
-    }
-    error "can't get field values. Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: blob ?<name>?
-#
-# Returns a string representing the blob of data for the mesh and values.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::blob {cname} {
-    if {$cname == "component0"} {
-        set cname "component"
-    }
-    if {[info exists _comp2dx($cname)]} {
-        return $_comp2dx($cname)  ;# return gzipped, base64-encoded DX data
-    }
-    if {[info exists _comp2mesh($cname)]} {
-        error "method \"blob\" not implemented for Rappture::Mesh"
-    }
-    if {[info exists _comp2vtk($cname)]} {
-        error "method \"blob\" not implemented for VTK file data"
-    }
-    if {[info exists _comp2xy($cname)]} {
-        error "method \"blob\" not implemented for XY data"
-    }
-    error "can't get field blob: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: valueLimits <cname>
-#
-# Returns an array for the requested component with a list {min max}
-# representing the limits for each axis.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::valueLimits { cname } {
-    if { [info exists _comp2limits($cname)] } {
-        return $_comp2limits($cname)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: limits <axis>
-#
-# Returns a list {min max} representing the limits for the specified
-# axis over all components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::limits {which} {
-    set min ""
-    set max ""
-
-    foreach cname [array names _comp2dims] {
-        switch -- $_comp2dims($cname) {
-            1D {
-                switch -- $which {
-                    x - xlin {
-                        set pos 0; set log 0; set axis x
-                    }
-                    xlog {
-                        set pos 0; set log 1; set axis x
-                    }
-                    y - ylin - v - vlin {
-                        set pos 1; set log 0; set axis y
-                    }
-                    ylog - vlog {
-                        set pos 1; set log 1; set axis y
-                    }
-                    default {
-                        error "bad axis \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
-                    }
-                }
-
-                set vname [lindex $_comp2xy($cname) $pos]
-
-                if {$log} {
-                    blt::vector tmp zero
-                    # on a log scale, use abs value and ignore zeros
-                    $vname dup tmp
-                    $vname dup zero
-                    zero expr {tmp == 0}            ;# find the zeros
-                    tmp expr {abs(tmp)}             ;# get the abs value
-                    tmp expr {tmp + zero*max(tmp)}  ;# replace 0s with abs max
-                    set axisMin [blt::vector expr min(tmp)]
-                    set axisMax [blt::vector expr max(tmp)]
-                    blt::vector destroy tmp zero
-                } else {
-                    set axisMin [$vname min]
-                    set axisMax [$vname max]
-                }
-
-                if {"" == $min} {
-                    set min $axisMin
-                } elseif {$axisMin < $min} {
-                    set min $axisMin
-                }
-                if {"" == $max} {
-                    set max $axisMax
-                } elseif {$axisMax > $max} {
-                    set max $axisMax
-                }
-            }
-            default {
-                if {[info exists _comp2limits($cname)]} {
-                    array set limits $_comp2limits($cname)
-                    switch -- $which {
-                        x - xlin - xlog {
-                            set axis x
-                            foreach {axisMin axisMax} $limits(x) break
-                        }
-                        y - ylin - ylog {
-                            set axis y
-                            foreach {axisMin axisMax} $limits(y) break
-                        }
-                        z - zlin - zlog {
-                            set axis z
-                            foreach {axisMin axisMax} $limits(z) break
-                        }
-                        v - vlin - vlog {
-                            set axis v
-                            foreach {axisMin axisMax} $limits(v) break
-                        }
-                        default {
-                            if { ![info exists limits($which)] } {
-                                error "limits: unknown axis \"$which\""
-                            }
-                            set axis v
-                            foreach {axisMin axisMax} $limits($which) break
-                        }
-                    }
-                } else {
-                    set axisMin 0  ;# HACK ALERT! must be OpenDX data
-                    set axisMax 1
-                    set axis v
-                }
-            }
-        }
-        if { "" == $min || $axisMin < $min } {
-            set min $axisMin
-        }
-        if { "" == $max || $axisMax > $max } {
-            set max $axisMax
-        }
-    }
-    set val [$_field get "${axis}axis.min"]
-    if {"" != $val && "" != $min} {
-        if {$val > $min} {
-            # tool specified this min -- don't go any lower
-            set min $val
-        }
-    }
-    set val [$_field get "${axis}axis.max"]
-    if {"" != $val && "" != $max} {
-        if {$val < $max} {
-            # tool specified this max -- don't go any higher
-            set max $val
-        }
-    }
-    return [list $min $max]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: fieldlimits
-#
-# This method is for use with VTK components that have multiple fields.
-# It really makes no sense to have multiple fields in a field, but this
-# is here until we add a proper dataset object to hold multiple fields.
-#
-# Returns an array mapping fieldname => list {min max} representing the
-# limits over all components for the given fieldname.  This assumes that
-# all components have the same set of fields.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::fieldlimits {} {
-    foreach cname [array names _comp2limits] {
-        array set limits $_comp2limits($cname)
-        foreach fname [fieldnames $cname] {
-            if { ![info exists limits($fname)] } {
-                puts stderr "ERROR: field \"$fname\" unknown in \"$cname\""
-                continue
-            }
-            foreach {min max} $limits($fname) break
-            if { ![info exists overall($fname)] } {
-                set overall($fname) $limits($fname)
-                continue
-            }
-            foreach {omin omax} $overall($fname) break
-            if { $min < $omin } {
-                set omin $min
-            }
-            if { $max > $omax } {
-                set omax $max
-            }
-            set overall($fname) [list $min $max]
-        }
-    }
-    if { [info exists overall] } {
-        return [array get overall]
-    }
-    return ""
+# USAGE: vectors ?<name>?
+#
+# Returns a list {xvec yvec} for the specified field component <name>.
+# If the name is not specified, then it returns the vectors for the
+# overall field (sum of all components).
+# ----------------------------------------------------------------------
+itcl::body Rappture::Field::vectors {{what -overall}} {
+    if {[info exists _comp2vecs($what)]} {
+        return $_comp2vecs($what)
+    }
+    error "bad option \"$what\": should be [join [lsort [array names _comp2vecs]] {, }]"
 }
 
 # ----------------------------------------------------------------------
 # USAGE: controls get ?<name>?
-# USAGE: controls validate <path> <value>
 # USAGE: controls put <path> <value>
 #
@@ -551,74 +131,18 @@
     switch -- $option {
         get {
-            set cname [lindex $args 0]
-            if {[info exists _comp2cntls($cname)]} {
-                return $_comp2cntls($cname)
-            }
-            return ""
-        }
-        validate {
-            set path [lindex $args 0]
-            set value [lindex $args 1]
-            set units [$_xmlobj get $path.units]
-
-            if {"" != $units} {
-                set nv [Rappture::Units::convert \
-                    $value -context $units -to $units -units off]
-            } else {
-                set nv $value
-            }
-            if {![string is double $nv]
-                  || [regexp -nocase {^(inf|nan)$} $nv]} {
-                error "Value out of range"
-            }
-
-            set rawmin [$_xmlobj get $path.min]
-            if {"" != $rawmin} {
-                set minv $rawmin
-                if {"" != $units} {
-                    set minv [Rappture::Units::convert \
-                        $minv -context $units -to $units -units off]
-                    set nv [Rappture::Units::convert \
-                        $value -context $units -to $units -units off]
-                }
-                # fix for the case when the user tries to
-                # compare values like minv=-500 nv=-0600
-                set nv [format "%g" $nv]
-                set minv [format "%g" $minv]
-
-                if {$nv < $minv} {
-                    error "Minimum value allowed here is $rawmin"
-                }
-            }
-
-            set rawmax [$_xmlobj get $path.max]
-            if {"" != $rawmax} {
-                set maxv $rawmax
-                if {"" != $units} {
-                    set maxv [Rappture::Units::convert \
-                        $maxv -context $units -to $units -units off]
-                    set nv [Rappture::Units::convert \
-                        $value -context $units -to $units -units off]
-                }
-                # fix for the case when the user tries to
-                # compare values like maxv=-500 nv=-0600
-                set nv [format "%g" $nv]
-                set maxv [format "%g" $maxv]
-
-                if {$nv > $maxv} {
-                    error "Maximum value allowed here is $rawmax"
-                }
-            }
-
-            return "ok"
+            set what [lindex $args 0]
+            if {[info exists _comp2cntls($what)]} {
+                return $_comp2cntls($what)
+            }
+            error "bad option \"$what\": should be [join [lsort [array names _comp2cntls]] {, }]"
         }
         put {
             set path [lindex $args 0]
             set value [lindex $args 1]
-            $_xmlobj put $path.current $value
-            Build
+            $_field put $path $value
+            _build
         }
         default {
-            error "bad field controls option \"$option\": should be get or put"
+            error "bad option \"$option\": should be get or put"
         }
     }
@@ -633,87 +157,22 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Field::hints {{keyword ""}} {
-    if { $keyword != "" } {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
+    foreach key {label scale color units restrict} {
+        set str [$_field get $key]
+        if {"" != $str} {
+            set hints($key) $str
+        }
+    }
+
+    if {$keyword != ""} {
+        if {[info exists hints($keyword)]} {
+            return $hints($keyword)
         }
         return ""
     }
-    return [array get _hints]
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: InitHints
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this field.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::InitHints {} {
-    # Order of duplicate keys matters here: later entries override
-    # earlier ones.  For example: camera.position is deprecated in
-    # favor of about.camera, so about.camera is listed after
-    # camera.position
-    foreach {key path} {
-        camera          camera.position
-        camera          about.camera
-        color           about.color
-        group           about.group
-        label           about.label
-        scale           about.scale
-        seeds           about.seeds
-        style           about.style
-        type            about.type
-        xlabel          about.xaxis.label
-        ylabel          about.yaxis.label
-        zlabel          about.zaxis.label
-        xunits          about.xaxis.units
-        yunits          about.yaxis.units
-        zunits          about.zaxis.units
-        units           units
-        updir           updir
-        vectors         about.vectors
-    } {
-        set str [$_field get $path]
-        if { "" != $str } {
-            set _hints($key) $str
-        }
-    }
-    foreach cname [components] {
-        if { ![info exists _comp2mesh($cname)] } {
-            continue
-        }
-        set mesh [lindex $_comp2mesh($cname) 0]
-        foreach axis {x y z} {
-            if { ![info exists _hints(${axis}units)] } {
-                set _hints(${axis}units) [$mesh units $axis]
-            }
-            if { ![info exists _hints(${axis}label)] } {
-                set _hints(${axis}label) [$mesh label $axis]
-            }
-        }
-    }
-    foreach {key path} {
-        toolid          tool.id
-        toolname        tool.name
-        toolcommand     tool.execute
-        tooltitle       tool.title
-        toolrevision    tool.version.application.revision
-    } {
-        set str [$_xmlobj get $path]
-        if { "" != $str } {
-            set _hints($key) $str
-        }
-    }
-    # Set toolip and path hints
-    set _hints(path) $_path
-    if { [info exists _hints(group)] && [info exists _hints(label)] } {
-        # pop-up help for each curve
-        set _hints(tooltip) $_hints(label)
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Build
+    return [array get hints]
+}
+
+# ----------------------------------------------------------------------
+# USAGE: _build
 #
 # Used internally to build up the vector representation for the
@@ -722,1109 +181,61 @@
 # from scratch.
 # ----------------------------------------------------------------------
-itcl::body Rappture::Field::Build {} {
-
-    # Discard any existing data
-    foreach name [array names _comp2xy] {
-        eval blt::vector destroy $_comp2xy($name)
-    }
-    array unset _comp2vtk
-    catch {unset _comp2xy}
-    catch {unset _comp2dx}
-    catch {unset _comp2dims}
-    catch {unset _comp2style}
-    array unset _dataobj2type
+itcl::body Rappture::Field::_build {} {
+    # discard any existing data
+    foreach name [array names _comp2vecs] {
+        eval blt::vector destroy $_comp2vecs($name)
+    }
+    catch {unset _comp2vecs}
+
     #
     # Scan through the components of the field and create
     # vectors for each part.
     #
-    array unset _isValidComponent
-    foreach cname [$_field children -type component] {
-        set type ""
-        if { ([$_field element $cname.constant] != "" &&
-              [$_field element $cname.domain] != "") ||
-              [$_field element $cname.xy] != "" } {
-            set type "1D"
-        } elseif { [$_field element $cname.mesh] != "" &&
-                   [$_field element $cname.values] != ""} {
-            set type "points-on-mesh"
-        } elseif { [$_field element $cname.vtk] != ""} {
-            set type "vtk"
-        } elseif {[$_field element $cname.opendx] != ""} {
-            set type "opendx"
-        } elseif {[$_field element $cname.dx] != ""} {
-            set type "dx"
-        } elseif {[$_field element $cname.ucd] != ""} {
-            set type "ucd"
-        } elseif {[$_field element $cname.dicom] != ""} {
-            set type "dicom"
-        }
-        set _comp2style($cname) ""
-        if { $type == "" } {
-            puts stderr "WARNING: Ignoring field component \"$_path.$cname\": no data found."
-            continue
-        }
-        set _type $type
-
-        GetTypeAndSize $cname
-        GetAssociation $cname
-
-        if { $_comp2size($cname) < 1 ||
-             $_comp2size($cname) > 9 } {
-            puts stderr "ERROR: Invalid <elemsize>: $_comp2size($cname)"
-            continue
-        }
-        # Some types have restrictions on number of components
-        if { $_comp2type($cname) == "vectors" &&
-             $_comp2size($cname) != 3 } {
-            puts stderr "ERROR: vectors <elemtype> must have <elemsize> of 3"
-            continue
-        }
-        if { $_comp2type($cname) == "normals" &&
-             $_comp2size($cname) != 3 } {
-            puts stderr "ERROR: normals <elemtype> must have <elemsize> of 3"
-            continue
-        }
-        if { $_comp2type($cname) == "tcoords" &&
-             $_comp2size($cname) > 3 } {
-            puts stderr "ERROR: tcoords <elemtype> must have <elemsize> <= 3"
-            continue
-        }
-        if { $_comp2type($cname) == "scalars" &&
-             $_comp2size($cname) > 4 } {
-            puts stderr "ERROR: scalars <elemtype> must have <elemsize> <= 4"
-            continue
-        }
-        if { $_comp2type($cname) == "colorscalars" &&
-             $_comp2size($cname) > 4 } {
-            puts stderr "ERROR: colorscalars <elemtype> must have <elemsize> <= 4"
-            continue
-        }
-        if { $_comp2type($cname) == "tensors" &&
-             $_comp2size($cname) != 9 } {
-            puts stderr "ERROR: tensors <elemtype> must have <elemsize> of 9"
-            continue
-        }
-
-        if { [$_field element $cname.flow] != "" } {
-            set haveFlow 1
+    set max [$_field get -count component]
+    for {set i 0} {$i < $max} {incr i} {
+        set xv ""
+        set yv ""
+
+        set val [$_field get component$i.constant]
+        if {$val != ""} {
+            set domain [$_field get component$i.domain]
+            if {$domain == "" || ![info exists _limits($domain)]} {
+                set z0 0
+                set z1 $_zmax
+            } else {
+                foreach {z0 z1} $_limits($domain) { break }
+            }
+            set xv [blt::vector create x$_counter]
+            $xv append $z0 $z1
+
+            if {$_units != ""} {
+                set val [Rappture::Units::convert $val \
+                    -context $_units -to $_units -units off]
+            }
+            set yv [blt::vector create y$_counter]
+            $yv append $val $val
+
+            set zm [expr {0.5*($z0+$z1)}]
+            set _comp2cntls(component$i) \
+                [list component$i.constant $zm $val "$val$_units"]
         } else {
-            set haveFlow 0
-        }
-        set viewer [$_field get "about.view"]
-        if { $viewer != "" } {
-            set _viewer $viewer
-        }
-        if { $_viewer == "" } {
-            if { $_comp2size($cname) > 1 && ! $haveFlow } {
-                set _viewer "glyphs"
-            } elseif { $_comp2size($cname) > 1 && $haveFlow } {
-                set _viewer "flowvis"
-            }
-        }
-
-        if {$type == "1D"} {
-            #
-            # 1D data can be represented as 2 BLT vectors,
-            # one for x and the other for y.
-            #
-            set xv ""
-            set yv ""
-            set _dim 1
-            set val [$_field get $cname.constant]
-            if {$val != ""} {
-                set domain [$_field get $cname.domain]
-                if {$domain == "" || ![info exists _limits($domain)]} {
-                    set z0 0
-                    set z1 $_zmax
-                } else {
-                    foreach {z0 z1} $_limits($domain) { break }
+            set xydata [$_field get component$i.xy]
+            if {"" != $xydata} {
+                set xv [blt::vector create x$_counter]
+                set yv [blt::vector create y$_counter]
+
+                foreach line [split $xydata \n] {
+                    if {[scan $line {%g %g} xval yval] == 2} {
+                        $xv append $xval
+                        $yv append $yval
+                    }
                 }
-                set xv [blt::vector create x$_counter]
-                $xv append $z0 $z1
-
-                foreach {val pcomp} [_getValue $val] break
-                set yv [blt::vector create y$_counter]
-                $yv append $val $val
-
-                if {$pcomp != ""} {
-                    set zm [expr {0.5*($z0+$z1)}]
-                    set _comp2cntls($cname) \
-                        [list $pcomp $zm $val "$val$_units"]
-                }
-            } else {
-                set xydata [$_field get $cname.xy]
-                if {"" != $xydata} {
-                    set xv [blt::vector create x$_counter]
-                    set yv [blt::vector create y$_counter]
-                    set tmp [blt::vector create \#auto]
-                    $tmp set $xydata
-                    $tmp split $xv $yv
-                    blt::vector destroy $tmp
-                }
-            }
-
-            if {$xv != "" && $yv != ""} {
-                # sort x-coords in increasing order
-                $xv sort $yv
-                set _dim 1
-                set _comp2dims($cname) "1D"
-                set _comp2xy($cname) [list $xv $yv]
-                incr _counter
-            }
-        } elseif {$type == "points-on-mesh"} {
-            if { ![BuildPointsOnMesh $cname] } {
-                continue;               # Ignore this component
-            }
-        } elseif {$type == "vtk"} {
-            set contents [$_field get $cname.vtk]
-            if { $contents == "" } {
-                puts stderr "WARNING: No data for \"$_path.$cname.vtk\""
-                continue;               # Ignore this component
-            }
-            if { ![ReadVtkDataSet $cname $contents] } {
-                puts stderr "WARNING: Invalid VTK file for \"$_path.$cname.vtk\""
-                continue;               # Ignore this component
-            }
-            set _comp2vtk($cname) $contents
-            set _comp2style($cname) [$_field get $cname.style]
+            }
+        }
+
+        if {$xv != "" && $yv != ""} {
+            set _comp2vecs(component$i) [list $xv $yv]
             incr _counter
-        } elseif {$type == "dx" || $type == "opendx" } {
-            #
-            # Extract gzipped, base64-encoded OpenDX data
-            #
-            if { $_viewer == "" } {
-                if {$haveFlow} {
-                    set _viewer "flowvis"
-                } else {
-                    global env
-                    if { [info exists env(VTKVOLUME)] } {
-                        set _viewer "vtkvolume"
-                    }
-                    set _viewer "nanovis"
-                }
-            }
-            set data [$_field get -decode no $cname.$type]
-            set contents [Rappture::encoding::decode -as zb64 $data]
-            if { $contents == "" } {
-                puts stderr "WARNING: No data for \"$_path.$cname.$type\""
-                continue;               # Ignore this component
-            }
-            if 0 {
-                set f [open /tmp/$_path.$cname.dx "w"]
-                puts -nonewline $f $contents
-                close $f
-            }
-            # Convert to VTK
-            if { [catch { Rappture::DxToVtk $contents } vtkdata] == 0 } {
-                unset contents
-                # Read back VTK: this will set the field limits and the mesh
-                # dimensions based on the bounds (sets _dim).  We rely on this
-                # conversion for limits even if we send DX data to nanovis.
-                if { ![ReadVtkDataSet $cname $vtkdata] } {
-                    puts stderr "WARNING: Could not parse generated VTK for \"$_path.$cname.$type\""
-                    continue;           # Ignore this component
-                }
-                if 0 {
-                    set f [open /tmp/$_path.$cname.vtk "w"]
-                    puts -nonewline $f $vtkdata
-                    close $f
-                }
-            } else {
-                unset contents
-                # vtkdata variable holds error message
-                puts stderr "Can't parse DX data\n$vtkdata"
-                continue;               # Ignore this component
-            }
-            if { $_alwaysConvertDX ||
-                 ($_viewer != "nanovis" && $_viewer != "flowvis") } {
-                set _type "vtk"
-                set _comp2vtk($cname) $vtkdata
-            } else {
-                set _type "dx"
-                set _comp2dx($cname) $data
-            }
-            unset data
-            unset vtkdata
-            set _comp2style($cname) [$_field get $cname.style]
-            if {$haveFlow} {
-                set _comp2flowhints($cname) \
-                    [Rappture::FlowHints ::\#auto $_field $cname $_units]
-            }
-            incr _counter
-        } elseif { $type == "dicom"} {
-            set contents [$_field get $cname.dicom]
-            if { $contents == "" } {
-                continue;               # Ignore this component
-            }
-            set vtkdata [DicomToVtk $cname $contents]
-            if { $vtkdata == "" } {
-                puts stderr "WARNING: Could not parse generated VTK for \"$_path.$cname.$type\""
-                continue;               # Ignore this component
-            }
-            if { $_viewer == "" } {
-                set _viewer [expr {($_dim == 3) ? "vtkvolume" : "vtkimage"}]
-            }
-            set _comp2vtk($cname) $vtkdata
-            set _comp2style($cname) [$_field get $cname.style]
-            incr _counter
-        } elseif { $type == "ucd"} {
-            set contents [$_field get $cname.ucd]
-            if { $contents == "" } {
-                continue;               # Ignore this component
-            }
-            set vtkdata [AvsToVtk $cname $contents]
-            if { ![ReadVtkDataSet $cname $vtkdata] } {
-                puts stderr "WARNING: Could not parse generated VTK for \"$_path.$cname.$type\""
-                continue;               # Ignore this component
-            }
-            set _comp2vtk($cname) $vtkdata
-            set _comp2style($cname) [$_field get $cname.style]
-            incr _counter
-        }
-        set _isValidComponent($cname) 1
-        #puts stderr "Field $cname type is: $_type"
-    }
-    if { [array size _isValidComponent] == 0 } {
-        puts stderr "ERROR: All components of field \"$_path\" are invalid."
-        return 0
-    }
-    # Sanity check.  Verify that all components of the field have the same
-    # dimension.
-    set dim ""
-    foreach cname [array names _comp2dims] {
-        if { $dim == "" } {
-            set dim $_comp2dims($cname)
-            continue
-        }
-        if { $dim != $_comp2dims($cname) } {
-            puts stderr "WARNING: A field can't have components of different dimensions: [join [array get _comp2dims] ,]"
-            return 0
-        }
-    }
-
-    # FIXME: about.scalars and about.vectors are temporary.  With views
-    #        the label and units for each field will be specified there.
-    #
-    # FIXME: Test that every <field><component> has the same field names,
-    #        units, components.
-    #
-    # Override what we found in the VTK file with names that the user
-    # selected.  We override the field label and units.
-    foreach { fname label units } [$_field get about.scalars] {
-        if { ![info exists _fld2Name($fname)] } {
-            set _fld2Name($fname) $fname
-            set _fld2Components($fname) 1
-        }
-        set _fld2Label($fname) $label
-        set _fld2Units($fname) $units
-    }
-    foreach { fname label units } [$_field get about.vectors] {
-        if { ![info exists _fld2Name($fname)] } {
-            set _fld2Name($fname) $fname
-            # We're just marking the field as vector (> 1) for now.
-            set _fld2Components($fname) 3
-        }
-        set _fld2Label($fname) $label
-        set _fld2Units($fname) $units
-    }
-    set _isValid 1
-    return 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getValue <expr>
-#
-# Used internally to get the value for an expression <expr>.  Returns
-# a list of the form {val parameterPath}, where val is the numeric
-# value of the expression, and parameterPath is the XML path to the
-# parameter representing the value, or "" if the <expr> does not
-# depend on any parameters.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Field::_getValue {expr} {
-    #
-    # First, look for the expression among the <parameter>'s
-    # associated with the device.
-    #
-    set found 0
-    foreach pcomp [$_xmlobj children parameters] {
-        set id [$_xmlobj element -as id parameters.$pcomp]
-        if {[string equal $id $expr]} {
-            set val [$_xmlobj get parameters.$pcomp.current]
-            if {"" == $val} {
-                set val [$_xmlobj get parameters.$pcomp.default]
-            }
-            if {"" != $val} {
-                set expr $val
-                set found 1
-                break
-            }
-        }
-    }
-    if {$found} {
-        set pcomp "parameters.$pcomp"
-    } else {
-        set pcomp ""
-    }
-
-    if {$_units != ""} {
-        set expr [Rappture::Units::convert $expr \
-            -context $_units -to $_units -units off]
-    }
-
-    return [list $expr $pcomp]
-}
-
-#
-# flowhints  --
-#
-# Returns the hints associated with a flow vector field.
-#
-itcl::body Rappture::Field::flowhints { cname } {
-    if { [info exists _comp2flowhints($cname)] } {
-        return $_comp2flowhints($cname)
-    }
-    return ""
-}
-
-#
-# style  --
-#
-# Returns the style associated with a component of the field.
-#
-itcl::body Rappture::Field::style { cname } {
-    if { [info exists _comp2style($cname)] } {
-        return $_comp2style($cname)
-    }
-    return ""
-}
-
-#
-# type  --
-#
-# Returns the data storage type of the field.
-#
-# Types:
-#   1D,cloud,dicom,dx,mesh,ucd,unirect2d,unirect3d,vtk
-#
-itcl::body Rappture::Field::type {} {
-    return $_type
-}
-
-#
-# numComponents --
-#
-# Returns the number of components in the field component.
-#
-itcl::body Rappture::Field::numComponents {cname} {
-    set name $cname
-    regsub -all { } $name {_} name
-    if {[info exists _fld2Components($name)] } {
-        return $_fld2Components($name)
-    }
-    return 1;                           # Default to scalar.
-}
-
-itcl::body Rappture::Field::VerifyVtkDataSet { contents } {
-    package require vtk
-
-    set reader $this-datasetreader
-    vtkDataSetReader $reader
-
-    # Write the contents to a file just in case it's binary.
-    set tmpfile file[pid].vtk
-    set f [open "$tmpfile" "w"]
-    fconfigure $f -translation binary -encoding binary
-    puts $f $contents
-    close $f
-
-    $reader SetFileName $tmpfile
-    $reader ReadAllNormalsOn
-    $reader ReadAllTCoordsOn
-    $reader ReadAllScalarsOn
-    $reader ReadAllColorScalarsOn
-    $reader ReadAllVectorsOn
-    $reader ReadAllTensorsOn
-    $reader ReadAllFieldsOn
-    $reader Update
-    file delete $tmpfile
-
-    set dataset [$reader GetOutput]
-    set dataAttrs [$dataset GetPointData]
-    if { $dataAttrs == ""} {
-        puts stderr "WARNING: No point data found in \"$_path\""
-        rename $reader ""
-        return 0
-    }
-    rename $reader ""
-}
-
-#
-# FIXME: Allowing a VTK file to be used as a Field <component> means
-# there can be multiple VTK fields with different association, type, and
-# number of components (array elements) within a single Rappture::Field.
-# This breaks the concept of the Field object since the <component>'s
-# <association>, <elemtype> and <elemsize> can't be set to a single
-# value in this case.
-#
-# Rappture needs a Dataset object with a single Mesh and multiple Fields.
-#
-itcl::body Rappture::Field::ReadVtkDataSet { cname contents } {
-    package require vtk
-
-    if {[string index $contents 0] == "<"} {
-        set reader $this-xmlreader
-        vtkXMLGenericDataObjectReader $reader
-
-        # Write the contents to a file, since the XML reader
-        # can't read from a memory buffer
-        set tmpfile file[pid]-vtk.xml
-        set f [open "$tmpfile" "w"]
-        fconfigure $f -translation binary -encoding binary
-        puts $f $contents
-        close $f
-
-        $reader SetFileName $tmpfile
-        $reader Update
-        file delete $tmpfile
-
-        set dataset [$reader GetOutputAsDataSet]
-    } else {
-        set reader $this-datasetreader
-        vtkDataSetReader $reader
-
-        # Write the contents to a file just in case it's binary.
-        set tmpfile file[pid].vtk
-        set f [open "$tmpfile" "w"]
-        fconfigure $f -translation binary -encoding binary
-        puts $f $contents
-        close $f
-
-        $reader SetFileName $tmpfile
-        $reader ReadAllNormalsOn
-        $reader ReadAllTCoordsOn
-        $reader ReadAllScalarsOn
-        $reader ReadAllColorScalarsOn
-        $reader ReadAllVectorsOn
-        $reader ReadAllTensorsOn
-        $reader ReadAllFieldsOn
-        $reader Update
-        file delete $tmpfile
-
-        set dataset [$reader GetOutput]
-    }
-    if { $dataset == "" } {
-        puts stderr "Failed to parse VTK file"
-        rename $reader ""
-        return 0
-    }
-    set limits {}
-    foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break
-    if {$xmin > $xmax || $ymin > $ymax || $zmin > $zmax} {
-        puts stderr "Invalid VTK file"
-        rename $reader ""
-        return 0
-    }
-    # Figure out the dimension of the mesh from the bounds.
-    set _dim 0
-    if { $xmax > $xmin } {
-        incr _dim
-    }
-    if { $ymax > $ymin } {
-        incr _dim
-    }
-    if { $zmax > $zmin } {
-        incr _dim
-    }
-    if { $_viewer == "" } {
-        if { $_dim == 2 } {
-            set _viewer contour
-        } else {
-            set _viewer isosurface
-        }
-    }
-    set _comp2dims($cname) ${_dim}D
-    lappend limits x [list $xmin $xmax]
-    lappend limits y [list $ymin $ymax]
-    lappend limits z [list $zmin $zmax]
-    set vmin 0
-    set vmax 1
-    set foundDefaultArray 0
-    set dataAttrs [$dataset GetPointData]
-    if { $dataAttrs == ""} {
-        puts stderr "ERROR: Can't get point data attributes in \"$_path\""
-        rename $reader ""
-        return 0
-    }
-    set numArrays [$dataAttrs GetNumberOfArrays]
-    for {set i 0} {$i < $numArrays} {incr i} {
-        set array [$dataAttrs GetArray $i]
-        set fname [$dataAttrs GetArrayName $i]
-        foreach {min max} [$array GetRange -1] break
-        if {!$foundDefaultArray} {
-            set vmin $min
-            set vmax $max
-            set foundDefaultArray 1
-        }
-        lappend limits $fname [list $min $max]
-        set _fld2Units($fname) ""
-        set _fld2Label($fname) $fname
-        # Let the VTK file override the <elemsize>
-        set _fld2Components($fname) [$array GetNumberOfComponents]
-        lappend _comp2fldName($cname) $fname
-    }
-    # FIXME: Can't properly handle field names that are re-used in point data
-    # cell data and/or field data even though this is permitted in VTK.
-    # For now, we'll use the first field found of point, cell, then field data
-    set dataAttrs [$dataset GetCellData]
-    if { $dataAttrs == ""} {
-        puts stderr "ERROR: Can't get cell data attributes found in \"$_path\""
-        rename $reader ""
-        return 0
-    }
-    set numArrays [$dataAttrs GetNumberOfArrays]
-    for {set i 0} {$i < $numArrays} {incr i} {
-        set array [$dataAttrs GetArray $i]
-        set fname [$dataAttrs GetArrayName $i]
-        foreach {min max} [$array GetRange -1] break
-        if {!$foundDefaultArray} {
-            set vmin $min
-            set vmax $max
-            set foundDefaultArray 1
-        }
-        if {[info exists _fld2Components($fname)]} {
-            puts stderr "WARNING: Re-use of field name within cell data attributes"
-        } else {
-            lappend limits $fname [list $min $max]
-            set _fld2Units($fname) ""
-            set _fld2Label($fname) $fname
-            # Let the VTK file override the <elemsize>
-            set _fld2Components($fname) [$array GetNumberOfComponents]
-            lappend _comp2fldName($cname) $fname
-        }
-    }
-    set dataAttrs [$dataset GetFieldData]
-    if { $dataAttrs == ""} {
-        puts stderr "ERROR: Can't get field data attributes found in \"$_path\""
-        rename $reader ""
-        return 0
-    }
-    set numArrays [$dataAttrs GetNumberOfArrays]
-    for {set i 0} {$i < $numArrays} {incr i} {
-        set array [$dataAttrs GetArray $i]
-        set fname [$dataAttrs GetArrayName $i]
-        foreach {min max} [$array GetRange -1] break
-        if {!$foundDefaultArray} {
-            set vmin $min
-            set vmax $max
-            set foundDefaultArray 1
-        }
-        if {[info exists _fld2Components($fname)]} {
-            puts stderr "WARNING: Re-use of field name within field data attributes"
-        } else {
-            lappend limits $fname [list $min $max]
-            set _fld2Units($fname) ""
-            set _fld2Label($fname) $fname
-            # Let the VTK file override the <elemsize>
-            set _fld2Components($fname) [$array GetNumberOfComponents]
-            lappend _comp2fldName($cname) $fname
-        }
-    }
-    # This is set to the range of the first array found
-    lappend limits v [list $vmin $vmax]
-    set _comp2limits($cname) $limits
-
-    rename $reader ""
-    return 1
-}
-
-#
-# VtkDataSetToXy --
-#
-#        Attempt to convert 0 or 1 dimensional VTK DataSet to XY data (curve).
-#
-itcl::body Rappture::Field::VtkDataSetToXy { dataset } {
-    foreach {xmin xmax ymin ymax zmin zmax} [$dataset GetBounds] break
-    # Only X can have non-zero range.  X can have zero range if there is
-    # only one point
-    if { $ymax > $ymin } {
-        return 0
-    }
-    if { $zmax > $zmin } {
-        return 0
-    }
-    set numPoints [$dataset GetNumberOfPoints]
-    set dataAttrs [$dataset GetPointData]
-    if { $dataAttrs == ""} {
-        puts stderr "WARNING: No point data found"
-        return 0
-    }
-    set array [$dataAttrs GetScalars]
-    if { $array == ""} {
-        puts stderr "WARNING: No scalar point data found"
-        return 0
-    }
-    # Multi-component scalars (e.g. color scalars) are not supported
-    if { [$array GetNumberOfComponents] != 1 } {
-        return 0
-    }
-    set numTuples [$array GetNumberOfTuples]
-    set xv [blt::vector create \#auto]
-    for { set i 0 } { $i < $numPoints } { incr i } {
-        set point [$dataset GetPoint $i]
-        $xv append [lindex $point 0]
-    }
-    set yv [blt::vector create \#auto]
-    for { set i 0 } { $i < $numTuples } { incr i } {
-        $yv append [$array GetComponent $i 0]
-    }
-    $xv sort $yv
-    set _comp2xy($cname) [list $xv $yv]
-    return 1
-}
-
-#
-# vtkdata --
-#
-#        Returns a string representing the mesh and field data for a specific
-#        component in the legacy VTK file format.
-#
-itcl::body Rappture::Field::vtkdata {cname} {
-    if {$cname == "component0"} {
-        set cname "component"
-    }
-    # VTK file data:
-    if { [info exists _comp2vtk($cname)] } {
-        return $_comp2vtk($cname)
-    }
-    # DX: Convert DX to VTK
-    if {[info exists _comp2dx($cname)]} {
-        set data $_comp2dx($cname)
-        set data [Rappture::encoding::decode -as zb64 $data]
-        return [Rappture::DxToVtk $data]
-    }
-    # Points on mesh:  Construct VTK file output.
-    if { [info exists _comp2mesh($cname)] } {
-        # Data is in the form mesh and vector
-        foreach {mesh vector} $_comp2mesh($cname) break
-        set label $cname
-        regsub -all { } $label {_} label
-        append out "# vtk DataFile Version 3.0\n"
-        append out "[hints label]\n"
-        append out "ASCII\n"
-        append out [$mesh vtkdata]
-
-        if { $_comp2assoc($cname) == "pointdata" } {
-            set vtkassoc "POINT_DATA"
-        } elseif { $_comp2assoc($cname) == "celldata" } {
-            set vtkassoc "CELL_DATA"
-        } elseif { $_comp2assoc($cname) == "fielddata" } {
-            set vtkassoc "FIELD"
-        } else {
-            error "unknown association \"$_comp2assoc($cname)\""
-        }
-        set elemSize [numComponents $cname]
-        set numValues [expr [$vector length] / $elemSize]
-        if { $_comp2assoc($cname) == "fielddata" } {
-            append out "$vtkassoc FieldData 1\n"
-            append out "$label $elemSize $numValues double\n"
-        } else {
-            append out "$vtkassoc $numValues\n"
-            if { $_comp2type($cname) == "colorscalars" } {
-                # Must be float for ASCII, unsigned char for BINARY
-                append out "COLOR_SCALARS $label $elemSize\n"
-            } elseif { $_comp2type($cname) == "normals" } {
-                # elemSize must equal 3
-                append out "NORMALS $label double\n"
-            } elseif { $_comp2type($cname) == "scalars" } {
-                # elemSize can be 1, 2, 3 or 4
-                append out "SCALARS $label double $elemSize\n"
-                append out "LOOKUP_TABLE default\n"
-            } elseif { $_comp2type($cname) == "tcoords" } {
-                # elemSize must be 1, 2, or 3
-                append out "TEXTURE_COORDINATES $label $elemSize double\n"
-            } elseif { $_comp2type($cname) == "tensors" } {
-                # elemSize must equal 9
-                append out "TENSORS $label double\n"
-            } elseif { $_comp2type($cname) == "vectors" } {
-                # elemSize must equal 3
-                append out "VECTORS $label double\n"
-            } else {
-                error "unknown element type \"$_comp2type($cname)\""
-            }
-        }
-        append out [$vector range 0 end]
-        append out "\n"
-        if 0 {
-            VerifyVtkDataSet $out
-        }
-        return $out
-    }
-    error "can't find vtkdata for $cname"
-}
-
-#
-# BuildPointsOnMesh --
-#
-#        Parses the field XML description to build a mesh and values vector
-#        representing the field.  Right now we handle the deprecated types
-#        of "cloud", "unirect2d", and "unirect3d" (mostly for flows).
-#
-itcl::body Rappture::Field::BuildPointsOnMesh {cname} {
-    #
-    # More complex 2D/3D data is represented by a mesh
-    # object and an associated vector for field values.
-    #
-    set path [$_field get $cname.mesh]
-    if {[$_xmlobj element $path] == ""} {
-        # Unknown mesh designated.
-        puts stderr "ERROR: Unknown mesh \"$path\""
-        return 0
-    }
-    set element [$_xmlobj element -as type $path]
-    set name $cname
-    regsub -all { } $name {_} name
-    set _fld2Label($name) $name
-    set label [hints zlabel]
-    if { $label != "" } {
-        set _fld2Label($name) $label
-    }
-    set _fld2Units($name) [hints zunits]
-    set _fld2Components($name) $_comp2size($cname)
-    lappend _comp2fldName($cname) $name
-
-    switch -- $element {
-        "cloud" {
-            set mesh [Rappture::Cloud::fetch $_xmlobj $path]
-            set _type cloud
-        }
-        "mesh" {
-            set mesh [Rappture::Mesh::fetch $_xmlobj $path]
-            set _type mesh
-        }
-        "unirect2d" {
-            if { $_viewer == "" } {
-                set _viewer "heightmap"
-            }
-            set mesh [Rappture::Unirect2d::fetch $_xmlobj $path]
-            set _type unirect2d
-        }
-        "unirect3d" {
-            set mesh [Rappture::Unirect3d::fetch $_xmlobj $path]
-            set _type unirect3d
-        }
-    }
-    if { ![$mesh isvalid] } {
-        puts stderr "Mesh is invalid"
-        return 0
-    }
-    set _dim [$mesh dimensions]
-    if { $_dim == 3 } {
-        set dim 0
-        foreach axis {x y z} {
-            foreach {min max} [$mesh limits $axis] {
-                if { $min < $max } {
-                    incr dim
-                }
-            }
-        }
-        if { $dim != 3 } {
-            set _dim $dim
-        }
-    }
-
-    if {$_dim < 2} {
-        puts stderr "ERROR: Can't convert 1D cloud/mesh to curve.  Please use curve output for 1D meshes."
-        return 0
-
-        # 1D data: Create vectors for graph widget.
-        # The prophet tool currently outputs 1D clouds with fields
-        # Band Structure Lab used to (see isosurface1 test in rappture-bat)
-        #
-        # Is there a natural growth path in generating output from 1D to
-        # higher dimensions?  If there isn't, let's kill this in favor
-        # or explicitly using a <curve> instead.  Otherwise, the features
-        # (methods such as xmarkers) of the <curve> need to be added
-        # to the <field>.
-        #
-        #set xv [blt::vector create x$_counter]
-        #set yv [blt::vector create y$_counter]
-
-        # This only works with a Cloud mesh type, since the points method
-        # is not implemented for the Mesh object
-        #$xv set [$mesh points]
-        # TODO: Put field values in yv
-        #set _comp2dims($cname) "1D"
-        #set _comp2xy($cname) [list $xv $yv]
-        #incr _counter
-        #return 1
-    }
-    if {$_dim == 2} {
-        # 2D data: By default surface or contour plot using heightmap widget.
-        set v [blt::vector create \#auto]
-        $v set [$_field get $cname.values]
-        if { [$v length] == 0 } {
-            return 0
-        }
-        if { $_viewer == "" } {
-            set _viewer "contour"
-        }
-        set numFieldValues [$v length]
-        set numComponentsPerTuple [numComponents $cname]
-        if { [expr $numFieldValues % $numComponentsPerTuple] != 0 } {
-            puts stderr "ERROR: Number of field values ($numFieldValues) not divisble by elemsize ($numComponentsPerTuple)"
-            return 0
-        }
-        set numFieldTuples [expr $numFieldValues / $numComponentsPerTuple]
-        if { $_comp2assoc($cname) == "pointdata" } {
-            set numPoints [$mesh numpoints]
-            if { $numPoints != $numFieldTuples } {
-                puts stderr "ERROR: Number of points in mesh ($numPoints) and number of field tuples ($numFieldTuples) don't agree"
-                return 0
-            }
-        } elseif { $_comp2assoc($cname) == "celldata" } {
-            set numCells [$mesh numcells]
-            if { $numCells != $numFieldTuples } {
-                puts stderr "ERROR: Number of cells in mesh ($numCells) and number of field tuples ($numFieldTuples) don't agree"
-                return 0
-            }
-        }
-        set _comp2dims($cname) "[$mesh dimensions]D"
-        set _comp2mesh($cname) [list $mesh $v]
-        set _comp2style($cname) [$_field get $cname.style]
-        if {[$_field element $cname.flow] != ""} {
-            set _comp2flowhints($cname) \
-                [Rappture::FlowHints ::\#auto $_field $cname $_units]
-        }
-        incr _counter
-        array unset _comp2limits $cname
-        foreach axis { x y z } {
-            lappend _comp2limits($cname) $axis [$mesh limits $axis]
-        }
-        set minmax [VectorLimits $v $_comp2size($cname)]
-        lappend _comp2limits($cname) $cname $minmax
-        lappend _comp2limits($cname) v $minmax
-        return 1
-    }
-    if {$_dim == 3} {
-        # 3D data: By default isosurfaces plot using isosurface widget.
-        if { $_viewer == "" } {
-            set _viewer "isosurface"
-        }
-        set v [blt::vector create \#auto]
-        $v set [$_field get $cname.values]
-        if { [$v length] == 0 } {
-            puts stderr "ERROR: No field values"
-            return 0
-        }
-        set numFieldValues [$v length]
-        set numComponentsPerTuple [numComponents $cname]
-        if { [expr $numFieldValues % $numComponentsPerTuple] != 0 } {
-            puts stderr "ERROR: Number of field values ($numFieldValues) not divisble by elemsize ($numComponentsPerTuple)"
-            return 0
-        }
-        set numFieldTuples [expr $numFieldValues / $numComponentsPerTuple]
-        if { $_comp2assoc($cname) == "pointdata" } {
-            set numPoints [$mesh numpoints]
-            if { $numPoints != $numFieldTuples } {
-                puts stderr "ERROR: Number of points in mesh ($numPoints) and number of field tuples ($numFieldTuples) don't agree"
-                return 0
-            }
-        } elseif { $_comp2assoc($cname) == "celldata" } {
-            set numCells [$mesh numcells]
-            if { $numCells != $numFieldTuples } {
-                puts stderr "ERROR: Number of cells in mesh ($numCells) and number of field tuples ($numFieldTuples) don't agree"
-                return 0
-            }
-        }
-        set _comp2dims($cname) "[$mesh dimensions]D"
-        set _comp2mesh($cname) [list $mesh $v]
-        set _comp2style($cname) [$_field get $cname.style]
-        if {[$_field element $cname.flow] != ""} {
-            set _comp2flowhints($cname) \
-                [Rappture::FlowHints ::\#auto $_field $cname $_units]
-        }
-        incr _counter
-        foreach axis { x y z } {
-            lappend _comp2limits($cname) $axis [$mesh limits $axis]
-        }
-        set minmax [VectorLimits $v $_comp2size($cname)]
-        lappend _comp2limits($cname) $cname $minmax
-        lappend _comp2limits($cname) v $minmax
-        return 1
-    }
-    error "unhandled case in field dim=$_dim element=$element"
-}
-
-itcl::body Rappture::Field::AvsToVtk { cname contents } {
-    package require vtk
-
-    set reader $this-datasetreader
-    vtkAVSucdReader $reader
-
-    # Write the contents to a file just in case it's binary.
-    set tmpfile $cname[pid].ucd
-    set f [open "$tmpfile" "w"]
-    fconfigure $f -translation binary -encoding binary
-    puts $f $contents
-    close $f
-    $reader SetFileName $tmpfile
-    $reader Update
-    file delete $tmpfile
-
-    set tmpfile $cname[pid].vtk
-    set writer $this-datasetwriter
-    vtkDataSetWriter $writer
-    $writer SetInputConnection [$reader GetOutputPort]
-    $writer SetFileName $tmpfile
-    $writer SetFileTypeToBinary
-    $writer Write
-    rename $reader ""
-    rename $writer ""
-
-    set f [open "$tmpfile" "r"]
-    fconfigure $f -translation binary -encoding binary
-    set vtkdata [read $f]
-    close $f
-    file delete $tmpfile
-    return $vtkdata
-}
-
-itcl::body Rappture::Field::DicomToVtk { cname path } {
-    package require vtk
-
-    if { ![file exists $path] } {
-        puts stderr "path \"$path\" doesn't exist."
-        return ""
-    }
-
-    if { [file isdir $path] } {
-        set files [glob -nocomplain $path/*.dcm]
-        if { [llength $files] == 0 } {
-            set files [glob -nocomplain $path/*]
-            if { [llength $files] == 0 } {
-                puts stderr "no dicom files found in \"$path\""
-                return ""
-            }
-        }
-
-        #array set data [Rappture::DicomToVtk files $files]
-        array set data [Rappture::DicomToVtk dir $path]
-    } else {
-        array set data [Rappture::DicomToVtk files [list $path]]
-    }
-
-    if 0 {
-        foreach key [array names data] {
-            if {$key == "vtkdata"} {
-                if 0 {
-                    set f [open /tmp/$cname.vtk "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $data(vtkdata)
-                    close $f
-                }
-            } else {
-                puts stderr "$key = \"$data($key)\""
-            }
-        }
-    }
-
-    if { ![ReadVtkDataSet $cname $data(vtkdata)] } {
-        return ""
-    }
-    return $data(vtkdata)
-}
-
-itcl::body Rappture::Field::GetTypeAndSize { cname } {
-    array set type2components {
-        "colorscalars"         4
-        "normals"              3
-        "scalars"              1
-        "tcoords"              2
-        "tensors"              9
-        "vectors"              3
-    }
-    set type [$_field get $cname.elemtype]
-    # <extents> is a deprecated synonym for <elemsize>
-    set extents  [$_field get $cname.extents]
-    if { $type == "" } {
-        if { $extents != "" && $extents > 1 } {
-            set type "vectors"
-        } else {
-            set type "scalars"
-        }
-    }
-    if { ![info exists type2components($type)] } {
-        error "unknown <elemtype> \"$type\" in field"
-    }
-    set size [$_field get $cname.elemsize]
-    if { $size == "" } {
-        if { $extents != "" } {
-            set size $extents
-        } else {
-            set size $type2components($type)
-        }
-    }
-    set _comp2type($cname) $type
-    set _comp2size($cname) $size
-}
-
-itcl::body Rappture::Field::GetAssociation { cname } {
-    set assoc [$_field get $cname.association]
-    if { $assoc == "" } {
-        set _comp2assoc($cname) "pointdata"
-        return
-    }
-    switch -- $assoc {
-        "pointdata" - "celldata" - "fielddata" {
-            set _comp2assoc($cname) $assoc
-            return
-        }
-        default {
-            error "unknown field association \"$assoc\""
-        }
-    }
-}
-
-#
-# Compute the per-component limits or limits of vector magnitudes
-#
-itcl::body Rappture::Field::VectorLimits {vector vectorsize {comp -1}} {
-    if {$vectorsize == 1} {
-        set minmax [$vector limits]
-    } else {
-        set len [$vector length]
-        if {[expr $len % $vectorsize] != 0} {
-            error "Invalid vectorsize: $vectorsize"
-        }
-        if {$comp > $vectorsize-1} {
-            error "Invalid vector component: $comp"
-        }
-        set numTuples [expr ($len/$vectorsize)]
-        for {set i 0} {$i < $numTuples} {incr i} {
-            if {$comp >= 0} {
-                set idx [expr ($i * $vectorsize + $comp)]
-                set val [$vector index $idx]
-            } else {
-                set idx [expr ($i * $vectorsize)]
-                set mag 0
-                for {set j 0} {$j < $vectorsize} {incr j} {
-                    set val [$vector index $idx]
-                    set mag [expr ($mag + $val * $val)]
-                    incr idx
-                }
-                set val [expr (sqrt($mag))]
-            }
-            if (![info exists minmax]) {
-                set minmax [list $val $val]
-            } else {
-                if {$val < [lindex $minmax 0]} {
-                    lset minmax 0 $val
-                }
-                if {$val > [lindex $minmax 1]} {
-                    lset minmax 1 $val
-                }
-            }
-        }
-    }
-    return $minmax
-}
+        }
+    }
+}
Index: trunk/gui/scripts/fieldresult.tcl
===================================================================
--- trunk/gui/scripts/fieldresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,218 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: fieldresult - plot a field in a ResultSet
-#
-#  This widget visualizes fields on meshes.
-#  It is normally used in the ResultViewer to show results from the
-#  run of a Rappture tool.  Use the "add" and "delete" methods to
-#  control the dataobjs showing on the plot.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *FieldResult.width 4i widgetDefault
-option add *FieldResult.height 4i widgetDefault
-option add *FieldResult.foreground black widgetDefault
-option add *FieldResult.controlBackground gray widgetDefault
-option add *FieldResult.controlDarkBackground #999999 widgetDefault
-option add *FieldResult.plotBackground black widgetDefault
-option add *FieldResult.plotForeground white widgetDefault
-option add *FieldResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::FieldResult {
-    inherit itk::Widget
-
-    itk_option define -mode mode Mode ""
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method snap {w h}
-    public method parameters {title args} { # do nothing }
-    public method download {option args}
-}
-
-itk::usual FieldResult {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::FieldResult::constructor {args} {
-    array set flags {
-        -mode ""
-    }
-    array set flags $args
-    switch -- $flags(-mode) {
-        "nanovis" {
-            itk_component add renderer {
-                Rappture::NanovisViewer $itk_interior.ren
-            }
-        }
-        "flowvis" {
-            itk_component add renderer {
-                Rappture::FlowvisViewer $itk_interior.ren
-            }
-        }
-        "glyphs" {
-            itk_component add renderer {
-                Rappture::VtkGlyphViewer $itk_interior.ren
-            }
-        }
-        "contour" - "heightmap" {
-            itk_component add renderer {
-                Rappture::VtkHeightmapViewer $itk_interior.ren \
-                    -mode $flags(-mode)
-            }
-        }
-        "isosurface" {
-            itk_component add renderer {
-                Rappture::VtkIsosurfaceViewer $itk_interior.ren
-            }
-        }
-        "streamlines" {
-            itk_component add renderer {
-                Rappture::VtkStreamlinesViewer $itk_interior.ren
-            }
-        }
-        "surface" {
-            itk_component add renderer {
-                Rappture::VtkSurfaceViewer $itk_interior.ren
-            }
-        }
-        "vtkimage" {
-            itk_component add renderer {
-                Rappture::VtkImageViewer $itk_interior.ren
-            }
-        }
-        "vtkviewer" {
-            itk_component add renderer {
-                Rappture::VtkViewer $itk_interior.ren
-            }
-        }
-        "vtkvolume" {
-            itk_component add renderer {
-                Rappture::VtkVolumeViewer $itk_interior.ren
-            }
-        }
-        default {
-            puts stderr "unknown render mode \"$flags(-mode)\""
-        }
-    }
-    pack $itk_component(renderer) -expand yes -fill both
-
-    # can't connect to rendering farm?
-    if {![$itk_component(renderer) isconnected]} {
-        # Should show a message here
-        #destroy $itk_component(renderer)
-    }
-
-    if {![info exists itk_component(renderer)]} {
-        # No valid renderer (or couldn't connect?)
-        # Should show a message here
-    }
-    eval itk_initialize $args
-    #update
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::FieldResult::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FieldResult::add {dataobj {settings ""}} {
-    if { ![info exists itk_component(renderer)] } {
-        puts stderr "add: no renderer created."
-        return
-    }
-    eval $itk_component(renderer) add $dataobj [list $settings]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FieldResult::get {} {
-    if { ![info exists itk_component(renderer)] } {
-        puts stderr "get: no renderer created."
-        return
-    }
-    return [$itk_component(renderer) get]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FieldResult::delete {args} {
-    if { [info exists itk_component(renderer)] } {
-        eval $itk_component(renderer) delete $args
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FieldResult::scale {args} {
-    if { ![info exists itk_component(renderer)] } {
-        puts stderr "scale: no renderer created."
-        return
-    }
-    eval $itk_component(renderer) scale $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FieldResult::download {option args} {
-    if { ![info exists itk_component(renderer)] } {
-        puts stderr "download: no renderer created."
-        return
-    }
-    eval $itk_component(renderer) download $option $args
-}
-
-itcl::body Rappture::FieldResult::snap { w h } {
-    if { ![info exists itk_component(renderer)] } {
-        puts stderr "snap: no renderer created."
-        return
-    }
-    return [$itk_component(renderer) snap $w $h]
-}
Index: trunk/gui/scripts/filechoiceentry.tcl
===================================================================
--- trunk/gui/scripts/filechoiceentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,321 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: FileChoiceEntry - widget for entering a choice of strings
-#
-#  This widget represents a <choice> entry on a control panel.
-#  It is used to choose one of several mutually-exclusive strings.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2005  Purdue Research Foundation
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::FileChoiceEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    private variable _rebuildPending 0
-
-    constructor {owner path args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method Rebuild {}
-    protected method NewValue {}
-    protected method Tooltip {}
-    protected method WhenIdle {}
-    private method DoGlob { cwd patterns }
-    private method Glob { pattern }
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-    private variable _str2val     ;# maps option label => option value
-}
-
-itk::usual FileChoiceEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileChoiceEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    itk_component add choice {
-        Rappture::Combobox $itk_interior.choice -editable no
-    }
-    pack $itk_component(choice) -expand yes -fill both
-    bind $itk_component(choice) <<Value>> [itcl::code $this NewValue]
-
-    # First time, parse the <pattern> elements to generate notify callbacks
-    # for each template found.
-    foreach cname [$_owner xml children -type pattern $_path] {
-        set glob [string trim [$_owner xml get $_path.$cname]]
-        # Successively replace each template with its value.
-        while { [regexp -indices {@@[^@]*@@} $glob range] } {
-            foreach {first last} $range break
-            set i1 [expr $first + 2]
-            set i2 [expr $last  - 2]
-            set cpath [string range $glob $i1 $i2]
-            set value [$_owner xml get $cpath.$cname]
-            set glob [string replace $glob $first $last $value]
-            $_owner notify add $this $cpath [itcl::code $this WhenIdle]
-        }
-    }
-    $_owner notify sync
-    eval itk_initialize $args
-    Rebuild
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileChoiceEntry::destructor {} {
-    $_owner notify remove $this
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileChoiceEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [lindex $args 0]
-        if {[info exists _str2val($newval)]} {
-            # this is a label -- use it directly
-            $itk_component(choice) value $newval
-            set newval $_str2val($newval)  ;# report the actual value
-        } else {
-            # this is a value -- search for corresponding label
-            foreach str [array names _str2val] {
-                if {$_str2val($str) == $newval} {
-                    $itk_component(choice) value $str
-                    break
-                }
-            }
-        }
-        return $newval
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    set str [$itk_component(choice) value]
-    if {[info exists _str2val($str)]} {
-        return $_str2val($str)
-    }
-    return $str
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileChoiceEntry::label {} {
-    set label [$_owner xml get $_path.about.label]
-    if {"" == $label} {
-        set label "Choice"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileChoiceEntry::tooltip {} {
-    # query tooltip on-demand based on current choice
-    return "@[itcl::code $this Tooltip]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Used internally to rebuild the contents of this choice widget
-# whenever something that it depends on changes.  Scans through the
-# information in the XML spec and builds a list of choices for the
-# widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileChoiceEntry::Rebuild {} {
-    set _rebuildPending 0
-    # get rid of any existing choices
-    $itk_component(choice) choices delete 0 end
-    array unset _str2val
-    #
-    # Plug in the various options for the choice.
-    #
-    set max 10
-    $_owner notify sync
-    set allfiles {}
-    foreach cname [$_owner xml children -type pattern $_path] {
-        set glob [string trim [$_owner xml get $_path.$cname]]
-        # Successively replace each template with its value.
-        while { [regexp -indices {@@[^@]*@@} $glob range] } {
-            foreach {first last} $range break
-            set i1 [expr $first + 2]
-            set i2 [expr $last  - 2]
-            set cpath [string range $glob $i1 $i2]
-            set value [$_owner xml get $cpath.current]
-            if { $value == "" } {
-                set value [$_owner xml get $cpath.default]
-            }
-            set glob [string replace $glob $first $last $value]
-        }
-        # Replace the template with the substituted value.
-        set files [Glob $glob]
-        set allfiles [concat $allfiles $files]
-    }
-    set first ""
-    set tail ""
-    foreach file $allfiles {
-        set tail [file tail $file]
-        if { $first == "" } {
-            set first $tail
-        }
-        set root [file root $tail]
-        $itk_component(choice) choices insert end $file $tail
-        set _str2val($tail) $file
-        set len [string length $tail]
-        if {$len > $max} { set max $len }
-    }
-    $itk_component(choice) configure -width $max
-    $itk_component(choice) value $tail
-}
-
-# ----------------------------------------------------------------------
-# USAGE: NewValue
-#
-# Invoked automatically whenever the value in the choice changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileChoiceEntry::NewValue {} {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Tooltip
-#
-# Returns the tooltip for this widget, given the current choice in
-# the selector.  This is normally called by the Rappture::Tooltip
-# facility whenever it is about to pop up a tooltip for this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileChoiceEntry::Tooltip {} {
-    set tip [string trim [$_owner xml get $_path.about.description]]
-    # get the description for the current choice, if there is one
-    set str [$itk_component(choice) value]
-    set path [$itk_component(choice) translate $str]
-    set desc $path
-    if {$path == ""} {
-        set desc [$_owner xml get $_path.about.description]
-    }
-
-    if {[string length $str] > 0 && [string length $desc] > 0} {
-        append tip "\n\n$str:\n$desc"
-    }
-    return $tip
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::FileChoiceEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(choice) configure -state $itk_option(-state)
-}
-
-itcl::body Rappture::FileChoiceEntry::WhenIdle {} {
-    if { !$_rebuildPending } {
-        after 10 [itcl::code $this Rebuild]
-        set _rebuildPending 1
-    }
-}
-
-itcl::body Rappture::FileChoiceEntry::DoGlob { cwd patterns } {
-    set rest [lrange $patterns 1 end]
-    set pattern [file join $cwd [lindex $patterns 0]]
-    set files ""
-    if { [llength $rest] > 0 } {
-        if { [catch {
-            glob -nocomplain -type d $pattern
-        } dirs] != 0 } {
-            puts stderr "can't glob \"$pattern\": $dirs"
-            return
-        }
-        foreach d $dirs {
-            set files [concat $files [DoGlob $d $rest]]
-        }
-    } else {
-        if { [catch {
-            glob -nocomplain $pattern
-        } files] != 0 } {
-            puts stderr "can't glob \"$pattern\": $files"
-            return
-        }
-    }
-    return [lsort -dictionary $files]
-}
-
-#
-# Glob --
-#
-#       Matches a single pattern for files. This differs from the
-#       Tcl glob by
-#
-#       1. Only matches files, not directories.
-#       2. Doesn't stop on errors (e.g. unreadable directories).
-#
-itcl::body Rappture::FileChoiceEntry::Glob { pattern } {
-    return [DoGlob "" [file split $pattern]]
-}
-
Index: trunk/gui/scripts/filelistentry.tcl
===================================================================
--- trunk/gui/scripts/filelistentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,437 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: FileListEntry - widget for entering a choice of strings
-#
-#  This widget represents a <choice> entry on a control panel.
-#  It is used to choose one of several mutually-exclusive strings.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2005  Purdue Research Foundation
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itk::usual BltTreeView {
-    keep -foreground -cursor
-}
-itk::usual BltScrollset {
-    #empty
-}
-
-itcl::class Rappture::FileListEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    private variable _rebuildPending 0
-    private variable _tree ""
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-    private variable _icon ""
-
-    constructor {owner path args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method Rebuild {}
-    protected method NewValue { args }
-    protected method Tooltip {}
-    protected method WhenIdle {}
-    private method DoGlob { cwd patterns }
-    private method Glob { pattern }
-}
-
-itk::usual FileListEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileListEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-    set _tree [blt::tree create]
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    set label [$_owner xml get $_path.about.label]
-    set desc [$_owner xml get $_path.about.description]
-    itk_component add scrollset {
-        blt::scrollset $itk_interior.ss \
-            -xscrollbar $itk_interior.ss.xs \
-            -yscrollbar $itk_interior.ss.ys \
-            -window $itk_interior.ss.tree \
-            -height 100
-    }
-    blt::tk::scrollbar $itk_interior.ss.xs
-    blt::tk::scrollbar $itk_interior.ss.ys
-    itk_component add tree {
-        blt::treeview $itk_component(scrollset).tree -linewidth 0 \
-            -alternatebackground "" \
-            -bg white -selectmode multiple \
-            -highlightthickness 0 \
-            -tree $_tree \
-            -flat yes -separator /  \
-            -selectcommand [itcl::code $this NewValue]
-    }
-    $itk_component(tree) column configure "treeView" -justify left \
-        -weight 1.0 -text "" -pad 0 -borderwidth 0 -edit no
-    pack $itk_component(scrollset) -fill both -expand yes
-
-    blt::table $itk_interior \
-        0,0 $itk_component(scrollset) -fill both
-    bind $itk_component(tree) <<Value>> [itcl::code $this NewValue]
-
-    # Standard ButtonPress-1
-    $itk_component(tree) bind Entry <ButtonPress-1> {
-        Rappture::FileListEntry::SetSelectionAnchor %W current yes set
-        set blt::TreeView::_private(scroll) 1
-    }
-    # Standard B1-Motion
-    $itk_component(tree) bind Entry <B1-Motion> {
-        set blt::TreeView::_private(x) %x
-        set blt::TreeView::_private(y) %y
-        set index [%W nearest %x %y]
-        Rappture::FileListEntry::SetSelectionAnchor %W $index yes set
-    }
-    # Standard ButtonRelease-1
-    $itk_component(tree) button bind all <ButtonRelease-1> {
-        set index [%W nearest %x %y blt::TreeView::_private(who)]
-        if { [%W index current] == $index &&
-             $blt::TreeView::_private(who) == "button" } {
-            %W see -anchor nw current
-            %W toggle current
-        }
-    }
-    # Shift-ButtonPress-1
-    $itk_component(tree) bind Entry <Shift-ButtonPress-1> {
-        Rappture::FileListEntry::SetSelectionAnchor %W current yes set
-        set blt::TreeView::_private(scroll) 1
-    }
-    # Shift-B1-Motion
-    $itk_component(tree) bind Entry <Shift-B1-Motion> {
-        set blt::TreeView::_private(x) %x
-        set blt::TreeView::_private(y) %y
-        set index [%W nearest %x %y]
-        if { [%W cget -selectmode] == "multiple" } {
-            %W selection mark $index
-        } else {
-            Rappture::FileListEntry::SetSelectionAnchor %W $index yes set
-        }
-    }
-    # Shift-ButtonRelease-1
-    $itk_component(tree) bind Entry <Shift-ButtonRelease-1> {
-        if { [%W cget -selectmode] == "multiple" } {
-            %W selection anchor current
-        }
-        after cancel $blt::TreeView::_private(afterId)
-        set blt::TreeView::_private(afterId) -1
-        set blt::TreeView::_private(scroll) 0
-    }
-    $itk_component(tree) bind Entry <Control-ButtonPress-1> {
-        Rappture::FileListEntry::SetSelectionAnchor %W current no toggle
-        set blt::TreeView::_private(scroll) 1
-    }
-    $itk_component(tree) bind Entry <Control-B1-Motion> {
-        set blt::TreeView::_private(x) %x
-        set blt::TreeView::_private(y) %y
-        set index [%W nearest %x %y]
-        if { [%W cget -selectmode] == "multiple" } {
-            %W selection mark $index
-        } else {
-            Rappture::FileListEntry::SetSelectionAnchor %W $index no toggle
-        }
-    }
-    $itk_component(tree) bind Entry <Control-ButtonRelease-1> {
-        if { [%W cget -selectmode] == "multiple" } {
-            %W selection anchor current
-        }
-        after cancel $blt::TreeView::_private(afterId)
-        set blt::TreeView::_private(afterId) -1
-        set blt::TreeView::_private(scroll) 0
-    }
-    # First time, parse the <pattern> elements to generate notify callbacks
-    # for each template found.
-    foreach cname [$_owner xml children -type pattern $_path] {
-        set glob [string trim [$_owner xml get $_path.$cname]]
-        # Successively replace each template with its value.
-        while { [regexp -indices {@@[^@]*@@} $glob range] } {
-            foreach {first last} $range break
-            set i1 [expr $first + 2]
-            set i2 [expr $last  - 2]
-            set cpath [string range $glob $i1 $i2]
-            set value [$_owner xml get $cpath.$cname]
-            set glob [string replace $glob $first $last $value]
-            $_owner notify add $this $cpath [itcl::code $this WhenIdle]
-        }
-    }
-    $_owner notify sync
-    eval itk_initialize $args
-
-    # if the control has an icon, plug it in
-    set str [$_owner xml get $path.about.icon]
-    if {$str != ""} {
-        set _icon [image create picture -data $str]
-    }
-    Rebuild
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileListEntry::destructor {} {
-    blt::tree destroy $_tree
-    $_owner notify remove $this
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileListEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        foreach id [$itk_component(tree) curselection] {
-            set path [$_tree get $id "path" ""]
-            set path2id($path) $id
-        }
-        set paths [split $newval ,]
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    set list {}
-    foreach id [$itk_component(tree) curselection] {
-        set path [$_tree get $id "path" ""]
-        if { $path != "" } {
-            lappend list $path
-        }
-    }
-    return [join $list ,]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileListEntry::label {} {
-    set label [$_owner xml get $_path.about.label]
-    if {"" == $label} {
-        set label "Choice"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileListEntry::tooltip {} {
-    # query tooltip on-demand based on current choice
-    return "@[itcl::code $this Tooltip]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Used internally to rebuild the contents of this choice widget
-# whenever something that it depends on changes.  Scans through the
-# information in the XML spec and builds a list of choices for the
-# widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileListEntry::Rebuild {} {
-    set _rebuildPending 0
-
-    #
-    # Plug in the various options for the choice.
-    #
-    set max 10
-    $_owner notify sync
-    set allfiles {}
-    foreach cname [$_owner xml children -type pattern $_path] {
-        set glob [string trim [$_owner xml get $_path.$cname]]
-        # Successively replace each template with its value.
-        while { [regexp -indices {@@[^@]*@@} $glob range] } {
-            foreach {first last} $range break
-            set i1 [expr $first + 2]
-            set i2 [expr $last  - 2]
-            set cpath [string range $glob $i1 $i2]
-            set value [$_owner xml get $cpath.current]
-            if { $value == "" } {
-                set value [$_owner xml get $cpath.default]
-            }
-            set glob [string replace $glob $first $last $value]
-        }
-        # Replace the template with the substituted value.
-        set files [Glob $glob]
-        set allfiles [concat $allfiles $files]
-    }
-    set first ""
-    eval $_tree tag add unused [$_tree children root]
-    foreach file $allfiles {
-        set tail [file tail $file]
-        if { $first == "" } {
-            set first $tail
-        }
-        set tail [file root $tail]
-        set id [$_tree index root->"$tail"]
-        if { $id < 0 } {
-            set data [list path $file show 0]
-            set id [$_tree insert root -label $tail -data $data -tag ""]
-        } else {
-            $_tree tag delete unused $id
-        }
-        set len [string length $tail]
-        if {$len > $max} { set max $len }
-    }
-    $itk_component(tree) configure -icons ""
-    $itk_component(tree) entry configure all -icons ""
-    eval $_tree delete [$_tree tag nodes unused]
-    $itk_component(tree) configure -width $max
-    catch {
-        if { ![$itk_component(tree) selection present] } {
-            $itk_component(tree) selection set [$_tree firstchild root]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: NewValue
-#
-# Invoked automatically whenever the value in the choice changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileListEntry::NewValue { args } {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Tooltip
-#
-# Returns the tooltip for this widget, given the current choice in
-# the selector.  This is normally called by the Rappture::Tooltip
-# facility whenever it is about to pop up a tooltip for this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FileListEntry::Tooltip {} {
-    set tip [string trim [$_owner xml get $_path.about.description]]
-    # get the description for the current choice, if there is one
-    set path ""
-    set desc ""
-    if {$path == ""} {
-        set desc [$_owner xml get $_path.about.description]
-    }
-    set str ""
-    if {[string length $str] > 0 && [string length $desc] > 0} {
-        append tip "\n\n$str:\n$desc"
-    }
-    return $tip
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::FileListEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    #$itk_component(tree) configure -state $itk_option(-state)
-}
-
-itcl::body Rappture::FileListEntry::WhenIdle {} {
-    if { !$_rebuildPending } {
-        after 10 [itcl::code $this Rebuild]
-        set _rebuildPending 1
-    }
-}
-
-proc Rappture::FileListEntry::SetSelectionAnchor { w tagOrId clear how } {
-    set index [$w index $tagOrId]
-    if { $clear } {
-        $w selection clearall
-    }
-    $w see $index
-    $w focus $index
-    $w selection $how $index
-    $w selection anchor $index
-}
-
-itcl::body Rappture::FileListEntry::DoGlob { cwd patterns } {
-    set rest [lrange $patterns 1 end]
-    set pattern [file join $cwd [lindex $patterns 0]]
-    set files ""
-    if { [llength $rest] > 0 } {
-        if { [catch {
-            glob -nocomplain -type d $pattern
-        } dirs] != 0 } {
-            puts stderr "can't glob \"$pattern\": $dirs"
-            return
-        }
-        foreach d $dirs {
-            set files [concat $files [DoGlob $d $rest]]
-        }
-    } else {
-        if { [catch {
-            glob -nocomplain $pattern
-        } files] != 0 } {
-            puts stderr "can't glob \"$pattern\": $files"
-            return
-        }
-    }
-    return $files
-}
-
-#
-# Glob --
-#
-#       Matches a single pattern for files. This differs from the
-#       Tcl glob by
-#
-#       1. Only matches files, not directories.
-#       2. Doesn't stop on errors (e.g. unreadable directories).
-#
-itcl::body Rappture::FileListEntry::Glob { pattern } {
-    return [DoGlob "" [file split $pattern]]
-}
-
Index: trunk/gui/scripts/filexfer.tcl
===================================================================
--- trunk/gui/scripts/filexfer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,397 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: filexfer - support for file transfer with user's desktop
-#
-#  Supports interactions with the filexfer middleware, enabling
-#  Rappture to transfer files to and from the user's desktop.
-#  Files are downloaded by invoking "exportfile", and uploaded by
-#  invoking "importfile".  The middleware handles the rest.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require BLT
-
-namespace eval Rappture { # forward declaration }
-namespace eval Rappture::filexfer {
-    variable enabled 0   ;# set to 1 when middleware is in place
-    variable commands    ;# complete path to exportfile/importfile
-    variable job         ;# used to manage bgexec jobs
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::filexfer::init
-#
-# Called in the main application to see if the filexfer middleware
-# is installed.  Returns 1 if the middleware is installed, and 0
-# otherwise.
-# ----------------------------------------------------------------------
-proc Rappture::filexfer::init {} {
-    variable enabled
-    variable commands
-
-    #
-    # Look for the exportfile/importfile commands and see if
-    # they appear to be working.  If we have both, then this
-    # is "enabled".
-    #
-    foreach op {export import} {
-        set prog "${op}file"
-        set path [auto_execok $prog]
-        if {"" == $path} {
-            foreach dir {/apps/bin /apps/filexfer/bin} {
-                set p [file join $dir $prog]
-                if {[file executable $p]} {
-                    set path $p
-                    break
-                }
-            }
-        }
-        if {[file executable $path]} {
-            # the new filexfer has a --provenance arg for file names
-            set info [exec $path --help  2>@1]
-            if {[regexp -- {--provenance} $info]} {
-                lappend path --provenance
-            }
-            set commands($op) $path
-        } else {
-            return 0
-        }
-    }
-
-    return [set enabled 1]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::filexfer::enabled
-#
-# Clients use this to see if the filexfer stuff is up and running.
-# If so, then the GUI will provide "Download..." and other filexfer
-# options.  If not, then Rappture must be running within an
-# environment that doesn't support it.  As a backup, Rappture provides
-# file load/save operations instead.
-# ----------------------------------------------------------------------
-proc Rappture::filexfer::enabled {} {
-    variable enabled
-    return $enabled
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::filexfer::label upload|download
-#
-# Clients use this to query the proper label for an "upload" or
-# "download" opertion.  These are usually "Upload..." and "Download",
-# but could change to "Load File..." and "Save As..." for applications
-# in desktop mode.
-# ----------------------------------------------------------------------
-proc Rappture::filexfer::label {operation} {
-    switch -- $operation {
-        upload {
-            if {[Rappture::filexfer::enabled]} {
-                return "Upload..."
-            } else {
-                return "Load File..."
-            }
-        }
-        uploadWord {
-            if {[Rappture::filexfer::enabled]} {
-                return "Upload"
-            } else {
-                return "Browse"
-            }
-        }
-        download {
-            if {[Rappture::filexfer::enabled]} {
-                return "Download"
-            } else {
-                return "Save As..."
-            }
-        }
-        downloadWord {
-            if {[Rappture::filexfer::enabled]} {
-                return "Download"
-            } else {
-                return "Save"
-            }
-        }
-        default {
-            error "bad option \"$operation\": should be upload, uploadWord, download, or downloadWord"
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::filexfer::upload <toolName> <controlList> <callback>
-#
-# Clients use this to prompt the user to upload a file.  The string
-# <toolName> is used to identify the application within the web form.
-# The <controlList> is a list of controls that could be uploaded:
-#
-#   { <id1> <label1> <desc1>  <id2> <label2> <desc2> ... }
-#
-# The user is prompted for each of the controls in <controlList>.
-# If successful, the <callback> is invoked to handle the uploaded
-# information.  If anything goes wrong, the same callback is used
-# to post errors near the widget that invoked this operation.
-#
-# The <id> is usually a Rappture path for the control that is being
-# uploaded into.  It is passed along to the <callback>, so that code
-# knows where to put the result.  If <id> is "@@<dir>", then the file
-# is uploaded into the specified directory <dir> using the name that
-# comes from the remote upload.
-# ----------------------------------------------------------------------
-proc Rappture::filexfer::upload {tool controlList callback} {
-    global env
-    variable enabled
-    variable commands
-    variable job
-
-    if {$enabled} {
-        set cmd $commands(import)
-        if {"" != $tool} {
-            lappend cmd --for "for $tool"
-        }
-
-        set dir ~/data/sessions/$env(SESSION)/spool
-        if {![file exists $dir]} {
-            catch {file mkdir $dir}
-        }
-
-        set i 0
-        foreach {path label desc} $controlList {
-            set file [file join $dir upload[pid]-[incr i]]
-            set file2path($file) $path
-            set file2label($file) $label
-            lappend cmd --label $label $file
-        }
-
-        uplevel #0 [list $callback error "Upload starting...\nA web browser page should pop up on your desktop.  Use that form to handle the upload operation.\n\nIf the upload form doesn't pop up, make sure that you're allowing pop ups from this site.  If it still doesn't pop up, you may be having trouble with the version of Java installed for your browser.  See our Support area for details.\n\nClick anywhere to dismiss this message."]
-
-        set job(output) ""
-        set job(error) ""
-
-        set status [catch {eval \
-            blt::bgexec ::Rappture::filexfer::job(control) \
-              -output ::Rappture::filexfer::job(output) \
-              -error ::Rappture::filexfer::job(error) \
-              $cmd
-        } result]
-
-        if {$status == 0} {
-            set changed ""
-            set errs ""
-            foreach line [split $job(output) \n] {
-                # the new filexfer reports "file <= desktopName"
-                # the old one just reports "file"
-                set remote ""
-                if {![regexp {(.+) +<= +(.+)} $line match file remote]} {
-                    set file [string trim $line]
-                }
-
-                # load the uploaded for this control
-                set status [catch {
-                    set fid [open $file r]
-                    fconfigure $fid -translation binary -encoding binary
-                    set info [read $fid]
-                    close $fid
-                    if {[string match @@* $file2path($file)]} {
-                        if {$remote ne "" && $remote ne "@CLIPBOARD"} {
-                            set dir [string range $file2path($file) 2 end]
-                            if {$dir eq ""} { set dir [pwd] }
-                            set newloc [file join $dir $remote]
-                            file rename -force -- $file $newloc
-                        }
-                    } else {
-                        file delete -force $file
-                    }
-                } result]
-
-                if {$status != 0} {
-                    append errs "Error loading data for \"$file2label($file)\":\n$result\n"
-                } else {
-                    lappend changed $file2path($file)
-                    set cmd [list $callback path $file2path($file) local $file data $info]
-                    if {$remote ne ""} {
-                        lappend cmd remote $remote
-                    }
-                    uplevel #0 $cmd
-                }
-            }
-            if {[llength $changed] == 0} {
-                set errs "The form was empty, so none of your controls were changed.  In order to upload a file, you must select the file name--or enter text into the copy/paste area--before pushing the Upload button."
-            }
-            if {[string length $errs] > 0} {
-                uplevel #0 [list $callback error $errs]
-            }
-        } else {
-            uplevel #0 [list $callback error $job(error)]
-        }
-    } else {
-        #
-        # Filexfer via importfile is disabled.  This tool must be
-        # running in a desktop environment.  Instead of uploading,
-        # perform a "Load File..." operation with a standard file
-        # selection dialog.
-        #
-        set i 0
-        foreach {path label desc} $controlList {
-            set file [tk_getOpenFile -title "Load File: $label"]
-            if {"" != $file} {
-                set cmds {
-                    # try to read first as binary
-                    set fid [open $file r]
-                    fconfigure $fid -encoding binary -translation binary
-                    set info [read $fid]
-                    close $fid
-                    if {![Rappture::encoding::is binary $info]} {
-                        # not binary? then re-read and translate CR/LF
-                        set fid [open $file r]
-                        set info [read $fid]
-                        close $fid
-                    }
-                }
-                if {[catch $cmds err]} {
-                    uplevel #0 [list $callback error "Error loading file [file tail $file]: $err"]
-                } else {
-                    uplevel #0 [list $callback path $path data $info filename $file]
-                }
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::filexfer::download <string> ?<filename>?
-#
-# Clients use this to send a file off to the user.  The <string>
-# is stored in a file called <filename> in the user's spool directory.
-# If there is already a file by that name, then the name is modified
-# to make it unique.  Once the string has been stored in the file,
-# a message is sent to all clients listening, letting them know
-# that the file is available.
-#
-# If anything goes wrong, this function returns a string that should
-# be displayed to the user to explain the problem.
-# ----------------------------------------------------------------------
-proc Rappture::filexfer::download {string {filename "output.txt"}} {
-    global env
-    variable enabled
-    variable commands
-    variable job
-
-    if {$enabled} {
-        # make a spool directory, if we don't have one already
-        set dir ~/data/sessions/$env(SESSION)/spool
-        if {![file exists $dir]} {
-            catch {file mkdir $dir}
-        }
-
-        if {[file exists [file join $dir $filename]]} {
-            #
-            # Find a similar file name that doesn't conflict
-            # with an existing file:  e.g., output2.txt
-            #
-            set root [file rootname $filename]
-            set ext [file extension $filename]
-            set counter 2
-            while {1} {
-                set filename "$root$counter$ext"
-                if {![file exists [file join $dir $filename]]} {
-                    break
-                }
-                incr counter
-            }
-        }
-
-        #
-        # Save the file in the spool directory, then have it
-        # exported.
-        #
-        if {[catch {
-            set file [file join $dir $filename]
-            set fid [open $file w]
-            fconfigure $fid -encoding binary -translation binary
-            puts -nonewline $fid $string
-            close $fid
-        } result]} {
-            return $result
-        }
-
-        set job(output) ""
-        set job(error) ""
-
-        # Make sure we normalize the file name here.  Don't count
-        # on filexfer command understanding tildes.
-        set file [file normalize $file]
-
-        set status [catch {blt::bgexec ::Rappture::filexfer::job(control) \
-            -output ::Rappture::filexfer::job(output) \
-            -error ::Rappture::filexfer::job(error) \
-            $commands(export) --timeout 300 --delete $file} result]
-
-        if {$status != 0} {
-            return $Rappture::filexfer::job(error)
-        }
-    } else {
-        #
-        # Filexfer via exportfile is disabled.  This tool must be
-        # running in a desktop environment.  Instead of downloading,
-        # perform a "Save As..." operation with a standard file
-        # selection dialog.
-        #
-        set file [tk_getSaveFile -title "Save As..." -initialfile $filename]
-        # FIXME: Why is there a grab still pending?
-        set grab [grab current]
-        if { $grab != "" } {
-            grab release $grab
-        }
-        if {"" != $file} {
-            if {[catch {
-                set fid [open $file w]
-                if {[Rappture::encoding::is binary $string]} {
-                    fconfigure $fid -encoding binary -translation binary
-                    puts -nonewline $fid $string
-                } else {
-                    puts $fid $string
-                }
-                close $fid
-            } result]} {
-                return $result
-            }
-        }
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::filexfer::webpage <url>
-#
-# Clients use this to pop up a web page for the specified <url> on
-# the user's desktop.  The <url> should start with http:// or https://.
-# If anything goes wrong, this function beeps.
-# ----------------------------------------------------------------------
-proc Rappture::filexfer::webpage {url} {
-    if {[regexp -nocase {^https?://} $url]} {
-        foreach prog {
-              clientaction
-              /usr/lib/hubzero/clientaction
-              /apps/bin/clientaction
-              /apps/xvnc/bin/clientaction
-              /usr/lib/mw/bin/clientaction
-              ""
-        } {
-            if {"" != [auto_execok $prog]} {
-                break
-            }
-        }
-        if {"" != $prog} {
-            exec $prog url $url &
-            return
-        }
-    }
-    bell
-}
Index: trunk/gui/scripts/flowdial.tcl
===================================================================
--- trunk/gui/scripts/flowdial.tcl	(revision 6716)
+++ 	(revision )
@@ -1,592 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Flowdial - selector, like the dial on a flow
-#
-#  This widget looks like the dial on an old-fashioned car flow.
-#  It draws a series of values along an axis, and allows a selector
-#  to move back and forth to select the values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *Flowdial.dialProgressColor #6666cc widgetDefault
-option add *Flowdial.thickness 10 widgetDefault
-option add *Flowdial.length 2i widgetDefault
-option add *Flowdial.knobImage knob widgetDefault
-option add *Flowdial.knobPosition n@middle widgetDefault
-option add *Flowdial.dialOutlineColor black widgetDefault
-option add *Flowdial.dialFillColor white widgetDefault
-option add *Flowdial.lineColor gray widgetDefault
-option add *Flowdial.activeLineColor black widgetDefault
-option add *Flowdial.padding 0 widgetDefault
-option add *Flowdial.valueWidth 10 widgetDefault
-option add *Flowdial.valuePadding 0.1 widgetDefault
-option add *Flowdial.foreground black widgetDefault
-option add *Flowdial.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Flowdial {
-    inherit itk::Widget
-
-    itk_option define -min min Min ""
-    itk_option define -max max Max ""
-    itk_option define -variable variable Variable ""
-
-    itk_option define -thickness thickness Thickness 0
-    itk_option define -length length Length 0
-    itk_option define -padding padding Padding 0
-
-    itk_option define -foreground foreground Foreground "black"
-    itk_option define -dialoutlinecolor dialOutlineColor Color "black"
-    itk_option define -dialfillcolor dialFillColor Color "white"
-    itk_option define -dialprogresscolor dialProgressColor Color ""
-    itk_option define -linecolor lineColor Color "black"
-    itk_option define -activelinecolor activeLineColor Color "black"
-    itk_option define -knobimage knobImage KnobImage ""
-    itk_option define -knobposition knobPosition KnobPosition ""
-
-    itk_option define -font font Font ""
-    itk_option define -valuewidth valueWidth ValueWidth 0
-    itk_option define -valuepadding valuePadding ValuePadding 0
-
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method current {value}
-    public method clear {}
-    public method color {value}
-
-    protected method _redraw {}
-    protected method _click {x y}
-    protected method _navigate {offset}
-    protected method _fixSize {}
-    protected method _fixValue {args}
-
-    private method _current {value}
-    private method ms2rel {value}
-    private method rel2ms {value}
-    private variable _values ""       ;# list of all values on the dial
-    private variable _val2label       ;# maps value => string label(s)
-    private variable _current ""      ;# current value (where pointer is)
-    private variable _variable ""     ;# variable associated with -variable
-    private variable _knob ""         ;# image for knob
-    private variable _spectrum ""     ;# width allocated for values
-    private variable _activecolor ""  ;# width allocated for values
-    private variable _vwidth 0        ;# width allocated for values
-    public variable min 0.0
-    public variable max 1.0
-}
-
-itk::usual Flowdial {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::constructor {args} {
-    itk_component add dial {
-        canvas $itk_interior.dial
-    }
-    pack $itk_component(dial) -expand yes -fill both
-    bind $itk_component(dial) <Configure> [itcl::code $this _redraw]
-
-    if 0 {
-    bind $itk_component(dial) <ButtonPress-1> [itcl::code $this _click %x %y]
-    bind $itk_component(dial) <B1-Motion> [itcl::code $this _click %x %y]
-    bind $itk_component(dial) <ButtonRelease-1> [itcl::code $this _click %x %y]
-    bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate -1]
-    bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate 1]
-    $itk_component(dial) bind  "knob" <Enter> \
-        [list $itk_component(dial) configure -cursor sb_h_double_arrow]
-    $itk_component(dial) bind  "knob" <Leave> \
-        [list $itk_component(dial) configure -cursor ""]
-    }
-    eval itk_initialize $args
-
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::destructor {} {
-    configure -variable ""  ;# remove variable trace
-    after cancel [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current ?<value>?
-#
-# Clients use this to set a new value for the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::current {value} {
-    if {"" == $value} {
-        return
-    }
-    _current [ms2rel $value]
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _current ?<value>?
-#
-# Clients use this to set a new value for the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::_current {relval} {
-    if { $relval < 0.0 } {
-        set relval 0.0
-    }
-    if { $relval > 1.0 } {
-        set relval 1.0
-    }
-    set _current $relval
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-    if { $_variable != "" } {
-        upvar #0 $_variable var
-        set var [rel2ms $_current]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: color <value>
-#
-# Clients use this to query the color associated with a <value>
-# along the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::color {value} {
-    if {"" != $_spectrum} {
-        set frac [expr {double($value-$min)/($max-$min)}]
-        set color [$_spectrum get $frac]
-    } else {
-        if {$value == $_current} {
-            set color $_activecolor
-        } else {
-            set color $itk_option(-linecolor)
-        }
-    }
-    return $color
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Called automatically whenever the widget changes size to redraw
-# all elements within it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::_redraw {} {
-    set c $itk_component(dial)
-    $c delete all
-
-    set fg $itk_option(-foreground)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set p [winfo pixels $c $itk_option(-padding)]
-    set t [expr {$itk_option(-thickness)+1}]
-    set y1 [expr {$h-1}]
-
-    if {"" != $_knob} {
-        set kw [image width $_knob]
-        set kh [image height $_knob]
-
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top {
-                set extra [expr {$t-$kh}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-            n@middle - nw@middle - ne@middle {
-                set extra [expr {int(ceil($kh-0.5*$t))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-            n@bottom - nw@bottom - ne@bottom {
-                set y1 [expr {$h-$kh-1}]
-            }
-
-            e@top - w@top - center@top -
-            e@bottom - w@bottom - center@bottom {
-                set extra [expr {int(ceil(0.5*$kh))}]
-                set y1 [expr {$h-$extra-1}]
-            }
-            e@middle - w@middle - center@middle {
-                set extra [expr {int(ceil(0.5*($kh-$t)))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-
-            s@top - sw@top - se@top -
-            s@middle - sw@middle - se@middle -
-            s@bottom - sw@bottom - se@bottom {
-                set y1 [expr {$h-2}]
-            }
-        }
-    }
-    set y0 [expr {$y1-$t}]
-    set x0 [expr {$p+1}]
-    set x1 [expr {$w-$_vwidth-$p-4}]
-
-    # draw the background rectangle
-    $c create rectangle $x0 $y0 $x1 $y1 \
-        -outline $itk_option(-dialoutlinecolor) \
-        -fill $itk_option(-dialfillcolor)
-
-    # draw the optional progress bar, from start to current
-    if {"" != $itk_option(-dialprogresscolor) } {
-        set xx1 [expr {$_current*($x1-$x0) + $x0}]
-        $c create rectangle [expr {$x0+1}] [expr {$y0+3}] $xx1 [expr {$y1-2}] \
-            -outline "" -fill $itk_option(-dialprogresscolor)
-    }
-
-    # draw lines for all values
-    set x [expr {$_current*($x1-$x0) + $x0}]
-    if {"" != $_spectrum} {
-        set color [$_spectrum get $_current]
-    } else {
-        set color $_activecolor
-        set thick 3
-        if {"" != $color} {
-            $c create line $x [expr {$y0+1}] $x $y1 -fill $color -width $thick
-        }
-    }
-    regexp {([nsew]+|center)@} $itk_option(-knobposition) match anchor
-    switch -glob -- $itk_option(-knobposition) {
-        *@top    { set kpos $y0 }
-        *@middle { set kpos [expr {int(ceil(0.5*($y1+$y0)))}] }
-        *@bottom { set kpos $y1 }
-    }
-    $c create image $x $kpos -anchor $anchor -image $_knob -tags "knob"
-
-    # if the -valuewidth is > 0, then make room for the value
-    set vw $itk_option(-valuewidth)
-    if {$vw > 0 && "" != $_current} {
-        set str [lindex $_val2label($_current) 0]
-        if {[string length $str] >= $vw} {
-            set str "[string range $str 0 [expr {$vw-3}]]..."
-        }
-
-        set dy [expr {([font metrics $itk_option(-font) -linespace]
-                        - [font metrics $itk_option(-font) -ascent])/2}]
-
-        set id [$c create text [expr {$x1+4}] [expr {($y1+$y0)/2+$dy}] \
-            -anchor w -text $str -font $itk_option(-font) -foreground $fg]
-        foreach {x0 y0 x1 y1} [$c bbox $id] break
-        set x0 [expr {$x0 + 10}]
-
-        # set up a tooltip so you can mouse over truncated values
-        Rappture::Tooltip::text $c [lindex $_val2label($_current) 0]
-        $c bind $id <Enter> \
-            [list ::Rappture::Tooltip::tooltip pending %W +$x0,$y1]
-        $c bind $id <Leave> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-        $c bind $id <ButtonPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-        $c bind $id <KeyPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _click <x> <y>
-#
-# Called automatically whenever the user clicks or drags on the widget
-# to select a value.  Moves the current value to the one nearest the
-# click point.  If the value actually changes, it generates a <<Value>>
-# event to notify clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::_click {x y} {
-    set c $itk_component(dial)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set x0 1
-    set x1 [expr {$w-$_vwidth-4}]
-    focus $itk_component(hull)
-    if {$x >= $x0 && $x <= $x1} {
-        current [rel2ms [expr double($x - $x0) / double($x1 - $x0)]]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::_navigate {offset} {
-    set index [lsearch -exact $_values $_current]
-    if {$index >= 0} {
-        incr index $offset
-        if {$index >= [llength $_values]} {
-            set index [expr {[llength $_values]-1}]
-        } elseif {$index < 0} {
-            set index 0
-        }
-
-        set newval [lindex $_values $index]
-        if {$newval != $_current} {
-            current $newval
-            _redraw
-
-            event generate $itk_component(hull) <<Value>>
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Used internally to compute the overall size of the widget based
-# on the -thickness and -length options.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::_fixSize {} {
-    set h [winfo pixels $itk_component(hull) $itk_option(-thickness)]
-
-    if {"" != $_knob} {
-        set kh [image height $_knob]
-
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top -
-            s@bottom - sw@bottom - se@bottom {
-                if {$kh > $h} { set h $kh }
-            }
-            n@middle - nw@middle - ne@middle -
-            s@middle - sw@middle - se@middle {
-                set h [expr {int(ceil(0.5*$h + $kh))}]
-            }
-            n@bottom - nw@bottom - ne@bottom -
-            s@top - sw@top - se@top {
-                set h [expr {$h + $kh}]
-            }
-            e@middle - w@middle - center@middle {
-                set h [expr {(($h > $kh) ? $h : $kh) + 1}]
-            }
-            n@middle - ne@middle - nw@middle -
-            s@middle - se@middle - sw@middle {
-                set extra [expr {int(ceil($kh-0.5*$h))}]
-                if {$extra < 0} { set extra 0 }
-                set h [expr {$h+$extra}]
-            }
-        }
-    }
-    incr h 1
-
-    set w [winfo pixels $itk_component(hull) $itk_option(-length)]
-
-    # if the -valuewidth is > 0, then make room for the value
-    if {$itk_option(-valuewidth) > 0} {
-        set charw [font measure $itk_option(-font) "n"]
-        set _vwidth [expr {$itk_option(-valuewidth)*$charw}]
-        set w [expr {$w+$_vwidth+4}]
-    } else {
-        set _vwidth 0
-    }
-
-    $itk_component(dial) configure -width $w -height $h
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowdial::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-    _current [ms2rel $var]
-}
-
-itcl::body Rappture::Flowdial::ms2rel { value } {
-    if { $max > $min } {
-        return [expr {($value - $min) / ($max - $min)}]
-    }
-    return 0
-}
-
-itcl::body Rappture::Flowdial::rel2ms { value } {
-    return [expr $value * ($max - $min) + $min]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -thickness
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::thickness {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -length
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::length {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -font
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::font {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuewidth
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::valuewidth {
-    if {![string is integer $itk_option(-valuewidth)]} {
-        error "bad value \"$itk_option(-valuewidth)\": should be integer"
-    }
-    _fixSize
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -foreground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::foreground {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialoutlinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::dialoutlinecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialfillcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::dialfillcolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialprogresscolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::dialprogresscolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -linecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::linecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -activelinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::activelinecolor {
-    set val $itk_option(-activelinecolor)
-    if {[catch {$val isa ::Rappture::Spectrum} valid] == 0 && $valid} {
-        set _spectrum $val
-        set _activecolor ""
-    } elseif {[catch {winfo rgb $itk_component(hull) $val}] == 0} {
-        set _spectrum ""
-        set _activecolor $val
-    } elseif {"" != $val} {
-        error "bad value \"$val\": should be Spectrum object or color"
-    }
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobimage
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::knobimage {
-    if {[regexp {^image[0-9]+$} $itk_option(-knobimage)]} {
-        set _knob $itk_option(-knobimage)
-    } elseif {"" != $itk_option(-knobimage)} {
-        set _knob [Rappture::icon $itk_option(-knobimage)]
-    } else {
-        set _knob ""
-    }
-    _fixSize
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobposition
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::knobposition {
-    if {![regexp {^([nsew]+|center)@(top|middle|bottom)$} $itk_option(-knobposition)]} {
-        error "bad value \"$itk_option(-knobposition)\": should be anchor@top|middle|bottom"
-    }
-    _fixSize
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -padding
-# This adds padding on left/right side of dial background.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::padding {
-    if {[catch {winfo pixels $itk_component(hull) $itk_option(-padding)}]} {
-        error "bad value \"$itk_option(-padding)\": should be size in pixels"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuepadding
-# This shifts min/max limits in by a fraction of the overall size.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::valuepadding {
-    if {![string is double $itk_option(-valuepadding)]
-          || $itk_option(-valuepadding) < 0} {
-        error "bad value \"$itk_option(-valuepadding)\": should be >= 0.0"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Flowdial::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
Index: trunk/gui/scripts/flowhints.tcl
===================================================================
--- trunk/gui/scripts/flowhints.tcl	(revision 6716)
+++ 	(revision )
@@ -1,231 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: flowhints - represents a uniform rectangular 2-D mesh.
-#
-#  This object represents one field in an XML description of a device.
-#  It simplifies the process of extracting data vectors that represent
-#  the field.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-package require Itcl
-package require BLT
-
-namespace eval Rappture {
-    # empty
-}
-
-itcl::class Rappture::FlowHints {
-    constructor {field cname units} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method hints {}     { return [array get _hints] }
-    public method particles {} { return $_particles }
-    public method boxes {}     { return $_boxes }
-
-    private method ConvertUnits { value }
-    private method GetAxis { obj path varName }
-    private method GetBoolean { obj path varName }
-    private method GetCorner { obj path varName }
-    private method GetPosition { obj path varName }
-    private method GetSize { obj path varName }
-
-    private variable _boxes "";         # List of boxes for the flow.
-    private variable _particles "";     # List of particle injection planes.
-    private variable _hints;            # Array of settings for the flow.
-    private variable _units ""
-}
-
-# ----------------------------------------------------------------------
-# Constructor
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowHints::constructor {field cname units} {
-    if {[$field element $cname.flow] == ""} {
-        puts stderr "no flow entry in $cname"
-        return
-    }
-    array set _hints {
-        "axis"          "x"
-        "description"   ""
-        "outline"       "on"
-        "position"      "0.0%"
-        "streams"       "on"
-        "arrows"        "off"
-        "volume"        "on"
-        "duration"      "1:00"
-        "speed"         "1x"
-    }
-    set _units $units
-    set f [$field element -as object $cname.flow]
-    set _hints(name) [$field element -as id $cname.flow]
-    foreach child [$f children] {
-        set value [$f get $child]
-        switch -glob -- $child {
-            "label"       { set _hints(label) $value }
-            "description" { set _hints(description) $value }
-            "outline"     { GetBoolean $f $child _hints(outline) }
-            "volume"      { GetBoolean $f $child _hints(volume) }
-            "streams"     { GetBoolean $f $child _hints(streams) }
-            "arrows"      { GetBoolean $f $child _hints(arrows) }
-            "axis"        { GetAxis $f  $child _hints(axis) }
-            "speed"       { set _hints(speed) $value }
-            "duration"    { set _hints(duration) $value }
-            "position"    { GetPosition $f $child _hints(position) }
-            "particles*" {
-                array unset data
-                array set data {
-                    "axis"          "x"
-                    "color"         "blue"
-                    "description"   ""
-                    "hide"          "no"
-                    "label"         ""
-                    "position"      "0.0%"
-                    "size"          "1.2"
-                }
-                set p [$f element -as object $child]
-                set data(name) [$f element -as id $child]
-                foreach child [$p children] {
-                    set value [$p get $child]
-                    switch -exact -- $child {
-                        "axis"        { GetAxis $p axis data(axis) }
-                        "color"       { set data(color) $value }
-                        "description" { set data(description) $value }
-                        "hide"        { GetBoolean $p hide data(hide) }
-                        "label"       { set data(label) $value }
-                        "position"    { GetPosition $p position data(position)}
-                        "size"        { GetSize $p size data(size)}
-                    }
-                }
-                if { $data(label) == "" } {
-                    set data(label) $data(name)
-                }
-                itcl::delete object $p
-                lappend _particles [array get data]
-            }
-            "box*" {
-                array unset data
-                array set data {
-                    "color"         "green"
-                    "description"   ""
-                    "hide"          "no"
-                    "label"         ""
-                    "linewidth"     "2"
-                }
-                set b [$f element -as object $child]
-                set name [$f element -as id $child]
-                set count 0
-                set data(name) $name
-                set data(color) [$f get $child.color]
-                foreach child [$b children] {
-                    set value [$b get $child]
-                    switch -glob -- $child {
-                        "color"       { set data(color) $value }
-                        "description" { set data(description) $value }
-                        "hide"        { GetBoolean $b hide data(hide) }
-                        "linewidth"   { GetSize $b linewidth data(linewidth) }
-                        "label"       { set data(label) $value }
-                        "corner*" {
-                            incr count
-                            GetCorner $b $child data(corner$count)
-                        }
-                    }
-                }
-                if { $data(label) == "" } {
-                    set data(label) $data(name)
-                }
-                itcl::delete object $b
-                lappend _boxes [array get data]
-            }
-        }
-    }
-    itcl::delete  object $f
-}
-
-itcl::body Rappture::FlowHints::ConvertUnits { value } {
-    set cmd Rappture::Units::convert
-    set n  [scan $value "%g%s" number suffix]
-    if { $n == 2 } {
-        if { $suffix == "%" } {
-            return $value
-        } else {
-            return [$cmd $number -context $suffix -to $_units -units off]
-        }
-    } elseif { [scan $value "%g" number]  == 1 } {
-        if { $_units == "" } {
-            return $number
-        }
-        return [$cmd $number -context $_units -to $_units -units off]
-    }
-    return ""
-}
-
-itcl::body Rappture::FlowHints::GetPosition { obj path varName } {
-    set value [$obj get $path]
-    set pos [ConvertUnits $value]
-    if { $pos == "" } {
-        puts stderr "can't convert units \"$value\" of \"$path\""
-    }
-    upvar $varName position
-    set position $pos
-}
-
-itcl::body Rappture::FlowHints::GetAxis { obj path varName } {
-    set value [$obj get $path]
-    set value [string tolower $value]
-    switch -- $value {
-        "x" - "y" - "z" {
-            upvar $varName axis
-            set axis $value
-            return
-        }
-    }
-    puts stderr "invalid axis \"$value\" in \"$path\""
-}
-
-itcl::body Rappture::FlowHints::GetCorner { obj path varName } {
-    set value [$obj get $path]
-    set coords ""
-    if { [llength $value] != 3 } {
-        puts stderr "wrong number of coordinates \"$value\" in \"$path\""
-        return ""
-    }
-    foreach coord $value {
-        set v [ConvertUnits $coord]
-        if { $v == "" } {
-            puts stderr "can't convert units \"$value\" of \"$path\""
-            return ""
-        }
-        lappend coords $v
-    }
-    upvar $varName corner
-    set corner $coords
-}
-
-itcl::body Rappture::FlowHints::GetBoolean { obj path varName } {
-    set value [$obj get $path]
-    if { [string is boolean $value] } {
-        upvar $varName bool
-        set bool [expr $value ? 1 : 0]
-        return
-    }
-    puts stderr "invalid boolean \"$value\" in \"$path\""
-}
-
-itcl::body Rappture::FlowHints::GetSize { obj path varName } {
-    set string [$obj get $path]
-    if { [scan $string "%d" value] != 1 || $value < 0 } {
-        puts stderr "can't get size \"$string\" of \"$path\""
-        return
-    }
-    upvar $varName size
-    set size $value
-}
Index: trunk/gui/scripts/flowspeed.tcl
===================================================================
--- trunk/gui/scripts/flowspeed.tcl	(revision 6716)
+++ 	(revision )
@@ -1,181 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: spinint - spinner for integer values
-#
-#  This widget is a spinner with up/down arrows for managing integer
-#  values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Flowspeed.width 5 widgetDefault
-option add *Flowspeed.textBackground white widgetDefault
-
-blt::bitmap define Flowspeed-up {
-#define up_width 8
-#define up_height 4
-static unsigned char up_bits[] = {
-   0x10, 0x38, 0x7c, 0xfe};
-}
-
-blt::bitmap define Flowspeed-down {
-#define arrow_width 8
-#define arrow_height 4
-static unsigned char arrow_bits[] = {
-   0xfe, 0x7c, 0x38, 0x10};
-}
-
-itcl::class Rappture::Flowspeed {
-    inherit itk::Widget
-
-    itk_option define -min min Min ""
-    itk_option define -max max Max ""
-    itk_option define -delta delta Delta 1
-
-    constructor {args} { # defined below }
-
-    public method value {args}
-    public method bump {{delta up}}
-    protected method _validate {char}
-    protected variable _value ""
-}
-
-itk::usual Flowspeed {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowspeed::constructor {args} {
-    itk_component add entry {
-        entry $itk_interior.entry
-    } {
-        usual
-        keep -width
-        rename -background -textbackground textBackground Background
-        rename -foreground -textforeground textForeground Foreground
-        rename -highlightbackground -background background Background
-    }
-    pack $itk_component(entry) -side left -expand yes -fill x
-
-    bind $itk_component(entry) <KeyPress> \
-        [itcl::code $this _validate %A]
-    bind $itk_component(entry) <Return> \
-        "$this value \[$itk_component(entry) get\]"
-    bind $itk_component(entry) <KP_Enter> \
-        "$this value \[$itk_component(entry) get\]"
-    bind $itk_component(entry) <KeyPress-Tab> \
-        "$this value \[$itk_component(entry) get\]"
-
-    itk_component add controls {
-        frame $itk_interior.cntls
-    }
-    pack $itk_component(controls) -side right
-
-    itk_component add up {
-        button $itk_component(controls).spinup -bitmap Flowspeed-up \
-            -borderwidth 1 -relief raised -highlightthickness 0 \
-            -command [itcl::code $this bump up]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(up) -side top -expand yes -fill both
-
-    itk_component add down {
-        button $itk_component(controls).spindn -bitmap Flowspeed-down \
-            -borderwidth 1 -relief raised -highlightthickness 0 \
-            -command [itcl::code $this bump down]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(down) -side bottom -expand yes -fill both
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowspeed::value {args} {
-    if {[llength $args] == 1} {
-        set string [lindex $args 0]
-        if { [regexp {^ *([0-9]+)x *$} $string match newval] } {
-        } elseif { [regexp {^ *([0-9]+) *$} $string match newval] } {
-        } else {
-            bell
-            return
-        }
-        if {"" != $newval} {
-            if {"" != $itk_option(-min) && $newval < $itk_option(-min)} {
-                set newval $itk_option(-min)
-            }
-            if {"" != $itk_option(-max) && $newval > $itk_option(-max)} {
-                set newval $itk_option(-max)
-            }
-        }
-        set _value $newval
-        $itk_component(entry) delete 0 end
-        $itk_component(entry) insert 0 ${newval}x
-        after 10 \
-            [list catch [list event generate $itk_component(hull) <<Value>>]]
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?newval?\""
-    }
-    return $_value
-}
-
-# ----------------------------------------------------------------------
-# USAGE: bump ?<delta>?
-#
-# Used internally when you click on the up/down arrows.  Clients
-# can also use it directly to bump values up/down.  The optional
-# <delta> can be an integer value or the keyword "up" or "down".
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowspeed::bump {{delta up}} {
-    if {"up" == $delta} {
-        set delta $itk_option(-delta)
-    } elseif {"down" == $delta} {
-        set delta [expr {-$itk_option(-delta)}]
-    } elseif {![string is integer $delta]} {
-        error "bad delta \"$delta\": should be up, down, or integer"
-    }
-
-    set val [$itk_component(entry) get]
-    if {$val == ""} {
-        set val 0
-    }
-    value [expr {$_value+$delta}]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _validate <char>
-#
-# Validates each character as it is typed into the spinner.
-# If the <char> is not a digit, then this procedure beeps and
-# prevents the character from being inserted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Flowspeed::_validate {char} {
-    if {[string match "\[ -~\]" $char]} {
-        if {![string match "\[0-9\]" $char]} {
-            bell
-            return -code break
-        }
-    }
-}
Index: trunk/gui/scripts/flowvisviewer.tcl
===================================================================
--- trunk/gui/scripts/flowvisviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,2975 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: flowvisviewer - 3D flow rendering
-#
-#  This widget performs volume and flow rendering on 3D vector datasets.
-#  It connects to the Nanovis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-package require Img
-
-option add *FlowvisViewer.width 5i widgetDefault
-option add *FlowvisViewer*cursor crosshair widgetDefault
-option add *FlowvisViewer.height 4i widgetDefault
-option add *FlowvisViewer.foreground black widgetDefault
-option add *FlowvisViewer.controlBackground gray widgetDefault
-option add *FlowvisViewer.controlDarkBackground #999999 widgetDefault
-option add *FlowvisViewer.plotBackground black widgetDefault
-option add *FlowvisViewer.plotForeground white widgetDefault
-option add *FlowvisViewer.plotOutline gray widgetDefault
-option add *FlowvisViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc FlowvisViewer_init_resources {} {
-    Rappture::resources::register \
-        nanovis_server Rappture::FlowvisViewer::SetServerList
-}
-
-itcl::class Rappture::FlowvisViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-    itk_option define -plotoutline plotOutline PlotOutline ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "nanovis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method flow {option}
-    public method get {args}
-    public method isconnected {}
-    public method limits { tf }
-    public method overMarker { m x }
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method removeDuplicateMarker { m x }
-    public method scale {args}
-    public method updateTransferFunctions {}
-
-    # The following methods are only used by this class.
-    private method AddIsoMarker { x y }
-    private method AdjustSetting {what {value ""}}
-    private method BuildCameraTab {}
-    private method BuildCutplanesTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildViewTab {}
-    private method BuildVolumeComponents {}
-    private method BuildVolumeTab {}
-    private method ComputeTransferFunction { tf }
-    private method Connect {}
-    private method CurrentDatasets {{what -all}}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DrawLegend { tf }
-    private method EventuallyGoto { nSteps }
-    private method EventuallyRedrawLegend { }
-    private method EventuallyResize { w h }
-    private method FixLegend {}
-    private method GetDatasetsWithComponent { cname }
-    private method GetFlowInfo { widget }
-    private method GetImage { args }
-    private method GetMovie { widget width height }
-    private method GetPngImage { widget width height }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method NameTransferFunction { dataobj comp }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method ParseLevelsOption { tf levels }
-    private method ParseMarkersOption { tf markers }
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveData { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { tf vmin vmax size }
-    private method Rotate {option x y}
-    private method SendFlowCmd { dataobj comp nbytes numComponents }
-    private method SendTransferFunctions {}
-    private method SetOrientation { side }
-    private method Slice {option args}
-    private method SlicerTip {axis}
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method WaitIcon { option widget }
-    private method Zoom {option}
-    private method arrows { tag name }
-    private method box { tag name }
-    private method millisecs2str { value }
-    private method particles { tag name }
-    private method str2millisecs { value }
-    private method streams { tag name }
-
-    private variable _arcball ""
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _serverDatasets;   # contains all the dataobj-component
-                                        # to volumes in the server
-    private variable _recvdDatasets;    # list of data objs to send to server
-    private variable _dataset2style;    # maps dataobj-component to transfunc
-    private variable _style2datasets;   # maps tf back to list of
-                                        # dataobj-components using the tf.
-    private variable _dataset2flow;     # Maps dataobj-component to a flow.
-
-    private variable _reset 1;          # Connection to server has been reset.
-    private variable _click;            # Info used for rotate operations.
-    private variable _limits;           # Autoscale min/max for all axes
-    private variable _view;             # View params for 3D view
-    private variable _isomarkers;       # array of isosurface level values 0..1
-    private variable _settings
-    private variable _activeTf "";      # Currently active transfer function
-    private variable _first "";         # This is the topmost volume.
-    private variable _volcomponents;    # Maps component name to list of
-                                        # dataobj-component tags
-    private variable _componentsList;   # List of components found
-    private variable _nextToken 0
-    private variable _icon 0
-    private variable _flow
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _resizeLegendPending 0
-    private variable _gotoPending 0
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual FlowvisViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::constructor {args} {
-    set _serverType "nanovis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list"
-
-    # Send transfer functions event
-    $_dispatcher register !send_transfunc
-    $_dispatcher dispatch $this !send_transfunc \
-        "[itcl::code $this SendTransferFunctions]; list"
-
-    $_dispatcher register !play
-    $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list"
-
-    $_dispatcher register !goto
-    $_dispatcher dispatch $this !goto "[itcl::code $this flow goto2]; list"
-
-    $_dispatcher register !movietimeout
-    $_dispatcher register !waiticon
-
-    set _flow(state) 0
-
-    array set _downloadPopup {
-        format vtk
-    }
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias data [itcl::code $this ReceiveData]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    set _limits(vmin) 0.0
-    set _limits(vmax) 1.0
-
-    array set _settings [subst {
-        -arrows                 0
-        -axesvisible            0
-        -background             black
-        -colormap               BCGYR
-        -currenttime            0
-        -cutplanesvisible       0
-        -duration               1:00
-        -gridvisible            0
-        -isosurfaceshading      0
-        -legendvisible          1
-        -lic                    1
-        -light                  40
-        -light2side             1
-        -loop                   0
-        -opacity                50
-        -outlinevisible         1
-        -particles              1
-        -play                   0
-        -qw                     $_view(-qw)
-        -qx                     $_view(-qx)
-        -qy                     $_view(-qy)
-        -qz                     $_view(-qz)
-        -speed                  500
-        -step                   0
-        -streams                0
-        -thickness              350
-        -volume                 1
-        -xcutplaneposition      50
-        -xcutplanevisible       1
-        -xpan                   $_view(-xpan)
-        -ycutplaneposition      50
-        -ycutplanevisible       1
-        -ypan                   $_view(-ypan)
-        -zcutplaneposition      50
-        -zcutplanevisible       1
-        -zoom                   $_view(-zoom)
-    }]
-
-    itk_component add view {
-        label $itk_component(plotarea).view -image $_image(plot) \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-    bind $itk_component(view) <Control-F1> [itcl::code $this ToggleConsole]
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add volume {
-        Rappture::PushButton $f.volume \
-            -onimage [Rappture::icon volume-on] \
-            -offimage [Rappture::icon volume-off] \
-            -variable [itcl::scope _settings(-volume)] \
-            -command [itcl::code $this AdjustSetting -volume]
-    }
-    $itk_component(volume) select
-    Rappture::Tooltip::for $itk_component(volume) \
-        "Toggle the volume cloud on/off"
-    pack $itk_component(volume) -padx 2 -pady 2
-
-    itk_component add cutplane {
-        Rappture::PushButton $f.cutplane \
-            -onimage [Rappture::icon cutbutton] \
-            -offimage [Rappture::icon cutbutton] \
-            -variable [itcl::scope _settings(-cutplanesvisible)] \
-            -command [itcl::code $this AdjustSetting -cutplanesvisible]
-    }
-    Rappture::Tooltip::for $itk_component(cutplane) \
-        "Show/Hide cutplanes"
-    pack $itk_component(cutplane) -padx 2 -pady 2
-
-    if { [catch {
-        BuildViewTab
-        BuildVolumeTab
-        BuildCutplanesTab
-        BuildCameraTab
-    } errs] != 0 } {
-        global errorInfo
-        puts stderr "errs=$errs errorInfo=$errorInfo"
-    }
-
-    # Legend
-    set _image(legend) [image create photo]
-    itk_component add legend {
-        canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -plotbackground plotBackground Background
-    }
-    bind $itk_component(legend) <Configure> \
-        [itcl::code $this EventuallyRedrawLegend]
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w \
-        1,0 $itk_component(legend) -fill x
-    blt::table configure $itk_component(plotarea) r1 -resize none
-
-    # Create flow controls...
-    itk_component add flowcontrols {
-        frame $itk_interior.flowcontrols
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    pack forget $itk_component(main)
-    blt::table $itk_interior \
-        0,0 $itk_component(main) -fill both  \
-        1,0 $itk_component(flowcontrols) -fill x
-    blt::table configure $itk_interior r1 -resize none
-
-    # Rewind
-    itk_component add rewind {
-        button $itk_component(flowcontrols).reset \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -image [Rappture::icon flow-rewind] \
-            -command [itcl::code $this flow reset]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground \
-            Background
-    }
-    Rappture::Tooltip::for $itk_component(rewind) \
-        "Rewind flow"
-
-    # Stop
-    itk_component add stop {
-        button $itk_component(flowcontrols).stop \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -image [Rappture::icon flow-stop] \
-            -command [itcl::code $this flow stop]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground \
-            Background
-    }
-    Rappture::Tooltip::for $itk_component(stop) \
-        "Stop flow"
-
-    # Play
-    itk_component add play {
-        Rappture::PushButton $itk_component(flowcontrols).play \
-            -onimage [Rappture::icon flow-pause] \
-            -offimage [Rappture::icon flow-play] \
-            -variable [itcl::scope _settings(-play)] \
-            -command [itcl::code $this flow toggle]
-    }
-    set fg [option get $itk_component(hull) font Font]
-    Rappture::Tooltip::for $itk_component(play) \
-        "Play/Pause flow"
-
-    # Loop
-    itk_component add loop {
-        Rappture::PushButton $itk_component(flowcontrols).loop \
-            -onimage [Rappture::icon flow-loop] \
-            -offimage [Rappture::icon flow-loop] \
-            -variable [itcl::scope _settings(-loop)]
-    }
-    Rappture::Tooltip::for $itk_component(loop) \
-        "Play continuously"
-
-    itk_component add dial {
-        Rappture::Flowdial $itk_component(flowcontrols).dial \
-            -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \
-            -linecolor "" -activelinecolor "" \
-            -min 0.0 -max 1.0 \
-            -variable [itcl::scope _settings(-currenttime)] \
-            -knobimage [Rappture::icon knob2] -knobposition center@middle
-    } {
-        usual
-        ignore -dialprogresscolor
-        rename -background -controlbackground controlBackground Background
-    }
-    $itk_component(dial) current 0.0
-    bind $itk_component(dial) <<Value>> [itcl::code $this flow goto]
-    # Duration
-    itk_component add duration {
-        entry $itk_component(flowcontrols).duration \
-            -textvariable [itcl::scope _settings(-duration)] \
-            -bg white -width 6 -font "arial 9"
-    } {
-        usual
-        ignore -highlightthickness -background
-    }
-    bind $itk_component(duration) <Return> [itcl::code $this flow duration]
-    bind $itk_component(duration) <KP_Enter> [itcl::code $this flow duration]
-    bind $itk_component(duration) <Tab> [itcl::code $this flow duration]
-    Rappture::Tooltip::for $itk_component(duration) \
-        "Set duration of flow (format is min:sec)"
-
-    itk_component add durationlabel {
-        label $itk_component(flowcontrols).durationl \
-            -text "Duration:" -font $fg \
-            -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-
-    itk_component add speedlabel {
-        label $itk_component(flowcontrols).speedl -text "Speed:" -font $fg \
-            -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-
-    # Speed
-    itk_component add speed {
-        Rappture::Flowspeed $itk_component(flowcontrols).speed \
-            -min 1 -max 10 -width 3 -font "arial 9"
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-    Rappture::Tooltip::for $itk_component(speed) \
-        "Change speed of flow"
-
-    $itk_component(speed) value 1
-    bind $itk_component(speed) <<Value>> [itcl::code $this flow speed]
-
-    blt::table $itk_component(flowcontrols) \
-        0,0 $itk_component(rewind) -padx {3 0} \
-        0,1 $itk_component(stop) -padx {2 0} \
-        0,2 $itk_component(play) -padx {2 0} \
-        0,3 $itk_component(loop) -padx {2 0} \
-        0,4 $itk_component(dial) -fill x -padx {2 0 } \
-        0,5 $itk_component(duration) -padx { 0 0} \
-        0,7 $itk_component(speed) -padx {2 3}
-
-#        0,6 $itk_component(speedlabel) -padx {2 0}
-    blt::table configure $itk_component(flowcontrols) c* -resize none
-    blt::table configure $itk_component(flowcontrols) c4 -resize both
-    blt::table configure $itk_component(flowcontrols) r0 -pady 1
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-
-    bind $itk_component(view) <Configure> \
-        [itcl::code $this EventuallyResize %w %h]
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::destructor {} {
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !send_transfunc
-    $_dispatcher cancel !resize
-    image delete $_image(plot)
-    image delete $_image(legend)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-    array unset _settings
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::add {dataobj {settings ""}} {
-    if { ![$dataobj isvalid] } {
-        return;                         # Object doesn't contain valid data.
-    }
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    foreach cname [$dataobj components] {
-        set flowobj [$dataobj flowhints $cname]
-        if { $flowobj == "" } {
-            puts stderr "no flowhints $dataobj-$cname"
-            continue
-        }
-        set _dataset2flow($dataobj-$cname) $flowobj
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-        set _obj2ovride($dataobj-color) $params(-color)
-        set _obj2ovride($dataobj-width) $params(-width)
-        set _obj2ovride($dataobj-raise) $params(-raise)
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-image view|legend?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist $_dlist
-            foreach dataobj $dlist {
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set i [lsearch -exact $dlist $dataobj]
-                    if {$i >= 0} {
-                        set dlist [lreplace $dlist $i $i]
-                        lappend dlist $dataobj
-                    }
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view|legend\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                legend {
-                    return $_image(legend)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view or legend"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::delete {args} {
-    flow stop
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos >= 0 } {
-            set _dlist [lreplace $_dlist $pos $pos]
-            array unset _obj2ovride $dataobj-*
-            set changed 1
-        }
-    }
-    # If anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::scale {args} {
-    array set style {
-        -color    BCGYR
-        -levels   6
-        -markers  ""
-    }
-    array unset _limits
-    array unset _volcomponents
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                     # Object doesn't contain valid data.
-        }
-        foreach cname [$dataobj components] {
-            if { ![info exists _volcomponents($cname)] } {
-                lappend _componentsList $cname
-                array set style [lindex [$dataobj components -style $cname] 0]
-                set cmap [ColorsToColormap $style(-color)]
-                set _settings($cname-colormap) $style(-color)
-            }
-            lappend _volcomponents($cname) $dataobj-$cname
-            array unset limits
-            array set limits [$dataobj valueLimits $cname]
-            set _limits($cname) $limits(v)
-        }
-        foreach axis {x y z v} {
-            foreach { min max } [$dataobj limits $axis] break
-            if {"" != $min && "" != $max} {
-                if { ![info exists _limits(${axis}min)] } {
-                    set _limits(${axis}min) $min
-                    set _limits(${axis}max) $max
-                    continue
-                }
-                if {$min < $_limits(${axis}min)} {
-                    set _limits(${axis}min) $min
-                }
-                if {$max > $_limits(${axis}max)} {
-                    set _limits(${axis}max) $max
-                }
-            }
-        }
-    }
-    #BuildVolumeComponents
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .flowvisviewerdownload
-            if { ![winfo exists $popup] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            # FIXME: we only support download of current active component
-            #set num [llength [get]]
-            #set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set num "current flow"
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .flowvisviewerdownload
-            if { [winfo exists $popup] } {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "640x480" {
-                    return [$this GetMovie [lindex $args 0] 640 480]
-                }
-                "1024x768" {
-                    return [$this GetMovie [lindex $args 0] 1024 768]
-                }
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-                default {
-                    error "bad download format \"$_downloadPopup(format)\""
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::Connect {} {
-    set _hosts [GetServerList "nanovis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "flowvisviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::FlowvisViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::FlowvisViewer::disconnect {} {
-    Disconnect
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::FlowvisViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    # disconnected -- no more data sitting on server
-    array unset _serverDatasets
-}
-
-# ----------------------------------------------------------------------
-# USAGE: SendTransferFunctions
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::SendTransferFunctions {} {
-    if { $_activeTf == "" } {
-        puts stderr "no active tf"
-        return
-    }
-    set tf $_activeTf
-    if { $_first == "" } {
-        puts stderr "first not set"
-        return
-    }
-
-    # Ensure that the global thickness setting (in the slider
-    # settings widget) is used for the active transfer-function.  Update
-    # the value in the _settings variable.
-
-    # Scale values between 0.00001 and 0.01000
-    set thickness [expr {double($_settings(-thickness)) * 0.0001}]
-    set _settings($tf-thickness) $thickness
-
-    foreach tag [array names _dataset2style $_first-*] {
-        if { [info exists _dataset2style($tag)] } {
-            foreach tf $_dataset2style($tag) {
-                ComputeTransferFunction $tf
-            }
-        }
-    }
-    EventuallyRedrawLegend
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::ReceiveImage { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    switch -- $info(-type) {
-        "image" {
-            #puts stderr "received image [image width $_image(plot)]x[image height $_image(plot)]"
-            $_image(plot) configure -data $bytes
-        }
-        "print" {
-            set tag $this-$info(-token)
-            set _hardcopy($tag) $bytes
-        }
-        "movie" {
-            set tag $this-$info(-token)
-            set _hardcopy($tag) $bytes
-        }
-        default {
-            puts stderr "unknown image type $info(-type)"
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-itcl::body Rappture::FlowvisViewer::DrawLegend { tag } {
-    set c $itk_component(legend)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set lx 10
-    set ly [expr {$h - 1}]
-    if {"" == [$c find withtag colorbar]} {
-        $c create image 10 10 -anchor nw \
-            -image $_image(legend) -tags colorbar
-        $c create text $lx $ly -anchor sw \
-            -fill $itk_option(-plotforeground) -tags "limits text vmin"
-        $c create text [expr {$w-$lx}] $ly -anchor se \
-            -fill $itk_option(-plotforeground) -tags "limits text vmax"
-        $c create text [expr {$w/2}] $ly -anchor s \
-            -fill $itk_option(-plotforeground) -tags "title text"
-        $c lower colorbar
-        $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y]
-    }
-
-    if {$tag == "" || ![info exists _dataset2style($tag)]} {
-        return
-    }
-    # Display the markers used by the current transfer function.
-    set tf $_dataset2style($tag)
-    array set limits [limits $tf]
-    $c itemconfigure vmin -text [format %g $limits(vmin)]
-    $c coords vmin $lx $ly
-
-    $c itemconfigure vmax -text [format %g $limits(vmax)]
-    $c coords vmax [expr {$w-$lx}] $ly
-
-    if { $_first == "" } {
-        return
-    }
-    set title [$_first hints label]
-    set units [$_first hints units]
-    if { $units != "" } {
-        set title "$title ($units)"
-    }
-    $c itemconfigure title -text $title
-    $c coords title [expr {$w/2}] $ly
-
-    if { [info exists _isomarkers($tf)] } {
-        foreach m $_isomarkers($tf) {
-            $m visible yes
-        }
-    }
-}
-
-#
-# ReceiveLegend --
-#
-# The procedure is the response from the render server to each "legend"
-# command.  The server sends back a "legend" command invoked our
-# the slave interpreter.  The purpose is to collect data of the image
-# representing the legend in the canvas.  In addition, the
-# active transfer function is displayed.
-#
-itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } {
-    if { ![isconnected] } {
-        return
-    }
-    set bytes [ReceiveBytes $size]
-    $_image(legend) configure -data $bytes
-    ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-
-    DrawLegend $tag
-}
-
-#
-# ReceiveData --
-#
-# The procedure is the response from the render server to each "data
-# follows" command.  The server sends back a "data" command invoked our
-# the slave interpreter.  The purpose is to collect the min/max of the
-# volume sent to the render server.  Since the client (flowvisviewer)
-# doesn't parse 3D data formats, we rely on the server (nanovis) to
-# tell us what the limits are.  Once we've received the limits to all
-# the data we've sent (tracked by _recvdDatasets) we can then determine
-# what the transfer functions are for these volumes.
-#
-#
-#       Note: There is a considerable tradeoff in having the server report
-#             back what the data limits are.  It means that much of the code
-#             having to do with transfer-functions has to wait for the data
-#             to come back, since the isomarkers are calculated based upon
-#             the data limits.  The client code is much messier because of
-#             this.  The alternative is to parse any of the 3D formats on the
-#             client side.
-#
-itcl::body Rappture::FlowvisViewer::ReceiveData { args } {
-    if { ![isconnected] } {
-        return
-    }
-
-    # Arguments from server are name value pairs. Stuff them in an array.
-    array set info $args
-
-    set tag $info(tag)
-    set parts [split $tag -]
-
-    #
-    # Volumes don't exist until we're told about them.
-    #
-    set dataobj [lindex $parts 0]
-    set _serverDatasets($tag) 0
-    set _limits($tag-min)  $info(min);  # Minimum value of the volume.
-    set _limits($tag-max)  $info(max);  # Maximum value of the volume.
-
-    unset _recvdDatasets($tag)
-    if { [array size _recvdDatasets] == 0 } {
-        updateTransferFunctions
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    # Hide all the isomarkers. Can't remove them. Have to remember the
-    # settings since the user may have created/deleted/moved markers.
-
-    foreach tf [array names _isomarkers] {
-        foreach m $_isomarkers($tf) {
-            $m visible no
-        }
-    }
-
-    if { $_width != $w || $_height != $h || $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-    }
-    if { $_reset } {
-        InitSettings -background -axesvisible -gridvisible
-    }
-    set _first ""
-    foreach dataobj [get] {
-        foreach cname [$dataobj components] {
-            set tag $dataobj-$cname
-            if {[$dataobj type] == "dx"} {
-                set data [$dataobj blob $cname]
-            } else {
-                set data [$dataobj vtkdata $cname]
-            }
-            set nbytes [string length $data]
-            if { $_reportClientInfo }  {
-                set info {}
-                lappend info "tool_id"       [$dataobj hints toolid]
-                lappend info "tool_name"     [$dataobj hints toolname]
-                lappend info "tool_title"    [$dataobj hints tooltitle]
-                lappend info "tool_command"  [$dataobj hints toolcommand]
-                lappend info "tool_revision" [$dataobj hints toolrevision]
-                lappend info "dataset_label" [$dataobj hints label]
-                lappend info "dataset_size"  $nbytes
-                lappend info "dataset_tag"   $tag
-                SendCmd "clientinfo [list $info]"
-            }
-            set numComponents [$dataobj numComponents $cname]
-            # I have a field. Is a vector field or a volume field?
-            if { $numComponents == 1 } {
-                SendCmd "volume data follows $nbytes $tag"
-            } else {
-                if {[SendFlowCmd $dataobj $cname $nbytes $numComponents] < 0} {
-                    continue
-                }
-            }
-            SendData $data
-            NameTransferFunction $dataobj $cname
-            set _recvdDatasets($tag) 1
-        }
-    }
-
-    set _first [lindex [get] 0]
-
-    # Turn off cutplanes for all volumes
-    foreach axis {x y z} {
-        SendCmd "cutplane state 0 $axis"
-    }
-
-    # Reset the camera and other view parameters
-    InitSettings -opacity -light2side -isosurfaceshading \
-        -light \
-        -volume -outlinevisible -cutplanesvisible \
-        -xcutplanevisible -ycutplanevisible -zcutplanevisible \
-        -xcutplaneposition -ycutplaneposition -zcutplaneposition
-
-    # nothing to send -- activate the proper volume
-    if {"" != $_first} {
-        set axis [$_first hints updir]
-        if {"" != $axis} {
-            SendCmd "up $axis"
-        }
-        set location [$_first hints camera]
-        if { $location != "" } {
-            array set _view $location
-        }
-    }
-    set _settings(-qw)    $_view(-qw)
-    set _settings(-qx)    $_view(-qx)
-    set _settings(-qy)    $_view(-qy)
-    set _settings(-qz)    $_view(-qz)
-    set _settings(-xpan)  $_view(-xpan)
-    set _settings(-ypan)  $_view(-ypan)
-    set _settings(-zoom)  $_view(-zoom)
-
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    PanCamera
-    SendCmd "camera zoom $_view(-zoom)"
-
-    foreach dataobj [get] {
-        foreach cname [$dataobj components] {
-            NameTransferFunction $dataobj $cname
-        }
-        set _reset 0
-    }
-
-    # nothing to send -- activate the proper ivol
-    set _first [lindex [get] 0]
-    if {"" != $_first} {
-        set axis [$_first hints updir]
-        if {"" != $axis} {
-            SendCmd "up $axis"
-        }
-        set location [$_first hints camera]
-        if { $location != "" } {
-            array set _view $location
-        }
-        set cname [lindex [$_first components] 0]
-        set _activeTf [lindex $_dataset2style($_first-$cname) 0]
-    }
-
-    # sync the state of slicers
-    set vols [CurrentDatasets -cutplanes]
-    foreach axis {x y z} {
-        set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}]
-        SendCmd "cutplane position $pos $axis $vols"
-    }
-    SendCmd "volume data state $_settings(-volume)"
-    EventuallyRedrawLegend
-
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-cutplanes?
-#
-# Returns a list of volume server IDs for the current volume being
-# displayed.  This is normally a single ID, but it might be a list
-# of IDs if the current data object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::CurrentDatasets {{what -all}} {
-    return ""
-    if { $_first == "" } {
-        return
-    }
-    foreach tag [array names _serverDatasets *-*] {
-        if {[string match $_first-* $tag]} {
-            array set style {
-                -cutplanes 1
-            }
-            foreach {dataobj cname} [split $tag -] break
-            array set style [lindex [$dataobj components -style $cname] 0]
-            if {$what != "-cutplanes" || $style(-cutplanes)} {
-                lappend rlist $_serverDatasets($tag)
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            set _settings(-zoom) $_view(-zoom)
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            set _settings(-zoom) $_view(-zoom)
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            set q [ViewToQuaternion]
-            $_arcball quaternion $q
-            SendCmd "camera orient $q"
-            SendCmd "camera reset"
-            set _settings(-qw)    $_view(-qw)
-            set _settings(-qx)    $_view(-qx)
-            set _settings(-qy)    $_view(-qy)
-            set _settings(-qz)    $_view(-qz)
-            set _settings(-xpan)  $_view(-xpan)
-            set _settings(-ypan)  $_view(-ypan)
-            set _settings(-zoom)  $_view(-zoom)
-        }
-    }
-}
-
-itcl::body Rappture::FlowvisViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::Rotate {option x y} {
-    switch -- $option {
-        click {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        drag {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                QuaternionToView $q
-                set _settings(-qw) $_view(-qw)
-                set _settings(-qx) $_view(-qx)
-                set _settings(-qy) $_view(-qy)
-                set _settings(-qz) $_view(-qz)
-                SendCmd "camera orient $q"
-
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        release {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::Pan {option x y} {
-    # Experimental stuff
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $option == "set" } {
-        set x [expr $x / double($w)]
-        set y [expr $y / double($h)]
-        set _view(-xpan) [expr $_view(-xpan) + $x]
-        set _view(-ypan) [expr $_view(-ypan) + $y]
-        PanCamera
-        set _settings(-xpan) $_view(-xpan)
-        set _settings(-ypan) $_view(-ypan)
-        return
-    }
-    if { $option == "click" } {
-        set _click(x) $x
-        set _click(y) $y
-        $itk_component(view) configure -cursor hand1
-    }
-    if { $option == "drag" || $option == "release" } {
-        set dx [expr ($_click(x) - $x)/double($w)]
-        set dy [expr ($_click(y) - $y)/double($h)]
-        set _click(x) $x
-        set _click(y) $y
-        set _view(-xpan) [expr $_view(-xpan) - $dx]
-        set _view(-ypan) [expr $_view(-ypan) - $dy]
-        PanCamera
-        set _settings(-xpan) $_view(-xpan)
-        set _settings(-ypan) $_view(-ypan)
-    }
-    if { $option == "release" } {
-        $itk_component(view) configure -cursor ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::InitSettings { args } {
-    foreach arg $args {
-        AdjustSetting $arg
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: AdjustSetting <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::AdjustSetting {what {value ""}} {
-    if {![isconnected]} {
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            SendCmd "axis visible $_settings($what)"
-        }
-        "-background" {
-            set bgcolor [$itk_component(background) value]
-            array set fgcolors {
-                "black" "white"
-                "white" "black"
-                "grey"  "black"
-            }
-            configure -plotbackground $bgcolor \
-                -plotforeground $fgcolors($bgcolor)
-            if { $_first != "" } {
-                set comp [lindex [$_first components] 0]
-                set tag $_first-$comp
-                DrawLegend $tag
-            }
-        }
-        "-colormap" {
-            set color [$itk_component(colormap) value]
-            set _settings($what) $color
-            #ResetColormap $color
-        }
-        "-cutplanesvisible" {
-            set bool $_settings($what)
-            set datasets [CurrentDatasets -cutplanes]
-            set tag [lindex $datasets 0]
-            SendCmd "cutplane visible $bool $tag"
-        }
-        "-gridvisible" {
-            SendCmd "grid visible $_settings($what)"
-        }
-        "-isosurfaceshading" {
-            if { $_first != "" } {
-                set comp [lindex [$_first components] 0]
-                set tag $_first-$comp
-                set val $_settings($what)
-                # This flag isn't implemented in the server
-                #SendCmd "$tag configure -isosurface $val"
-            }
-        }
-        "-legendvisible" {
-            if { $_settings($what) } {
-                blt::table $itk_component(plotarea) \
-                    0,0 $itk_component(view) -fill both \
-                    1,0 $itk_component(legend) -fill x
-                blt::table configure $itk_component(plotarea) r1 -resize none
-            } else {
-                blt::table forget $itk_component(legend)
-            }
-        }
-        "-light" {
-            if { $_first != "" } {
-                set comp [lindex [$_first components] 0]
-                set tag $_first-$comp
-                set diffuse [expr {0.01*$_settings($what)}]
-                set ambient [expr {1.0 - $diffuse}]
-                set specularLevel 0.3
-                set specularExp 90.0
-                SendCmd "$tag configure -ambient $ambient -diffuse $diffuse -specularLevel $specularLevel -specularExp $specularExp"
-            }
-        }
-        "-light2side" {
-            if { $_first != "" } {
-                set comp [lindex [$_first components] 0]
-                set tag $_first-$comp
-                set val $_settings($what)
-                SendCmd "$tag configure -light2side $val"
-            }
-        }
-        "-opacity" {
-            if { $_first != "" } {
-                set comp [lindex [$_first components] 0]
-                set tag $_first-$comp
-                set opacity [expr { 0.01 * double($_settings($what)) }]
-                SendCmd "$tag configure -opacity $opacity"
-            }
-        }
-        "-outlinevisible" {
-            if { $_first != "" } {
-                set comp [lindex [$_first components] 0]
-                set tag $_first-$comp
-                SendCmd "$tag configure -outline $_settings($what)"
-            }
-        }
-        "-thickness" {
-            if { $_first != "" && $_activeTf != "" } {
-                set val $_settings($what)
-                # Scale values between 0.00001 and 0.01000
-                set sval [expr {0.0001*double($val)}]
-                set tf $_activeTf
-                set _settings($tf${what}) $sval
-                updateTransferFunctions
-            }
-        }
-        "-volume" {
-            if { $_first != "" } {
-                set comp [lindex [$_first components] 0]
-                set tag $_first-$comp
-                SendCmd "$tag configure -volume $_settings($what)"
-            }
-        }
-        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
-            set axis [string range $what 1 1]
-            set pos [expr $_settings($what) * 0.01]
-            # We only set cutplanes on the first dataset.
-            set datasets [CurrentDatasets -cutplanes]
-            set tag [lindex $datasets 0]
-            SendCmd "cutplane position $pos $axis $tag"
-        }
-        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
-            set axis [string range $what 1 1]
-            set bool $_settings($what)
-            # We only set cutplanes on the first dataset.
-            set datasets [CurrentDatasets -cutplanes]
-            set tag [lindex $datasets 0]
-            SendCmd "cutplane state $bool $axis $tag"
-            if { $bool } {
-                $itk_component(${axis}CutScale) configure -state normal \
-                    -troughcolor white
-            } else {
-                $itk_component(${axis}CutScale) configure -state disabled \
-                    -troughcolor grey82
-            }
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: FixLegend
-#
-# Used internally to update the legend area whenever it changes size
-# or when the field changes.  Asks the server to send a new legend
-# for the current field.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::FixLegend {} {
-    set _resizeLegendPending 0
-    set lineht [font metrics $itk_option(-font) -linespace]
-    set w [expr {$_width-20}]
-    set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
-
-    if { $_first == "" } {
-        return
-    }
-    set comp [lindex [$_first components] 0]
-    set tag $_first-$comp
-    #set _activeTf [lindex $_dataset2style($tag) 0]
-    if {$w > 0 && $h > 0 && "" != $_activeTf} {
-        #SendCmd "legend $_activeTf $w $h"
-        SendCmd "$tag legend $w $h"
-    }
-}
-
-#
-# NameTransferFunction --
-#
-# Creates a transfer function name based on the <style> settings in the
-# library run.xml file. This placeholder will be used later to create
-# and send the actual transfer function once the data info has been sent
-# to us by the render server. [We won't know the volume limits until the
-# server parses the 3D data and sends back the limits via ReceiveData.]
-#
-itcl::body Rappture::FlowvisViewer::NameTransferFunction { dataobj cname } {
-    array set style {
-        -color BCGYR
-        -levels 6
-        -opacity 0.5
-    }
-    array set style [lindex [$dataobj components -style $cname] 0]
-    set tf "$style(-color):$style(-levels)"
-    # Some tools erroneously set -opacity to 1 in style, so
-    # override the requested opacity for now
-    set style(-opacity) 0.5
-    set _settings(-opacity) [expr $style(-opacity) * 100]
-    set _dataset2style($dataobj-$cname) $tf
-    lappend _style2datasets($tf) $dataobj $cname
-    return $tf
-}
-
-#
-# ComputeTransferFunction --
-#
-# Computes and sends the transfer function to the render server.  It's
-# assumed that the volume data limits are known and that the global
-# transfer-functions slider values have been set up.  Both parts are
-# needed to compute the relative value (location) of the marker, and
-# the alpha map of the transfer function.
-#
-itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } {
-    array set style {
-        -color BCGYR
-        -levels 6
-        -opacity 0.5
-    }
-    set dataobj ""; set cname ""
-    foreach {dataobj cname} $_style2datasets($tf) break
-    if { $dataobj == "" } {
-        return 0
-    }
-    array set style [lindex [$dataobj components -style $cname] 0]
-    # Some tools erroneously set -opacity to 1 in style, so
-    # override the requested opacity for now
-    set style(-opacity) 0.5
-
-    # We have to parse the style attributes for a volume using this
-    # transfer-function *once*.  This sets up the initial isomarkers for the
-    # transfer function.  The user may add/delete markers, so we have to
-    # maintain a list of markers for each transfer-function.  We use the one
-    # of the volumes (the first in the list) using the transfer-function as a
-    # reference.
-
-    if { ![info exists _isomarkers($tf)] } {
-        # Have to defer creation of isomarkers until we have data limits
-        if { [info exists style(-markers)] &&
-             [llength $style(-markers)] > 0 } {
-            ParseMarkersOption $tf $style(-markers)
-        } else {
-            ParseLevelsOption $tf $style(-levels)
-        }
-    }
-    if { [info exists style(-nonuniformcolors)] } {
-        foreach { value color } $style(-nonuniformcolors) {
-            append cmap "$value [Color2RGB $color] "
-        }
-    } else {
-        set cmap [ColorsToColormap $style(-color)]
-    }
-
-    if { ![info exists _settings(-opacity)] } {
-        set _settings(-opacity) [expr $style(-opacity) * 100]
-    }
-
-    # Transfer function should be normalized with [0,1] range
-    # The volume shading opacity setting is used to scale opacity
-    # in the volume shader.
-    set max 1.0
-
-    set isovalues {}
-    foreach m $_isomarkers($tf) {
-        lappend isovalues [$m relval]
-    }
-    # Sort the isovalues
-    set isovalues [lsort -real $isovalues]
-
-    set tag $tf
-    if { ![info exists _settings($tag-thickness)]} {
-        set _settings($tag-thickness) 0.005
-    }
-    set delta $_settings($tag-thickness)
-
-    set first [lindex $isovalues 0]
-    set last [lindex $isovalues end]
-    set amap ""
-    if { $first == "" || $first != 0.0 } {
-        lappend amap 0.0 0.0
-    }
-    foreach x $isovalues {
-        set x1 [expr {$x-$delta-0.00001}]
-        set x2 [expr {$x-$delta}]
-        set x3 [expr {$x+$delta}]
-        set x4 [expr {$x+$delta+0.00001}]
-        if { $x1 < 0.0 } {
-            set x1 0.0
-        } elseif { $x1 > 1.0 } {
-            set x1 1.0
-        }
-        if { $x2 < 0.0 } {
-            set x2 0.0
-        } elseif { $x2 > 1.0 } {
-            set x2 1.0
-        }
-        if { $x3 < 0.0 } {
-            set x3 0.0
-        } elseif { $x3 > 1.0 } {
-            set x3 1.0
-        }
-        if { $x4 < 0.0 } {
-            set x4 0.0
-        } elseif { $x4 > 1.0 } {
-            set x4 1.0
-        }
-        # add spikes in the middle
-        lappend amap $x1 0.0
-        lappend amap $x2 $max
-        lappend amap $x3 $max
-        lappend amap $x4 0.0
-    }
-    if { $last == "" || $last != 1.0 } {
-        lappend amap 1.0 0.0
-    }
-    SendCmd "transfunc define $tf { $cmap } { $amap }"
-    return [SendCmd "$dataobj-$cname configure -transferfunction $tf"]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::FlowvisViewer::plotbackground {
-    if { [isconnected] } {
-        set color $itk_option(-plotbackground)
-        set rgb [Color2RGB $color]
-        SendCmd "screen bgcolor $rgb"
-        $itk_component(legend) configure -background $color
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::FlowvisViewer::plotforeground {
-    if { [isconnected] } {
-        set color $itk_option(-plotforeground)
-        set rgb [Color2RGB $color]
-        SendCmd "volume outline color $rgb"
-        SendCmd "grid axiscolor $rgb"
-        SendCmd "grid linecolor $rgb"
-        $itk_component(legend) itemconfigure text -fill $color
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotoutline
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::FlowvisViewer::plotoutline {
-    # Must check if we are connected because this routine is called from the
-    # class body when the -plotoutline itk_option is defined.  At that point
-    # the FlowvisViewer class constructor hasn't been called, so we can't
-    # start sending commands to visualization server.
-    if { [isconnected] } {
-        if {"" == $itk_option(-plotoutline)} {
-            SendCmd "volume outline state off"
-        } else {
-            SendCmd "volume outline state on"
-            SendCmd "volume outline color [Color2RGB $itk_option(-plotoutline)]"
-        }
-    }
-}
-
-#
-# The -levels option takes a single value that represents the number
-# of evenly distributed markers based on the current data range. Each
-# marker is a relative value from 0.0 to 1.0.
-#
-itcl::body Rappture::FlowvisViewer::ParseLevelsOption { tf levels } {
-    set c $itk_component(legend)
-    regsub -all "," $levels " " levels
-    if {[string is int $levels]} {
-        for {set i 1} { $i <= $levels } {incr i} {
-            set x [expr {double($i)/($levels+1)}]
-            set m [Rappture::IsoMarker \#auto $c $this $tf]
-            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-            $m relval $x
-            lappend _isomarkers($tf) $m
-        }
-    } else {
-        foreach x $levels {
-            set m [Rappture::IsoMarker \#auto $c $this $tf]
-            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-            $m relval $x
-            lappend _isomarkers($tf) $m
-        }
-    }
-}
-
-#
-# The -markers option takes a list of zero or more values (the values
-# may be separated either by spaces or commas) that have the following
-# format:
-#
-#   N%  Percent of current total data range.  Converted to
-#       to a relative value between 0.0 and 1.0.
-#   N   Absolute value of marker.  If the marker is outside of
-#       the current range, it will be displayed on the outer
-#       edge of the legends, but it range it represents will
-#       not be seen.
-#
-itcl::body Rappture::FlowvisViewer::ParseMarkersOption { tf markers } {
-    set c $itk_component(legend)
-    regsub -all "," $markers " " markers
-    foreach marker $markers {
-        set n [scan $marker "%g%s" value suffix]
-        if { $n == 2 && $suffix == "%" } {
-            # ${n}% : Set relative value.
-            set value [expr {$value * 0.01}]
-            set m [Rappture::IsoMarker \#auto $c $this $tf]
-            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-            $m relval $value
-            lappend _isomarkers($tf) $m
-        } else {
-            # ${n} : Set absolute value.
-            set m [Rappture::IsoMarker \#auto $c $this $tf]
-            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-            $m absval $value
-            lappend _isomarkers($tf) $m
-        }
-    }
-}
-
-itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} {
-    $_dispatcher event -after 100 !send_transfunc
-}
-
-itcl::body Rappture::FlowvisViewer::AddIsoMarker { x y } {
-    if { $_activeTf == "" } {
-        error "active transfer function isn't set"
-    }
-    set tf $_activeTf
-    set c $itk_component(legend)
-    set m [Rappture::IsoMarker \#auto $c $this $tf]
-    $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-    set w [winfo width $c]
-    $m relval [expr {double($x-10)/($w-20)}]
-    lappend _isomarkers($tf) $m
-    updateTransferFunctions
-    return 1
-}
-
-itcl::body Rappture::FlowvisViewer::removeDuplicateMarker { marker x } {
-    set tf [$marker transferfunc]
-    set bool 0
-    if { [info exists _isomarkers($tf)] } {
-        set list {}
-        set marker [namespace tail $marker]
-        foreach m $_isomarkers($tf) {
-            set sx [$m screenpos]
-            if { $m != $marker } {
-                if { $x >= ($sx-3) && $x <= ($sx+3) } {
-                    $marker relval [$m relval]
-                    itcl::delete object $m
-                    bell
-                    set bool 1
-                    continue
-                }
-            }
-            lappend list $m
-        }
-        set _isomarkers($tf) $list
-        updateTransferFunctions
-    }
-    return $bool
-}
-
-itcl::body Rappture::FlowvisViewer::overMarker { marker x } {
-    set tf [$marker transferfunc]
-    if { [info exists _isomarkers($tf)] } {
-        set marker [namespace tail $marker]
-        foreach m $_isomarkers($tf) {
-            set sx [$m screenpos]
-            if { $m != $marker } {
-                set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }]
-                $m activate $bool
-            }
-        }
-    }
-    return ""
-}
-
-itcl::body Rappture::FlowvisViewer::limits { tf } {
-    set _limits(vmin) 0.0
-    set _limits(vmax) 1.0
-    if { ![info exists _style2datasets($tf)] } {
-        puts stderr "no _style2datasets for tf=($tf)"
-        return [array get _limits]
-    }
-    set min ""; set max ""
-    foreach {dataobj comp} $_style2datasets($tf) {
-        set tag $dataobj-$comp
-        if { ![info exists _serverDatasets($tag)] } {
-            puts stderr "$tag not in _serverDatasets?"
-            continue
-        }
-        if { ![info exists _limits($tag-min)] } {
-            puts stderr "$tag no min?"
-            continue
-        }
-        if { $min == "" || $min > $_limits($tag-min) } {
-            set min $_limits($tag-min)
-        }
-        if { $max == "" || $max < $_limits($tag-max) } {
-            set max $_limits($tag-max)
-        }
-    }
-    if { $min != "" } {
-        set _limits(vmin) $min
-    }
-    if { $max != "" } {
-        set _limits(vmax) $max
-    }
-    return [array get _limits]
-}
-
-itcl::body Rappture::FlowvisViewer::BuildViewTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "View Settings" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    # General options
-    checkbutton $inner.axes \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.grid \
-        -text "Grid" \
-        -variable [itcl::scope _settings(-gridvisible)] \
-        -command [itcl::code $this AdjustSetting -gridvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.legend \
-        -text "Legend" \
-        -variable [itcl::scope _settings(-legendvisible)] \
-        -command [itcl::code $this AdjustSetting -legendvisible] \
-        -font "Arial 9"
-
-    label $inner.background_l -text "Background" -font "Arial 9"
-    itk_component add background {
-        Rappture::Combobox $inner.background -width 10 -editable no
-    }
-    $inner.background choices insert end \
-        "black" "black" \
-        "white" "white" \
-        "grey"  "grey"
-
-    $itk_component(background) value $_settings(-background)
-    bind $inner.background <<Value>> \
-        [itcl::code $this AdjustSetting -background]
-
-    # Dataset options
-    label $inner.flow_l -text "Flow" -font "Arial 9 bold"
-
-    checkbutton $inner.outline \
-        -text "Outline" \
-        -variable [itcl::scope _settings(-outlinevisible)] \
-        -command [itcl::code $this AdjustSetting -outlinevisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.volume \
-        -text "Volume" \
-        -variable [itcl::scope _settings(-volume)] \
-        -command [itcl::code $this AdjustSetting -volume] \
-        -font "Arial 9"
-
-    frame $inner.frame
-
-    blt::table $inner \
-        0,0 $inner.axes -cspan 2 -anchor w \
-        1,0 $inner.grid -cspan 2 -anchor w \
-        2,0 $inner.legend -cspan 2 -anchor w \
-        3,0 $inner.background_l -anchor e -pady 2 \
-        3,1 $inner.background -fill x \
-        4,0 $inner.flow_l -anchor w \
-        5,0 $inner.outline -cspan 2 -anchor w \
-        6,0 $inner.volume -cspan 2 -anchor w \
-
-    bind $inner <Map> [itcl::code $this GetFlowInfo $inner]
-
-    blt::table configure $inner c* r* -resize none
-    blt::table configure $inner c2 r7 -resize expand
-}
-
-itcl::body Rappture::FlowvisViewer::BuildVolumeTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Volume Settings" \
-        -icon [Rappture::icon volume-on]]
-    $inner configure -borderwidth 4
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    checkbutton $inner.vol -text "Show volume" -font $fg \
-        -text "Volume" \
-        -variable [itcl::scope _settings(-volume)] \
-        -command [itcl::code $this AdjustSetting -volume] \
-        -font "Arial 9"
-
-    label $inner.lighting_l \
-        -text "Lighting / Material Properties" \
-        -font "Arial 9 bold"
-
-    checkbutton $inner.isosurface -text "Isosurface shading" -font $fg \
-        -variable [itcl::scope _settings(-isosurfaceshading)] \
-        -command [itcl::code $this AdjustSetting -isosurfaceshading]
-
-    checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \
-        -variable [itcl::scope _settings(-light2side)] \
-        -command [itcl::code $this AdjustSetting -light2side]
-
-    label $inner.dim -text "Glow" -font $fg
-    ::scale $inner.light -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-light)] \
-        -width 10 \
-        -showvalue off -command [itcl::code $this AdjustSetting -light]
-    label $inner.bright -text "Surface" -font $fg
-
-    # Opacity
-    label $inner.opacity_l -text "Opacity" -font $fg
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-opacity)] \
-        -width 10 \
-        -showvalue off -command [itcl::code $this AdjustSetting -opacity]
-
-    label $inner.transferfunction_l \
-        -text "Transfer Function" -font "Arial 9 bold"
-
-    # Tooth thickness
-    label $inner.thin -text "Thin" -font $fg
-    ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \
-        -variable [itcl::scope _settings(-thickness)] \
-        -width 10 \
-        -showvalue off -command [itcl::code $this AdjustSetting -thickness]
-    label $inner.thick -text "Thick" -font $fg
-
-    # Colormap
-    label $inner.colormap_l -text "Colormap" -font $fg
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable no
-    }
-
-    $inner.colormap choices insert end [GetColormapList -includeNone]
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -colormap]
-    $itk_component(colormap) value "BCGYR"
-    set _settings(-colormap) "BCGYR"
-
-    blt::table $inner \
-        0,0 $inner.vol -cspan 4 -anchor w -pady 2 \
-        1,0 $inner.lighting_l -cspan 4 -anchor w -pady {10 2} \
-        2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \
-        3,0 $inner.dim -anchor e -pady 2 \
-        3,1 $inner.light -cspan 2 -pady 2 -fill x \
-        3,3 $inner.bright -anchor w -pady 2 \
-        4,0 $inner.opacity_l -anchor e -pady 2 \
-        4,1 $inner.opacity -cspan 3 -pady 2 -fill x \
-        5,0 $inner.thin -anchor e -pady 2 \
-        5,1 $inner.thickness -cspan 2 -pady 2 -fill x \
-        5,3 $inner.thick -anchor w -pady 2
-
-    blt::table configure $inner c0 c1 c3 r* -resize none
-    blt::table configure $inner r6 -resize expand
-}
-
-itcl::body Rappture::FlowvisViewer::BuildCutplanesTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Cutplane Settings" \
-        -icon [Rappture::icon cutbutton]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Show Cutplanes" \
-        -variable [itcl::scope _settings(-cutplanesvisible)] \
-        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
-        -font "Arial 9"
-
-    # X-value slicer...
-    itk_component add xCutButton {
-        Rappture::PushButton $inner.xbutton \
-            -onimage [Rappture::icon x-cutplane] \
-            -offimage [Rappture::icon x-cutplane] \
-            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
-            -variable [itcl::scope _settings(-xcutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(xCutButton) \
-        "Toggle the X cut plane on/off"
-    $itk_component(xCutButton) select
-
-    itk_component add xCutScale {
-        ::scale $inner.xval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue off \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move x] \
-            -variable [itcl::scope _settings(-xcutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(xCutScale) set 50
-    $itk_component(xCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(xCutScale) \
-        "@[itcl::code $this SlicerTip x]"
-
-    # Y-value slicer...
-    itk_component add yCutButton {
-        Rappture::PushButton $inner.ybutton \
-            -onimage [Rappture::icon y-cutplane] \
-            -offimage [Rappture::icon y-cutplane] \
-            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
-            -variable [itcl::scope _settings(-ycutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(yCutButton) \
-        "Toggle the Y cut plane on/off"
-    $itk_component(yCutButton) select
-
-    itk_component add yCutScale {
-        ::scale $inner.yval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue off \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move y] \
-            -variable [itcl::scope _settings(-ycutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    Rappture::Tooltip::for $itk_component(yCutScale) \
-        "@[itcl::code $this SlicerTip y]"
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(yCutScale) set 50
-    $itk_component(yCutScale) configure -state disabled
-
-    # Z-value slicer...
-    itk_component add zCutButton {
-        Rappture::PushButton $inner.zbutton \
-            -onimage [Rappture::icon z-cutplane] \
-            -offimage [Rappture::icon z-cutplane] \
-            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
-            -variable [itcl::scope _settings(-zcutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(zCutButton) \
-        "Toggle the Z cut plane on/off"
-    $itk_component(zCutButton) select
-
-    itk_component add zCutScale {
-        ::scale $inner.zval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue off \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move z] \
-            -variable [itcl::scope _settings(-zcutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    $itk_component(zCutScale) set 50
-    $itk_component(zCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(zCutScale) \
-        "@[itcl::code $this SlicerTip z]"
-
-    blt::table $inner \
-        0,1 $inner.visible -anchor w -pady 2 -cspan 4 \
-        1,1 $itk_component(xCutScale) \
-        1,2 $itk_component(yCutScale) \
-        1,3 $itk_component(zCutScale) \
-        2,1 $itk_component(xCutButton) \
-        2,2 $itk_component(yCutButton) \
-        2,3 $itk_component(zCutButton)
-
-    blt::table configure $inner r0 r1 r2 c* -resize none
-    blt::table configure $inner r3 c4 -resize expand
-    blt::table configure $inner c0 -width 2
-    blt::table configure $inner c1 c2 c3 -padx 2
-}
-
-itcl::body Rappture::FlowvisViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set row 1
-    set labels { qw qx qy qz xpan ypan zoom }
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _settings(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-itcl::body Rappture::FlowvisViewer::GetFlowInfo { w } {
-    set flowobj ""
-    foreach key [array names _dataset2flow] {
-        set flowobj $_dataset2flow($key)
-        break
-    }
-    if { $flowobj == "" } {
-        return
-    }
-    if { [winfo exists $w.frame] } {
-        destroy $w.frame
-    }
-    set inner [frame $w.frame]
-    blt::table $w \
-        7,0 $inner -fill both -cspan 2 -anchor nw
-    array set hints [$flowobj hints]
-    checkbutton $inner.showstreams -text "Streams Plane" \
-        -variable [itcl::scope _settings(-streams)] \
-        -command  [itcl::code $this streams $key $hints(name)]  \
-        -font "Arial 9"
-    Rappture::Tooltip::for $inner.showstreams $hints(description)
-
-    checkbutton $inner.showarrows -text "Arrows" \
-        -variable [itcl::scope _settings(-arrows)] \
-        -command  [itcl::code $this arrows $key $hints(name)]  \
-        -font "Arial 9"
-
-    label $inner.particles -text "Particles" -font "Arial 9 bold"
-    label $inner.boxes -text "Boxes" -font "Arial 9 bold"
-
-    blt::table $inner \
-        1,0 $inner.showstreams  -anchor w \
-        2,0 $inner.showarrows  -anchor w
-    blt::table configure $inner c0 c1 -resize none
-    blt::table configure $inner c2 -resize expand
-
-    set row 3
-    set particles [$flowobj particles]
-    if { [llength $particles] > 0 } {
-        blt::table $inner $row,0 $inner.particles  -anchor w
-        incr row
-    }
-    foreach part $particles {
-        array unset info
-        array set info $part
-        set name $info(name)
-        if { ![info exists _settings(-particles-$name)] } {
-            set _settings(-particles-$name) $info(hide)
-        }
-        checkbutton $inner.part$row -text $info(label) \
-            -variable [itcl::scope _settings(-particles-$name)] \
-            -onvalue 0 -offvalue 1 \
-            -command [itcl::code $this particles $key $name] \
-            -font "Arial 9"
-        Rappture::Tooltip::for $inner.part$row $info(description)
-        blt::table $inner $row,0 $inner.part$row -anchor w
-        if { !$_settings(-particles-$name) } {
-            $inner.part$row select
-        }
-        incr row
-    }
-    set boxes [$flowobj boxes]
-    if { [llength $boxes] > 0 } {
-        blt::table $inner $row,0 $inner.boxes  -anchor w
-        incr row
-    }
-    foreach box $boxes {
-        array unset info
-        array set info $box
-        set name $info(name)
-        if { ![info exists _settings(-box-$name)] } {
-            set _settings(-box-$name) $info(hide)
-        }
-        checkbutton $inner.box$row -text $info(label) \
-            -variable [itcl::scope _settings(-box-$name)] \
-            -onvalue 0 -offvalue 1 \
-            -command [itcl::code $this box $key $name] \
-            -font "Arial 9"
-        Rappture::Tooltip::for $inner.box$row $info(description)
-        blt::table $inner $row,0 $inner.box$row -anchor w
-        if { !$_settings(-box-$name) } {
-            $inner.box$row select
-        }
-        incr row
-    }
-    blt::table configure $inner r* -resize none
-    blt::table configure $inner r$row -resize expand
-    blt::table configure $inner c3 -resize expand
-    event generate [winfo parent [winfo parent $w]] <Configure>
-}
-
-itcl::body Rappture::FlowvisViewer::particles { tag name } {
-    set bool $_settings(-particles-$name)
-    SendCmd "$tag particles configure {$name} -hide $bool"
-}
-
-itcl::body Rappture::FlowvisViewer::box { tag name } {
-    set bool $_settings(-box-$name)
-    SendCmd "$tag box configure {$name} -hide $bool"
-}
-
-itcl::body Rappture::FlowvisViewer::streams { tag name } {
-    set bool $_settings(-streams)
-    SendCmd "$tag configure -slice $bool"
-}
-
-itcl::body Rappture::FlowvisViewer::arrows { tag name } {
-    set bool $_settings(-arrows)
-    SendCmd "$tag configure -arrows $bool"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Slice move x|y|z <newval>
-#
-# Called automatically when the user drags the slider to move the
-# cut plane that slices 3D data.  Gets the current value from the
-# slider and moves the cut plane to the appropriate point in the
-# data set.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::Slice {option args} {
-    switch -- $option {
-        move {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Slice move x|y|z newval\""
-            }
-            set axis [lindex $args 0]
-            set newval [lindex $args 1]
-
-            set newpos [expr {0.01*$newval}]
-            set datasets [CurrentDatasets -cutplanes]
-            set tag [lindex $datasets 0]
-            SendCmd "cutplane position $newpos $axis $tag"
-        }
-        default {
-            error "bad option \"$option\": should be axis, move, or volume"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: SlicerTip <axis>
-#
-# Used internally to generate a tooltip for the x/y/z slicer controls.
-# Returns a message that includes the current slicer value.
-# ----------------------------------------------------------------------
-itcl::body Rappture::FlowvisViewer::SlicerTip {axis} {
-    set val [$itk_component(${axis}CutScale) get]
-    return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
-}
-
-itcl::body Rappture::FlowvisViewer::DoResize {} {
-    $_arcball resize $_width $_height
-    SendCmd "screen size $_width $_height"
-    set _resizePending 0
-}
-
-itcl::body Rappture::FlowvisViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        $_dispatcher event -after 200 !resize
-        set _resizePending 1
-    }
-}
-
-itcl::body Rappture::FlowvisViewer::EventuallyRedrawLegend {} {
-    if { !$_resizeLegendPending } {
-        $_dispatcher event -after 100 !legend
-        set _resizeLegendPending 1
-    }
-}
-
-itcl::body Rappture::FlowvisViewer::EventuallyGoto { nSteps } {
-    set _flow(goto) $nSteps
-    if { !$_gotoPending } {
-        $_dispatcher event -after 1000 !goto
-        set _gotoPending 1
-    }
-}
-
-#  camera --
-#
-itcl::body Rappture::FlowvisViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_settings($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                set _settings($what) $_view($what)
-                return
-            }
-            switch -- $what {
-                "-xpan" - "-ypan" {
-                    set _view($what) $_settings($what)
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set _view($what) $_settings($what)
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    SendCmd "camera orient $q"
-                }
-                "-zoom" {
-                    set _view($what) $_settings($what)
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::FlowvisViewer::SendFlowCmd { dataobj comp nbytes numComponents } {
-    set tag "$dataobj-$comp"
-    if { ![info exists _dataset2flow($tag)] } {
-        SendCmd "flow add $tag"
-        SendCmd "$tag data follows $nbytes $numComponents"
-        return 0
-    }
-    set flowobj $_dataset2flow($tag)
-    if { $flowobj == "" } {
-        puts stderr "no flowobj"
-        return -1
-    }
-    SendCmd "if {\[flow exists $tag\]} {flow delete $tag}"
-    array set info [$flowobj hints]
-    set _settings(-volume) $info(volume)
-    set _settings(-outlinevisible) $info(outline)
-    set _settings(-arrows) $info(arrows)
-    set _settings(-duration) $info(duration)
-    $itk_component(speed) value $info(speed)
-    set cmd {}
-    append cmd "flow add $tag"
-    append cmd " -position $info(position)"
-    append cmd " -axis $info(axis)"
-    append cmd " -volume $info(volume)"
-    append cmd " -outline $info(outline)"
-    append cmd " -slice $info(streams)"
-    append cmd " -arrows $info(arrows)"
-    SendCmd $cmd
-    foreach part [$flowobj particles] {
-        set cmd {}
-        array unset info
-        array set info $part
-        set color [Color2RGB $info(color)]
-        append cmd "$tag particles add $info(name)"
-        append cmd " -position $info(position)"
-        append cmd " -hide $info(hide)"
-        append cmd " -axis $info(axis)"
-        append cmd " -color {$color}"
-        append cmd " -size $info(size)"
-        SendCmd $cmd
-    }
-    foreach box [$flowobj boxes] {
-        set cmd {}
-        array unset info
-        set info(corner1) ""
-        set info(corner2) ""
-        array set info $box
-        if { $info(corner1) == "" || $info(corner2) == "" } {
-            continue
-        }
-        set color [Color2RGB $info(color)]
-        append cmd "$tag box add $info(name)"
-        append cmd " -color {$color}"
-        append cmd " -hide $info(hide)"
-        append cmd " -linewidth $info(linewidth) "
-        append cmd " -corner1 {$info(corner1)} "
-        append cmd " -corner2 {$info(corner2)}"
-        SendCmd $cmd
-    }
-    SendCmd "$tag data follows $nbytes $numComponents"
-    return 0
-}
-
-#
-# flow --
-#
-# Called when the user clicks on the stop or play buttons
-# for flow visualization.
-#
-#        $this flow play
-#        $this flow stop
-#        $this flow toggle
-#        $this flow reset
-#        $this flow pause
-#        $this flow next
-#
-itcl::body Rappture::FlowvisViewer::flow { args } {
-    set option [lindex $args 0]
-    switch -- $option {
-        "goto2" {
-            puts stderr "actually sending \"flow goto $_flow(goto)\""
-            SendCmd "flow goto $_flow(goto)"
-            set _gotoPending 0
-        }
-        "goto" {
-            puts stderr "flow goto to $_settings(-currenttime)"
-            # Figure out how many steps to the current time based upon
-            # the speed and duration.
-            set current $_settings(-currenttime)
-            set speed [$itk_component(speed) value]
-            set time [str2millisecs $_settings(-duration)]
-            $itk_component(dial) configure -max $time
-            set delay [expr int(round(500.0/$speed))]
-            set timePerStep [expr {double($time) / $delay}]
-            set nSteps [expr {int(ceil($current/$timePerStep))}]
-            EventuallyGoto $nSteps
-        }
-        "speed" {
-            set speed [$itk_component(speed) value]
-            set _flow(delay) [expr int(round(500.0/$speed))]
-        }
-        "duration" {
-            set max [str2millisecs $_settings(-duration)]
-            if { $max < 0 } {
-                bell
-                return
-            }
-            set _flow(duration) $max
-            set _settings(-duration) [millisecs2str $max]
-            $itk_component(dial) configure -max $max
-        }
-        "off" {
-            set _flow(state) 0
-            $_dispatcher cancel !play
-            $itk_component(play) deselect
-        }
-        "on" {
-            flow speed
-            flow duration
-            set _flow(state) 1
-            set _settings(-currenttime) 0
-            $itk_component(play) select
-        }
-        "stop" {
-            if { $_flow(state) } {
-                flow off
-                flow reset
-            }
-        }
-        "pause" {
-            if { $_flow(state) } {
-                flow off
-            }
-        }
-        "play" {
-            # If the flow is currently off, then restart it.
-            if { !$_flow(state) } {
-                flow on
-                # If we're at the end of the flow, reset the flow.
-                set _settings(-currenttime) \
-                    [expr {$_settings(-currenttime) + $_flow(delay)}]
-                if { $_settings(-currenttime) >= $_flow(duration) } {
-                    set _settings(-step) 1
-                    SendCmd "flow reset"
-                }
-                flow next
-            }
-        }
-        "toggle" {
-            if { $_settings(-play) } {
-                flow play
-            } else {
-                flow pause
-            }
-        }
-        "reset" {
-            set _settings(-currenttime) 0
-            SendCmd "flow reset"
-        }
-        "next" {
-            if { ![winfo viewable $itk_component(view)] } {
-                flow stop
-                return
-            }
-            set _settings(-currenttime) \
-                [expr {$_settings(-currenttime) + $_flow(delay)}]
-            if { $_settings(-currenttime) >= $_flow(duration) } {
-                if { !$_settings(-loop) } {
-                    flow off
-                    return
-                }
-                flow reset
-            } else {
-                SendCmd "flow next"
-            }
-            $_dispatcher event -after $_flow(delay) !play
-        }
-        default {
-            error "bad option \"$option\": should be play, stop, toggle, or reset."
-        }
-    }
-}
-
-itcl::body Rappture::FlowvisViewer::WaitIcon { option widget } {
-    switch -- $option {
-        "start" {
-            $_dispatcher dispatch $this !waiticon \
-                "[itcl::code $this WaitIcon "next" $widget] ; list"
-            set _icon 0
-            $widget configure -image [Rappture::icon bigroller${_icon}]
-            $_dispatcher event -after 100 !waiticon
-        }
-        "next" {
-            incr _icon
-            if { $_icon >= 8 } {
-                set _icon 0
-            }
-            $widget configure -image [Rappture::icon bigroller${_icon}]
-            $_dispatcher event -after 100 !waiticon
-        }
-        "stop" {
-            $_dispatcher cancel !waiticon
-        }
-    }
-}
-
-itcl::body Rappture::FlowvisViewer::GetVtkData { args } {
-    # FIXME: We can only put one component of one dataset in a single
-    # VTK file.  To download all components/results, we would need
-    # to put them in an archive (e.g. zip or tar file)
-    if { $_first != "" } {
-        set cname [lindex [$_first components] 0]
-        set bytes [$_first vtkdata $cname]
-        return [list .vtk $bytes]
-    }
-    puts stderr "Failed to get vtkdata"
-    return ""
-}
-
-itcl::body Rappture::FlowvisViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::FlowvisViewer::GetPngImage { widget width height } {
-    set token "print[incr _nextToken]"
-    set var ::Rappture::FlowvisViewer::_hardcopy($this-$token)
-    set $var ""
-
-    # Setup an automatic timeout procedure.
-    $_dispatcher dispatch $this !pngtimeout "set $var {} ; list"
-
-    set popup .flowvisviewerprint
-    if {![winfo exists $popup]} {
-        Rappture::Balloon $popup -title "Generating file..."
-        set inner [$popup component inner]
-        label $inner.title -text "Generating hardcopy." -font "Arial 10 bold"
-        label $inner.please -text "This may take a minute." -font "Arial 10"
-        label $inner.icon -image [Rappture::icon bigroller0]
-        button $inner.cancel -text "Cancel" -font "Arial 10 bold" \
-            -command [list set $var ""]
-        blt::table $inner \
-            0,0 $inner.title -cspan 2 \
-            1,0 $inner.please -anchor w \
-            1,1 $inner.icon -anchor e  \
-            2,0 $inner.cancel -cspan 2
-        blt::table configure $inner r0 -pady 4
-        blt::table configure $inner r2 -pady 4
-        bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
-    } else {
-        set inner [$popup component inner]
-    }
-
-    $_dispatcher event -after 60000 !pngtimeout
-    WaitIcon start $inner.icon
-    grab set $inner
-    focus $inner.cancel
-
-    SendCmd "print $token $width $height"
-
-    $popup activate $widget below
-    update idletasks
-    update
-    # We wait here for either
-    #  1) the png to be delivered or
-    #  2) timeout or
-    #  3) user cancels the operation.
-    tkwait variable $var
-
-    # Clean up.
-    $_dispatcher cancel !pngtimeout
-    WaitIcon stop $inner.icon
-    grab release $inner
-    $popup deactivate
-    update
-
-    if { $_hardcopy($this-$token) != "" } {
-        return [list .png $_hardcopy($this-$token)]
-    }
-    return ""
-}
-
-itcl::body Rappture::FlowvisViewer::GetMovie { widget w h } {
-    set token "movie[incr _nextToken]"
-    set var ::Rappture::FlowvisViewer::_hardcopy($this-$token)
-    set $var ""
-
-    # Setup an automatic timeout procedure.
-    $_dispatcher dispatch $this !movietimeout "set $var {} ; list"
-    set popup .flowvisviewermovie
-    if {![winfo exists $popup]} {
-        Rappture::Balloon $popup -title "Generating movie..."
-        set inner [$popup component inner]
-        label $inner.title -text "Generating movie for download" \
-                -font "Arial 10 bold"
-        label $inner.please -text "This may take a few minutes." \
-                -font "Arial 10"
-        label $inner.icon -image [Rappture::icon bigroller0]
-        button $inner.cancel -text "Cancel" -font "Arial 10 bold" \
-            -command [list set $var ""]
-        blt::table $inner \
-            0,0 $inner.title -cspan 2 \
-            1,0 $inner.please -anchor w \
-            1,1 $inner.icon -anchor e  \
-            2,0 $inner.cancel -cspan 2
-        blt::table configure $inner r0 -pady 4
-        blt::table configure $inner r2 -pady 4
-        bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
-    } else {
-        set inner [$popup component inner]
-    }
-    update
-    # Timeout is set to 10 minutes.
-    $_dispatcher event -after 600000 !movietimeout
-    WaitIcon start $inner.icon
-    grab set $inner
-    focus $inner.cancel
-
-    flow duration
-    flow speed
-    set nframes [expr round($_flow(duration) / $_flow(delay))]
-    set framerate [expr 1000.0 / $_flow(delay)]
-
-    # These are specific to MPEG1 video generation
-    set framerate 25.0
-    set bitrate 6.0e+6
-
-    set start [clock seconds]
-    SendCmd "flow video $token -width $w -height $h -numframes $nframes "
-
-    $popup activate $widget below
-    update idletasks
-    update
-    # We wait here until
-    #  1. the movie is delivered or
-    #  2. we've timed out or
-    #  3. the user has canceled the operation.b
-    tkwait variable $var
-
-    puts stderr "Video generated in [expr [clock seconds] - $start] seconds."
-
-    # Clean up.
-    $_dispatcher cancel !movietimeout
-    WaitIcon stop $inner.icon
-    grab release $inner
-    $popup deactivate
-    destroy $popup
-    update
-
-    # This will both cancel the movie generation (if it hasn't already
-    # completed) and reset the flow.
-    SendCmd "flow reset"
-    if { $_hardcopy($this-$token) != "" } {
-        return [list .mpg $_hardcopy($this-$token)]
-    }
-    return ""
-}
-
-itcl::body Rappture::FlowvisViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    set res "640x480"
-    radiobutton $inner.movie_std -text "Movie (standard $res)" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -value $res
-    Rappture::Tooltip::for $inner.movie_std \
-        "Save as movie file."
-
-    set res "1024x768"
-    radiobutton $inner.movie_high -text "Movie (high quality $res)" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -value $res
-    Rappture::Tooltip::for $inner.movie_high \
-        "Save as movie file."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        3,0 $inner.movie_std -anchor w -cspan 2 -padx { 4 0 } \
-        4,0 $inner.movie_high -anchor w -cspan 2 -padx { 4 0 } \
-        6,1 $inner.cancel -width .9i -fill y \
-        6,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r5 -height 4
-    blt::table configure $inner r6 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::FlowvisViewer::str2millisecs { value } {
-    set parts [split $value :]
-    set secs 0
-    set mins 0
-    if { [llength $parts] == 1 } {
-        scan [lindex $parts 0] "%d" secs
-    } else {
-        scan [lindex $parts 1] "%d" secs
-        scan [lindex $parts 0] "%d" mins
-    }
-    set ms [expr {(($mins * 60) + $secs) * 1000.0}]
-    if { $ms > 600000.0 } {
-        set ms 600000.0
-    }
-    if { $ms == 0.0 } {
-        set ms 60000.0
-    }
-    return $ms
-}
-
-itcl::body Rappture::FlowvisViewer::millisecs2str { value } {
-    set min [expr floor($value / 60000.0)]
-    set sec [expr ($value - ($min*60000.0)) / 1000.0]
-    return [format %02d:%02d [expr round($min)] [expr round($sec)]]
-}
-
-itcl::body Rappture::FlowvisViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-    set _settings(-xpan) $_view(-xpan)
-    set _settings(-ypan) $_view(-ypan)
-    set _settings(-zoom) $_view(-zoom)
-}
-
-#
-# BuildVolumeComponents --
-#
-# This is called from the "scale" method which is called when a new
-# dataset is added or deleted.  It repopulates the dropdown menu of
-# volume component names.  It sets the current component to the first
-# component in the list (of components found).  Finally, if there is
-# only one component, don't display the label or the combobox in the
-# volume settings tab.
-#
-itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} {
-    $itk_component(volcomponents) choices delete 0 end
-    foreach name $_componentsList {
-        $itk_component(volcomponents) choices insert end $name $name
-    }
-    set _current [lindex $_componentsList 0]
-    $itk_component(volcomponents) value $_current
-}
-
-#
-# GetDatasetsWithComponents --
-#
-# Returns a list of all the datasets (known by the combination of their
-# data object and component name) that match the given component name.
-# For example, this is used where we want to change the settings of
-# volumes that have the current component.
-#
-itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } {
-    if { ![info exists _volcomponents($cname)] } {
-        return ""
-    }
-    set list ""
-    foreach tag $_volcomponents($cname) {
-        if { ![info exists _serverDatasets($tag)] } {
-            continue
-        }
-        lappend list $tag
-    }
-    return $list
-}
Index: trunk/gui/scripts/gauge.tcl
===================================================================
--- trunk/gui/scripts/gauge.tcl	(revision 6716)
+++ trunk/gui/scripts/gauge.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: gauge - compact readout for real values
@@ -10,16 +9,11 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
 package require BLT
 
-option add *Gauge.sampleWidth 30 widgetDefault
-option add *Gauge.sampleHeight 20 widgetDefault
-option add *Gauge.borderWidth 2 widgetDefault
-option add *Gauge.relief sunken widgetDefault
+option add *Gauge.width 30 widgetDefault
+option add *Gauge.height 20 widgetDefault
 option add *Gauge.valuePosition "right" widgetDefault
 option add *Gauge.textBackground #cccccc widgetDefault
@@ -30,7 +24,5 @@
 
     itk_option define -editable editable Editable ""
-    itk_option define -state state State "normal"
     itk_option define -spectrum spectrum Spectrum ""
-    itk_option define -type type Type "real"
     itk_option define -units units Units ""
     itk_option define -minvalue minValue MinValue ""
@@ -39,17 +31,10 @@
     itk_option define -valueposition valuePosition ValuePosition ""
     itk_option define -image image Image ""
-    itk_option define -samplewidth sampleWidth SampleWidth 0
-    itk_option define -sampleheight sampleHeight SampleHeight 0
-    itk_option define -log log Log ""
-    itk_option define -varname varname Varname ""
-    itk_option define -label label Label ""
-    itk_option define -validatecommand validateCommand ValidateCommand ""
-    itk_option define -uq uq Uq no
+    itk_option define -width width Width 0
+    itk_option define -height height Height 0
 
     constructor {args} { # defined below }
 
     public method value {args}
-    public method edit {option}
-    public method bump {delta}
 
     protected method _redraw {}
@@ -58,15 +43,6 @@
     protected method _editor {option args}
     protected method _presets {option}
-    protected method _layout {}
-    protected method _log {event args}
-    protected method _change_param_type {choice}
-    protected method _pop_uq {win}
-    protected method _pop_uq_deactivate {}
-
-    private variable _value 0;    # value for this widget
-    private variable _mode exact; # current mode
-    private variable _pde "";     # ProbDistEditor
-    private variable _val "";     # value choice combobox
-    private variable uq no
+
+    private variable _value 0  ;# value for this widget
 
     blt::bitmap define GaugeArrow {
@@ -77,5 +53,5 @@
     }
 }
-
+                                                                                
 itk::usual Gauge {
     keep -cursor -font -foreground -background
@@ -87,47 +63,21 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Gauge::constructor {args} {
-    # puts "GAUGE CONS: $args"
-    array set attrs $args
-
-    itk_option remove hull.borderwidth hull.relief
-    component hull configure -borderwidth 0
-
     itk_component add icon {
-        canvas $itk_interior.icon -width 1 -height 1 \
-            -borderwidth 0 -highlightthickness 0
+        canvas $itk_interior.icon -borderwidth 0 -highlightthickness 0
     } {
         usual
         ignore -highlightthickness -highlightbackground -highlightcolor
-        ignore -borderwidth -relief
-    }
+    }
+    pack $itk_component(icon) -side left
     bind $itk_component(icon) <Configure> [itcl::code $this _redraw]
-
-    if {[info exists attrs(-uq)]} {
-        set uq $attrs(-uq)
-        if {[string is true $uq]} {
-            set uq 1
-            itk_component add uq {
-                button $itk_interior.uq -image [Rappture::icon UQ] \
-                    -command [itcl::code $this _pop_uq $itk_interior]
-            }
-            pack $itk_component(uq) -side right -padx 10
-        } else {
-            set uq 0
-        }
-    } else {
-        set uq 0
-    }
 
     itk_component add -protected vframe {
         frame $itk_interior.vframe
+    }
+
+    itk_component add value {
+        label $itk_component(vframe).value -borderwidth 1 -width 7 \
+            -textvariable [itcl::scope _value]
     } {
-        keep -borderwidth -relief
-    }
-
-    itk_component add value {
-        label $itk_component(vframe).value -width 20 \
-            -borderwidth 1 -relief flat -textvariable [itcl::scope _value]
-    } {
-        keep -font
         rename -background -textbackground textBackground Background
     }
@@ -136,23 +86,4 @@
     bind $itk_component(value) <Enter> [itcl::code $this _hilite value on]
     bind $itk_component(value) <Leave> [itcl::code $this _hilite value off]
-
-    bind $itk_component(value) <<Cut>> [itcl::code $this edit cut]
-    bind $itk_component(value) <<Copy>> [itcl::code $this edit copy]
-    bind $itk_component(value) <<Paste>> [itcl::code $this edit paste]
-
-    itk_component add emenu {
-        menu $itk_component(value).menu -tearoff 0
-    } {
-        usual
-        ignore -tearoff
-    }
-    $itk_component(emenu) add command -label "Cut" -accelerator "^X" \
-        -command [list event generate $itk_component(value) <<Cut>>]
-    $itk_component(emenu) add command -label "Copy" -accelerator "^C" \
-        -command [list event generate $itk_component(value) <<Copy>>]
-    $itk_component(emenu) add command -label "Paste" -accelerator "^V" \
-        -command [list event generate $itk_component(value) <<Paste>>]
-    bind $itk_component(value) <<PopupMenu>> \
-        [itcl::code $this _editor menu %X %Y]
 
     itk_component add editor {
@@ -165,37 +96,11 @@
         [itcl::code $this _editor popup]
 
-
-    itk_component add spinner {
-        frame $itk_component(vframe).spinner
-    }
-
-    itk_component add spinup {
-        button $itk_component(spinner).up -image [Rappture::icon intplus] \
-            -borderwidth 1 -relief raised -highlightthickness 0 \
-            -command [itcl::code $this bump 1]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-        rename -background -buttonbackground buttonBackground Background
-    }
-    pack $itk_component(spinup) -side left -expand yes -fill both
-
-    itk_component add spindn {
-        button $itk_component(spinner).down -image [Rappture::icon intminus] \
-            -borderwidth 1 -relief raised -highlightthickness 0 \
-            -command [itcl::code $this bump -1]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-        rename -background -buttonbackground buttonBackground Background
-    }
-    pack $itk_component(spindn) -side right -expand yes -fill both
-
     itk_component add presets {
         button $itk_component(vframe).psbtn -bitmap GaugeArrow \
-            -borderwidth 1 -highlightthickness 0 -relief raised
+            -borderwidth 1 -highlightthickness 0 -relief flat
     } {
         usual
         ignore -borderwidth -relief -highlightthickness
+        rename -background -textbackground textBackground Background
     }
 
@@ -228,135 +133,54 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Gauge::value {args} {
-    #puts "Gauge value: $args"
-
-    # Query.  Just return the current value.
-    if {[llength $args] == 0} {
-        return $_value
-    }
-
+    set onlycheck 0
     set i [lsearch -exact $args -check]
     if {$i >= 0} {
         set onlycheck 1
         set args [lreplace $args $i $i]
-    } else {
-        set onlycheck 0
-    }
-
-    if {[llength $args] != 1} {
+    }
+
+    if {[llength $args] == 1} {
+        #
+        # If this gauge has -units, try to convert the incoming
+        # value to that system of units.  Also, make sure that
+        # the value is bound by any min/max value constraints.
+        #
+        set newval [lindex $args 0]
+        if {$itk_option(-units) != ""} {
+            set units $itk_option(-units)
+            set newval [Rappture::Units::convert $newval -context $units]
+            set nv [Rappture::Units::convert $newval \
+                -context $units -to $units -units off]
+
+            if {"" != $itk_option(-minvalue)} {
+                set minv [Rappture::Units::convert $itk_option(-minvalue) \
+                    -context $units -to $units -units off]
+                if {$nv < $minv} {
+                    error "minimum value allowed here is $itk_option(-minvalue)"
+                }
+            }
+
+            if {"" != $itk_option(-maxvalue)} {
+                set maxv [Rappture::Units::convert $itk_option(-maxvalue) \
+                    -context $units -to $units -units off]
+                if {$nv > $maxv} {
+                    error "maximum value allowed here is $itk_option(-maxvalue)"
+                }
+            }
+        } elseif {![string is double -strict $newval]} {
+            error "Should be a real number"
+        }
+
+        if {$onlycheck} {
+            return
+        }
+        set _value $newval
+        _redraw
+        event generate $itk_component(hull) <<Value>>
+
+    } elseif {[llength $args] != 0} {
         error "wrong # args: should be \"value ?-check? ?newval?\""
     }
-
-    set newval [Rappture::Units::mcheck_range [lindex $args 0] \
-    $itk_option(-minvalue) $itk_option(-maxvalue) $itk_option(-units)]
-
-    set newmode [lindex $newval 0]
-    switch -- $newmode {
-        uniform -
-        gaussian {
-            set _mode $newmode
-        }
-        exact -
-        default {
-            set _mode exact
-        }
-    }
-
-    switch -- $itk_option(-type) {
-        integer {
-            if { [scan $newval "%g" value] != 1 || int($newval) != $value } {
-                error "bad value \"$newval\": should be an integer value"
-            }
-        }
-    }
-
-    #
-    # If there's a -validatecommand option, then invoke the code
-    # now to check the new value.
-    #
-    if {[string length $itk_option(-validatecommand)] > 0} {
-        set cmd "uplevel #0 [list $itk_option(-validatecommand) [list $newval]]"
-        set result [eval $cmd]
-    }
-
-    if {$onlycheck} {
-        return
-    }
-
-    set _value $newval
-    $itk_component(value) configure -width [string length $_value]
-    _redraw
-    event generate $itk_component(hull) <<Value>>
-
-    if {"" != $_pde} {
-        set val [$_val translate [$_val value]]
-        $_val value $_mode
-        $_pde value $_value
-
-    }
     return $_value
-}
-
-# ----------------------------------------------------------------------
-# USAGE: edit cut
-# USAGE: edit copy
-# USAGE: edit paste
-#
-# Used internally to handle cut/copy/paste operations for the current
-# value.  Usually invoked by <<Cut>>, <<Copy>>, <<Paste>> events, but
-# can also be called directly through this method.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Gauge::edit {option} {
-    if {$itk_option(-state) == "disabled"} {
-        return; # disabled? then bail out here!
-    }
-    switch -- $option {
-        cut {
-            edit copy
-            _editor popup
-            $itk_component(editor) value ""
-            $itk_component(editor) deactivate
-        }
-        copy {
-            clipboard clear
-            clipboard append $_value
-        }
-        paste {
-            _editor popup
-            $itk_component(editor) value [clipboard get]
-            $itk_component(editor) deactivate
-        }
-        default {
-            error "bad option \"$option\": should be cut, copy, paste"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: bump <delta>
-#
-# Changes the current value up/down by the <delta> value.  Used
-# internally by the up/down spinner buttons when the value is
-# -type integer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Gauge::bump {delta} {
-    set val $_value
-    if {$val == ""} {
-        set val 0
-    }
-    if {[catch {value [expr {$val+$delta}]} result]} {
-        if {[regexp {allowed here is (.+)} $result match newval]} {
-            set _value $newval
-            $itk_component(value) configure -text $newval
-        }
-        if {[regexp {^bad.*: +(.)(.+)} $result match first tail]
-              || [regexp {(.)(.+)} $result match first tail]} {
-            set result "[string toupper $first]$tail"
-        }
-        bell
-        Rappture::Tooltip::cue $itk_component(value) $result
-        _log warning $result
-        return 0
-    }
-    _log input [value]
 }
 
@@ -378,5 +202,4 @@
         $c create rectangle 0 0 1 1 -outline black -tags block
         $c create image 0 0 -anchor center -image "" -tags bimage
-        $c create rectangle 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags screen
     }
 
@@ -389,14 +212,7 @@
     # update the items based on current values
     $c coords block 0 0 [expr {$w-1}] [expr {$h-1}]
-    $c coords screen 0 0 $w $h
     $c itemconfigure block -fill $color
 
     $c coords bimage [expr {0.5*$w}] [expr {0.5*$h}]
-
-    if {$itk_option(-state) == "disabled"} {
-        $c itemconfigure screen -fill white
-    } else {
-        $c itemconfigure screen -fill ""
-    }
 }
 
@@ -408,32 +224,25 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Gauge::_resize {} {
-    set w 0
-    set h 0
-
-    if {"" != $itk_option(-image) || "" != $itk_option(-spectrum)} {
-        if {$itk_option(-samplewidth) > 0} {
-            set w $itk_option(-samplewidth)
+    if {$itk_option(-width) > 0} {
+        set w $itk_option(-width)
+    } else {
+        if {$itk_option(-image) != ""} {
+            set w [expr {[image width $itk_option(-image)]+4}]
         } else {
-            if {$itk_option(-image) != ""} {
-                set w [expr {[image width $itk_option(-image)]+4}]
-            } else {
-                set w [winfo reqheight $itk_component(value)]
-            }
-        }
-
-        if {$itk_option(-sampleheight) > 0} {
-            set h $itk_option(-sampleheight)
+            set w [winfo reqheight $itk_component(value)]
+        }
+    }
+
+    if {$itk_option(-height) > 0} {
+        set h $itk_option(-height)
+    } else {
+        if {$itk_option(-image) != ""} {
+            set h [expr {[image height $itk_option(-image)]+4}]
         } else {
-            if {$itk_option(-image) != ""} {
-                set h [expr {[image height $itk_option(-image)]+4}]
-            } else {
-                set h [winfo reqheight $itk_component(value)]
-            }
-        }
-    }
-
-    if {$w > 0 && $h > 0} {
-        $itk_component(icon) configure -width $w -height $h
-    }
+            set h [winfo reqheight $itk_component(value)]
+        }
+    }
+
+    $itk_component(icon) configure -width $w -height $h
 }
 
@@ -445,7 +254,4 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Gauge::_hilite {comp state} {
-    if {$itk_option(-state) == "disabled"} {
-        set state 0; # disabled? then don't hilite
-    }
     if {$comp == "value" && !$itk_option(-editable)} {
         $itk_component(value) configure -relief flat
@@ -454,11 +260,7 @@
 
     if {$state} {
+        $itk_component($comp) configure -relief solid
+    } else {
         $itk_component($comp) configure -relief flat
-    } else {
-        if {$comp eq "presets"} {
-            $itk_component($comp) configure -relief raised
-        } else {
-            $itk_component($comp) configure -relief flat
-        }
     }
 }
@@ -469,5 +271,4 @@
 # USAGE: _editor validate <value>
 # USAGE: _editor apply <value>
-# USAGE: _editor menu <rootx> <rooty>
 #
 # Used internally to handle the various functions of the pop-up
@@ -475,8 +276,4 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Gauge::_editor {option args} {
-    # puts "Gauge::editor option=$option args=$args"
-    if {$itk_option(-state) == "disabled"} {
-        return; # disabled? then bail out here!
-    }
     switch -- $option {
         popup {
@@ -497,4 +294,5 @@
             }
             set val [lindex $args 0]
+
             if {[catch {value -check $val} result]} {
                 if {[regexp {allowed here is (.+)} $result match newval]} {
@@ -507,5 +305,4 @@
                 bell
                 Rappture::Tooltip::cue $itk_component(editor) $result
-                _log warning $result
                 return 0
             }
@@ -515,13 +312,8 @@
                 error "wrong # args: should be \"_editor apply val\""
             }
-            set newval [lindex $args 0]
-            value $newval
-            _log input $newval
-        }
-        menu {
-            eval tk_popup $itk_component(emenu) $args
+            value [lindex $args 0]
         }
         default {
-            error "bad option \"$option\": should be popup, activate, validate, apply, and menu"
+            error "bad option \"$option\": should be popup, activate, validate, apply"
         }
     }
@@ -550,5 +342,5 @@
         }
         unpost {
-            $itk_component(presets) configure -relief raised
+            $itk_component(presets) configure -relief flat
         }
         select {
@@ -556,5 +348,4 @@
             if {"" != $val} {
                 value $val
-                _log input $val
             }
         }
@@ -566,20 +357,53 @@
 
 # ----------------------------------------------------------------------
-# USAGE: _layout
-#
-# Used internally to fix the layout of widgets whenever there is a
-# change in the options that affect layout.  Puts the value in the
-# proper position according to the -valueposition option.  Also,
-# adds or removes the icon if it needs to be shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Gauge::_layout {} {
-    foreach w [pack slaves $itk_component(hull)] {
-        pack forget $w
-    }
-
-    if {$itk_option(-type) != "integer" && $uq} {
-        pack $itk_component(uq) -side right -padx 10
-    }
-
+# CONFIGURATION OPTION: -editable
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Gauge::editable {
+    if {![string is boolean -strict $itk_option(-editable)]} {
+        error "bad value \"$itk_option(-editable)\": should be boolean"
+    }
+    if {!$itk_option(-editable) && [winfo ismapped $itk_component(editor)]} {
+        $itk_component(editor) deactivate -abort
+    }
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -spectrum
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Gauge::spectrum {
+    if {$itk_option(-spectrum) != ""
+          && ([catch {$itk_option(-spectrum) isa ::Rappture::Spectrum} valid]
+               || !$valid)} {
+        error "bad option \"$itk_option(-spectrum)\": should be Rappture::Spectrum object"
+    }
+    _redraw
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -image
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Gauge::image {
+    if {$itk_option(-image) != ""
+          && [catch {image width $itk_option(-image)}]} {
+        error "bad value \"$itk_option(-image)\": should be Tk image"
+    }
+    _resize
+    $itk_component(icon) itemconfigure bimage -image $itk_option(-image)
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -units
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Gauge::units {
+    if {$itk_option(-units) != ""
+          && [::Rappture::Units::System::for $itk_option(-units)] == ""} {
+        error "unrecognized system of units \"$itk_option(-units)\""
+    }
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -valueposition
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Gauge::valueposition {
     array set side2anchor {
         left   e
@@ -589,104 +413,10 @@
     }
     set pos $itk_option(-valueposition)
-    pack $itk_component(vframe) -side $pos \
-        -expand yes -fill both -ipadx 2
+    if {![info exists side2anchor($pos)]} {
+        error "bad value \"$pos\": should be [join [lsort [array names side2anchor]] {, }]"
+    }
+    pack $itk_component(vframe) -before $itk_component(icon) \
+        -side $pos -expand yes -fill both -ipadx 2
     $itk_component(value) configure -anchor $side2anchor($pos)
-
-    if {"" != $itk_option(-image) || "" != $itk_option(-spectrum)} {
-        pack $itk_component(icon) -side $pos -padx 2
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _log event ?arg arg...?
-#
-# Used internally to send info to the logging mechanism.  If the -log
-# argument is set, then this calls the Rappture::Logger mechanism to
-# log the rest of the arguments as an action.  Otherwise, it does
-# nothing.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Gauge::_log {event args} {
-    if {$itk_option(-log) ne ""} {
-        eval Rappture::Logger::log $event [list $itk_option(-log)] $args
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -editable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Gauge::editable {
-    if {![string is boolean -strict $itk_option(-editable)]} {
-        error "bad value \"$itk_option(-editable)\": should be boolean"
-    }
-    if {!$itk_option(-editable) && [winfo ismapped $itk_component(editor)]} {
-        $itk_component(editor) deactivate -abort
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Gauge::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(value) configure -state $itk_option(-state)
-    $itk_component(spinup) configure -state $itk_option(-state)
-    $itk_component(spindn) configure -state $itk_option(-state)
-    $itk_component(presets) configure -state $itk_option(-state)
-    if { [info exists itk_component(uq)] } {
-        $itk_component(uq) configure -state $itk_option(-state)
-    }
-    _redraw; # fix gauge
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -spectrum
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Gauge::spectrum {
-    if {$itk_option(-spectrum) != ""
-          && ([catch {$itk_option(-spectrum) isa ::Rappture::Spectrum} valid]
-               || !$valid)} {
-        error "bad option \"$itk_option(-spectrum)\": should be Rappture::Spectrum object"
-    }
-    _resize
-    _layout
-    _redraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -image
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Gauge::image {
-    if {$itk_option(-image) != ""
-          && [catch {image width $itk_option(-image)}]} {
-        error "bad value \"$itk_option(-image)\": should be Tk image"
-    }
-    _resize
-    _layout
-    $itk_component(icon) itemconfigure bimage -image $itk_option(-image)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -units
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Gauge::units {
-    if {$itk_option(-units) != ""
-          && [::Rappture::Units::System::for $itk_option(-units)] == ""} {
-        error "unrecognized system of units \"$itk_option(-units)\""
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -valueposition
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Gauge::valueposition {
-    set pos $itk_option(-valueposition)
-    set opts {left right top bottom}
-    if {[lsearch -exact $opts $pos] < 0} {
-        error "bad value \"$pos\": should be [join $opts {, }]"
-    }
-    _layout
 }
 
@@ -703,6 +433,6 @@
             set s "right"
         }
-        set first [lindex [pack slaves $itk_component(vframe)] 0]
-        pack $itk_component(presets) -before $first -side $s -fill y
+        pack $itk_component(presets) -before $itk_component(value) \
+            -side $s -fill y
 
         $itk_component(presetlist) delete 0 end
@@ -710,66 +440,2 @@
     }
 }
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -type
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Gauge::type {
-    switch -- $itk_option(-type) {
-        integer {
-            set first [lindex [pack slaves $itk_component(vframe)] 0]
-            if {$first == $itk_component(presets)} {
-                pack $itk_component(spinner) -after $first -side left -fill y
-            } else {
-                pack $itk_component(spinner) -before $first -side right -fill y
-            }
-        }
-        real {
-            pack forget $itk_component(spinner)
-        }
-        default {
-            error "bad number type \"$itk_option(-type)\": should be integer or real"
-        }
-    }
-}
-
-itcl::body Rappture::Gauge::_pop_uq {win} {
-    # puts "min=$itk_option(-minvalue) max=$itk_option(-maxvalue) units=$itk_option(-units)"
-    set varname $itk_option(-varname)
-    set popup .pop_uq_$varname
-    if { ![winfo exists $popup] } {
-        Rappture::Balloon $popup -title $itk_option(-label)
-        set inner [$popup component inner]
-        frame $inner.type
-        pack $inner.type -side top -fill x
-        label $inner.type.l -text "Parameter Value:"
-        pack $inner.type.l -side left
-
-        set _val [Rappture::Combobox $inner.type.val -width 20 -editable no]
-        pack $_val -side left -expand yes -fill x
-        $_val choices insert end exact "Exact Value"
-        $_val choices insert end uniform "Uniform Distribution"
-        $_val choices insert end gaussian "Gaussian Distribution"
-        bind $_val <<Value>> [itcl::code $this _change_param_type $inner]
-
-        set _pde [Rappture::ProbDistEditor $inner.entry \
-        $itk_option(-minvalue) $itk_option(-maxvalue) $itk_option(-units) $_value]
-        $_val value $_mode
-        $_pde value $_value
-        pack $inner.entry -expand yes -fill both -pady {10 0}
-
-        $popup configure \
-            -deactivatecommand [itcl::code $this _pop_uq_deactivate]
-    }
-    update
-    $popup activate $win right
-}
-
-itcl::body Rappture::Gauge::_pop_uq_deactivate {} {
-    # puts "deactivate [$_pde value]"
-    value [$_pde value]
-}
-
-itcl::body Rappture::Gauge::_change_param_type {inner} {
-    set val [$_val translate [$_val value]]
-    $_pde mode $val
-}
Index: trunk/gui/scripts/getopts.tcl
===================================================================
--- trunk/gui/scripts/getopts.tcl	(revision 6716)
+++ 	(revision )
@@ -1,151 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: getopts - simple argument parser
-#
-#  This utility makes it easy to process arguments for various
-#  commands.  You give a description of arguments, and it will
-#  parse and return the values.
-#
-#    getopts args params {
-#        value -foo foo_default
-#        flag group -bar default
-#        flag group -baz
-#    }
-#
-#  Note that both args and params are passed by name, not by
-#  value (not $args or $params).  This function initializes the
-#  params variable according to the values in the spec list.
-#  It then loops through all args, matching as many as possible
-#  from the list.  It throws an error on the first error
-#  encountered.  If there are extra arguments that don't match
-#  the flags and don't start with -, they are left in args, and
-#  processing stops.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-namespace eval Rappture { # forward declaration }
-
-# ----------------------------------------------------------------------
-# USAGE: getopts <listvar> <returnvar> <spec>
-#
-# Processes options in <listvar>, storing results in <returnvar>.
-# Throws an exception if an error is encountered.  Leaves any remaining
-# arguments (after flags) in <listvar>.
-# ----------------------------------------------------------------------
-proc Rappture::getopts {listVar returnVar spec} {
-    upvar $listVar args
-    upvar $returnVar params
-    catch {unset params}
-    set opts ""
-
-    #
-    # Pick apart the info in the <spec> and set up flags/params
-    #
-    foreach line [split $spec \n] {
-        if {[llength $line] == 0} {
-            continue  ;# ignore blank lines
-        }
-
-        set type [lindex $line 0]
-        switch -- $type {
-            value {
-                if {[llength $line] < 3} {
-                    error "bad value spec \"$line\": should be \"value -flag default\""
-                }
-                set name [lindex $line 1]
-                set flags($name) $type
-                set params($name) [lindex $line 2]
-                lappend opts $name
-            }
-            flag {
-                if {[llength $line] < 3 || [llength $line] > 4} {
-                    error "bad value spec \"$line\": should be \"flag group -flag ?default?\""
-                }
-                set group [lindex $line 1]
-                set name [lindex $line 2]
-                set flags($name) [list $type $group]
-                if {[llength $line] > 3} {
-                    set params($group) $name
-                    set params($name) 1
-                } else {
-                    if {![info exists params($group)]} {
-                        set params($group) ""
-                    }
-                    set params($name) 0
-                }
-                lappend opts $name
-            }
-            list {
-                if {[llength $line] < 3} {
-                    error "bad value spec \"$line\": should be \"list -flag default\""
-                }
-                set name [lindex $line 1]
-                set flags($name) $type
-                set params($name) [lindex $line 2]
-                lappend opts $name
-            }
-            default {
-                error "bad arg type \"$type\": should be flag or value"
-            }
-        }
-    }
-
-    #
-    # Now, walk through the values in $args and extract parameters.
-    #
-    while {[llength $args] > 0} {
-        set first [lindex $args 0]
-        if {[string index $first 0] != "-"} {
-            break
-        }
-        if {"--" == $first} {
-            set args [lrange $args 1 end]
-            break
-        }
-        if {![info exists params($first)]} {
-            error "bad option \"$first\": should be [join [lsort $opts] {, }]"
-        }
-        switch -- [lindex $flags($first) 0] {
-            value {
-                if {[llength $args] < 2} {
-                    error "missing value for option $first"
-                }
-                set params($first) [lindex $args 1]
-                set args [lrange $args 2 end]
-            }
-            flag {
-                set group [lindex $flags($first) 1]
-                set params($group) $first
-                set params($first) 1
-                set args [lrange $args 1 end]
-            }
-            list {
-                if {[llength $args] < 2} {
-                    error "missing value for option $first"
-                }
-                foreach arg [lrange $args 1 end] {
-                    if {[string index $arg 0] == "-"} {
-                        break
-                    }
-                }
-                set idx [lsearch -exact $args $arg]
-                if {$idx == [expr [llength $args] - 1]} {
-                    # reached the end of the $args list
-                    # with no other -'d arguments
-                    set params($first) [lrange $args 1 end]
-                    set args ""
-                } else {
-                    # there are further -'d arguments to process
-                    set params($first) [lrange $args 1 [expr $idx-1]]
-                    set args [lrange $args $idx end]
-                }
-            }
-        }
-    }
-    return ""
-}
Index: trunk/gui/scripts/grab.tcl
===================================================================
--- trunk/gui/scripts/grab.tcl	(revision 6716)
+++ 	(revision )
@@ -1,138 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: grab - improved version of the Tk grab command
-#
-#  This version of "grab" keeps a stack of grab windows, so one
-#  window can steal and release the grab, and the grab will revert
-#  to the previous window.  If things get jammed up, you can press
-#  <Escape> three times to release the grab.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require BLT
-
-namespace eval Rappture { # forward declaration }
-namespace eval Rappture::grab {
-    variable state ""  ;# local ("") or global ("-global") grab
-    variable stack ""  ;# stack of grab windows
-}
-
-proc Rappture::grab::init {} { # used for autoloading this module }
-
-bind all <Escape><Escape><Escape> Rappture::grab::reset
-
-# ----------------------------------------------------------------------
-# USAGE: grab ?-global? <window>
-# USAGE: grab set ?-global? <window>
-# USAGE: grab release <window>
-# USAGE: grab current ?<window>?
-# USAGE: grab status <window>
-#
-# This is a replacement for the usual Tk grab command.  It works
-# exactly the same way, but supports a stack of grab windows, so
-# one window can steal grab from another, and then give it back
-# later.
-# ----------------------------------------------------------------------
-rename grab _tk_grab
-proc grab { args } {
-    set op [lindex $args 0]
-    if {[winfo exists $op]} {
-        set op "set"
-    } elseif {$op == "-global" && [winfo exists [lindex $args end]]} {
-        set op "set"
-    }
-
-    if {$op == "set"} {
-        #
-        # Handle GRAB SET specially.
-        # Add the new grab window to the grab stack.
-        #
-        set state $::Rappture::grab::state
-        set window [lindex $args end]
-
-        if {[lsearch -exact $args -global] >= 0} {
-            set state "-global"
-        }
-
-        if {"" != $state} {
-            # if it's a global grab, store the -global flag away for later
-            set window [linsert $window 0 $state]
-
-            # all grabs from now on are global
-            set ::Rappture::grab::state "-global"
-        }
-
-        # if the window is already on the stack, then skip it
-        if {[string equal [lindex $::Rappture::grab::stack 0] $window]} {
-            return $window
-        }
-
-        # add the current configuration to the grab stack
-        set ::Rappture::grab::stack \
-            [linsert $::Rappture::grab::stack 0 $window]
-
-        return [eval _grabset $window]
-
-    } elseif {$op == "release"} {
-        #
-        # Handle GRAB RELEASE specially.
-        # Release the current grab and grab the next window on the stack.
-        # Note that the current grab is on the top of the stack.  The
-        # next one down is the one we want to revert to.
-        #
-        set window [lindex $::Rappture::grab::stack 1]
-        set ::Rappture::grab::stack [lrange $::Rappture::grab::stack 1 end]
-
-        # release the current grab
-        eval _tk_grab $args
-
-        # and set the next one
-        if {[lindex $window 0] != "-global"} {
-            # no more global grabs -- resume local grabs
-            set ::Rappture::grab::state ""
-        }
-        if { $window != "" } {
-            eval _grabset $window
-        }
-        return ""
-    }
-
-    # perform any other grab operation as usual...
-    return [eval _tk_grab $args]
-}
-
-proc _grabset {args} {
-    # give it 3 tries, if necessary
-    for {set i 0} {$i < 3} {incr i} {
-        set status [catch {eval _tk_grab set $args} result]
-        if {$status == 0} {
-            return $result
-        }
-        after 100; update
-    }
-    # oh well, we tried...
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::grab::reset
-#
-# Used internally to reset the grab whenever the user presses
-# Escape a bunch of times to break out of the grab.
-# ----------------------------------------------------------------------
-proc Rappture::grab::reset {} {
-    set w [_tk_grab current]
-    if {"" != $w} {
-        _tk_grab release $w
-    }
-    set Rappture::grab::stack ""
-    set Rappture::grab::state ""
-
-    foreach win [blt::busy windows] {
-        blt::busy release $win
-    }
-}
Index: trunk/gui/scripts/groupentry.tcl
===================================================================
--- trunk/gui/scripts/groupentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,157 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: GroupEntry - widget containing a group of controls
-#
-#  This widget represents a <group> entry on a control panel.
-#  It contains a series of other controls.  Sort of a glorified
-#  frame widget.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *GroupEntry.headingBackground #b5b5b5 widgetDefault
-option add *GroupEntry.headingForeground white widgetDefault
-option add *GroupEntry.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::GroupEntry {
-    inherit itk::Widget
-
-    itk_option define -heading heading Heading 1
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _fixheading {}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-}
-
-itk::usual GroupEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::GroupEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    itk_component add heading {
-        ::label $itk_interior.heading -anchor w
-    } {
-        usual
-        rename -background -headingbackground headingBackground Background
-        rename -foreground -headingforeground headingForeground Foreground
-    }
-
-    $itk_component(heading) configure \
-        -text [string trim [$_owner xml get $_path.about.label]]
-    Rappture::Tooltip::for $itk_component(heading) \
-        [string trim [$_owner xml get $_path.about.description]]
-
-    itk_component add outline {
-        frame $itk_interior.outline -borderwidth 1
-    } {
-        usual
-        ignore -borderwidth
-        rename -background -headingbackground headingBackground Background
-    }
-    pack $itk_component(outline) -expand yes -fill both
-
-    itk_component add inner {
-        frame $itk_component(outline).inner -borderwidth 3
-    } {
-        usual
-        ignore -borderwidth
-    }
-    pack $itk_component(inner) -expand yes -fill both
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::GroupEntry::value {args} {
-    # groups have no value
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::GroupEntry::label {} {
-    return ""  ;# manage the label inside this group
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::GroupEntry::tooltip {} {
-    return [string trim [$_owner xml get $_path.about.description]]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -heading
-# Turns the heading bar at the top of this group on/off.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::GroupEntry::heading {
-    if {![string is boolean -strict $itk_option(-heading)]} {
-        error "bad value \"$itk_option(-heading)\": should be boolean"
-    }
-
-    set str [$itk_component(heading) cget -text]
-    if {$itk_option(-heading) && "" != $str} {
-        eval pack forget [pack slaves $itk_component(hull)]
-        pack $itk_component(heading) -side top -fill x
-        pack $itk_component(outline) -expand yes -fill both
-        $itk_component(outline) configure -borderwidth 1
-        $itk_component(inner) configure -borderwidth 3
-    } else {
-        pack forget $itk_component(heading)
-        $itk_component(outline) configure -borderwidth 0
-        $itk_component(inner) configure -borderwidth 0
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::GroupEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-}
Index: trunk/gui/scripts/histogram.tcl
===================================================================
--- trunk/gui/scripts/histogram.tcl	(revision 6716)
+++ 	(revision )
@@ -1,419 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: histogram - extracts data from an XML description of a field
-#
-#  This object represents a histogram of data in an XML description of
-#  simulator output.  A histogram is similar to a field, but a field is
-#  a quantity versus position in device.  A histogram is any quantity
-#  versus any other quantity.  This class simplifies the process of
-#  extracting data vectors that represent the histogram.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture { # forward declaration }
-
-itcl::class Rappture::Histogram {
-    constructor {xmlobj path} { # defined below }
-    destructor { # defined below }
-
-    public method components {{pattern *}}
-    public method mesh { component }
-    public method values { component }
-    public method widths { component }
-    public method xlabels { component }
-    public method limits {which}
-    public method xmarkers {}
-    public method ymarkers {}
-    public method hints {{key ""}}
-
-    protected method Build {}
-    private method Clear { {comp ""} }
-    private method ParseData { comp }
-
-    private variable _xmlobj ""  ;# ref to lib obj with histogram data
-    private variable _hist ""    ;# lib obj representing this histogram
-    private variable _widths     ;# array of vectors of bin widths
-    private variable _yvalues    ;# array of vectors of bin heights along
-                                 ;# y-axis.
-    private variable _xvalues    ;# array of vectors of bin locations along
-                                 ;# x-axis.
-    private variable _xlabels    ;# array of labels
-    private variable _hints      ;# cache of hints stored in XML
-    private variable _xmarkers "";# list of {x,label,options} triplets.
-    private variable _ymarkers "";# list of {y,label,options} triplets.
-    private common _counter 0    ;# counter for unique vector names
-    private variable _comp2hist  ;# maps component name => x,y,w,l vectors
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be LibraryObj"
-    }
-    set _xmlobj $xmlobj
-    set _hist [$xmlobj element -as object $path]
-
-    # build up vectors for various components of the histogram
-    Build
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::destructor {} {
-    # don't destroy the _xmlobj! we don't own it!
-    itcl::delete object $_hist
-    Clear
-}
-
-# ----------------------------------------------------------------------
-# USAGE: mesh
-#
-# Returns the vector for the histogram bin locations along the
-# x-axis.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::mesh { comp } {
-    if { [info exists _xvalues($comp)] } {
-        return $_xvalues($comp)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: heights
-#
-# Returns the vector for the histogram bin heights along the y-axis.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::values { comp } {
-    if { [info exists _yvalues($comp)] } {
-        return $_yvalues($comp)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: widths
-#
-# Returns the vector for the specified histogram component <name>.
-# If the name is not specified, then it returns the vectors for the
-# overall histogram (sum of all components).
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::widths { comp } {
-    if { [info exists _widths($comp)] } {
-        return $_widths($comp)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: xlabels
-#
-# Returns the vector for the specified histogram component <name>.
-# If the name is not specified, then it returns the vectors for the
-# overall histogram (sum of all components).
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::xlabels { comp } {
-    if { [info exists _xlabels($comp)] } {
-        return $_xlabels($comp)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: xmarkers
-#
-# Returns the list of settings for each marker on the x-axis.
-# If no markers have been specified the empty string is returned.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::xmarkers {} {
-    return $_xmarkers;
-}
-
-# ----------------------------------------------------------------------
-# USAGE: components ?<pattern>?
-#
-# Returns a list of names for the various components of this curve.
-# If the optional glob-style <pattern> is specified, then it returns
-# only the component names matching the pattern.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::components {{pattern *}} {
-    set rlist ""
-    foreach name [array names _comp2hist] {
-        if {[string match $pattern $name]} {
-            lappend rlist $name
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ymarkers
-#
-# Returns the list of settings for each marker on the y-axis.
-# If no markers have been specified the empty string is returned.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::ymarkers {} {
-    return $_ymarkers;
-}
-
-# ----------------------------------------------------------------------
-# USAGE: limits x|xlin|xlog|y|ylin|ylog
-#
-# Returns the {min max} limits for the specified axis.
-#
-# What does it mean to view a distribution (the bins) as log scale?
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::limits {which} {
-    set min ""
-    set max ""
-    switch -- $which {
-        x - xlin { set pos 0; set log 0; set axis xaxis }
-        xlog { set pos 0; set log 1; set axis xaxis }
-        y - ylin - v - vlin { set pos 1; set log 0; set axis yaxis }
-        ylog - vlog { set pos 1; set log 1; set axis yaxis }
-        default {
-            error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
-        }
-    }
-
-    blt::vector create tmp
-    blt::vector create zero
-    foreach comp [array names _comphist] {
-        set vname [lindex $_comp2hist($comp) $pos]
-        $vname variable vec
-
-        if {$log} {
-            # on a log scale, use abs value and ignore 0's
-            $vname dup tmp
-            $vname dup zero
-            zero expr {tmp == 0}            ;# find the 0's
-            tmp expr {abs(tmp)}             ;# get the abs value
-            tmp expr {tmp + zero*max(tmp)}  ;# replace 0's with abs max
-            set vmin [blt::vector expr min(tmp)]
-            set vmax [blt::vector expr max(tmp)]
-        } else {
-            set vmin $vec(min)
-            set vmax $vec(max)
-        }
-
-        if {"" == $min} {
-            set min $vmin
-        } elseif {$vmin < $min} {
-            set min $vmin
-        }
-        if {"" == $max} {
-            set max $vmax
-        } elseif {$vmax > $max} {
-            set max $vmax
-        }
-    }
-    blt::vector destroy tmp zero
-
-    set val [$_hist get $axis.min]
-    if {"" != $val && "" != $min} {
-        if {$val > $min} {
-            # tool specified this min -- don't go any lower
-            set min $val
-        }
-    }
-
-    set val [$_hist get $axis.max]
-    if {"" != $val && "" != $max} {
-        if {$val < $max} {
-            # tool specified this max -- don't go any higher
-            set max $val
-        }
-    }
-    return [list $min $max]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this histogram.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::hints {{keyword ""}} {
-    if {![info exists _hints]} {
-        foreach {key path} {
-            group   about.group
-            label   about.label
-            color   about.color
-            style   about.style
-            type    about.type
-            xlabel  xaxis.label
-            xdesc   xaxis.description
-            xunits  xaxis.units
-            xorient xaxis.orientation
-            xscale  xaxis.scale
-            xmin    xaxis.min
-            xmax    xaxis.max
-            ylabel  yaxis.label
-            ydesc   yaxis.description
-            yunits  yaxis.units
-            yscale  yaxis.scale
-            ymin    yaxis.min
-            ymax    yaxis.max
-        } {
-            set str [$_hist get $path]
-            if {"" != $str} {
-                set _hints($key) $str
-            }
-        }
-
-        if {[info exists _hints(xlabel)] && "" != $_hints(xlabel)
-              && [info exists _hints(xunits)] && "" != $_hints(xunits)} {
-            set _hints(xlabel) "$_hints(xlabel) ($_hints(xunits))"
-        }
-        if {[info exists _hints(ylabel)] && "" != $_hints(ylabel)
-              && [info exists _hints(yunits)] && "" != $_hints(yunits)} {
-            set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))"
-        }
-
-        if {[info exists _hints(group)] && [info exists _hints(label)]} {
-            # pop-up help for each histogram
-            set _hints(tooltip) $_hints(label)
-        }
-    }
-
-    if {$keyword != ""} {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
-        }
-        return ""
-    }
-    return [array get _hints]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Build
-#
-# Used internally to build up the vector representation for the
-# histogram when the object is first constructed, or whenever the histogram
-# data changes.  Discards any existing vectors and builds everything
-# from scratch.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Histogram::Build {} {
-    # discard any existing data
-    Clear
-    #
-    # Scan through the components of the histogram and create
-    # vectors for each part.  Right now there's only one
-    # component.  I left in the component tag in case future
-    # enhancements require more than one component.
-    #
-    foreach cname [$_hist children -type component] {
-        ParseData $cname
-    }
-    # Creates lists of x and y marker data.
-    set _xmarkers {}
-    set _ymarkers {}
-    foreach cname [$_hist children -type "marker" xaxis] {
-        set at     [$_hist get "xaxis.$cname.at"]
-        set label  [$_hist get "xaxis.$cname.label"]
-        set styles [$_hist get "xaxis.$cname.style"]
-        set data [list $at $label $styles]
-        lappend _xmarkers $data
-    }
-    foreach cname [$_hist children -type "marker" yaxis] {
-        set at     [$_hist get "yaxis.$cname.at"]
-        set label  [$_hist get "yaxis.$cname.label"]
-        set styles [$_hist get "yaxis.$cname.style"]
-        set data [list $at $label $styles]
-        lappend _xmarkers $data
-    }
-}
-
-#
-# ParseData --
-#
-#       Parse the components data representations.  The following
-#       elements may be used <xy>, <xhw>, <namevalue>, <xvector>,
-#       <yvector>.  Only one element is used for data.
-#
-itcl::body Rappture::Histogram::ParseData { comp } {
-    # Create new vectors or discard any existing data
-    set _xvalues($comp) [blt::vector create \#auto]
-    set _yvalues($comp) [blt::vector create \#auto]
-    set _widths($comp) [blt::vector create \#auto]
-    set _xlabels($comp) {}
-
-    set xydata [$_hist get ${comp}.xy]
-    if { $xydata != "" } {
-        set count 0
-        foreach {name value} [regsub -all "\[ \t\n]+" $xydata { }] {
-            $_yvalues($comp) append $value
-            $_xvalues($comp) append $count
-            lappend _xlabels($comp) $name
-            incr count
-        }
-        set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
-        return
-    }
-    set xhwdata [$_hist get ${comp}.xhw]
-    if { $xhwdata != "" } {
-        set count 0
-        foreach {name h w} [regsub -all "\[ \t\n]+" $xhwdata { }] {
-            lappend _xlabels($comp) $name
-            $_xvalues($comp) append $count
-            $_yvalues($comp) append $h
-            $_widths($comp) append $w
-            incr count
-        }
-        set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
-        return
-    }
-
-    # If we reached here, must be <yvector>
-    $_yvalues($comp) set [$_hist get ${comp}.yvector]
-    $_xvalues($comp) length [$_yvalues($comp) length]
-    $_xvalues($comp) seq 1 [$_yvalues($comp) length]
-    set _xlabels($comp) [$_hist get ${comp}.xvector]
-    set _comp2hist($comp) [list $_xvalues($comp) $_yvalues($comp)]
-}
-
-itcl::body Rappture::Histogram::Clear { {comp ""} } {
-    if { $comp == "" } {
-        foreach name [array names _widths] {
-            blt::vector destroy $_widths($name)
-        }
-        array unset _widths
-        foreach name [array names _yvalues] {
-            blt::vector destroy $_yvalues($name)
-        }
-        array unset _yvalues
-        foreach name [array names _xvalues] {
-            blt::vector destroy $_xvalues($name)
-        }
-        array unset _xvalues
-        array unset _xlabels
-        array unset _comp2hist
-        return
-    }
-    if { [info exists _widths($comp)] } {
-        blt::vector destroy $_widths($comp)
-    }
-    if { [info exists _yvalues($comp)] } {
-        blt::vector destroy $_yvalues($comp)
-    }
-    if { [info exists _xvalues($comp)] } {
-        blt::vector destroy $_xvalues($comp)
-    }
-    array unset _xvalues $comp
-    array unset _yvalues $comp
-    array unset _widths $comp
-    array unset _xlabels $comp
-    array unset _comp2hist $comp
-}
-
Index: trunk/gui/scripts/histogramresult.tcl
===================================================================
--- trunk/gui/scripts/histogramresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1612 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: HistogramResult - X/Y plot in a ResultSet
-#
-#  This widget is an X/Y plot, meant to view histograms produced
-#  as output from the run of a Rappture tool.  Use the "add" and
-#  "delete" methods to control the dataobjs showing on the plot.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *HistogramResult*Element.borderWidth 1 widgetDefault
-option add *HistogramResult*Element.relief solid widgetDefault
-option add *HistogramResult*x.loose 0 widgetDefault
-option add *HistogramResult*y.loose 1 widgetDefault
-option add *HistogramResult*Element.relief solid widgetDefault
-option add *HistogramResult*Element.borderWidth 1 widgetDefault
-# Don't let the step size default to 1.0 (for barcharts)
-option add *HistogramResult*x.stepSize 1.0 widgetDefault
-option add *HistogramResult*x.subdivisions 0 widgetDefault
-
-option add *HistogramResult.width 3i widgetDefault
-option add *HistogramResult.height 3i widgetDefault
-option add *HistogramResult.gridColor #d9d9d9 widgetDefault
-option add *HistogramResult.activeColor blue2 widgetDefault
-option add *HistogramResult.dimColor gray widgetDefault
-option add *HistogramResult.controlBackground gray widgetDefault
-option add *HistogramResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-option add *HistogramResult*Balloon*Entry.background white widgetDefault
-
-option add *HistogramResult*autoColors {
-    #3a5fcd
-    #cdcd00
-    #cd1076
-    #0000cd
-    #cd0000
-    #00cd00
-    #009acd
-    #00c5cd
-    #a2b5cd
-    #7ac5cd
-    #66cdaa
-    #a2cd5a
-    #cd9b9b
-    #cdba96
-    #cd3333
-    #cd6600
-    #cd8c95
-    #cd00cd
-    #9a32cd
-    #6ca6cd
-    #9ac0cd
-    #9bcd9b
-    #00cd66
-    #cdc673
-    #cdad00
-    #cd5555
-    #cd853f
-    #cd7054
-    #cd5b45
-    #cd6889
-    #cd69c9
-    #551a8b
-} widgetDefault
-
-itcl::class Rappture::HistogramResult {
-    inherit itk::Widget
-
-    itk_option define -gridcolor gridColor GridColor ""
-    itk_option define -activecolor activeColor ActiveColor ""
-    itk_option define -dimcolor dimColor DimColor ""
-    itk_option define -autocolors autoColors AutoColors ""
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method download {option args}
-
-    protected method Rebuild {}
-    protected method ResetLimits {}
-    protected method Zoom {option args}
-    protected method Hilite {state x y}
-    protected method Axis {option args}
-    protected method GetAxes {dataobj}
-    protected method GetLineMarkerOptions { style }
-    protected method GetTextMarkerOptions { style }
-    protected method EnterMarker { g name x y text }
-    protected method LeaveMarker { g name }
-    protected method FormatLabels { g value }
-    private method ResetLegend {}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-    private variable _dlist ""     ;# list of dataobj objects
-    private variable _dataobj2color  ;# maps dataobj => plotting color
-    private variable _dataobj2width  ;# maps dataobj => line width
-    private variable _dataobj2dashes ;# maps dataobj => BLT -dashes list
-    private variable _dataobj2raise  ;# maps dataobj => raise flag 0/1
-    private variable _dataobj2desc   ;# maps dataobj => description of data
-    private variable _elem2dataobj   ;# maps graph element => dataobj
-    private variable _label2axis   ;# maps axis label => axis ID
-    private variable _limits       ;# axis limits:  x-min, x-max, etc.
-    private variable _autoColorI 0 ;# index for next "-color auto"
-
-    private variable _hilite       ;# info for element currently highlighted
-    private variable _axis         ;# info for axis manipulations
-    private variable _axisPopup    ;# info for axis being edited in popup
-    common _downloadPopup          ;# download options from popup
-    private variable _markers
-    private variable _xlabels
-}
-
-itk::usual HistogramResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    array set _downloadPopup {
-        format csv
-    }
-
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add main {
-        Rappture::SidebarFrame $itk_interior.main
-    }
-    pack $itk_component(main) -expand yes -fill both
-    set f [$itk_component(main) component controls]
-
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(reset) -padx 4 -pady 2 -anchor e
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    set f [$itk_component(main) component frame]
-    itk_component add plot {
-        blt::barchart $f.plot \
-            -highlightthickness 0 -plotpadx 0 -plotpady 4
-    } {
-        keep -foreground -cursor -font
-    }
-    pack $itk_component(plot) -expand yes -fill both
-    $itk_component(plot) pen configure activeBar \
-        -foreground red -borderwidth 0
-
-    #
-    # Add bindings so you can mouse over points to see values:
-    #
-    $itk_component(plot) element bind all <Enter> \
-        [itcl::code $this Hilite at %x %y]
-    $itk_component(plot) element bind all <Motion> \
-        [itcl::code $this Hilite at %x %y]
-    $itk_component(plot) element bind all <Leave> \
-        [itcl::code $this Hilite off %x %y]
-
-    # Add support for editing axes:
-    Rappture::Balloon $itk_component(hull).axes -title "Axis Options"
-    set inner [$itk_component(hull).axes component inner]
-
-    label $inner.labell -text "Label:"
-    entry $inner.label -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.labell -row 1 -column 0 -sticky e
-    grid $inner.label -row 1 -column 1 -sticky ew -pady 4
-
-    label $inner.minl -text "Minimum:"
-    entry $inner.min -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.minl -row 2 -column 0 -sticky e
-    grid $inner.min -row 2 -column 1 -sticky ew -pady 4
-
-    label $inner.maxl -text "Maximum:"
-    entry $inner.max -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.maxl -row 3 -column 0 -sticky e
-    grid $inner.max -row 3 -column 1 -sticky ew -pady 4
-
-    label $inner.formatl -text "Format:"
-    Rappture::Combobox $inner.format -width 15 -editable no
-    $inner.format choices insert end \
-        "%.6g"  "Auto"         \
-        "%.0f"  "X"          \
-        "%.1f"  "X.X"          \
-        "%.2f"  "X.XX"         \
-        "%.3f"  "X.XXX"        \
-        "%.6f"  "X.XXXXXX"     \
-        "%.1e"  "X.Xe+XX"      \
-        "%.2e"  "X.XXe+XX"     \
-        "%.3e"  "X.XXXe+XX"    \
-        "%.6e"  "X.XXXXXXe+XX"
-    grid $inner.formatl -row 4 -column 0 -sticky e
-    grid $inner.format -row 4 -column 1 -sticky ew -pady 4
-
-    label $inner.scalel -text "Scale:"
-    frame $inner.scales
-    radiobutton $inner.scales.linear -text "Linear" \
-        -variable [itcl::scope _axisPopup(scale)] -value "linear"
-    pack $inner.scales.linear -side left
-    radiobutton $inner.scales.log -text "Logarithmic" \
-        -variable [itcl::scope _axisPopup(scale)] -value "log"
-    pack $inner.scales.log -side left
-    grid $inner.scalel -row 5 -column 0 -sticky e
-    grid $inner.scales -row 5 -column 1 -sticky ew -pady 4
-
-    foreach axis {x y} {
-        set _axisPopup(format-$axis) "%.6g"
-    }
-    Axis scale x linear
-    Axis scale y linear
-
-    $itk_component(plot) legend configure -hide yes
-
-    #
-    # Add legend for editing hidden/elements:
-    #
-    set inner [$itk_component(main) insert end \
-        -title "Legend" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    itk_component add legend {
-        Rappture::XyLegend $inner.legend $itk_component(plot)
-    }
-    pack $itk_component(legend) -expand yes -fill both
-    after idle [itcl::code $this ResetLegend]
-
-    # quick-and-dirty zoom functionality, for now...
-    Blt_ZoomStack $itk_component(plot)
-    eval itk_initialize $args
-
-    set _hilite(elem) ""
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a dataobj to the plot.  The optional <settings>
-# are used to configure the plot.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -type "histogram"
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    # if the color is "auto", then select a color from -autocolors
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        if {$params(-color) == "autoreset"} {
-            set _autoColorI 0
-        }
-        set color [lindex $itk_option(-autocolors) $_autoColorI]
-        if {"" == $color} { set color black }
-        set params(-color) $color
-
-        # set up for next auto color
-        if {[incr _autoColorI] >= [llength $itk_option(-autocolors)]} {
-            set _autoColorI 0
-        }
-    }
-
-    # convert -linestyle to BLT -dashes
-    switch -- $params(-linestyle) {
-        dashed { set params(-linestyle) {4 4} }
-        dotted { set params(-linestyle) {2 4} }
-        default { set params(-linestyle) {} }
-    }
-
-    # if -brightness is set, then update the color
-    if {$params(-brightness) != 0} {
-        set params(-color) [Rappture::color::brightness \
-            $params(-color) $params(-brightness)]
-
-        set bg [$itk_component(plot) cget -plotbackground]
-        foreach {h s v} [Rappture::color::RGBtoHSV $bg] break
-        if {$v > 0.5} {
-            set params(-color) [Rappture::color::brightness_max \
-                $params(-color) 0.8]
-        } else {
-            set params(-color) [Rappture::color::brightness_min \
-                $params(-color) 0.2]
-        }
-    }
-
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-        set _dataobj2color($dataobj) $params(-color)
-        set _dataobj2width($dataobj) $params(-width)
-        set _dataobj2dashes($dataobj) $params(-linestyle)
-        set _dataobj2raise($dataobj) $params(-raise)
-        set _dataobj2desc($dataobj) $params(-description)
-
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::get {} {
-    # put the dataobj list in order according to -raise options
-    set bottom {}
-    set top {}
-    foreach obj $_dlist {
-        if {[info exists _dataobj2raise($obj)] && $_dataobj2raise($obj)} {
-            lappend top $obj
-        } else {
-            lappend bottom $obj
-        }
-    }
-    set _dlist [concat $bottom $top]
-    return $_dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            catch {unset _dataobj2color($dataobj)}
-            catch {unset _dataobj2width($dataobj)}
-            catch {unset _dataobj2dashes($dataobj)}
-            catch {unset _dataobj2raise($dataobj)}
-            foreach elem [array names _elem2dataobj] {
-                if {$_elem2dataobj($elem) == $dataobj} {
-                    unset _elem2dataobj($elem)
-                }
-            }
-            set changed 1
-        }
-    }
-
-    # If anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-
-    # Nothing left? then start over with auto colors
-    if {[llength $_dlist] == 0} {
-        set _autoColorI 0
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all dataobjs--even those not showing on the screen.
-# Because of this, the limits are appropriate for all dataobjs as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::scale {args} {
-    set allx [$itk_component(plot) x2axis use]
-    lappend allx x  ;# fix main x-axis too
-    foreach axis $allx {
-        Axis scale $axis linear
-    }
-
-    set ally [$itk_component(plot) y2axis use]
-    lappend ally y  ;# fix main y-axis too
-    foreach axis $ally {
-        Axis scale $axis linear
-    }
-
-    catch {unset _limits}
-    foreach dataobj $args {
-        # find the axes for this dataobj (e.g., {x y2})
-        foreach {map(x) map(y)} [GetAxes $dataobj] break
-
-        foreach axis {x y} {
-            # get defaults for both linear and log scales
-            foreach type {lin log} {
-                # store results -- ex: _limits(x2log-min)
-                set id $map($axis)$type
-                foreach {min max} [$dataobj limits $axis$type] break
-                if {"" != $min && "" != $max} {
-                    if {![info exists _limits($id-min)]} {
-                        set _limits($id-min) $min
-                        set _limits($id-max) $max
-                    } else {
-                        if {$min < $_limits($id-min)} {
-                            set _limits($id-min) $min
-                        }
-                        if {$max > $_limits($id-max)} {
-                            set _limits($id-max) $max
-                        }
-                    }
-                }
-            }
-
-            if {[$dataobj hints ${axis}scale] == "log"} {
-                Axis scale $map($axis) log
-            }
-        }
-    }
-    ResetLimits
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            set popup .histogramresultdownload
-            if {![winfo exists .histogramresultdownload]} {
-                # if we haven't created the popup yet, do it now
-                Rappture::Balloon $popup \
-                    -title "[Rappture::filexfer::label downloadWord] as..."
-                set inner [$popup component inner]
-                label $inner.summary -text "" -anchor w
-                pack $inner.summary -side top
-                radiobutton $inner.csv -text "Data as Comma-Separated Values" \
-                    -variable Rappture::HistogramResult::_downloadPopup(format) \
-                    -value csv
-                pack $inner.csv -anchor w
-                radiobutton $inner.image -text "Image (PS/PDF/PNG/JPEG)" \
-                    -variable Rappture::HistogramResult::_downloadPopup(format) \
-                    -value image
-                pack $inner.image -anchor w
-                button $inner.go -text [Rappture::filexfer::label download] \
-                    -command [lindex $args 0]
-                pack $inner.go -pady 4
-            } else {
-                set inner [$popup component inner]
-            }
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:"
-            update idletasks ;# fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .histogramresultdownload
-            if {[winfo exists .histogramresultdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                csv {
-                    # reverse the objects so the selected data appears on top
-                    set dlist ""
-                    foreach dataobj [get] {
-                        set dlist [linsert $dlist 0 $dataobj]
-                    }
-
-                    # generate the comma-separated value data for these objects
-                    set csvdata ""
-                    foreach dataobj $dlist {
-                        append csvdata "[string repeat - 60]\n"
-                        append csvdata " [$dataobj hints label]\n"
-                        if {[info exists _dataobj2desc($dataobj)]
-                            && [llength [split $_dataobj2desc($dataobj) \n]] > 1} {
-                            set indent "for:"
-                            foreach line [split $_dataobj2desc($dataobj) \n] {
-                                append csvdata " $indent $line\n"
-                                set indent "    "
-                            }
-                        }
-                        append csvdata "[string repeat - 60]\n"
-
-                        append csvdata "[$dataobj hints xlabel], [$dataobj hints ylabel]\n"
-                        set first 1
-                        foreach comp [$dataobj components] {
-                            if {!$first} {
-                                # blank line between components
-                                append csvdata "\n"
-                            }
-                            set xv [$dataobj mesh $comp]
-                            set yv [$dataobj values $comp]
-                            if { [$xv length] > 0 && [$yv length] > 0 } {
-                                foreach x [$xv range 0 end] y [$yv range 0 end] {
-                                    append csvdata \
-                                        [format "%20.15g, %20.15g\n" $x $y]
-                                }
-                            }
-                            set first 0
-                        }
-                        append csvdata "\n"
-                    }
-                    return [list .txt $csvdata]
-                }
-                image {
-                    set popup .histogramprintdownload
-                    if { ![winfo exists $popup] } {
-                        # Create a popup for the print dialog
-                        Rappture::Balloon $popup -title "Save as image..."
-                        set inner [$popup component inner]
-                        # Create the print dialog widget and add it to the
-                        # the balloon popup.
-                        Rappture::XyPrint $inner.print
-                        $popup configure \
-                            -deactivatecommand [list $inner.print reset]
-                        blt::table $inner 0,0 $inner.print -fill both
-                    }
-                    update
-                    # Activate the popup and call for the output.
-                    foreach { widget toolName plotName } $args break
-                    $popup activate $widget left
-                    set inner [$popup component inner]
-                    set output [$inner.print print $itk_component(plot) \
-                                    $toolName $plotName]
-                    $popup deactivate
-                    return $output
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::Rebuild {} {
-    set g $itk_component(plot)
-
-    # First clear out the widget
-    eval $g element delete [$g element names]
-    eval $g marker delete [$g marker names]
-    foreach axis [$g axis names] {
-        $g axis configure $axis -hide yes
-    }
-    # Presumably you want at least an X-axis and Y-axis displayed.
-    $g xaxis configure -hide no
-    $g yaxis configure -hide no
-    array unset _label2axis
-
-    #
-    # Scan through all objects and create a list of all axes.
-    # The first x-axis gets mapped to "x".  The second, to "x2".
-    # Beyond that, we must create new axes "x3", "x4", etc.
-    # We do the same for y.
-    #
-    set anum(x) 0
-    set anum(y) 0
-    foreach dataobj [get] {
-        foreach ax {x y} {
-            set label [$dataobj hints ${ax}label]
-            if {"" != $label} {
-                if {![info exists _label2axis($ax-$label)]} {
-                    switch [incr anum($ax)] {
-                        1 { set axis $ax }
-                        2 { set axis ${ax}2 }
-                        default {
-                            set axis $ax$anum($ax)
-                            catch {$g axis create $axis}
-                        }
-                    }
-                    $g axis configure $axis -title $label -hide no \
-                        -checklimits no
-                    set _label2axis($ax-$label) $axis
-
-                    # if this axis has a description, add it as a tooltip
-                    set desc [string trim [$dataobj hints ${ax}desc]]
-                    Rappture::Tooltip::text $g-$axis $desc
-                }
-            }
-        }
-    }
-
-    #
-    # All of the extra axes get mapped to the x2/y2 (top/right)
-    # position.
-    #
-    set all ""
-    foreach ax {x y} {
-        lappend all $ax
-
-        set extra ""
-        for {set i 2} {$i <= $anum($ax)} {incr i} {
-            lappend extra ${ax}$i
-        }
-        eval lappend all $extra
-        $g ${ax}2axis use $extra
-        if {$ax == "y"} {
-            $g configure -rightmargin [expr {($extra == "") ? 10 : 0}]
-        }
-    }
-
-    foreach axis $all {
-        set _axisPopup(format-$axis) "%.6g"
-        $g axis bind $axis <Enter> \
-            [itcl::code $this Axis hilite $axis on]
-        $g axis bind $axis <Leave> \
-            [itcl::code $this Axis hilite $axis off]
-        $g axis bind $axis <ButtonPress-1> \
-            [itcl::code $this Axis click $axis %x %y]
-        $g axis bind $axis <B1-Motion> \
-            [itcl::code $this Axis drag $axis %x %y]
-        $g axis bind $axis <ButtonRelease-1> \
-            [itcl::code $this Axis release $axis %x %y]
-        $g axis bind $axis <KeyPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-    }
-    set invert 0
-    array unset _xlabels
-    #
-    # Plot all of the dataobjs.
-    #
-    set count 0
-    foreach dataobj $_dlist {
-        set label [$dataobj hints label]
-        foreach {mapx mapy} [GetAxes $dataobj] break
-        foreach comp [$dataobj components] {
-            set xv [$dataobj mesh $comp]
-            set yv [$dataobj values $comp]
-            set zv [$dataobj widths $comp]
-            if {$xv eq "" || $yv eq "" || $zv eq ""} {
-                continue
-            }
-            if {[info exists _dataobj2color($dataobj)]} {
-                set color $_dataobj2color($dataobj)
-            } else {
-                set color [$dataobj hints color]
-                if {"" == $color} {
-                    set color black
-                }
-            }
-            if {[info exists _dataobj2width($dataobj)]} {
-                set lwidth $_dataobj2width($dataobj)
-            } else {
-                set lwidth 2
-            }
-            if {[info exists _dataobj2dashes($dataobj)]} {
-                set dashes $_dataobj2dashes($dataobj)
-            } else {
-                set dashes ""
-            }
-            if {([$xv length] <= 1) || ($lwidth == 0)} {
-                set sym square
-                set pixels 2
-            } else {
-                set sym ""
-                set pixels 6
-            }
-            # Compute default bar width for histogram elements.
-            if { [$zv length] == [$xv length] } {
-                if { [$xv length] > 0 && [$yv length] > 0 } {
-                    set xvalues [$xv range 0 end]
-                    set yvalues [$yv range 0 end]
-                    set zvalues [$zv range 0 end]
-                    foreach x $xvalues y $yvalues z $zvalues {
-                        set elem "elem[incr count]"
-                        set _elem2dataobj($elem) $dataobj
-                        $g element create $elem -x $x -y $y -barwidth $z \
-                            -label $label -foreground $color \
-                            -mapx $mapx -mapy $mapy
-                    }
-                }
-            } else {
-                set r [blt::vector expr {max($xv) - min($xv)}]
-                set length [$xv length]
-                if { $length > 1 } {
-                    set z [expr {$r / ([$xv length]-1) * 0.8}]
-                } else {
-                    set z 1
-                }
-                set elem "elem[incr count]"
-                set _elem2dataobj($elem) $dataobj
-                $g element create $elem -x $xv -y $yv -barwidth $z \
-                    -label $label -foreground $color \
-                    -mapx $mapx -mapy $mapy
-            }
-            set index 0
-            foreach label [$dataobj xlabels $comp] {
-                if  { [string length $label] > 6 } {
-                    set invert 1
-                }
-                set _xlabels($index) $label
-                incr index
-            }
-        }
-    }
-    foreach dataobj $_dlist {
-        set xmin -Inf
-        set ymin -Inf
-        set xmax Inf
-        set ymax Inf
-        #
-        # Create text/line markers for each *axis.marker specified.
-        #
-        foreach m [$dataobj xmarkers] {
-            foreach {at label style} $m break
-            set id [$g marker create line -coords [list $at $ymin $at $ymax]]
-            $g marker bind $id <Enter> \
-                [itcl::code $this EnterMarker $g x-$label $at $ymin $at]
-            $g marker bind $id <Leave> \
-                [itcl::code $this LeaveMarker $g x-$label]
-            set options [GetLineMarkerOptions $style]
-            if { $options != "" } {
-                eval $g marker configure $id $options
-            }
-            if { $label != "" } {
-                set id [$g marker create text -anchor nw \
-                            -text $label -coords [list $at $ymax]]
-                set options [GetTextMarkerOptions $style]
-                if { $options != "" } {
-                    eval $g marker configure $id $options
-                }
-            }
-        }
-        foreach m [$dataobj ymarkers] {
-            foreach {at label style} $m break
-            set id [$g marker create line -coords [list $xmin $at $xmax $at]]
-            $g marker bind $id <Enter> \
-                [itcl::code $this EnterMarker $g y-$label $at $xmin $at]
-            $g marker bind $id <Leave> \
-                [itcl::code $this LeaveMarker $g y-$label]
-            set options [GetLineMarkerOptions $style]
-            if { $options != "" } {
-                eval $g marker configure $id $options
-            }
-            if { $label != "" } {
-                set id [$g marker create text -anchor se \
-                        -text $label -coords [list $xmax $at]]
-                set options [GetTextMarkerOptions $style]
-                if { $options != "" } {
-                    eval $g marker configure $id $options
-                }
-            }
-        }
-    }
-    set stepsize 1.0
-    if { [array size _xlabels] > 0 } {
-        set command [itcl::code $this FormatLabels]
-        if { [array size _xlabels] > 20 } {
-           set stepsize 0.0
-        }
-    } else {
-        set command ""
-    }
-    $g axis configure x -command $command -stepsize $stepsize
-    set xorient [$dataobj hints xorient]
-    if { $xorient == "horizontal" } {
-        set invert 0
-    } elseif { $xorient == "vertical" } {
-        set invert 1
-    }
-    $g configure -invertxy $invert
-    ResetLegend
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ResetLimits
-#
-# Used internally to apply automatic limits to the axes for the
-# current plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::ResetLimits {} {
-    set g $itk_component(plot)
-    foreach axis [$g axis names] {
-        $g axis configure $axis -min "" -max ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::Zoom {option args} {
-    switch -- $option {
-        reset {
-            ResetLimits
-            Rappture::Logger::log histogram zoom -reset
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Hilite <state> <x> <y>
-#
-# Called automatically when the user brushes one of the elements
-# on the plot.  Causes the element to highlight and a tooltip to
-# pop up with element info.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::Hilite {state x y} {
-    set g $itk_component(plot)
-    set elem ""
-
-    # Peek inside of Blt_ZoomStack package to see if we're currently in the
-    # middle of a zoom selection.
-    if {[info exists ::zoomInfo($g,corner)] && $::zoomInfo($g,corner) == "B" } {
-        return;
-    }
-    set tip ""
-    set index ""
-    if {$state == "at"} {
-        set bool [$g element closest $x $y info -along y -halo 1]
-        # Must be in the element.
-        if { $bool } {
-            # for dealing with xy line plots
-            set elem $info(name)
-
-            # Some elements are generated dynamically and therefore will
-            # not have a dataobj object associated with them.
-            set mapx [$g element cget $elem -mapx]
-            set mapy [$g element cget $elem -mapy]
-            if {[info exists _elem2dataobj($elem)]} {
-                foreach {mapx mapy} [GetAxes $_elem2dataobj($elem)] break
-            }
-
-            # search again for an exact point -- this time don't interpolate
-            set tip ""
-            if { $info(name) == $elem} {
-                set x [$g axis transform $mapx $info(x)]
-                set y [$g axis transform $mapy $info(y)]
-                if { [$g cget -invertxy] } {
-                    set tmp $x
-                    set x $y
-                    set y $tmp
-                }
-                 if {[info exists _elem2dataobj($elem)]} {
-                    set dataobj $_elem2dataobj($elem)
-                    set yunits [$dataobj hints yunits]
-                    set xunits [$dataobj hints xunits]
-                } else {
-                    set xunits ""
-                    set yunits ""
-                }
-                set tip [$g element cget $elem -label]
-                set yval [Axis format y dummy $info(y)]
-                append tip "\n$yval$yunits"
-                set xval [Axis format x dummy $info(x)]
-                append tip " @ $xval"
-                set tip [string trim $tip]
-                set index $info(index)
-            }
-            set state 1
-        } else {
-            set bool [$g element closest $x $y info -interpolate no -along y]
-            if { $bool } {
-                # for dealing with xy scatter plot
-                set elem $info(name)
-                # Some elements are generated dynamically and therefore will
-                # not have a dataobj object associated with them.
-                set mapx [$g element cget $elem -mapx]
-                set mapy [$g element cget $elem -mapy]
-                if {[info exists _elem2dataobj($elem)]} {
-                    foreach {mapx mapy} [GetAxes $_elem2dataobj($elem)] break
-                }
-                set tip ""
-                set x [$g axis transform $mapx $info(x)]
-                set y [$g axis transform $mapy $info(y)]
-                if { [$g cget -invertxy] } {
-                    set tmp $x
-                    set x $y
-                    set y $tmp
-                }
-               if {[info exists _elem2dataobj($elem)]} {
-                    set dataobj $_elem2dataobj($elem)
-                    set yunits [$dataobj hints yunits]
-                    set xunits [$dataobj hints xunits]
-                } else {
-                    set xunits ""
-                    set yunits ""
-                }
-                set tip [$g element cget $elem -label]
-                set yval [Axis format y dummy $info(y)]
-                append tip "\n$yval$yunits"
-                set xval [Axis format x dummy $info(x)]
-                append tip " @ $xval"
-                set tip [string trim $tip]
-                set index $info(index)
-                set state 1
-            } else {
-                set state 0
-            }
-        }
-    }
-
-    if {$state} {
-        #
-        # Highlight ON:
-        # - activate trace
-        # - multiple axes? dim other axes
-        # - pop up tooltip about data
-        #
-        if { [$g element exists $_hilite(elem)] && $_hilite(elem) != $elem } {
-            $g element deactivate $_hilite(elem)
-            $g crosshairs configure -hide yes
-            Rappture::Tooltip::tooltip cancel
-        }
-        if { $index != "" } {
-            $g element activate $elem $index
-            set _hilite(index) $index
-        }
-        set _hilite(elem) $elem
-
-        set mapx [$g element cget $elem -mapx]
-        set mapy [$g element cget $elem -mapy]
-        if {[info exists _elem2dataobj($elem)]} {
-            foreach {mapx mapy} [GetAxes $_elem2dataobj($elem)] break
-        }
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;# fix main x-axis too
-            foreach axis $allx {
-                if {$axis == $mapx} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;# fix main y-axis too
-            foreach axis $ally {
-                if {$axis == $mapy} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-
-        if {"" != $tip} {
-            $g crosshairs configure -hide no -position @$x,$y
-
-            if {$x > 0.5*[winfo width $g]} {
-                if {$x < 4} {
-                    set tipx "-0"
-                } else {
-                    set tipx "-[expr {$x-20}]"  ;# move tooltip to the left
-                }
-            } else {
-                if {$x < -4} {
-                    set tipx "+0"
-                } else {
-                    set tipx "+[expr {$x+20}]"  ;# move tooltip to the right
-                }
-            }
-            if {$y > 0.5*[winfo height $g]} {
-                if {$y < 4} {
-                    set tipy "-0"
-                } else {
-                    set tipy "-[expr {$y-20}]"  ;# move tooltip to the top
-                }
-            } else {
-                if {$y < -4} {
-                    set tipy "+0"
-                } else {
-                    set tipy "+[expr {$y+20}]"  ;# move tooltip to the bottom
-                }
-            }
-            Rappture::Tooltip::text $g $tip
-            Rappture::Tooltip::tooltip show $g $tipx,$tipy
-            Rappture::Logger::log tooltip -for "histogram probe -- [string map [list \n " // "] $tip]"
-        }
-    } else {
-        #
-        # Highlight OFF:
-        # - deactivate (color back to normal)
-        # - put all axes back to normal color
-        # - take down tooltip
-        #
-        if { [$g element exists $_hilite(elem)] } {
-            $g element deactivate $_hilite(elem)
-        }
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;# fix main x-axis too
-            foreach axis $allx {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;# fix main y-axis too
-            foreach axis $ally {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        $g crosshairs configure -hide yes
-
-        # only cancel in plotting area or we'll mess up axes
-        if {[$g inside $x $y]} {
-            Rappture::Tooltip::tooltip cancel
-        }
-
-        # There is no currently highlighted element
-        set _hilite(elem) ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Axis hilite <axis> <state>
-#
-# USAGE: Axis click <axis> <x> <y>
-# USAGE: Axis drag <axis> <x> <y>
-# USAGE: Axis release <axis> <x> <y>
-#
-# USAGE: Axis edit <axis>
-# USAGE: Axis changed <axis> <what>
-# USAGE: Axis format <axis> <widget> <value>
-# USAGE: Axis scale <axis> linear|log
-#
-# Used internally to handle editing of the x/y axes.  The hilite
-# operation causes the axis to light up.  The edit operation pops
-# up a panel with editing options.  The changed operation applies
-# changes from the panel.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::Axis {option args} {
-    set inner [$itk_component(hull).axes component inner]
-
-    switch -- $option {
-        hilite {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Axis hilite axis state\""
-            }
-            set g $itk_component(plot)
-            set axis [lindex $args 0]
-            set state [lindex $args 1]
-
-            if {$state} {
-                $g axis configure $axis \
-                    -color $itk_option(-activecolor) \
-                    -titlecolor $itk_option(-activecolor)
-                set x [expr {[winfo pointerx $g]+4}]
-                set y [expr {[winfo pointery $g]+4}]
-                Rappture::Tooltip::tooltip pending $g-$axis @$x,$y
-            } else {
-                $g axis configure $axis \
-                    -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-                Rappture::Tooltip::tooltip cancel
-            }
-        }
-        click {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis click axis x y\""
-            }
-            foreach { axis x y } $args break
-            set g $itk_component(plot)
-            if { [$g cget -invertxy] } {
-                set tmp $x
-                set x $y
-                set y $tmp
-            }
-
-            set _axis(moved) 0
-            set _axis(click-x) $x
-            set _axis(click-y) $y
-            foreach {min max} [$g axis limits $axis] break
-            set _axis(min0) $min
-            set _axis(max0) $max
-            Rappture::Tooltip::tooltip cancel
-        }
-        drag {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis drag axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            foreach { axis x y } $args break
-            set g $itk_component(plot)
-            if { [$g cget -invertxy] } {
-                set tmp $x
-                set x $y
-                set y $tmp
-            }
-
-            if {[info exists _axis(click-x)] && [info exists _axis(click-y)]} {
-                foreach {x0 y0 pw ph} [$g extents plotarea] break
-                switch -glob $axis {
-                  x* {
-                    set pix $x
-                    set pix0 $_axis(click-x)
-                    set pixmin $x0
-                    set pixmax [expr {$x0+$pw}]
-                  }
-                  y* {
-                    set pix $y
-                    set pix0 $_axis(click-y)
-                    set pixmin [expr {$y0+$ph}]
-                    set pixmax $y0
-                  }
-                }
-                set log [$g axis cget $axis -logscale]
-                set min $_axis(min0)
-                set max $_axis(max0)
-                set dpix [expr {abs($pix-$pix0)}]
-                set v0 [$g axis invtransform $axis $pixmin]
-                set v1 [$g axis invtransform $axis [expr {$pixmin+$dpix}]]
-                if {$log} {
-                    set v0 [expr {log10($v0)}]
-                    set v1 [expr {log10($v1)}]
-                    set min [expr {log10($min)}]
-                    set max [expr {log10($max)}]
-                }
-
-                if {$pix > $pix0} {
-                    set delta [expr {$v1-$v0}]
-                } else {
-                    set delta [expr {$v0-$v1}]
-                }
-                set min [expr {$min-$delta}]
-                set max [expr {$max-$delta}]
-                if {$log} {
-                    set min [expr {pow(10.0,$min)}]
-                    set max [expr {pow(10.0,$max)}]
-                }
-                $g axis configure $axis -min $min -max $max
-
-                # move axis, don't edit on release
-                set _axis(move) 1
-            }
-        }
-        release {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis release axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            foreach { axis x y } $args break
-            set g $itk_component(plot)
-            if { [$g cget -invertxy] } {
-                set tmp $x
-                set x $y
-                set y $tmp
-            }
-
-            if {!$_axis(moved)} {
-                # small movement? then treat as click -- pop up axis editor
-                set dx [expr {abs($x-$_axis(click-x))}]
-                set dy [expr {abs($y-$_axis(click-y))}]
-                if {$dx < 2 && $dy < 2} {
-                    Axis edit $axis
-                    return
-                }
-            }
-            # one last movement
-            Axis drag $axis $x $y
-
-            # log this change
-            Rappture::Logger::log histogram axis $axis \
-                -drag [$itk_component(plot) axis limits $axis]
-
-            catch {unset _axis}
-        }
-        edit {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"Axis edit axis\""
-            }
-            set axis [lindex $args 0]
-            set _axisPopup(current) $axis
-
-            # apply last value when deactivating
-            $itk_component(hull).axes configure -deactivatecommand \
-                [itcl::code $this Axis changed $axis focus]
-
-            # fix axis label controls...
-            set label [$itk_component(plot) axis cget $axis -title]
-            $inner.label delete 0 end
-            $inner.label insert end $label
-            bind $inner.label <Return> \
-                [itcl::code $this Axis changed $axis label]
-            bind $inner.label <KP_Enter> \
-                [itcl::code $this Axis changed $axis label]
-            bind $inner.label <FocusOut> \
-                [itcl::code $this Axis changed $axis label]
-
-            # fix min/max controls...
-            foreach {min max} [$itk_component(plot) axis limits $axis] break
-            $inner.min delete 0 end
-            $inner.min insert end $min
-            bind $inner.min <Return> \
-                [itcl::code $this Axis changed $axis min]
-            bind $inner.min <KP_Enter> \
-                [itcl::code $this Axis changed $axis min]
-            bind $inner.min <FocusOut> \
-                [itcl::code $this Axis changed $axis min]
-
-            $inner.max delete 0 end
-            $inner.max insert end $max
-            bind $inner.max <Return> \
-                [itcl::code $this Axis changed $axis max]
-            bind $inner.max <KP_Enter> \
-                [itcl::code $this Axis changed $axis max]
-            bind $inner.max <FocusOut> \
-                [itcl::code $this Axis changed $axis max]
-
-            # fix format control...
-            set fmts [$inner.format choices get -value]
-            set i [lsearch -exact $fmts $_axisPopup(format-$axis)]
-            if {$i < 0} { set i 0 }  ;# use Auto choice
-            $inner.format value [$inner.format choices get -label $i]
-
-            bind $inner.format <<Value>> \
-                [itcl::code $this Axis changed $axis format]
-
-            # fix scale control...
-            if {[$itk_component(plot) axis cget $axis -logscale]} {
-                set _axisPopup(scale) "log"
-                $inner.format configure -state disabled
-            } else {
-                set _axisPopup(scale) "linear"
-                $inner.format configure -state normal
-            }
-            $inner.scales.linear configure \
-                -command [itcl::code $this Axis changed $axis scale]
-            $inner.scales.log configure \
-                -command [itcl::code $this Axis changed $axis scale]
-
-            #
-            # Figure out where the window should pop up.
-            #
-            set x [winfo rootx $itk_component(plot)]
-            set y [winfo rooty $itk_component(plot)]
-            set w [winfo width $itk_component(plot)]
-            set h [winfo height $itk_component(plot)]
-            foreach {x0 y0 pw ph} [$itk_component(plot) extents plotarea] break
-            switch -glob -- $axis {
-                x {
-                    set x [expr {round($x + $x0+0.5*$pw)}]
-                    set y [expr {round($y + $y0+$ph + 0.5*($h-$y0-$ph))}]
-                    set dir "above"
-                }
-                x* {
-                    set x [expr {round($x + $x0+0.5*$pw)}]
-                    set dir "below"
-                    set allx [$itk_component(plot) x2axis use]
-                    set max [llength $allx]
-                    set i [lsearch -exact $allx $axis]
-                    set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-                }
-                y {
-                    set x [expr {round($x + 0.5*$x0)}]
-                    set y [expr {round($y + $y0+0.5*$ph)}]
-                    set dir "right"
-                }
-                y* {
-                    set y [expr {round($y + $y0+0.5*$ph)}]
-                    set dir "left"
-                    set ally [$itk_component(plot) y2axis use]
-                    set max [llength $ally]
-                    set i [lsearch -exact $ally $axis]
-                    set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-                    set x [expr {round($x+$x0+$pw + ($i+0.5)*($w-$x0-$pw)/double($max))}]
-                }
-            }
-            $itk_component(hull).axes activate @$x,$y $dir
-        }
-        changed {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Axis changed axis what\""
-            }
-            set axis [lindex $args 0]
-            set what [lindex $args 1]
-            if {$what == "focus"} {
-                set what [focus]
-                if {[winfo exists $what]} {
-                    set what [winfo name $what]
-                }
-            }
-
-            switch -- $what {
-                label {
-                    set val [$inner.label get]
-                    $itk_component(plot) axis configure $axis -title $val
-                    Rappture::Logger::log histogram axis $axis -title $val
-                }
-                min {
-                    set val [$inner.min get]
-                    if {![string is double -strict $val]} {
-                        Rappture::Tooltip::cue $inner.min "Must be a number"
-                        bell
-                        return
-                    }
-
-                    set max [lindex [$itk_component(plot) axis limits $axis] 1]
-                    if {$val >= $max} {
-                        Rappture::Tooltip::cue $inner.min "Must be <= max ($max)"
-                        bell
-                        return
-                    }
-                    catch {
-                        # can fail in log mode
-                        $itk_component(plot) axis configure $axis -min $val
-                        Rappture::Logger::log histogram axis $axis -min $val
-                    }
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.min delete 0 end
-                    $inner.min insert end $min
-                }
-                max {
-                    set val [$inner.max get]
-                    if {![string is double -strict $val]} {
-                        Rappture::Tooltip::cue $inner.max "Should be a number"
-                        bell
-                        return
-                    }
-
-                    set min [lindex [$itk_component(plot) axis limits $axis] 0]
-                    if {$val <= $min} {
-                        Rappture::Tooltip::cue $inner.max "Must be >= min ($min)"
-                        bell
-                        return
-                    }
-                    catch {
-                        # can fail in log mode
-                        $itk_component(plot) axis configure $axis -max $val
-                        Rappture::Logger::log histogram axis $axis -max $val
-                    }
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.max delete 0 end
-                    $inner.max insert end $max
-                }
-                format {
-                    set fmt [$inner.format translate [$inner.format value]]
-                    set _axisPopup(format-$axis) $fmt
-
-                    # force a refresh
-                    $itk_component(plot) axis configure $axis -min \
-                        [$itk_component(plot) axis cget $axis -min]
-                }
-                scale {
-                    Axis scale $axis $_axisPopup(scale)
-                    Rappture::Logger::log histogram axis $axis -scale $_axisPopup(scale)
-
-                    if {$_axisPopup(scale) == "log"} {
-                        $inner.format configure -state disabled
-                    } else {
-                        $inner.format configure -state normal
-                    }
-
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.min delete 0 end
-                    $inner.min insert end $min
-                    $inner.max delete 0 end
-                    $inner.max insert end $max
-                }
-                default {
-                    # be lenient so we can handle the "focus" case
-                }
-            }
-        }
-        format {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis format axis widget value\""
-            }
-            set axis [lindex $args 0]
-            set value [lindex $args 2]
-            if { $axis == "x" } {
-                return [FormatLabels $itk_component(plot) $value]
-            }
-            if {[$itk_component(plot) axis cget $axis -logscale]} {
-                set fmt "%.6g"
-            } else {
-                set fmt $_axisPopup(format-$axis)
-            }
-            return [format $fmt $value]
-        }
-        scale {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Axis scale axis type\""
-            }
-            set axis [lindex $args 0]
-            set type [lindex $args 1]
-
-            if {$type == "log"} {
-                catch {$itk_component(plot) axis configure $axis -logscale 1}
-                # leave format alone in log mode
-                $itk_component(plot) axis configure $axis -command ""
-            } else {
-                catch {$itk_component(plot) axis configure $axis -logscale 0}
-                # use special formatting for linear mode
-                $itk_component(plot) axis configure $axis -command \
-                    [itcl::code $this Axis format $axis]
-            }
-        }
-        default {
-            error "bad option \"$option\": should be changed, edit, hilite, or format"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetLineMarkerOptions <style>
-#
-# Used internally to create a list of configuration options specific to the
-# axis line marker.  The input is a list of name value pairs.  Options that
-# are not recognized are ignored.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::GetLineMarkerOptions {style} {
-    array set lineOptions {
-        "-color"  "-outline"
-        "-dashes" "-dashes"
-        "-linecolor" "-outline"
-        "-linewidth" "-linewidth"
-    }
-    set options {}
-    foreach {name value} $style {
-        if { [info exists lineOptions($name)] } {
-            lappend options $lineOptions($name) $value
-        }
-    }
-    return $options
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetTextMarkerOptions <style>
-#
-# Used internally to create a list of configuration options specific to the
-# axis text marker.  The input is a list of name value pairs.  Options that
-# are not recognized are ignored.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::GetTextMarkerOptions {style} {
-    array set textOptions {
-        "-color"  "-outline"
-        "-textcolor"  "-outline"
-        "-font"   "-font"
-        "-xoffset" "-xoffset"
-        "-yoffset" "-yoffset"
-        "-anchor" "-anchor"
-        "-rotate" "-rotate"
-    }
-    set options {}
-    foreach {name value} $style {
-        if { [info exists textOptions($name)] } {
-            lappend options $textOptions($name) $value
-        }
-    }
-    return $options
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetAxes <dataobj>
-#
-# Used internally to figure out the axes used to plot the given
-# <dataobj>.  Returns a list of the form {x y}, where x is the
-# x-axis name (x, x2, x3, etc.), and y is the y-axis name.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HistogramResult::GetAxes {dataobj} {
-    # rebuild if needed, so we know about the axes
-    if {[$_dispatcher ispending !rebuild]} {
-        $_dispatcher cancel !rebuild
-        $_dispatcher event -now !rebuild
-    }
-
-    # what is the x axis?  x? x2? x3? ...
-    set xlabel [$dataobj hints xlabel]
-    if {[info exists _label2axis(x-$xlabel)]} {
-        set mapx $_label2axis(x-$xlabel)
-    } else {
-        set mapx "x"
-    }
-
-    # what is the y axis?  y? y2? y3? ...
-    set ylabel [$dataobj hints ylabel]
-    if {[info exists _label2axis(y-$ylabel)]} {
-        set mapy $_label2axis(y-$ylabel)
-    } else {
-        set mapy "y"
-    }
-
-    return [list $mapx $mapy]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -gridcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HistogramResult::gridcolor {
-    if {"" == $itk_option(-gridcolor)} {
-        $itk_component(plot) grid off
-    } else {
-        $itk_component(plot) grid configure -color $itk_option(-gridcolor)
-        $itk_component(plot) grid on
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -autocolors
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HistogramResult::autocolors {
-    foreach c $itk_option(-autocolors) {
-        if {[catch {winfo rgb $itk_component(hull) $c}]} {
-            error "bad color \"$c\""
-        }
-    }
-    if {$_autoColorI >= [llength $itk_option(-autocolors)]} {
-        set _autoColorI 0
-    }
-}
-
-itcl::body Rappture::HistogramResult::EnterMarker { g name x y text } {
-    LeaveMarker $g $name
-    set id [$g marker create text \
-                -coords [list $x $y] \
-                -anchor n \
-                -text $text]
-    set _markers($name) $id
-}
-
-itcl::body Rappture::HistogramResult::LeaveMarker { g name } {
-    if { [info exists _markers($name)] } {
-        set id $_markers($name)
-        $g marker delete $id
-        unset _markers($name)
-    }
-}
-
-
-itcl::body Rappture::HistogramResult::FormatLabels { w value } {
-    # Determine the element name from the value
-    set index [expr round($value)]
-    set d [expr abs($value - $index)]
-    # Ignore values that aren't close to the integer value
-    if { $d < 0.00000001 } {
-        if { [info exists _xlabels($index)] } {
-            return $_xlabels($index)
-        }
-    }
-    return " "
-}
-
-#
-# ResetLegend --
-#
-itcl::body Rappture::HistogramResult::ResetLegend {} {
-    set g $itk_component(plot)
-    update idletasks
-    $itk_component(legend) reset [$g element show]
-}
Index: trunk/gui/scripts/htmlviewer.tcl
===================================================================
--- trunk/gui/scripts/htmlviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,440 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: htmlviewer - easy way to display HTML text
-#
-#  This is a thin layer on top of the Tkhtml widget.  It makes it
-#  easier to load HTML text and render it with proper behaviors.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require Tkhtml
-package require Img
-
-option add *HTMLviewer.width 3i widgetDefault
-option add *HTMLviewer.height 0 widgetDefault
-option add *HTMLviewer.maxLines 4 widgetDefault
-
-itcl::class Rappture::HTMLviewer {
-    inherit itk::Widget
-
-    itk_option define -foreground foreground Foreground black
-    itk_option define -background background Background white
-    itk_option define -linknormalcolor linkNormalColor LinkColor blue
-    itk_option define -linkactivecolor linkActiveColor LinkColor black
-    itk_option define -linkactivebackground linkActiveBackground LinkActiveBackground #cccccc
-    itk_option define -xscrollcommand xScrollCommand XScrollCommand ""
-    itk_option define -yscrollcommand yScrollCommand YScrollCommand ""
-    itk_option define -width width Width 0
-    itk_option define -height height Height 0
-    itk_option define -maxlines maxLines MaxLines 0
-
-    constructor {args} { # defined below }
-
-    public method load {htmlText args}
-    public method add {htmlText args}
-    public method followLink {url}
-
-    # this widget works with scrollbars
-    public method xview {args} { eval $itk_component(html) xview $args }
-    public method yview {args} { eval $itk_component(html) yview $args }
-
-    protected method _config {args}
-    private variable _dispatcher "" ;# dispatcher for !events
-
-    protected method _fixHeight {args}
-    private variable _linesize ""   ;# height of default font size
-
-    protected method _mouse {option x y}
-    private variable _hover ""   ;# list of nodes that mouse is hovering over
-
-    protected method _getImage {file}
-    protected method _freeImage {file}
-    private common _file2icon        ;# maps file name => image handle
-    private common _icon2file        ;# maps image handle => file name
-    private variable _dirlist "" ;# list of directories where HTML came from
-}
-
-itk::usual HTMLviewer {
-    keep -cursor
-    keep -foreground -background
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::HTMLviewer::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !config
-    $_dispatcher dispatch $this !config [itcl::code $this _config]
-    $_dispatcher register !fixHeight
-    $_dispatcher dispatch $this !fixHeight [itcl::code $this _fixHeight]
-
-    itk_component add html {
-        html $itk_interior.html -imagecmd [itcl::code $this _getImage]
-    } {
-        # no real options to work with for this widget
-    }
-    pack $itk_component(html) -expand yes -fill both
-
-    bind $itk_component(html) <Motion> \
-        [itcl::code $this _mouse over %x %y]
-    bind $itk_component(html) <ButtonPress-1> \
-        [itcl::code $this _mouse over %x %y]
-    bind $itk_component(html) <ButtonRelease-1> \
-        [itcl::code $this _mouse release %x %y]
-
-    # measure the default font height
-    $itk_component(html) reset
-    $itk_component(html) parse -final "Testing"
-    set node [$itk_component(html) node]
-    foreach {x0 y0 x1 y1} [$itk_component(html) bbox $node] break
-    set _linesize [expr {$y1-$y0}]
-    $itk_component(html) reset
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load <htmlText> ?-in <fileName>?
-#
-# Clients use this to clear the contents and load a new string of
-# <htmlText>.  If the text is empty, this has the effect of clearing
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HTMLviewer::load {htmlText args} {
-    Rappture::getopts args params {
-        value -in ""
-    }
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"load text ?-in name?\""
-    }
-
-    $itk_component(html) reset
-    set _hover ""
-    set _dirlist ""
-
-    $itk_component(html) parse $htmlText
-
-    if {"" != $params(-in) && [file exists $params(-in)]} {
-        if {[file isdirectory $params(-in)]} {
-            lappend _dirlist $params(-in)
-        } else {
-            lappend _dirlist [file dirname $params(-in)]
-        }
-    }
-    $_dispatcher event -now !config
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <htmlText> ?-in <fileName>?
-#
-# Clients use this to add the <htmlText> to the bottom of the contents
-# being displayed in the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HTMLviewer::add {htmlText args} {
-    Rappture::getopts args params {
-        value -in ""
-    }
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"add text ?-in name?\""
-    }
-
-    $itk_component(html) parse $htmlText
-
-    if {"" != $params(-in) && [file exists $params(-in)]} {
-        if {[file isdirectory $params(-in)]} {
-            lappend _dirlist $params(-in)
-        } else {
-            lappend _dirlist [file dirname $params(-in)]
-        }
-    }
-    $_dispatcher event -now !config
-}
-
-# ----------------------------------------------------------------------
-# USAGE: followLink <url>
-#
-# Invoked automatically whenever the user clicks on a link within
-# an HTML page.  Tries to follow the <url> by invoking "exportfile"
-# to pop up further information.  If the <url> starts with http://
-# or https://, then it is used directly.  Otherwise, it is treated
-# as a relative file path and resolved with respect to the -in
-# options passed into load/add.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HTMLviewer::followLink {url} {
-    if {[regexp -nocase {^https?://} $url]} {
-        foreach prog {
-                clientaction
-                /apps/bin/clientaction
-                /apps/xvnc/bin/clientaction
-                /usr/lib/mw/bin/clientaction
-                ""
-        } {
-            if {"" != [auto_execok $prog]} {
-                break
-            }
-        }
-        if {"" != $prog} {
-            exec $prog url $url &
-        } else {
-            bell
-        }
-        return
-    }
-
-    # must be a file -- use exportfile
-    set url [string trimleft $url /]
-    set path ""
-    foreach dir $_dirlist {
-        if {[file readable [file join $dir $url]]} {
-            set path [file join $dir $url]
-            break
-        }
-    }
-
-    foreach prog {exportfile /apps/bin/exportfile ""} {
-        if {"" != [auto_execok $prog]} {
-            break
-        }
-    }
-    if {"" != $path && "" != $prog} {
-        exec $prog --format html $path &
-    } else {
-        bell
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _mouse over <x> <y>
-# USAGE: _mouse release <x> <y>
-#
-# Invoked automatically as the mouse pointer moves around or otherwise
-# interacts with this widget.  When the mouse is over a link, the link
-# becomes annotated with the "hover" style, so it can be highlighted.
-# Clicking and releasing on the same link invokes the action associated
-# with the link.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HTMLviewer::_mouse {option x y} {
-    switch -- $option {
-        over {
-            # get a list of nodes with tags we care about
-            set nlist ""
-            foreach node [$itk_component(html) node $x $y] {
-                while {"" != $node} {
-                    if {[$node tag] == "a"} {
-                        lappend nlist $node
-                        break
-                    }
-                    set node [$node parent]
-                }
-            }
-
-            # over something new? then tag it with "hover"
-            if {$nlist != $_hover} {
-                foreach node $_hover {
-                    catch {$node dynamic clear hover}
-                }
-                set _hover $nlist
-                foreach node $_hover {
-                    catch {$node dynamic set hover}
-                }
-            }
-        }
-        release {
-            set prev $_hover
-            _mouse over $x $y
-
-            # mouse release on same node as mouse click? then follow link
-            if {$prev == $_hover} {
-                foreach node $_hover {
-                    if {[$node tag] == "a"} {
-                        followLink [$node attr -default {} href]
-                    }
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be over or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _config <arg> <arg>...
-#
-# Invoked automatically whenever the style-related configuration
-# options change for this widget.  Changes the main style sheet to
-# configure the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HTMLviewer::_config {args} {
-    component html style -id "author" "
-      body {
-        background: $itk_option(-background);
-        color: $itk_option(-foreground);
-        font: 12px helvetica,arial;
-      }
-      a {
-        color: $itk_option(-linknormalcolor);
-        text-decoration: underline;
-      }
-      a:hover {
-        color: $itk_option(-linkactivecolor);
-        background: $itk_option(-linkactivebackground);
-      }
-    "
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixHeight <arg> <arg>...
-#
-# Invoked automatically whenever the height-related configuration
-# options change for this widget.  If -height is set to 0, then this
-# routine figures out a good height for the widget based on -maxlines.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HTMLviewer::_fixHeight {args} {
-    set ht [winfo pixels $itk_component(html) $itk_option(-height)]
-    if {$ht <= 0} {
-        # figure out a good size automatically
-        set realht [winfo pixels $itk_component(html) 1i]
-        set node [$itk_component(html) node]
-        if {"" != $node} {
-            set bbox [$itk_component(html) bbox $node]
-            if { [llength $bbox] == 4 } {
-                set realht [expr {[lindex $bbox 3]-[lindex $bbox 1]}]
-            }
-        }
-        if {$itk_option(-maxlines) > 0} {
-            set ht [expr {$itk_option(-maxlines)*$_linesize}]
-            if {$realht < $ht} {
-                set ht $realht
-            }
-        } else {
-            set ht $realht
-        }
-    }
-    $itk_component(html) configure -height $ht
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getImage <fileName>
-#
-# Used internally to convert a <fileName> to its corresponding image
-# handle.  If the <fileName> is relative, then it is loaded with
-# respect to the paths given by the -in option for the load/add
-# methods.  Returns an image handle for the image within the file,
-# or the broken image icon if anything goes wrong.
-# ----------------------------------------------------------------------
-itcl::body Rappture::HTMLviewer::_getImage {fileName} {
-    if {[info exists _file2icon($fileName)]} {
-        set imh $_file2icon($fileName)
-        return [list $imh [itcl::code $this _freeImage]]
-    }
-
-    set searchlist $fileName
-    if {[file pathtype $fileName] != "absolute"} {
-        foreach dir $_dirlist {
-            lappend searchlist [file join $dir $fileName]
-        }
-    }
-
-    foreach name $searchlist {
-        if {[catch {image create photo -file $name} imh] == 0} {
-            set _file2icon($fileName) $imh
-            set _icon2file($imh) $fileName
-            return [list $imh [itcl::code $this _freeImage]]
-        }
-    }
-    puts stderr "Problem in your html: image \"$fileName\" does not exist"
-    # The htmlwidget assumes it owns the image and will delete it.
-    # Always create a copy of the image.
-    set img [Rappture::icon exclaim]
-    set file [$img cget -file]
-    set img [image create photo -file $file]
-    return $img
-}
-
-itcl::body Rappture::HTMLviewer::_freeImage { imh } {
-    if {[info exists _icon2file($imh)]} {
-        image delete $imh
-        set fileName $_icon2file($imh)
-        unset _icon2file($imh)
-        unset _file2icon($fileName)
-    }
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -background
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::background {
-    $_dispatcher event -idle !config
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -foreground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::foreground {
-    $_dispatcher event -idle !config
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -linknormalcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::linknormalcolor {
-    $_dispatcher event -idle !config
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -linkactivecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::linkactivecolor {
-    $_dispatcher event -idle !config
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -linkactivebackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::linkactivebackground {
-    $_dispatcher event -idle !config
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -xscrollcommand
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::xscrollcommand {
-    $itk_component(html) configure -xscrollcommand $itk_option(-xscrollcommand)
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -yscrollcommand
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::yscrollcommand {
-    $itk_component(html) configure -yscrollcommand $itk_option(-yscrollcommand)
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -width
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::width {
-    $itk_component(html) configure -width $itk_option(-width)
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -maxlines
-# Sets the maximum number of lines for widgets with "-height 0"
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::maxlines {
-    $_dispatcher event -idle !fixHeight
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -height
-# Set to absolute size ("3i") or 0 for default size based on -maxlines.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::HTMLviewer::height {
-    $_dispatcher event -idle !fixHeight
-}
Index: trunk/gui/scripts/icons.tcl
===================================================================
--- trunk/gui/scripts/icons.tcl	(revision 6716)
+++ 	(revision )
@@ -1,397 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: icons - utility for loading icons from a library
-#
-#  This utility makes it easy to load GIF and XBM files installed
-#  in a library in the final installation.  It is used throughout
-#  the Rappture GUI, whenever an icon is needed.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-package require BLT
-
-namespace eval Rappture::icon {
-    variable iconpath [list [file join $RapptureGUI::library scripts images]]
-    variable icons
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::searchpath ?<dirname> <dirname>...?
-#
-# Adds one or more directories onto the icon path searched when
-# locating icons in Rappture::icon.  You can do the same thing by
-# lappend'ing onto the "iconpath" variable, but this call avoids
-# duplicates and makes it easier
-# ----------------------------------------------------------------------
-proc Rappture::icon::searchpath {args} {
-    variable iconpath
-    foreach dir $args {
-        if {[file isdirectory $dir]} {
-            if {[lsearch $iconpath $dir] < 0} {
-                lappend iconpath $dir
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon <name>
-#
-# Searches for an icon called <name> on all of the directories in
-# the search path set up by RapptureGUI::iconpath.
-# ----------------------------------------------------------------------
-proc Rappture::icon {name} {
-    variable ::Rappture::icon::iconpath
-    variable ::Rappture::icon::icons
-
-    #
-    # Already loaded? then return it directly
-    #
-    if {[info exists icons($name)]} {
-        return $icons($name)
-    }
-
-    #
-    # Search for the icon along the iconpath search path
-    #
-    set file ""
-    foreach dir $iconpath {
-        set path [file join $dir $name.*]
-        set file [lindex [glob -nocomplain $path] 0]
-        if {"" != $file} {
-            break
-        }
-    }
-
-    set imh ""
-    if {"" != $file} {
-        switch -- [file extension $file] {
-            .gif - .jpg - .png {
-                set imh [image create photo -file $file]
-            }
-            .xbm {
-                set fid [open $file r]
-                set data [read $fid]
-                close $fid
-                set imh bitmap-$name
-                blt::bitmap define $imh $data
-            }
-        }
-    }
-    if {"" != $imh} {
-        set icons($name) $imh
-    }
-    return $imh
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::data <image> ?<format>?
-#
-# Returns the bytes the represent an <image> in the requested
-# <format>, which can get "gif" or "jpeg".
-# ----------------------------------------------------------------------
-proc Rappture::icon::data {image {format "gif"}} {
-    if {[catch {$image data -format $format} result]} {
-        if {"too many colors" == $result && "" != [auto_execok djpeg]} {
-            #
-            # HACK ALERT!  We should use "blt::winop quantize" to
-            #   reduce the number of colors for GIF format.  But
-            #   it has a bug right now, so we work around it like this.
-            #
-            set tmpfile /tmp/image[pid].dat
-            $image write $tmpfile -format "jpeg -quality 100"
-            set fid [open "| djpeg -gif -quantize 250 $tmpfile" r]
-            fconfigure $fid -encoding binary -translation binary
-            set result [read $fid]
-            close $fid
-            file delete -force $tmpfile
-        } else {
-            set result ""
-        }
-    }
-    return $result
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::gif_animate <delay> ?<image> <image>...?
-#
-# Takes a series if <images> and composited them into a single,
-# animated GIF image, with the <delay> in milliseconds between
-# frames.  Returns binary data in GIF89a format.
-# ----------------------------------------------------------------------
-proc Rappture::icon::gif_animate {delay args} {
-    if {[llength $args] < 1} {
-        error "must have at least one image for animation"
-    }
-    set delay [expr {round($delay*0.01)}] ;# convert to 1/100s of second
-
-    set imh [lindex $args 0]
-    set bytes [data $imh gif]
-    if {[string length $bytes] == 0} {
-        return ""  ;# can't query image data -- bail out!
-    }
-    gif_parse $bytes first
-
-    set final "GIF89a"
-    gif_put_short final $first(screen-w)
-    gif_put_short final $first(screen-h)
-    gif_put_byte final $first(screen-packed)
-    gif_put_byte final $first(screen-bg)
-    gif_put_byte final $first(screen-aspect)
-    gif_put_block final $first(colors)
-
-    gif_put_byte final 0x21  ;# looping block
-    gif_put_byte final 0xFF
-    gif_put_byte final 11
-    gif_put_block final "NETSCAPE2.0"
-    gif_put_byte final 3     ;# 3 bytes in this block
-    gif_put_byte final 1     ;# turn looping on
-    gif_put_short final 0    ;# number of loops (forever)
-    gif_put_byte final 0     ;# block terminator
-
-    gif_put_byte final 0x21  ;# graphic control block
-    gif_put_byte final 0xF9
-    gif_put_byte final 4     ;# 4 bytes in this block
-    gif_put_byte final 0     ;# packed bits
-    gif_put_short final [expr {5*$delay}]  ;# delay time *0.01s
-    gif_put_byte final 0     ;# transparency index
-    gif_put_byte final 0     ;# block terminator
-
-    gif_put_byte final 0x2C  ;# image block
-    gif_put_short final $first(im-0-left)
-    gif_put_short final $first(im-0-top)
-    gif_put_short final $first(im-0-wd)
-    gif_put_short final $first(im-0-ht)
-    gif_put_byte final $first(im-0-packed)
-    if {($first(im-0-packed) & 0x80) != 0} {
-        gif_put_block final $first(im-0-colors)
-    }
-    gif_put_block final $first(im-0-data)
-
-    foreach imh [lrange $args 1 end] {
-        catch {unset gif}
-        gif_parse [data $imh gif] gif
-
-        gif_put_byte final 0x21     ;# graphic control block
-        gif_put_byte final 0xF9
-        gif_put_byte final 4        ;# 4 bytes in this block
-        gif_put_byte final 0        ;# packed bits
-        gif_put_short final $delay  ;# delay time *0.01s
-        gif_put_byte final 0        ;# transparency index
-        gif_put_byte final 0        ;# block terminator
-
-        gif_put_byte final 0x2C     ;# image block
-        gif_put_short final $gif(im-0-left)
-        gif_put_short final $gif(im-0-top)
-        gif_put_short final $gif(im-0-wd)
-        gif_put_short final $gif(im-0-ht)
-
-        if {[string length $gif(im-0-colors)] > 0} {
-            gif_put_byte final $gif(im-0-packed)
-            gif_put_block final $gif(im-0-colors)
-        } else {
-            set packed [expr {($gif(im-0-packed) & 0xF8)
-                | ($gif(screen-packed) & 0x87)}]
-            gif_put_byte final $packed
-            gif_put_block final $gif(colors)
-        }
-        gif_put_block final $gif(im-0-data)
-    }
-
-    gif_put_byte final 0x3B  ;# terminate GIF
-
-    return $final
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::gif_parse <gifImageData> <array>
-#
-# Takes the data from a GIF image, parses it into various components,
-# and returns the information in the <array> in the calling scope.
-# ----------------------------------------------------------------------
-proc Rappture::icon::gif_parse {gifImageData arrayVar} {
-    upvar $arrayVar data
-    if {[string range $gifImageData 0 2] != "GIF"} {
-        error "not GIF data"
-    }
-    set data(version) [string range $gifImageData 0 5]
-    set pos 6
-
-    set data(screen-w) [gif_get_short $gifImageData pos]
-    set data(screen-h) [gif_get_short $gifImageData pos]
-    set data(screen-packed) [gif_get_byte $gifImageData pos]
-    set data(screen-bg) [gif_get_byte $gifImageData pos]
-    set data(screen-aspect) [gif_get_byte $gifImageData pos]
-
-    set ctsize [expr {3*(1 << ($data(screen-packed) & 0x07)+1)}]
-    set data(colors) [gif_get_block $gifImageData pos $ctsize]
-
-    set n 0
-    while {1} {
-        set ctrl [gif_get_byte $gifImageData pos]
-        switch -- [format "0x%02X" $ctrl] {
-          0x21 {
-            set ext [gif_get_byte $gifImageData pos]
-            switch -- [format "0x%02X" $ext] {
-              0xF9 {
-                # graphic control
-                set bsize [gif_get_byte $gifImageData pos]
-                set data(gc-$n-packed) [gif_get_byte $gifImageData pos]
-                set data(gc-$n-delay) [gif_get_short $gifImageData pos]
-                set data(gc-$n-transp) [gif_get_byte $gifImageData pos]
-                set bterm [gif_get_byte $gifImageData pos]
-                if {$bterm != 0} { error "bad magic $bterm" }
-              }
-              0xFE {
-                # comment extension -- skip and ignore
-                while {1} {
-                    set count [gif_get_byte $gifImageData pos]
-                    if {$count == 0} {
-                        break
-                    }
-                    incr pos $count
-                }
-              }
-              0xFF {
-                set bsize [gif_get_byte $gifImageData pos]
-                set data(app-name) [gif_get_block $gifImageData pos $bsize]
-                set data(app-bytes) ""
-                while {1} {
-                    set count [gif_get_byte $gifImageData pos]
-                    gif_put_byte data(app-bytes) $count
-                    if {$count == 0} {
-                        break
-                    }
-                    gif_put_block data(app-bytes) \
-                        [gif_get_block $gifImageData pos $count]
-                }
-              }
-              default {
-                error [format "unknown extension code 0x%02X" $ext]
-              }
-            }
-          }
-          0x2C {
-            # image data
-            set data(im-$n-left) [gif_get_short $gifImageData pos]
-            set data(im-$n-top) [gif_get_short $gifImageData pos]
-            set data(im-$n-wd) [gif_get_short $gifImageData pos]
-            set data(im-$n-ht) [gif_get_short $gifImageData pos]
-            set data(im-$n-packed) [gif_get_byte $gifImageData pos]
-            set data(im-$n-colors) ""
-            if {($data(im-$n-packed) & 0x80) != 0} {
-                set ctsize [expr {3*(1 << ($data(im-$n-packed) & 0x07)+1)}]
-                set data(im-$n-colors) [gif_get_block $gifImageData pos $ctsize]
-            }
-
-            set data(im-$n-data) ""
-            gif_put_byte data(im-$n-data) \
-                [gif_get_byte $gifImageData pos] ;# lwz min code size
-            while {1} {
-                set count [gif_get_byte $gifImageData pos]
-                gif_put_byte data(im-$n-data) $count
-                if {$count == 0} {
-                    break
-                }
-                gif_put_block data(im-$n-data) \
-                    [gif_get_block $gifImageData pos $count]
-            }
-            incr n
-          }
-          0x3B {
-            # end of image data
-            break
-          }
-          default {
-            error [format "unexpected control byte 0x%02X" $ctrl]
-          }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::gif_get_byte <buffer> <posVar>
-#
-# Extracts one byte of information from the <buffer> at the index
-# specified by <posVar> in the calling scope.  Increments <posVar>
-# to move past the byte and returns the byte of information.
-# ----------------------------------------------------------------------
-proc Rappture::icon::gif_get_byte {buffer posVar} {
-    upvar $posVar pos
-    set byte [string range $buffer $pos $pos]
-    incr pos 1
-
-    binary scan $byte c rval
-    if {$rval < 0} {incr rval 256}
-    return $rval
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::gif_get_short <buffer> <posVar>
-#
-# Extracts one short int of information from the <buffer> at the index
-# specified by <posVar> in the calling scope.  Increments <posVar>
-# to move past the int and returns the information.
-# ----------------------------------------------------------------------
-proc Rappture::icon::gif_get_short {buffer posVar} {
-    upvar $posVar pos
-    set bytes [string range $buffer $pos [expr {$pos+1}]]
-    incr pos 2
-
-    binary scan $bytes s rval
-    if {$rval < 0} {incr rval 65536}
-    return $rval
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::gif_get_block <buffer> <posVar> <size>
-#
-# Extracts <size> bytes of information from the <buffer> at the index
-# specified by <posVar> in the calling scope.  Increments <posVar>
-# to move past the byte and returns the byte of information.
-# ----------------------------------------------------------------------
-proc Rappture::icon::gif_get_block {buffer posVar size} {
-    upvar $posVar pos
-    set bytes [string range $buffer $pos [expr {$pos+$size-1}]]
-    incr pos $size
-    return $bytes
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::gif_put_byte <buffer> <charVal>
-#
-# Appends one byte of information onto the <buffer> in the calling
-# scope.  The <charVal> is an integer in the range 0-255.  It is
-# formated as a single byte and appended onto the buffer.
-# ----------------------------------------------------------------------
-proc Rappture::icon::gif_put_byte {bufferVar char} {
-    upvar $bufferVar buffer
-    append buffer [binary format c $char]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::gif_put_short <buffer> <shortVal>
-#
-# Appends one byte of information onto the <buffer> in the calling
-# scope.  The <shortVal> is an integer in the range 0-65535.  It is
-# formated as a 2-byte short integer and appended onto the buffer.
-# ----------------------------------------------------------------------
-proc Rappture::icon::gif_put_short {bufferVar short} {
-    upvar $bufferVar buffer
-    append buffer [binary format s $short]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::icon::gif_put_block <buffer> <val>
-#
-# Appends a string <val> onto the <buffer> in the calling scope.
-# ----------------------------------------------------------------------
-proc Rappture::icon::gif_put_block {bufferVar val} {
-    upvar $bufferVar buffer
-    append buffer $val
-}
Index: trunk/gui/scripts/image.tcl
===================================================================
--- trunk/gui/scripts/image.tcl	(revision 6716)
+++ 	(revision )
@@ -1,75 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: image - represents a picture image
-#
-#  This object represents a Tk image.  It is convenient to have it
-#  expressed as an Itcl object, so it can be managed just like a
-#  curve, table, etc.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture { # forward declaration }
-
-itcl::class Rappture::Image {
-    constructor {xmlobj path} { # defined below }
-    destructor { # defined below }
-
-    public method tkimage {} { return $_image }
-    public method hints {{keyword ""}}
-
-    private variable _xmlobj ""  ;# ref to lib obj with image data
-    private variable _path ""    ;# path in _xmlobj where data sits
-    private variable _image ""   ;# underlying image data
-    private variable _hints
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Image::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be LibraryObj"
-    }
-    set _xmlobj $xmlobj
-    set _path $path
-    set data [string trim [$xmlobj get $path.current]]
-    if {[string length $data] == 0} {
-        set _image [image create photo]
-    } else {
-        set _image [image create photo -data $data]
-    }
-
-    set _hints(note) [string trim [$_xmlobj get $_path.note.contents]]
-    set _hints(tooldir) [$_xmlobj get tool.version.application.directory(tool)]
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Image::destructor {} {
-    image delete $_image
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about showing
-# this image.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Image::hints {{keyword ""}} {
-    if {$keyword != ""} {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
-        }
-        return ""
-    }
-    return [array get _hints]
-}
Index: trunk/gui/scripts/imageentry.tcl
===================================================================
--- trunk/gui/scripts/imageentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,403 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: ImageEntry - widget for displaying images
-#
-#  This widget represents an <image> entry on a control panel.
-#  It displays images which help explain the input.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require Img
-
-itcl::class Rappture::ImageEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-    destructor { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _redraw {}
-    protected method _outline {imh color}
-    protected method _uploadValue {args}
-    protected method _downloadValue {}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this image
-    private variable _data ""     ;# current image data
-    private variable _imh ""      ;# image handle for current value
-    private variable _resize ""   ;# image for resize operations
-
-    private common _thumbsize 100 ;# std size for thumbnail images
-}
-
-itk::usual ImageEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-    set _resize [image create photo]
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.  Two ways to display:  Old apps use images
-    # without labels as decorations.  In that case, show the image
-    # alone, probably full size.  Newer apps use images as inputs.
-    # In that case, show a thumbnail of the image with some extra
-    # facts about image type, file size, etc.
-    #
-    itk_component add image {
-        ::label $itk_interior.image -borderwidth 0
-    }
-
-    itk_component add info {
-        ::label $itk_interior.info -borderwidth 0 -width 5 \
-            -anchor w -justify left
-    }
-
-    itk_component add rmenu {
-        menu $itk_interior.menu -tearoff 0
-    } {
-        usual
-        ignore -tearoff
-    }
-    $itk_component(rmenu) add command \
-        -label [Rappture::filexfer::label upload] \
-        -command [itcl::code $this _uploadValue -start]
-    $itk_component(rmenu) add command \
-        -label [Rappture::filexfer::label download] \
-        -command [itcl::code $this _downloadValue]
-
-
-    if {[string length [label]] == 0} {
-        # old mode -- big image
-        pack $itk_component(image) -expand yes -fill both
-        bind $itk_component(image) <Configure> [itcl::code $this _redraw]
-    } else {
-        # new mode -- thumbnail and details
-        pack $itk_component(image) -side left
-        pack $itk_component(info) -side left -expand yes -fill both -padx 4
-
-        bind $itk_component(image) <<PopupMenu>> \
-            [list tk_popup $itk_component(rmenu) %X %Y]
-        bind $itk_component(info) <<PopupMenu>> \
-            [list tk_popup $itk_component(rmenu) %X %Y]
-
-        _redraw  ;# draw Empty image/info
-    }
-
-    # Don't trim this string.  It make be important.
-    set str [$_owner xml get $path.current]
-    if {[string length $str] == 0} {
-        set str [$_owner xml get $path.default]
-    }
-    if {[string length $str] > 0} {
-        value $str
-    }
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::destructor {} {
-    if {"" != $_imh} { image delete $_imh }
-    if {"" != $_resize} { image delete $_resize }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [lindex $args 0]
-        if {[string length $newval] > 0} {
-            set imh [image create photo -data $newval]
-        } else {
-            set imh ""
-        }
-
-        if {$_imh != ""} {
-            image delete $_imh
-        }
-        set _imh $imh
-        set _data $newval
-
-        _redraw
-
-        return $newval
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    set bytes $_data
-    set fmt [string trim [$_owner xml get $_path.convert]]
-    if {"" != $fmt && "" != $_imh} {
-        if {"pgm" == $fmt} { set fmt "ppm -grayscale" }
-        set bytes [eval $_imh data -format $fmt]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-    }
-    return $bytes
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::tooltip {} {
-    set str [string trim [$_owner xml get $_path.about.description]]
-    return $str
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Used internally to update the image displayed in this entry.
-# If the <resize> parameter is set, then the image is resized.
-# The "auto" value resizes to the current area.  The "width=XX" or
-# "height=xx" form resizes to a particular size.  The "none" value
-# leaves the image as-is; this is the default.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::_redraw {} {
-    if {"" == $_imh} {
-        # generate a big diagonal cross-hatch image
-        set diag [Rappture::icon diag]
-        set dw [image width $diag]
-        set dh [image height $diag]
-        $_resize configure -width $_thumbsize -height $_thumbsize
-        for {set i 0} {$i < $_thumbsize/$dw+1} {incr i} {
-            for {set j 0} {$j < $_thumbsize/$dh+1} {incr j} {
-                set x [expr {$i*$dw}]
-                set y [expr {$j*$dh}]
-                $_resize copy $diag -to $x $y
-            }
-        }
-        _outline $_resize black
-        $itk_component(image) configure -image $_resize
-        $itk_component(info) configure -text "Empty"
-        return
-    }
-
-    set iw [image width $_imh]
-    set ih [image height $_imh]
-    $itk_component(image) configure -image "" -width $iw -height $ih
-
-    #
-    # Build a description of the image if the info is showing.
-    #
-    set desc ""
-    if {[string length [label]] != 0} {
-        # if data is base64-encoded, try to decode it
-        if {![regexp {^[a-zA-Z0-9+/=]+(\n[a-zA-Z0-9+/=]+)*$} $_data]
-              || [catch {Rappture::encoding::decode -as b64 $_data} bytes]} {
-            # oops! not base64 -- use data directly
-            set bytes $_data
-        }
-        set desc [Rappture::utils::datatype $bytes]
-        if {[string equal $desc "Binary data"]} {
-            # generic description -- we can do a little better
-            set iw [image width $_imh]
-            set ih [image height $_imh]
-            set desc "Image, ${iw} x ${ih}"
-        }
-        append desc "\n[Rappture::utils::binsize [string length $_data]]"
-    }
-    $itk_component(info) configure -text $desc
-
-    #
-    # Put up the preview image, resizing if necessary.
-    #
-    set str [string trim [$_owner xml get $_path.resize]]
-    if {"" == $str} {
-        set str "none"
-    }
-    switch -glob -- $str {
-        width=* - height=* {
-            if {[regexp {^width=([0-9]+)$} $str match size]} {
-                set w $size
-                set h [expr {round($w*$ih/double($iw))}]
-                $_resize configure -width $w -height $h
-                $_resize blank
-                blt::winop resample $_imh $_resize box
-                _outline $_resize black
-                $itk_component(image) configure -image $_resize \
-                    -width $w -height $h
-            } elseif {[regexp {^height=([0-9]+)$} $str match size]} {
-                set h $size
-                set w [expr {round($h*$iw/double($ih))}]
-                $_resize configure -width $w -height $h
-                $_resize blank
-                blt::winop resample $_imh $_resize box
-                _outline $_resize black
-                $itk_component(image) configure -image $_resize \
-                    -width $w -height $h
-            } else {
-                $itk_component(image) configure -image $_imh
-            }
-        }
-        auto - none - default {
-            if {[string length [label]] == 0} {
-                # old mode -- big image with no label
-                $itk_component(image) configure -image $_imh
-            } else {
-                # new mode -- thumbnail and image info
-                set w $_thumbsize
-                set h $_thumbsize
-                $itk_component(image) configure -width $w -height $h
-
-                if {$iw <= $_thumbsize && $ih <= $_thumbsize} {
-                    $_resize configure -width $iw -height $ih
-                    $_resize copy $_imh
-                    _outline $_resize black
-                } else {
-                    # large image -- scale it down
-                    if {$iw > $ih} {
-                        set h [expr {round($w/double($iw)*$ih)}]
-                    } else {
-                        set w [expr {round($h/double($ih)*$iw)}]
-                    }
-                    $_resize configure -width $w -height $h
-                    $_resize blank
-                    blt::winop resample $_imh $_resize box
-                    _outline $_resize black
-                }
-                $itk_component(image) configure -image $_resize
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _outline <image> <color>
-#
-# Used internally to outline the given <image> with a single-pixel
-# line of the specified <color>.  Updates the image in place.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::_outline {im color} {
-    if {"" != $im} {
-        set w [image width $im]
-        set h [image height $im]
-        $im put $color -to 0 0 $w 1
-        $im put $color -to 0 0 1 $h
-        $im put $color -to 0 [expr {$h-1}] $w $h
-        $im put $color -to [expr {$w-1}] 0 $w $h
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _uploadValue -start
-# USAGE: _uploadValue -assign <key> <value> <key> <value> ...
-#
-# Used internally to initiate an upload operation.  Prompts the
-# user to upload into the image area of this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::_uploadValue {args} {
-    set opt [lindex $args 0]
-    switch -- $opt {
-        -start {
-            set tool [Rappture::Tool::resources -appname]
-            set cntls [list $_path [label] [tooltip]]
-            Rappture::filexfer::upload \
-                $tool $cntls [itcl::code $this _uploadValue -assign]
-        }
-        -assign {
-            array set data [lrange $args 1 end] ;# skip option
-            if {[info exists data(error)]} {
-                Rappture::Tooltip::cue $itk_component(image) $data(error)
-            }
-            if {[info exists data(data)]} {
-                Rappture::Tooltip::cue hide  ;# take down note about the popup
-                if {[catch {value $data(data)} err]} {
-                    Rappture::Tooltip::cue $itk_component(image) "Upload failed:\n$err"
-                }
-            }
-        }
-        default {
-            error "bad option \"$opt\": should be -start or -assign"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _downloadValue
-#
-# Used internally to initiate a download operation.  Takes the current
-# value and downloads it to the user in a new browser window.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageEntry::_downloadValue {} {
-    set bytes [Rappture::encoding::decode -as b64 [$_imh data -format png]]
-    set mesg [Rappture::filexfer::download $bytes image.png]
-
-    if {"" != $mesg} {
-        Rappture::Tooltip::cue $itk_component(image) $mesg
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::ImageEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(image) configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/imageresult.tcl
===================================================================
--- trunk/gui/scripts/imageresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,601 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: imageresult - picture image in a ResultSet
-#
-#  This widget displays an image found in the output of a Rappture
-#  tool run.  Use the "add" and "delete" methods to control the images
-#  showing in the widget.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-package require Img
-
-option add *ImageResult.width 3i widgetDefault
-option add *ImageResult.height 3i widgetDefault
-option add *ImageResult.controlBackground gray widgetDefault
-option add *ImageResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::ImageResult {
-    inherit itk::Widget
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method add {image {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} { # do nothing }
-    public method download {option args}
-
-    protected method _rebuild {args}
-    protected method _top {what}
-    protected method _zoom {option args}
-    protected method _move {option args}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-    private variable _dlist ""      ;# list of data objects
-    private variable _topmost ""    ;# topmost image in _dlist
-    private variable _max           ;# max size of all images
-    private variable _scale         ;# info related to zoom
-    private variable _image         ;# image buffers used for scaling
-}
-
-itk::usual ImageResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild [itcl::code $this _rebuild]
-
-    array set _scale {
-        max 1.0
-        current 1.0
-        default 1
-        x 0
-        y 0
-    }
-
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    Rappture::Panes $itk_interior.panes \
-        -sashwidth 2 -sashrelief solid -sashpadding 1
-
-    pack $itk_interior.panes -expand yes -fill both
-    set main [$itk_interior.panes pane 0]
-    $itk_interior.panes fraction 0 1
-
-    itk_component add controls {
-        frame $main.cntls
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    pack $itk_component(controls) -side right -fill y
-
-    itk_component add reset {
-        button $itk_component(controls).reset \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -bitmap [Rappture::icon reset] \
-            -command [itcl::code $this _zoom reset]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground Background
-    }
-    pack $itk_component(reset) -padx 4 -pady 4
-    Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $itk_component(controls).zin \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -bitmap [Rappture::icon zoomin] \
-            -command [itcl::code $this _zoom in]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground Background
-    }
-    pack $itk_component(zoomin) -padx 4 -pady 4
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $itk_component(controls).zout \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -bitmap [Rappture::icon zoomout] \
-            -command [itcl::code $this _zoom out]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground Background
-    }
-    pack $itk_component(zoomout) -padx 4 -pady 4
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-
-    set _image(zoom) [image create photo]
-    set _image(final) [image create photo]
-
-    itk_component add image {
-        label $main.image -image $_image(final) -anchor c
-    } {
-        keep -background -foreground -cursor -font
-    }
-    pack $itk_component(image) -expand yes -fill both
-
-    #
-    # Add bindings for resize/move
-    #
-    bind $itk_component(image) <Configure> \
-        [list $_dispatcher event -idle !rebuild resize 1]
-
-    bind $itk_component(image) <ButtonPress-1> \
-        [itcl::code $this _move click %x %y]
-    bind $itk_component(image) <B1-Motion> \
-        [itcl::code $this _move drag %x %y]
-    bind $itk_component(image) <ButtonRelease-1> \
-        [itcl::code $this _move release %x %y]
-
-    #
-    # Add area at the bottom for notes.
-    #
-    set notes [$itk_interior.panes insert end -fraction 0.15]
-    $itk_interior.panes visibility 1 off
-    Rappture::Scroller $notes.scr -xscrollmode auto -yscrollmode auto
-    pack $notes.scr -expand yes -fill both
-    itk_component add notes {
-        Rappture::HTMLviewer $notes.scr.html
-    }
-    $notes.scr contents $notes.scr.html
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::destructor {} {
-    foreach name [array names _image] {
-        image delete $_image($name)
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <image> ?<settings>?
-#
-# Clients use this to add an image to the plot.  The optional <settings>
-# are used to configure the image.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::add {image {settings ""}} {
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    if {$params(-raise)} {
-        set _topmost $image
-        $_dispatcher event -idle !rebuild
-    }
-
-    set pos [lsearch -exact $_dlist $image]
-    if {$pos < 0} {
-        lappend _dlist $image
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of images being displayed, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-
-    set i [lsearch $_dlist $_topmost]
-    if {$i >= 0} {
-        set dlist [lreplace $dlist $i $i]
-        set dlist [linsert $dlist 0 $_topmost]
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<image1> <image2> ...?
-#
-# Clients use this to delete an image from the plot.  If no images
-# are specified, then all images are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified curves
-    set changed 0
-    foreach image $args {
-        set pos [lsearch -exact $_dlist $image]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            set changed 1
-
-            if {$image == $_topmost} {
-                set _topmost ""
-            }
-        }
-    }
-
-    # if anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<image1> <image2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <image> objects.  This
-# accounts for all images--even those not showing on the screen.
-# Because of this, the limits are appropriate for all images as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::scale {args} {
-    set _max(w) 0
-    set _max(h) 0
-    foreach image $args {
-        set imh [$image tkimage]
-
-        set w [image width $imh]
-        if {$w > $_max(w)} { set _max(w) $w }
-
-        set h [image height $imh]
-        if {$h > $_max(h)} { set _max(h) $h }
-    }
-
-    # scale is unknown for now... scale later at next _rebuild
-    set _scale(max) "?"
-    set _scale(current) "?"
-
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            # no controls for this download yet
-            return ""
-        }
-        now {
-            set top [_top image]
-            if {$top == ""} {
-                return ""
-            }
-            # Get the image data (as base64) and decode it back to binary.
-            # This is better than writing to temporary files.  When we switch
-            # to the BLT picture image it won't be necessary to decode the
-            # image data.
-            set bytes [$top data -format "jpeg -quality 100"]
-            set bytes [Rappture::encoding::decode -as b64 $bytes]
-            return [list .jpg $bytes]
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _rebuild ?<eventData>...?
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::_rebuild {args} {
-    array set event $args
-    if {[info exists event(resize)] && $event(resize)} {
-        # window changed size -- recompute max scale below
-        set _scale(max) "?"
-    }
-
-    if {$_scale(max) == "?"} {
-        if {![_zoom rescale]} {
-            return
-        }
-    }
-    if {$_scale(current) == "?" || $_scale(default)} {
-        set _scale(current) $_scale(max)
-        set _scale(x) 0.5
-        set _scale(y) 0.5
-    }
-
-    set w [winfo width $itk_component(image)]
-    set h [winfo height $itk_component(image)]
-    set bg [$itk_component(image) cget -background]
-
-    set imh [_top image]
-    if {$imh != ""} {
-        set iw [image width $imh]
-        set ih [image height $imh]
-        set wz [expr {round($w*$_scale(current))}]
-        set hz [expr {round($h*$_scale(current))}]
-
-        if {$wz < $iw || $hz < $ih} {
-            #
-            # Scale the image up by creating a "zoom" image which
-            # is smaller than the current image.  Sample a small
-            # part of the original image by copying into the "zoom"
-            # image, then scale that part up to the full "view" area.
-            #
-            if {$wz > $iw} {
-                set wz $iw
-            }
-            if {$hz > $ih} {
-                set hz $ih
-            }
-
-            set sx [expr {round($_scale(x)*$_max(w)-0.5*$wz)}]
-            if {$sx+$wz > $iw} {
-                set sx [expr {$iw-$wz}]
-            }
-            if {$sx < 0} {
-                set sx 0
-            }
-
-            set sy [expr {round($_scale(y)*$_max(h)-0.5*$hz)}]
-            if {$sy+$hz > $ih} {
-                set sy [expr {$ih-$hz}]
-            }
-            if {$sy < 0} {
-                set sy 0
-            }
-
-            if {$wz > 1 && $hz > 1} {
-                $_image(zoom) configure -width $wz -height $hz
-                set wf [expr {round(double($wz)/$_scale(current))}]
-                set hf [expr {round(double($hz)/$_scale(current))}]
-                $_image(final) configure -width $wf -height $hf
-                $_image(zoom) copy $imh -from $sx $sy
-                blt::winop resample $_image(zoom) $_image(final) sinc
-            }
-        } else {
-            #
-            # Scale the image down by creating a "zoom" image which
-            # is smaller than the current image.  Resize the original
-            # image to the smaller size, then copy into the current
-            # view.
-            #
-            set wz [expr {round(double($iw)/$_scale(current))}]
-            set hz [expr {round(double($ih)/$_scale(current))}]
-            if {$wz > 1 && $hz > 1} {
-                $_image(zoom) configure -width $wz -height $hz
-                $_image(zoom) put $bg -to 0 0 $wz $hz
-                blt::winop resample $imh $_image(zoom) sinc
-
-                $_image(final) configure -width $wz -height $hz
-                $_image(final) copy $_image(zoom) -from 0 0
-            }
-        }
-    }
-
-    set note [_top note]
-    if {[string length $note] > 0} {
-        if {[regexp {^html://} $note]} {
-            set note [string range $note 7 end]
-        } else {
-            regexp {&} $note {\007} note
-            regexp {<} $note {\&lt;} note
-            regexp {>} $note {\&gt;} note
-            regexp {\007} $note {\&amp;} note
-            regexp "\n\n" $note {<br/>} note
-            set note "<html><body>$note</body></html>"
-        }
-        set notes [$itk_interior.panes pane 1]
-        $itk_component(notes) load $note -in [file join [_top tooldir] docs]
-        $itk_interior.panes visibility 1 on
-    } else {
-        $itk_interior.panes visibility 1 off
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _top image|note|tooldir
-#
-# Used internally to get the topmost image currently being displayed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::_top {option} {
-    set top $_topmost
-    if {"" == $top} {
-        set top [lindex $_dlist 0]
-    }
-    if {"" != $top} {
-        switch -- $option {
-            image   { return [$top tkimage] }
-            note    { return [$top hints note] }
-            tooldir { return [$top hints tooldir] }
-            default { error "bad option \"$option\": should be image, note, tooldir" }
-        }
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _zoom reset
-# USAGE: _zoom in
-# USAGE: _zoom out
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::_zoom {option args} {
-    switch -- $option {
-        rescale {
-            # empty list? then reset w/h max size
-            if {[llength $_dlist] == 0} {
-                set _max(w) 0
-                set _max(h) 0
-                set _scale(max) 1.0
-            } else {
-                set w [winfo width $itk_component(image)]
-                set h [winfo height $itk_component(image)]
-                if {$w <= 1 && $h <= 1} {
-                    return 0
-                }
-
-                if {$w < $h} {
-                    if {$_max(w)/double($_max(h)) > $w/double($h)} {
-                        set _scale(max) [expr {$_max(w)/double($w)}]
-                    } else {
-                        set _scale(max) [expr {$_max(h)/double($h)}]
-                    }
-                } else {
-                    if {$_max(w)/double($_max(h)) < $w/double($h)} {
-                        set _scale(max) [expr {$_max(h)/double($h)}]
-                    } else {
-                        set _scale(max) [expr {$_max(w)/double($w)}]
-                    }
-                }
-            }
-            return 1
-        }
-        reset {
-            set _scale(current) $_scale(max)
-            set _scale(default) 1
-            set _scale(x) 0.5
-            set _scale(y) 0.5
-            Rappture::Logger::log image zoom -reset
-        }
-        in {
-            set _scale(current) [expr {$_scale(current)*0.8}]
-            set _scale(default) 0
-            Rappture::Logger::log image zoom -in
-        }
-        out {
-            set w [winfo width $itk_component(image)]
-            set h [winfo height $itk_component(image)]
-            if {$_max(w)/$_scale(current) > $w
-                  || $_max(h)/$_scale(current) > $h} {
-                # must be room left to zoom -- zoom out, but not beyond max
-                set _scale(current) [expr {$_scale(current)*1.25}]
-                if {$_scale(current) > $_scale(max)} {
-                    set _scale(current) $_scale(max)
-                }
-            } else {
-                # no room left to zoom -- zoom out max
-                set _scale(current) $_scale(max)
-            }
-
-            # fix the center of view, in case it is now out of bounds
-            if {$_scale(current) > 1.0} {
-                set _scale(x) 0.5
-                set _scale(y) 0.5
-            }
-
-            # keep this zoom setting now that we've zoomed out
-            set _scale(default) 0
-
-            Rappture::Logger::log image zoom -out
-        }
-    }
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _move click <x> <y>
-# USAGE: _move drag <x> <y>
-# USAGE: _move release <x> <y>
-#
-# Called automatically when the user clicks and drags on the image
-# to pan the view.  Adjusts the (x,y) offset for the scaling info
-# and redraws the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ImageResult::_move {option args} {
-    switch -- $option {
-        click {
-            foreach {x y} $args break
-            $itk_component(image) configure -cursor fleur
-            set _scale(x0) $_scale(x)
-            set _scale(y0) $_scale(y)
-            set _scale(xclick) $x
-            set _scale(yclick) $y
-        }
-        drag {
-            foreach {x y} $args break
-            if {[info exists _scale(xclick)] && [info exists _scale(yclick)]} {
-                set w [winfo width $itk_component(image)]
-                set h [winfo height $itk_component(image)]
-                set wx [expr {round($_max(w)/$_scale(current))}]
-                set hy [expr {round($_max(h)/$_scale(current))}]
-                if {$wx > $w || $hy > $h} {
-                    set x [expr {$_scale(x0)-($x-$_scale(xclick))/double($wx)}]
-                    set y [expr {$_scale(y0)-($y-$_scale(yclick))/double($hy)}]
-                    if {$x*$_max(w) < 0.5*$w*$_scale(current)} {
-                        set x [expr {0.5*$w*$_scale(current)/$_max(w)}]
-                    }
-                    if {$x*$_max(w) > $_max(w) - 0.5*$w*$_scale(current)} {
-                        set x [expr {1 - 0.5*$w*$_scale(current)/$_max(w)}]
-                    }
-                    if {$y*$_max(h) < 0.5*$h*$_scale(current)} {
-                        set y [expr {0.5*$h*$_scale(current)/$_max(h)}]
-                    }
-                    if {$y*$_max(h) > $_max(h) - 0.5*$h*$_scale(current)} {
-                        set y [expr {1 - 0.5*$h*$_scale(current)/$_max(h)}]
-                    }
-                    set _scale(x) $x
-                    set _scale(y) $y
-                } else {
-                    set _scale(x) 0.5
-                    set _scale(y) 0.5
-                }
-                $_dispatcher event -idle !rebuild
-            }
-        }
-        release {
-            eval _move drag $args
-            $itk_component(image) configure -cursor ""
-            catch {unset _scale(xclick)}
-            catch {unset _scale(yclick)}
-
-            Rappture::Logger::log image moveto $_scale(x),$_scale(y)
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
Index: trunk/gui/scripts/images/atoms.xbm
===================================================================
--- trunk/gui/scripts/images/atoms.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define atoms_width 12
-#define atoms_height 12
-static unsigned char atoms_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x02, 0x4c, 0x02, 0xc8, 0x03,
-   0x48, 0x02, 0x48, 0x02, 0x5c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/dismiss.xbm
===================================================================
--- trunk/gui/scripts/images/dismiss.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define dismiss_width 10
-#define dismiss_height 8
-static unsigned char dismiss_bits[] = {
-   0x87, 0x03, 0xce, 0x01, 0xfc, 0x00, 0x78, 0x00, 0x78, 0x00, 0xfc, 0x00,
-   0xce, 0x01, 0x87, 0x03};
Index: trunk/gui/scripts/images/empty.xbm
===================================================================
--- trunk/gui/scripts/images/empty.xbm	(revision 6716)
+++ 	(revision )
@@ -1,4 +1,0 @@
-#define empty_width 1
-#define empty_height 1
-static unsigned char empty_bits[] = {
-   0x00};
Index: trunk/gui/scripts/images/flipxy.xbm
===================================================================
--- trunk/gui/scripts/images/flipxy.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define flipxy_width 12
-#define flipxy_height 12
-static unsigned char flipxy_bits[] = {
-   0x00, 0x00, 0x70, 0x04, 0x30, 0x02, 0x50, 0x01, 0x80, 0x00, 0x44, 0x01,
-   0x28, 0x02, 0x10, 0x00, 0xa8, 0x00, 0xc4, 0x00, 0xe2, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/pause.xbm
===================================================================
--- trunk/gui/scripts/images/pause.xbm	(revision 6716)
+++ 	(revision )
@@ -1,6 +1,0 @@
-#define pause_width 16
-#define pause_height 16
-static unsigned char pause_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e,
-   0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e, 0x70, 0x0e,
-   0x70, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
Index: trunk/gui/scripts/images/play.xbm
===================================================================
--- trunk/gui/scripts/images/play.xbm	(revision 6716)
+++ 	(revision )
@@ -1,6 +1,0 @@
-#define play_width 16
-#define play_height 16
-static unsigned char play_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x78, 0x00, 0xf8, 0x01,
-   0xf8, 0x07, 0xf8, 0x1f, 0xf8, 0x1f, 0xf8, 0x07, 0xf8, 0x01, 0x78, 0x00,
-   0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/rarrow.xbm
===================================================================
--- trunk/gui/scripts/images/rarrow.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define rarrow_width 9
-#define rarrow_height 9
-static unsigned char rarrow_bits[] = {
-   0x04, 0x00, 0x0c, 0x00, 0x1c, 0x00, 0x3c, 0x00, 0x7c, 0x00, 0x3c, 0x00,
-   0x1c, 0x00, 0x0c, 0x00, 0x04, 0x00};
Index: trunk/gui/scripts/images/rarrow2.xbm
===================================================================
--- trunk/gui/scripts/images/rarrow2.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define rarrow2_width 9
-#define rarrow2_height 9
-static unsigned char rarrow2_bits[] = {
-   0x04, 0x00, 0x0c, 0x00, 0x14, 0x00, 0x24, 0x00, 0x44, 0x00, 0x24, 0x00,
-   0x14, 0x00, 0x0c, 0x00, 0x04, 0x00};
Index: trunk/gui/scripts/images/rdiag.xbm
===================================================================
--- trunk/gui/scripts/images/rdiag.xbm	(revision 6716)
+++ 	(revision )
@@ -1,4 +1,0 @@
-#define rdiag_width 8
-#define rdiag_height 8
-static unsigned char rdiag_bits[] = {
-   0x66, 0x33, 0x99, 0xcc, 0x66, 0x33, 0x99, 0xcc};
Index: trunk/gui/scripts/images/record.xbm
===================================================================
--- trunk/gui/scripts/images/record.xbm	(revision 6716)
+++ 	(revision )
@@ -1,6 +1,0 @@
-#define record_width 16
-#define record_height 16
-static unsigned char record_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f, 0xfc, 0x3f,
-   0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xfc, 0x3f, 0xf8, 0x1f,
-   0xf0, 0x0f, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/reset.xbm
===================================================================
--- trunk/gui/scripts/images/reset.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define reset_width 12
-#define reset_height 12
-static unsigned char reset_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x04, 0x02, 0x04, 0x02, 0x04, 0x02,
-   0x04, 0x02, 0x04, 0x02, 0x04, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/rocker.xbm
===================================================================
--- trunk/gui/scripts/images/rocker.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define rocker_width 12
-#define rocker_height 12
-static unsigned char rocker_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0a, 0x05, 0x06, 0x06, 0x0e, 0x07,
-   0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/stop.xbm
===================================================================
--- trunk/gui/scripts/images/stop.xbm	(revision 6716)
+++ 	(revision )
@@ -1,6 +1,0 @@
-#define stop_width 16
-#define stop_height 16
-static unsigned char stop_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f,
-   0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f, 0xf0, 0x0f,
-   0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/up.xbm
===================================================================
--- trunk/gui/scripts/images/up.xbm	(revision 6716)
+++ 	(revision )
@@ -1,4 +1,0 @@
-#define up_width 8
-#define up_height 4
-static unsigned char up_bits[] = {
-   0x10, 0x38, 0x7c, 0xfe};
Index: trunk/gui/scripts/images/x.xbm
===================================================================
--- trunk/gui/scripts/images/x.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define x_width 12
-#define x_height 12
-static unsigned char x_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0x9c, 0x03, 0x98, 0x01, 0xf0, 0x00, 0x60, 0x00,
-   0x60, 0x00, 0xf0, 0x00, 0x98, 0x01, 0x9c, 0x03, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/y.xbm
===================================================================
--- trunk/gui/scripts/images/y.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define y_width 12
-#define y_height 12
-static unsigned char y_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0x0e, 0x07, 0x0c, 0x03, 0x98, 0x01, 0xf0, 0x00,
-   0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/z.xbm
===================================================================
--- trunk/gui/scripts/images/z.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define z_width 12
-#define z_height 12
-static unsigned char z_bits[] = {
-   0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x84, 0x03, 0xc0, 0x01, 0xe0, 0x00,
-   0x70, 0x00, 0x38, 0x00, 0x1c, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00};
Index: trunk/gui/scripts/images/zoomin.xbm
===================================================================
--- trunk/gui/scripts/images/zoomin.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define zoomin_width 12
-#define zoomin_height 12
-static unsigned char zoomin_bits[] = {
-   0x7c, 0x00, 0x82, 0x00, 0x11, 0x01, 0x11, 0x01, 0x7d, 0x01, 0x11, 0x01,
-   0x11, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};
Index: trunk/gui/scripts/images/zoomout.xbm
===================================================================
--- trunk/gui/scripts/images/zoomout.xbm	(revision 6716)
+++ 	(revision )
@@ -1,5 +1,0 @@
-#define zoomout_width 12
-#define zoomout_height 12
-static unsigned char zoomout_bits[] = {
-   0x7c, 0x00, 0x82, 0x00, 0x01, 0x01, 0x01, 0x01, 0x7d, 0x01, 0x01, 0x01,
-   0x01, 0x01, 0x82, 0x03, 0xfc, 0x07, 0x80, 0x0f, 0x00, 0x0f, 0x00, 0x06};
Index: trunk/gui/scripts/integerentry.tcl
===================================================================
--- trunk/gui/scripts/integerentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,197 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: IntegerEntry - widget for entering integer values
-#
-#  This widget represents an <integer> entry on a control panel.
-#  It is used to enter integral values with no units.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::IntegerEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _newValue {}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-}
-
-itk::usual IntegerEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::IntegerEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    itk_component add spinner {
-        Rappture::Gauge $itk_interior.spinner -type integer -log $path
-    }
-    pack $itk_component(spinner) -expand yes -fill both
-    bind $itk_component(spinner) <<Value>> [itcl::code $this _newValue]
-
-    # if there are min/max values, plug them in.
-    set min [string trim [$_owner xml get $path.min]]
-    if {"" != $min} {
-        $itk_component(spinner) configure -minvalue $min
-    }
-
-    set max [string trim [$_owner xml get $path.max]]
-    if {"" != $max} {
-        $itk_component(spinner) configure -maxvalue $max
-    }
-
-    # if there is a color, use it for the min/max spectrum
-    set color [string trim [$_owner xml get $path.about.color]]
-    if {$color != "" && $min != "" && $max != ""} {
-        # For compatibility. If only one color use white for min
-        if {[llength $color] == 1} {
-            set color [list $min white $max $color]
-        }
-        $itk_component(spinner) configure \
-            -spectrum [Rappture::Spectrum ::\#auto $color]
-    }
-
-    # if the control has an icon, plug it in
-    set str [string trim [$_owner xml get $path.about.icon]]
-    if {$str != ""} {
-        $itk_component(spinner) configure -image \
-            [image create photo -data $str]
-    }
-
-    eval itk_initialize $args
-
-    #
-    # Assign the default value to this widget, if there is one.
-    #
-    set str [string trim [$_owner xml get $path.default]]
-    if {"" != $str != ""} {
-        $itk_component(spinner) value $str
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::IntegerEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [lindex $args 0]
-        $itk_component(spinner) value $newval
-        return $newval
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    return [$itk_component(spinner) value]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::IntegerEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {"" == $label} {
-        set label "Integer"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::IntegerEntry::tooltip {} {
-    set str [string trim [$_owner xml get $_path.about.description]]
-    set min [string trim [$_owner xml get $_path.min]]
-    set max [string trim [$_owner xml get $_path.max]]
-
-    if {$min != "" || $max != ""} {
-        append str "\n\nEnter an integer"
-
-        if {$min != "" && $max != ""} {
-            append str " between $min and $max"
-        } elseif {$min != ""} {
-            append str " greater than $min"
-        } elseif {$max != ""} {
-            append str " less than $max"
-        }
-    }
-    return [string trim $str]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _newValue
-#
-# Invoked automatically whenever the value in the gauge changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::IntegerEntry::_newValue {} {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::IntegerEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(spinner) configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/isomarker.tcl
===================================================================
--- trunk/gui/scripts/isomarker.tcl	(revision 6716)
+++ 	(revision )
@@ -1,190 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: nanovisviewer::isomarker - Marker for 3D volume rendering
-#
-#  This widget performs volume rendering on 3D scalar/vector datasets.
-#  It connects to the Nanovis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-package require Img
-
-itcl::class Rappture::IsoMarker {
-    constructor {c obj tf args} {}
-    destructor {}
-    public method transferfunc {}
-    public method activate { bool }
-    public method visible { bool }
-    public method screenpos {}
-    public method absval { {x "-get"} }
-    public method relval { {x "-get"} }
-
-    private method EnterTick {}
-    private method LeaveTick {}
-    private method StartDrag { x y }
-    private method ContinueDrag { x y }
-    private method StopDrag { x y }
-
-    private variable _value     0.0;    # Absolute value of marker.
-    private variable _label     ""
-    private variable _tick      ""
-    private variable _canvas    ""
-    private variable _nvobj     "";     # Parent nanovis object.
-    private variable _tf        "";     # Transfer function that this marker is
-                                        # associated with.
-    private variable _activeMotion   0
-    private variable _activePress    0
-
-    private common   _normalIcon [Rappture::icon nvlegendmark]
-    private common   _activeIcon [Rappture::icon nvlegendmark2]
-}
-
-itcl::body Rappture::IsoMarker::constructor {c obj tf args} {
-    set _canvas $c
-    set _nvobj $obj
-    set _tf $tf
-    set w [winfo width $_canvas]
-    set h [winfo height $_canvas]
-    set _tick [$c create image 0 $h \
-                   -image $_normalIcon -anchor s \
-                   -tags "tick $this $obj" -state hidden]
-    set _label [$c create text 0 $h \
-                    -anchor n -fill white -font "Helvetica 8" \
-                    -tags "labels text $this $obj" -state hidden]
-    $c bind $_tick <Enter>           [itcl::code $this EnterTick]
-    $c bind $_tick <Leave>           [itcl::code $this LeaveTick]
-    $c bind $_tick <ButtonPress-1>   [itcl::code $this StartDrag %x %y]
-    $c bind $_tick <B1-Motion>       [itcl::code $this ContinueDrag %x %y]
-    $c bind $_tick <ButtonRelease-1> [itcl::code $this StopDrag %x %y]
-}
-
-itcl::body Rappture::IsoMarker::destructor {} {
-    if { [winfo exists $_canvas] } {
-        $_canvas delete $this
-    }
-}
-
-itcl::body Rappture::IsoMarker::transferfunc {} {
-    return $_tf
-}
-
-itcl::body Rappture::IsoMarker::activate { bool } {
-    if  { $bool || $_activePress || $_activeMotion } {
-        $_canvas itemconfigure $_label -state normal
-        $_canvas itemconfigure $_tick -image $_activeIcon
-        $_canvas itemconfigure title -state hidden
-    } else {
-        $_canvas itemconfigure $_label -state hidden
-        $_canvas itemconfigure $_tick -image $_normalIcon
-        $_canvas itemconfigure title -state normal
-    }
-}
-
-itcl::body Rappture::IsoMarker::visible { bool } {
-    if { $bool } {
-        absval $_value
-        $_canvas itemconfigure $_tick -state normal
-        $_canvas raise $_tick
-    } else {
-        $_canvas itemconfigure $_tick -state hidden
-    }
-}
-
-itcl::body Rappture::IsoMarker::screenpos { } {
-    set x [relval]
-    if { $x < 0.0 } {
-        set x 0.0
-    } elseif { $x > 1.0 } {
-        set x 1.0
-    }
-    set low 10
-    set w [winfo width $_canvas]
-    set high [expr {$w  - 10}]
-    set x [expr {round($x*($high - $low) + $low)}]
-    return $x
-}
-
-itcl::body Rappture::IsoMarker::absval { {x "-get"} } {
-    if { $x != "-get" } {
-        set _value $x
-        set y 31
-        $_canvas itemconfigure $_label -text [format %g $_value]
-        set x [screenpos]
-        $_canvas coords $_tick $x [expr {$y+3}]
-        $_canvas coords $_label $x [expr {$y+5}]
-    }
-    return $_value
-}
-
-itcl::body Rappture::IsoMarker::relval { {x "-get"} } {
-    array set limits [$_nvobj limits $_tf]
-    set min $limits(vmin)
-    set max $limits(vmax)
-    if { $x == "-get" } {
-        if { $max == $min } {
-            if { $max == 0.0 } {
-                set min 0.0
-                set max 1.0
-            } else {
-                set max [expr $min + 1.0]
-            }
-        }
-        return [expr {($_value - $min) / ($max - $min)}]
-    }
-    if { $max == $min } {
-        set min 0.0
-        set max 1.0
-    }
-    if { [catch {expr $max - $min} r] != 0 } {
-        return 0.0
-    }
-    absval [expr {($x * $r) + $min}]
-}
-
-itcl::body Rappture::IsoMarker::EnterTick {} {
-    set _activeMotion 1
-    activate yes
-    $_canvas raise $_tick
-}
-
-itcl::body Rappture::IsoMarker::LeaveTick {} {
-    set _activeMotion 0
-    activate no
-}
-
-itcl::body Rappture::IsoMarker::StartDrag { x y } {
-    $_canvas raise $_tick
-    set _activePress 1
-    activate yes
-    $_canvas itemconfigure limits -state hidden
-    $_canvas itemconfigure title -state hidden
-}
-
-itcl::body Rappture::IsoMarker::StopDrag { x y } {
-    if { ![$_nvobj removeDuplicateMarker $this $x]} {
-        ContinueDrag $x $y
-    }
-    set _activePress 0
-    activate no
-    $_canvas itemconfigure limits -state normal
-    $_canvas itemconfigure title -state normal
-}
-
-itcl::body Rappture::IsoMarker::ContinueDrag { x y } {
-    set w [winfo width $_canvas]
-    relval [expr {double($x-10)/($w-20)}]
-    $_nvobj overMarker $this $x
-    $_nvobj updateTransferFunctions
-    $_canvas raise $_tick
-    set _activePress 1
-    activate yes
-    $_canvas itemconfigure limits -state hidden
-    $_canvas itemconfigure title -state hidden
-}
Index: trunk/gui/scripts/loader.tcl
===================================================================
--- trunk/gui/scripts/loader.tcl	(revision 6716)
+++ 	(revision )
@@ -1,509 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: loader - widget for loading examples and old runs
-#
-#  This widget is a glorified combobox that is used to load various
-#  example files into the application.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *Loader.textForeground black widgetDefault
-option add *Loader.textBackground white widgetDefault
-
-itcl::class Rappture::Loader {
-    inherit itk::Widget
-
-    itk_option define -tool tool Tool ""
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-    destructor { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _newValue {}
-    protected method _uploadValue {path args}
-    protected method _downloadValues {}
-    protected method _tooltip {}
-    protected method _log {}
-
-    private method SetDefaultValue { value }
-    private method EventuallySetDefaultValue { value }
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this loader
-    private variable _lastlabel "";# label of last example loaded
-
-    private variable _uppath ""   ;# list: path label desc ...
-    private variable _dnpaths ""  ;# list of download element paths
-    private common _dnpath2state  ;# maps download path => yes/no state
-    private variable _copyfrom "" ;# copy xml objects from here in example lib
-    private variable _copyto ""   ;# copy xml objects here in example lib
-    private variable _label2file  ;# maps combobox labels to filenames
-}
-
-itk::usual Loader {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    itk_component add combo {
-        Rappture::Combobox $itk_interior.combo -editable no \
-            -interactcommand [itcl::code $this _log]
-    } {
-        usual
-        keep -width
-    }
-    pack $itk_component(combo) -expand yes -fill both
-    bind $itk_component(combo) <<Value>> [itcl::code $this _newValue]
-
-    eval itk_initialize $args
-
-    # example files are stored here
-    if {$itk_option(-tool) != ""} {
-        set fdir [$itk_option(-tool) installdir]
-    } else {
-        set fdir "."
-    }
-    set defval [string trim [$_owner xml get $path.default]]
-
-    #
-    # If this loader has a <new> section, then create that
-    # entry first.
-    #
-    set newfile ""
-    foreach comp [$_owner xml children -type new $path] {
-        set name  [string trim [$_owner xml get $path.$comp]]
-        set fname [file join $fdir examples $name]
-
-        if {[file exists $fname]} {
-            set newfile $fname
-
-            if {[catch {set obj [Rappture::library $fname]} result]} {
-                puts stderr "WARNING: can't load example file \"$fname\""
-                puts stderr "  $result"
-            } else {
-                set label "New"
-                $itk_component(combo) choices insert end $obj $label
-
-                # if this is new, add it to the label->file hash
-                if {![info exists entries($label)]} {
-                    set entries($label) $obj
-                    set _label2file($label) [file tail $fname]
-                }
-
-                # translate default file name => default label
-                if {[string equal $defval [file tail $fname]]} {
-                    $_owner xml put $path.default "New"
-                }
-            }
-            break
-        } else {
-            puts stderr "WARNING: missing example file \"$fname\""
-        }
-    }
-
-    #
-    # If this loader has an <upload> section, then create that
-    # entry next.
-    #
-    foreach comp [$_owner xml children -type upload $path] {
-        foreach tcomp [$_owner xml children -type to $path.$comp] {
-            set topath [string trim [$_owner xml get $path.$comp.$tcomp]]
-            if { [$_owner xml element -as id $topath] == "" } {
-                puts stderr \
-                    "unknown <upload> path \"$topath\": please fix tool.xml"
-                continue
-            }
-            set label [string trim [$_owner xml get $topath.about.label]]
-            set desc  [string trim [$_owner xml get $topath.about.description]]
-            lappend _uppath $topath $label $desc
-        }
-        break
-    }
-    if {[llength $_uppath] > 0} {
-        $itk_component(combo) choices insert end \
-            @upload [Rappture::filexfer::label upload]
-    }
-
-    #
-    # If this loader has a <download> section, then create that
-    # entry next.  Build a popup for choices if there is more than
-    # one download element.
-    #
-    Rappture::Balloon $itk_component(hull).download \
-        -title "Choose what to [string tolower [Rappture::filexfer::label downloadWord]]:"
-    set inner [$itk_component(hull).download component inner]
-
-    set i 0
-    foreach comp [$_owner xml children -type download $path] {
-        foreach dcomp [$_owner xml children -type from $path.$comp] {
-            set frompath [string trim [$_owner xml get $path.$comp.$dcomp]]
-            if {"" != $frompath} {
-                lappend _dnpaths $frompath
-                set _dnpath2state($this-$frompath) [expr {$i == 0}]
-
-                set label [string trim [$_owner xml get $frompath.about.label]]
-                checkbutton $inner.cb$i -text $label \
-                    -variable ::Rappture::Loader::_dnpath2state($this-$frompath)
-                pack $inner.cb$i -anchor w
-                incr i
-            }
-        }
-    }
-    button $inner.go -text [Rappture::filexfer::label download] \
-        -command [itcl::code $this _downloadValues]
-    pack $inner.go -side bottom -padx 50 -pady {4 2}
-
-    if {[llength $_dnpaths] > 0} {
-        $itk_component(combo) choices insert end \
-            @download [Rappture::filexfer::label download]
-    }
-
-    if {[$itk_component(combo) choices size] > 0} {
-        $itk_component(combo) choices insert end "---" "---"
-    }
-
-    #
-    # Scan through and extract example objects, and load them into
-    # the combobox.
-    #
-    set flist ""
-    foreach comp [$_owner xml children -type example $path] {
-        lappend flist [string trim [$_owner xml get $path.$comp]]
-    }
-
-    # if there are no examples, then look for *.xml
-    if {[llength $flist] == 0} {
-        set flist *.xml
-    }
-
-    catch {unset entries}
-    set _counter 0
-    foreach ftail $flist {
-        set fpath [file join $fdir examples $ftail]
-
-        foreach fname [glob -nocomplain $fpath] {
-            if {[string equal $fname $newfile]} {
-                continue
-            }
-            if {[file exists $fname]} {
-                if {[catch {set obj [Rappture::library $fname]} result]} {
-                    puts stderr "WARNING: can't load example file \"$fname\""
-                    puts stderr "  $result"
-                } else {
-                    set label [$obj get about.label]
-                    if {$label == ""} {
-                        set label "Example #[incr _counter]"
-                    }
-
-                    # if this is new, add it to the label->file hash
-                    if {![info exists entries($label)]} {
-                        set entries($label) $obj
-                        set _label2file($label) [file tail $fname]
-                    }
-
-                    # translate default file name => default label
-                    if {[string equal $defval [file tail $fname]]} {
-                        $_owner xml put $path.default $label
-                    }
-                }
-            } else {
-                puts stderr "WARNING: missing example file \"$fname\""
-            }
-        }
-    }
-    foreach label [lsort -dictionary [array names entries]] {
-        $itk_component(combo) choices insert end $entries($label) $label
-    }
-
-    set _copyfrom [string trim [$_owner xml get $path.copy.from]]
-    set _copyto   [string trim [$_owner xml get $path.copy.to]]
-
-    #
-    # Assign the default value to this widget, if there is one.
-    #
-    set str [string trim [$_owner xml get $path.default]]
-    if { $str != "" } {
-        EventuallySetDefaultValue $str
-    }
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::destructor {} {
-    # be sure to clean up entries for this widget's download paths
-    foreach path $_dnpaths {
-        catch {unset _dnpath2state($this-$path)}
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [lindex $args 0]
-        $itk_component(combo) value $newval
-        return $newval
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    return [$itk_component(combo) value]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {"" == $label} {
-        set label "Example"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::tooltip {} {
-    # query tooltip on-demand based on current choice
-    return "@[itcl::code $this _tooltip]"
-}
-
-itcl::body Rappture::Loader::SetDefaultValue { value } {
-    $itk_component(combo) value $value
-    _newValue
-}
-#
-#
-# EventuallySetDefaultValue --
-#
-#   Sets the designated default value for the loader.  This must be done
-#   after the entire application is assembled, otherwise the default values
-#   set up by the loader will be overwritten by the various widgets
-#   themselves when they try to set their default values.
-#
-itcl::body Rappture::Loader::EventuallySetDefaultValue { value } {
-    after 100 [itcl::code $this SetDefaultValue $value]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _newValue
-#
-# Invoked automatically whenever the value in the combobox changes.
-# Tries to load the selected example into the tool's data structure.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::_newValue {} {
-    set newval [$itk_component(combo) value]
-    set obj [$itk_component(combo) translate $newval]
-    if {$obj == "@upload"} {
-        set tool [Rappture::Tool::resources -appname]
-        Rappture::filexfer::upload \
-            $tool $_uppath [itcl::code $this _uploadValue]
-
-        # put the combobox back to its last value
-        $itk_component(combo) component entry configure -state normal
-        $itk_component(combo) component entry delete 0 end
-        $itk_component(combo) component entry insert end $_lastlabel
-        $itk_component(combo) component entry configure -state disabled
-
-    } elseif {$obj == "@download"} {
-        if {[llength $_dnpaths] == 1} {
-            _downloadValues
-        } else {
-            $itk_component(hull).download activate $itk_component(combo) below
-        }
-
-        # put the combobox back to its last value
-        $itk_component(combo) component entry configure -state normal
-        $itk_component(combo) component entry delete 0 end
-        $itk_component(combo) component entry insert end $_lastlabel
-        $itk_component(combo) component entry configure -state disabled
-
-    } elseif {$obj == "---"} {
-        # put the combobox back to its last value
-        $itk_component(combo) component entry configure -state normal
-        $itk_component(combo) component entry delete 0 end
-        $itk_component(combo) component entry insert end $_lastlabel
-        $itk_component(combo) component entry configure -state disabled
-    } elseif {$obj != "" && $itk_option(-tool) != ""} {
-        if {("" != $_copyfrom) && ("" != $_copyto)} {
-            $obj copy $_copyto from $_copyfrom
-        }
-        $_owner xml put $_path.file $_label2file($newval)
-        $itk_option(-tool) load $obj
-        set _lastlabel $newval
-    }
-
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _tooltip
-#
-# Returns the tooltip for this widget, given the current choice in
-# the selector.  This is normally called by the Rappture::Tooltip
-# facility whenever it is about to pop up a tooltip for this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::_tooltip {} {
-    set str [string trim [$_owner xml get $_path.about.description]]
-
-    # get the description for the current choice, if there is one
-    set newval [$itk_component(combo) value]
-    set obj [$itk_component(combo) translate $newval]
-    if {$obj != ""} {
-        if {$obj == "@upload"} {
-            append str "\n\nUse this option to upload data from your desktop."
-        } else {
-            set label [$obj get about.label]
-            if {[string length $label] > 0} {
-                append str "\n\n$label"
-            }
-
-            set desc [$obj get about.description]
-            if {[string length $desc] > 0} {
-                if {[string length $label] > 0} {
-                    append str ":\n"
-                } else {
-                    append str "\n\n"
-                }
-                append str $desc
-            }
-        }
-    }
-    return [string trim $str]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _log
-#
-# Used internally to send info to the logging mechanism.  Calls the
-# Rappture::Logger mechanism to log the change to this input.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::_log {} {
-    Rappture::Logger::log input $_path [$itk_component(combo) value]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _uploadValue ?<key> <value> <key> <value> ...?
-#
-# Invoked automatically whenever the user has uploaded data from
-# the "Upload..." option.  Takes the data value (passed as an
-# argument) and loads into the destination widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::_uploadValue {args} {
-    array set data $args
-
-    if {[info exists data(error)]} {
-        Rappture::Tooltip::cue $itk_component(combo) $data(error)
-    }
-
-    if {[info exists data(path)] && [info exists data(data)]} {
-        Rappture::Tooltip::cue hide  ;# take down note about the popup window
-        $itk_option(-tool) valuefor $data(path) $data(data)
-
-        $itk_component(combo) component entry configure -state normal
-        $itk_component(combo) component entry delete 0 end
-        $itk_component(combo) component entry insert end "Uploaded data"
-        $itk_component(combo) component entry configure -state disabled
-        set _lastlabel "Uploaded data"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _downloadValues
-#
-# Used internally to download all values checked by the popup that
-# controls downloading.  Sends the values for the various controls
-# out to the user by popping up separate browser windows.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Loader::_downloadValues {} {
-    # take down the popup (in case it was posted)
-    $itk_component(hull).download deactivate
-
-    set mesg ""
-    foreach path $_dnpaths {
-        if {$_dnpath2state($this-$path)} {
-            set info [$itk_option(-tool) valuefor $path]
-            set mesg [Rappture::filexfer::download $info input.txt]
-            if {"" != $mesg} { break }
-        }
-    }
-
-    if {"" != $mesg} {
-        Rappture::Tooltip::cue $itk_component(combo) $mesg
-    }
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -tool
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Loader::tool {
-    if {[catch {$itk_option(-tool) isa Rappture::Tool} valid] || !$valid} {
-        error "object \"$itk_option(-tool)\" is not a Rappture Tool"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Loader::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(combo) configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/logger.tcl
===================================================================
--- trunk/gui/scripts/logger.tcl	(revision 6716)
+++ 	(revision )
@@ -1,214 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: logger - log user activities within the Rappture program
-#
-#  This library is used throughout a Rappture application to log
-#  things that the user does.  This is useful for debugging, and also
-#  for studying the effectiveness of simulation in education.  The
-#  information is logged only if the RAPPTURE_LOG environment variable
-#  is set.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-namespace eval Rappture::Logger {
-    # by default, the logger is off
-    variable enabled 0
-
-    # log file name
-    variable fileName ""
-
-    # all activitiy is logged to this file channel
-    variable fid ""
-}
-
-#
-# HACK ALERT!  Many of the BLT graph-related widgets rely on BLT
-#   bindings for zoom.  If we want to log these, we need to catch
-#   them at the push/pop zoom level.  We do this once, here, by
-#   wrapping the usual BLT procs in logging procs.
-#
-package require BLT
-auto_load Blt_ZoomStack
-
-rename ::blt::PushZoom ::blt::RealPushZoom
-proc ::blt::PushZoom {graph} {
-    # do the BLT call first
-    ::blt::RealPushZoom $graph
-
-    # now, log the results
-    foreach {x0 x1} [$graph axis limits x] break
-    foreach {y0 y1} [$graph axis limits y] break
-    ::Rappture::Logger::log zoomrect -in $x0,$y0 $x1,$y1
-}
-
-rename ::blt::PopZoom ::blt::RealPopZoom
-proc ::blt::PopZoom {graph} {
-    # do the BLT call first
-    ::blt::RealPopZoom $graph
-
-    # now, log the results
-    foreach {x0 x1} [$graph axis limits x] break
-    foreach {y0 y1} [$graph axis limits y] break
-    ::Rappture::Logger::log zoomrect -out $x0,$y0 $x1,$y1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: init ?on|off|auto?
-#
-# Called within the main program to initialize the logger package.
-# Can be given the value "on" or "off" to turn logging on/off, or
-# "auto" to rely on the RAPPTURE_LOG environment variable to control
-# logging.  The default is "auto".
-# ----------------------------------------------------------------------
-proc Rappture::Logger::init {{state "auto"}} {
-    global env tcl_platform
-    variable enabled
-    variable fileName
-    variable fid
-
-    if {$state eq "auto"} {
-        set state "off"
-        if {[info exists env(RAPPTURE_LOG)] && $env(RAPPTURE_LOG) ne ""} {
-            if {[file isdirectory $env(RAPPTURE_LOG)]} {
-                set state "on"
-            } else {
-                error "can't log: RAPPTURE_LOG directory does not exist"
-            }
-        }
-    }
-    if {![string is boolean -strict $state]} {
-        error "bad value \"$state\": should be on, off, or auto"
-    }
-
-    if {$state} {
-        # turn logging on
-        package require base32
-        package require md5
-
-        # make a date subdir within the log dir
-        if {![info exists env(RAPPTURE_LOG)]} {
-            set env(RAPPTURE_LOG) /tmp
-        }
-        set dir [clock format [clock seconds] -format "%Y-%m-%d"]
-        set dir [file join $env(RAPPTURE_LOG) $dir]
-        if {![file isdirectory $dir]} {
-            puts stderr "WARNING: log directory \"$dir\" doesn't exist"
-            return
-        }
-
-        # generate a unique random file name for the log
-        set app [Rappture::Tool::resources -appname]
-        if {$app eq ""} {
-            error "app name not set before logging -- init logging after initializing tool resources"
-        }
-
-        for {set ntries 0} {$ntries < 5} {incr ntries} {
-            set unique [string map {= _} [base32::encode [md5::md5 "$tcl_platform(user):$app:[clock seconds]:[clock clicks]"]]]
-
-            set fileName [file join $dir $unique.log]
-            if {![file exists $fileName]} {
-                break
-            }
-        }
-        if {[file exists $fileName]} {
-            error "can't seem to create a unique log file name in $dir"
-        }
-
-        # open the log file
-        set fid [open $fileName w]
-
-        # set the buffer size low so we don't lose much output if the
-        # program suddenly terminates
-        fconfigure $fid -buffersize 1024
-
-        # set permissions on the file so that it's not readable
-        # NOTE: middleware should do this automatically
-        ##file attributes $fileName -permissions 0400
-
-        # logging is now turned on
-        set enabled 1
-
-        # create the logging proc -- this is faster than checking "enabled"
-        proc ::Rappture::Logger::log {event args} {
-            variable fid
-            # limit the side of log messages (which could be really large)
-            set shortArgs ""
-            foreach str $args {
-                if {[string length $str] > 255} {
-                    set str "[string range $str 0 255]..."
-                }
-                lappend shortArgs $str
-            }
-            catch {
-              set t [clock seconds]
-              set tstr [clock format $t -format "%T"]
-              puts $fid "$t = $tstr>> $event $shortArgs"
-            }
-        }
-
-        # save out some info about the user and the session
-        puts $fid "# Application: $app"
-        puts $fid "# User: $tcl_platform(user)"
-        if {[info exists env(SESSION)]} {
-            puts $fid "# Session: $env(SESSION)"
-        }
-        puts $fid "# Date: [clock format [clock seconds]]"
-        Rappture::Logger::log started
-
-    } else {
-        # turn logging off
-        if {$fid ne ""} {
-            catch {close $fid}
-            set fid ""
-        }
-        set enabled 0
-
-        # null out the logging proc -- this is faster than checking "enabled"
-        proc ::Rappture::Logger::log {event args} { # do nothing }
-    }
-
-    # catch signals that kill the program and clean up logging
-    package require Rappture
-    Rappture::signal SIGHUP RapptureLogger ::Rappture::Logger::cleanup
-    Rappture::signal SIGINT RapptureLogger ::Rappture::Logger::cleanup
-    Rappture::signal SIGQUIT RapptureLogger ::Rappture::Logger::cleanup
-    Rappture::signal SIGTERM RapptureLogger ::Rappture::Logger::cleanup
-    Rappture::signal SIGKILL RapptureLogger ::Rappture::Logger::cleanup
-}
-
-# ----------------------------------------------------------------------
-# USAGE: log <event> ?<detail> <detail> ...?
-#
-# Used throughout the Rappture application to log various activities.
-# Each <event> is a short name like "tooltip" or "inputChanged" that
-# indicates what happened.  All remaining arguments are appended to
-# the log as details about what happened or what changed.
-# ----------------------------------------------------------------------
-proc Rappture::Logger::log {event args} {
-    # do nothing by default until turned on by init
-}
-
-# ----------------------------------------------------------------------
-# USAGE: cleanup
-#
-# Called when the program receives a signal that would normally kill
-# the program.  Flushes the buffer and closes the log file cleanly
-# before dying.
-# ----------------------------------------------------------------------
-proc Rappture::Logger::cleanup {} {
-    variable enabled
-    variable fid
-
-    if {$enabled && $fid ne ""} {
-        log finished
-        catch {flush $fid}
-        catch {close $fid}
-        set fid ""
-        set enabled 0
-    }
-    after idle exit
-}
Index: trunk/gui/scripts/main.tcl
===================================================================
--- trunk/gui/scripts/main.tcl	(revision 6716)
+++ 	(revision )
@@ -1,447 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-#!/bin/sh
-# ----------------------------------------------------------------------
-#  USER INTERFACE DRIVER
-#
-#  This driver program loads a tool description from a tool.xml file,
-#  and produces a user interface automatically to drive an application.
-#  The user can set up input, click and button to launch a tool, and
-#  browse through output.
-#
-#  RUN AS FOLLOWS:
-#    wish main.tcl ?-tool <toolfile>?
-#
-#  If the <toolfile> is not specified, it defaults to "tool.xml" in
-#  the current working directory.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-# take the main window down for now, so we can avoid a flash on the screen
-wm withdraw .
-
-package require Itcl
-package require Img
-package require Rappture
-package require RapptureGUI
-
-option add *MainWin.mode desktop startupFile
-option add *MainWin.borderWidth 0 startupFile
-option add *MainWin.anchor fill startupFile
-
-# "web site" look
-option add *MainWin.bgScript {
-    rectangle 0 0 200 <h> -outline "" -fill #5880BB
-    rectangle 200 0 300 <h> -outline "" -fill #425F8B
-    rectangle 300 0 <w> <h> -outline "" -fill #324565
-} startupFile
-
-# "clean" look
-option add *MainWin.bgScript "" startupFile
-option add *MainWin.bgColor white startupFile
-option add *Tooltip.background white
-option add *Editor.background white
-option add *Gauge.textBackground white
-option add *TemperatureGauge.textBackground white
-option add *Switch.textBackground white
-option add *Progress.barColor #ffffcc
-option add *Balloon.titleBackground #6666cc
-option add *Balloon.titleForeground white
-option add *Balloon*Label.font -*-helvetica-medium-r-normal-*-12-*
-option add *Balloon*Radiobutton.font -*-helvetica-medium-r-normal-*-12-*
-option add *Balloon*Checkbutton.font -*-helvetica-medium-r-normal-*-12-*
-option add *ResultSelector.controlbarBackground #6666cc
-option add *ResultSelector.controlbarForeground white
-option add *ResultSelector.activeControlBackground #ccccff
-option add *ResultSelector.activeControlForeground black
-option add *Radiodial.length 3i
-option add *BugReport*banner*foreground white
-option add *BugReport*banner*background #a9a9a9
-option add *BugReport*banner*highlightBackground #a9a9a9
-option add *BugReport*banner*font -*-helvetica-bold-r-normal-*-18-*
-option add *hubcntls*Button.padX 0 widgetDefault
-option add *hubcntls*Button.padY 0 widgetDefault
-option add *hubcntls*Button.relief flat widgetDefault
-option add *hubcntls*Button.overRelief raised widgetDefault
-option add *hubcntls*Button.borderWidth 1 widgetDefault
-option add *hubcntls*Button.font \
-    -*-helvetica-medium-r-normal-*-8-* widgetDefault
-
-switch $tcl_platform(platform) {
-    unix - windows {
-        event add <<PopupMenu>> <ButtonPress-3>
-    }
-    macintosh {
-        event add <<PopupMenu>> <Control-ButtonPress-1>
-    }
-}
-
-# install a better bug handler
-Rappture::bugreport::install
-# fix the "grab" command to support a stack of grab windows
-Rappture::grab::init
-
-#
-# Process command line args to get the names of files to load...
-#
-Rappture::getopts argv params {
-    value -tool tool.xml
-    list  -load ""
-    value -input ""
-    value -simset ""
-    value -nosim 0
-}
-
-proc ReadToolParameters { numTries } {
-    incr numTries -1
-    if { $numTries < 0 } {
-        return
-    }
-    global env
-    set paramsFile $env(TOOL_PARAMETERS)
-    if { ![file readable $paramsFile] } {
-        after 500 ReadToolParmeters $numTries
-        return
-    }
-    catch {
-        set f [open $paramsFile "r"]
-        set contents [read $f]
-        close $f
-        set pattern {^file\((.*)\):(.*)$}
-        foreach line [split $contents "\n"] {
-            if { [regexp $pattern $line match path rest] } {
-                set ::Rappture::parameters($path) $rest
-            }
-        }
-    }
-}
-
-if { [info exists env(TOOL_PARAMETERS)] } {
-    ReadToolParameters 10
-}
-
-set loadobjs {}
-foreach runfile $params(-load) {
-    if {![file exists $runfile]} {
-        puts stderr "can't find run: \"$runfile\""
-        exit 1
-    }
-    set status [catch {Rappture::library $runfile} result]
-    lappend loadobjs $result
-}
-
-set inputobj {}
-if {$params(-input) ne ""} {
-    if {![file exists $params(-input)]} {
-        puts stderr "can't find input file: \"$params(-input)\""
-        exit 1
-    }
-    if {[catch {Rappture::library $params(-input)} result] == 0} {
-        set inputobj $result
-    }
-}
-
-# open the XML file containing the tool parameters
-if {![file exists $params(-tool)]} {
-    # check to see if the user specified any run.xml files to load.
-    # if so, we can use that as the tool.xml. if we can find where
-    # the original application was installed using the xml tag
-    # tool.version.application.directory(top), the user can
-    # run new simulations, otherwise they can only revisualize the
-    # run.xml files they are loading.
-    set pseudotool ""
-    if {[llength $loadobjs] == 0 && $inputobj eq ""} {
-        puts stderr "can't find tool \"$params(-tool)\""
-        exit 1
-    }
-    # search the loadfiles for the install location
-    # we could just use run.xml files as tool.xml, but
-    # if there are loaders or notes, they will still need
-    # examples/ and docs/ dirs from the install location
-    set check [concat $loadobjs $inputobj]
-    foreach runobj $check {
-        set tdir \
-            [string trim [$runobj get tool.version.application.directory(tool)]]
-        if {[file isdirectory $tdir] && \
-            [file exists $tdir/tool.xml]} {
-            set pseudotool $tdir/tool.xml
-            break
-        }
-    }
-    if {![file exists $pseudotool]} {
-        # we didn't find a tool.xml file,
-        # use info from a runfile to build gui
-        # disable simulation, because no tool.xml
-        set pseudotool [lindex $params(-load) 0]
-        array set params [list -nosim true]
-    }
-    if {![file exists $pseudotool]} {
-        puts stderr "can't find tool \"$params(-tool)\""
-        exit 1
-    }
-    array set params [list -tool $pseudotool]
-}
-
-set xmlobj [Rappture::library $params(-tool)]
-
-set installdir [file normalize [file dirname $params(-tool)]]
-$xmlobj put tool.version.application.directory(tool) $installdir
-set tool [Rappture::Tool ::#auto $xmlobj $installdir]
-
-# ----------------------------------------------------------------------
-# CHECK JOB FAILURE REPORTING
-#
-# If this tool might fail when it launches jobs (i.e., Rappture
-# can't check some inputs, such as strings), then disable the
-# automatic ticket submission for job failures
-# ----------------------------------------------------------------------
-set val [string trim [$tool xml get tool.reportJobFailures]]
-if { "" != $val} {
-    if {[catch {Rappture::bugreport::shouldReport jobfailures $val} result]} {
-        puts stderr "WARNING for reportJobFailures: $result"
-    }
-}
-
-# ----------------------------------------------------------------------
-# LOAD RESOURCE SETTINGS
-#
-# Try to load the $SESSIONDIR/resources file, which contains
-# middleware settings, such as the application name and the
-# filexfer settings.
-# ----------------------------------------------------------------------
-Rappture::resources::load
-
-# ----------------------------------------------------------------------
-# START LOGGING
-#
-# If the $RAPPTURE_LOG directory is set to a directory used for
-# logging, then open a log file and start logging.
-# ----------------------------------------------------------------------
-Rappture::Logger::init
-
-# ----------------------------------------------------------------------
-# INITIALIZE THE DESKTOP CONNECTION
-#
-# If there's a SESSION ID, then this must be running within the
-# nanoHUB.  Try to initialize the server handling the desktop
-# connection.
-# ----------------------------------------------------------------------
-Rappture::filexfer::init
-
-# ----------------------------------------------------------------------
-# MAIN WINDOW
-# ----------------------------------------------------------------------
-Rappture::MainWin .main -borderwidth 0
-.main configure -title [string trim [$tool xml get tool.title]]
-wm withdraw .main
-wm protocol .main WM_DELETE_WINDOW {Rappture::Logger::cleanup; exit}
-
-# if the FULLSCREEN variable is set, then nanoHUB wants us to go full screen
-if {[info exists env(FULLSCREEN)]} {
-    .main configure -mode web
-}
-
-#
-# The main window has a pager that acts as a notebook for the
-# various parts.  This notebook as at least two pages--an input
-# page and an output (analysis) page.  If there are <phase>'s
-# for input, then there are more pages in the notebook.
-#
-set win [.main component app]
-Rappture::Postern $win.postern
-pack $win.postern -side bottom -fill x
-
-Rappture::Pager $win.pager
-pack $win.pager -expand yes -fill both
-
-#
-# Add a place for menu button in the breadcrumbs area of this pager.
-#
-set app [string trim [$tool xml get tool.id]]
-set url [Rappture::Tool::resources -huburl]
-set crumbs [$win.pager component breadcrumbarea]
-frame $crumbs.hubcntls
-pack $crumbs.hubcntls -side right -padx 4
-
-set m $crumbs.hubcntls.help.menu
-menubutton $crumbs.hubcntls.help \
-    -image [Rappture::icon hamburger_menu] \
-    -highlightthickness 0 \
-    -menu $m
-pack $crumbs.hubcntls.help -side top -anchor w
-
-#
-# Load up the components in the various phases of input.
-#
-set phases [$tool xml children -type phase input]
-if {[llength $phases] > 0} {
-    set plist ""
-    foreach name $phases {
-        lappend plist input.$name
-    }
-    set phases $plist
-} else {
-    set phases input
-}
-
-foreach comp $phases {
-    set title [string trim [$tool xml get $comp.about.label]]
-    if {$title == ""} {
-        set title "Input #auto"
-    }
-    $win.pager insert end -name $comp -title $title
-
-    #
-    # Build the page of input controls for this phase.
-    #
-    set f [$win.pager page $comp]
-    Rappture::Page $f.cntls $tool $comp
-    pack $f.cntls -expand yes -fill both
-}
-
-# let components (loaders) in the newly created pages settle
-update
-
-# ----------------------------------------------------------------------
-# OUTPUT AREA
-# ----------------------------------------------------------------------
-
-# adjust the title of the page here.
-# to adjust the button text, look in analyzer.tcl
-set simtxt [string trim [$xmlobj get tool.action.label]]
-if {"" == $simtxt} {
-    set simtxt "Simulate"
-}
-$win.pager insert end -name analyzer -title $simtxt
-set f [$win.pager page analyzer]
-$win.pager page analyzer -command [subst {
-    if { !$params(-nosim) } {
-        $win.pager busy yes
-        update
-        $f.analyze simulate -ifneeded
-        $win.pager busy no
-    }
-}]
-
-Rappture::Analyzer $f.analyze $tool -simcontrol auto -notebookpage about
-pack $f.analyze -expand yes -fill both
-
-$tool notify add analyzer * [list $f.analyze reset]
-$f.analyze buildMenu $m $url $app
-
-# ----------------------------------------------------------------------
-# Finalize the arrangement
-# ----------------------------------------------------------------------
-if {[llength [$win.pager page]] > 2} {
-    # We have phases, so we shouldn't allow the "Simulate" button.
-    # If it pops up, there are two ways to push simulate and duplicate
-    # links for "About" and "Questions?".
-    $f.analyze configure -simcontrol off
-} elseif {[llength [$win.pager page]] == 2} {
-    set style [string trim [$xmlobj get tool.layout]]
-    set screenw [winfo screenwidth .]
-
-    update idletasks
-    set w0 [winfo reqwidth [$win.pager page @0]]
-    set w1 [winfo reqwidth [$win.pager page @1]]
-
-    if { $style != "wizard" } {
-        # If only two windows and they're small enough, put them up
-        # side-by-side
-        if {$w0+$w1 < $screenw } {
-            $win.pager configure -arrangement side-by-side
-            $f.analyze configure -holdwindow [$win.pager page @0]
-        }
-    }
-    set type [string trim [$tool xml get tool.control]]
-    if {$type == ""} {
-        set type [string trim [$tool xml get tool.control.type]]
-    }
-    set arrangement [$win.pager cget -arrangement]
-    if { $type == "" } {
-        if { $arrangement != "side-by-side" } {
-           set type auto
-        }
-    }
-    if { $arrangement != "side-by-side" &&
-            ($type == "manual" || $type == "manual-resim" ||
-             $type == "auto" || $style == "wizard") } {
-        # in "auto" mode, we don't need a simulate button
-        $f.analyze configure -simcontrol off
-    } else {
-        # not in "auto" mode but side-by-side, we always need the button
-        $f.analyze configure -simcontrol on
-    }
-}
-
-# load previous xml runfiles
-update
-if {[llength $params(-load)] > 0} {
-    foreach runobj $loadobjs {
-        $f.analyze load $runobj
-    }
-    # load the inputs for the very last run
-    $tool load $runobj
-
-    # don't need simulate button if we cannot simulate
-    if {$params(-nosim)} {
-        $f.analyze configure -simcontrol off
-    }
-    $f.analyze configure -notebookpage analyze
-    $win.pager configure -nosim 1 
-    $win.pager current analyzer
-    $win.pager configure -nosim 0 
-} elseif {$params(-simset) ne ""} {
-    $f.analyze reload $params(-simset)
-} elseif {$params(-input) ne ""} {
-    $tool load $inputobj
-}
-
-# let components (loaders) settle after the newly loaded runs
-#
-# This update was put in to allow the loader to wait for all the
-# widgets to get created before updating them with whatever is the
-# default for the loader.
-#
-# This update is a source of problems for tools that are 1) loading
-# previously saved/shared simulation results and 2) talk to a visualization
-# server.
-#
-# So we're commenting out the "update".  It may need to go back
-# if this breaks loaders with a default setting.
-#update
-
-foreach path [array names ::Rappture::parameters] {
-    if { $path == "simset" } {
-        continue;                       # Don't consider file(simset)
-    }
-    set fname $::Rappture::parameters($path)
-    if { ![file exists $fname] } {
-        puts stderr "WARNING: tool parameters file \"$fname\" doesn't exist"
-        continue;                       # Can't find parameters file
-    }        
-    if { ![file readable $fname] } {
-        puts stderr "WARNING: can't read tool parameters file \"$fname\""
-        continue;                       # Can't read parameters file
-    }
-    set f [open $fname r]
-    set contents [read $f]
-    close $f
-    
-    set w [$tool widgetfor $path]
-    if { $w == "" } {
-        puts stderr "WARNING: can't find control for tool parameter: $path"
-        continue;                       # Can't find rappture control for path
-    }
-    if {[catch {$w value [string trim $info]} result]} {
-        puts stderr "WARNING: bad tool parameter value for \"$path\""
-        puts stderr "  $result"
-    }
-}
-
-wm deiconify .main
Index: trunk/gui/scripts/mainwin.tcl
===================================================================
--- trunk/gui/scripts/mainwin.tcl	(revision 6716)
+++ trunk/gui/scripts/mainwin.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: mainwin - main application window for Rappture
@@ -10,11 +9,7 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
-package require BLT
 
 option add *MainWin.mode desktop widgetDefault
@@ -23,51 +18,6 @@
 option add *MainWin.anchor center widgetDefault
 option add *MainWin.titleFont \
-    -*-helvetica-bold-o-normal-*-14-* widgetDefault
-
-#
-# Tk text widget doesn't honor Ctrl-V by default.  Get rid
-# of the default binding so that Ctrl-V works for <<Paste>>
-# as expected.
-#
-bind Text <Control-KeyPress-v> {}
-
-#
-# Fix the built-in <<Paste>> bindings to work properly even
-# for the X11 windowing system.  By default, Tk won't replace
-# selected text in X11.  What kind of stupid nonsense is that?
-#
-bind Entry <<Paste>> {
-    catch {
-        # always replace existing selection
-        catch { %W delete sel.first sel.last }
-
-        %W insert insert [::tk::GetSelection %W CLIPBOARD]
-        tk::EntrySeeInsert %W
-    }
-}
-proc ::tk_textPaste w {
-    global tcl_platform
-    if {![catch {::tk::GetSelection $w CLIPBOARD} sel]} {
-        if {[catch {$w cget -autoseparators} oldSeparator]} {
-            # in case we're using an older version of Tk
-            set oldSeparator 0
-        }
-        if { $oldSeparator } {
-            $w configure -autoseparators 0
-            $w edit separator
-        }
-
-        # always replace existing selection
-        catch { $w delete sel.first sel.last }
-        $w insert insert $sel
-
-        if { $oldSeparator } {
-            $w edit separator
-            $w configure -autoseparators 1
-        }
-    }
-}
-
-# ======================================================================
+    -*-helvetica-bold-o-normal-*-*-140-* widgetDefault
+
 itcl::class Rappture::MainWin {
     inherit itk::Toplevel
@@ -80,14 +30,12 @@
 
     public method draw {option args}
-    public method syncCutBuffer {option args}
 
     protected method _redraw {}
 
     private variable _contents ""  ;# frame containing app
-    private variable _sync         ;# to sync current selection and cut buffer
     private variable _bgscript ""  ;# script of background drawing cmds
     private variable _bgparser ""  ;# parser for bgscript
 }
-
+                                                                                
 itk::usual MainWin {
     keep -background -cursor foreground -font
@@ -127,5 +75,5 @@
         -menu $itk_component(filemenu)
     $itk_component(filemenu) add command -label "Exit" -underline 1 \
-        -command {destroy .}
+        -command exit
 
     #
@@ -147,105 +95,4 @@
     set btags [bindtags $itk_component(hull)]
     bindtags $itk_component(hull) [lappend btags RapptureMainWin]
-
-    set _sync(cutbuffer) ""
-    set _sync(selection) ""
-
-    #
-    # We used to do this to make "copy/paste with desktop" work
-    # properly.  Well, it never really worked *properly*, but
-    # it was an attempt.  We might as well skip it.  We use
-    # the importfile/exportfile stuff now.
-    #
-    ##global tcl_platform
-    ##if {$tcl_platform(platform) == "unix"} {
-    ##    # this sync stuff works only for X windows
-    ##    blt::cutbuffer set ""
-    ##    syncCutBuffer ifneeded
-    ##}
-}
-
-# ----------------------------------------------------------------------
-# USAGE: syncCutBuffer ifneeded
-# USAGE: syncCutBuffer transfer <offset> <maxchars>
-# USAGE: syncCutBuffer lostselection
-#
-# Invoked automatically whenever the mouse pointer enters or leaves
-# a main window to sync the cut buffer with the primary selection.
-# This helps applications work properly with the "Copy/Paste with
-# Desktop" option on the VNC applet for the nanoHUB.
-#
-# The "ifneeded" option syncs the cutbuffer and the primary selection
-# if either one has new data.
-#
-# The "fromselection" option syncs from the primary selection to the
-# cut buffer.  If there's a primary selection, it gets copied to the
-# cut buffer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MainWin::syncCutBuffer {option args} {
-    set mainwin $itk_component(hull)
-    switch -- $option {
-        ifneeded {
-            #
-            # See if the incoming cut buffer has changed.
-            # If so, then sync the new input to the primary selection.
-            #
-            set s [blt::cutbuffer get]
-            if {"" != $s && ![string equal $s $_sync(cutbuffer)]} {
-                #
-                # Convert any \r's in the cutbuffer to \n's.
-                #
-                if {[string first "\r" $s] >= 0} {
-                    regsub -all "\r\n" $s "\n" s
-                    regsub -all "\r" $s "\n" s
-                    blt::cutbuffer set $s
-                }
-
-                set _sync(cutbuffer) $s
-
-                if {![string equal $s $_sync(selection)]
-                      && [selection own -selection PRIMARY] != $mainwin} {
-                    set _sync(selection) $s
-
-                    clipboard clear
-                    clipboard append -- $s
-                    selection handle -selection PRIMARY $mainwin \
-                        [itcl::code $this syncCutBuffer transfer]
-                    selection own -selection PRIMARY -command \
-                        [itcl::code $this syncCutBuffer lostselection] \
-                        $mainwin
-                }
-            }
-
-            #
-            # See if the selection has changed.  If so, then sync
-            # the new input to the cut buffer, so it's available
-            # outside the VNC client.
-            #
-            if {[catch {selection get -selection PRIMARY} s]} {
-                set s ""
-            }
-            if {"" != $s && ![string equal $s $_sync(selection)]} {
-                set _sync(selection) $s
-                blt::cutbuffer set $s
-            }
-
-            # do this again soon
-            after 1000 [itcl::code $this syncCutBuffer ifneeded]
-        }
-        transfer {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"syncCutBuffer transfer offset max\""
-            }
-            set offset [lindex $args 0]
-            set maxchars [lindex $args 1]
-            return [string range $_currseln $offset [expr {$offset+$maxchars-1}]]
-        }
-        lostselection {
-            # nothing to do
-        }
-        default {
-            error "bad option \"$option\": should be ifneeded, transfer, or lostselection"
-        }
-    }
 }
 
@@ -279,5 +126,4 @@
         }
 
-        set bd 0  ;# optional border
         set sw [winfo width $itk_component(area)]
         set sh [winfo height $itk_component(area)]
@@ -286,54 +132,73 @@
         set w [winfo reqwidth $itk_component(app)]
         set h [winfo reqheight $itk_component(app)]
-        if {$w > $sw-2*$bd} {
-            set $w [expr {$sw-2*$bd}]
+        if {$w > $sw} {
+            set $w $sw
             set clip 1
         }
 
-        set anchor $itk_option(-anchor)
+        set titleh 0
+        set fnt [option get $itk_component(hull) titleFont Font]
+        if {$itk_option(-title) != "" && $fnt != ""} {
+            set titleh [expr {[font metrics $fnt -linespace]+2}]
+        }
+        if {$h+$titleh > $sh} {
+            set $h [expr {$sh-$titleh}]
+            set clip 1
+        }
+
         switch -- $itk_option(-anchor) {
             n {
                 set x [expr {$sw/2}]
-                set y $bd
+                set y $titleh
+                set tx [expr {$x-$w/2}]
+                set ty $titleh
             }
             s {
                 set x [expr {$sw/2}]
-                set y [expr {$sh-$bd}]
+                set y $sh
+                set tx [expr {$x-$w/2}]
+                set ty [expr {$sh-$h}]
             }
             center {
                 set x [expr {$sw/2}]
                 set y [expr {$sh/2}]
+                set tx [expr {$x-$w/2}]
+                set ty [expr {$y-$h/2}]
             }
             w {
-                set x $bd
+                set x 0
                 set y [expr {$sh/2}]
+                set tx 0
+                set ty [expr {$y-$h/2}]
             }
             e {
-                set x [expr {$sw-$bd}]
+                set x $sw
                 set y [expr {$sh/2}]
+                set tx [expr {$sw-$w}]
+                set ty [expr {$y-$h/2}]
             }
             nw {
-                set x $bd
-                set y $bd
+                set x 0
+                set y $titleh
+                set tx 0
+                set ty $titleh
             }
             ne {
-                set x [expr {$sw-$bd}]
-                set y $bd
+                set x $sw
+                set y $titleh
+                set tx [expr {$sw-$w}]
+                set ty $titleh
             }
             sw {
-                set x $bd
-                set y [expr {$sh-$bd}]
+                set x 0
+                set y $sh
+                set tx 0
+                set ty [expr {$sh-$h}]
             }
             se {
-                set x [expr {$sw-$bd}]
-                set y [expr {$sh-$bd}]
-            }
-            fill {
-                set anchor nw
-                set x $bd
-                set y $bd
-                set w [expr {$sw-2*$bd}]
-                set h [expr {$sh-2*$bd}]
-                set clip 1
+                set x $sw
+                set y $sh
+                set tx [expr {$sw-$w}]
+                set ty [expr {$sh-$h}]
             }
         }
@@ -346,6 +211,11 @@
 
         $itk_component(area) create window $x $y \
-            -anchor $anchor -window $itk_component(app) \
+            -anchor $itk_option(-anchor) -window $itk_component(app) \
             -width $w -height $h
+
+        if {$itk_option(-title) != "" && $fnt != ""} {
+            $itk_component(area) create text $tx [expr {$ty-2}] \
+                -anchor sw -text $itk_option(-title) -font $fnt
+        }
     }
 }
@@ -386,5 +256,5 @@
 # ----------------------------------------------------------------------
 itcl::configbody Rappture::MainWin::anchor {
-    if {[lsearch {n s e w ne nw se sw center fill} $itk_option(-anchor)] < 0} {
+    if {[lsearch {n s e w ne nw se sw center} $itk_option(-anchor)] < 0} {
         error "bad anchor \"$itk_option(-anchor)\""
     }
Index: trunk/gui/scripts/map.tcl
===================================================================
--- trunk/gui/scripts/map.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1422 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: map - extracts data from an XML description of a field
-#
-#  This object represents a map of data in an XML description of
-#  simulator output.  A map is similar to a field, but a field is
-#  a quantity versus position in device.  A map is any quantity
-#  versus any other quantity.  This class simplifies the process of
-#  extracting data vectors that represent the map.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture {
-    # forward declaration
-}
-
-itcl::class Rappture::Map {
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method addLayer { type name paramArray driver driverParamArray {stylesheet {}} {script {}} {selectors {}} }
-    public method addSelector { layerName selectorName paramArray }
-    public method addViewpoint { name props }
-    public method clearExtents {}
-    public method deleteLayer { layerName }
-    public method deleteSelector { layerName selectorName }
-    public method deleteViewpoint { viewpointName }
-    public method dirty { key args } {
-        if {[llength $args] == 0} {
-            if { [info exists _dirty($key)] } {
-                return $_dirty($key)
-            } else {
-                return 0
-            }
-        } else {
-            set _dirty($key) [lindex $args 0]
-        }
-    }
-    public method getPlacardConfig { layerName }
-    public method hasLayer { layerName }
-    public method hasSelector { layerName selectorName }
-    public method hasViewpoint { viewpointName }
-    public method hints { args }
-    public method isGeocentric {}
-    public method isvalid {} {
-        return $_isValid;
-    }
-    public method layer { layerName args }
-    public method layers {}
-    public method selectors { layerName }
-    public method selector { layerName selectorName }
-    public method setAttribution { attribution }
-    public method setCamera { camera }
-    public method setColormap { layerName colormap }
-    public method setDescription { description }
-    public method setExtents { xmin ymin xmax ymax {srs "wgs84"} }
-    public method setLabel { label }
-    public method setPlacardConfig { layerName attrlist style padding }
-    public method setProjection { projection }
-    public method setScript { layerName script }
-    public method setStyle { style }
-    public method setStylesheet { layerName stylesheet }
-    public method setToolInfo { id name command title revision }
-    public method setType { type }
-    public method viewpoint { viewpointName }
-    public method viewpoints {}
-
-    public proc getFilesFromStylesheet { stylesheet }
-
-    protected method parseXML { xmlobj path }
-
-    protected proc colorToHTML { color }
-    protected proc fixBoolean { val }
-    protected proc fixEnum { str }
-    protected proc fixQuotes { str }
-    protected proc isBooleanProp { prop }
-    protected proc isColorProp { prop }
-    protected proc isFileProp { prop }
-    protected proc parseStylesheet { stylesheet }
-    protected proc styleToCSS { layerType props {styleName "style"} }
-    protected proc translateProp { layerType styleProp styleValue }
-
-    private variable _tree "";         # Tree of information about the map.
-    private variable _isValid 0;
-    private variable _dirty;
-    array set _dirty {
-        viewpoints 0
-    }
-    private common _nextSelector 0;
-    private common _layerTypes
-    private common _mapTypes
-    array set _layerTypes {
-        "image"         0
-        "elevation"     1
-        "feature"       2
-        "mask"          3
-        "model"         4
-        "polygon"       5
-        "point"         6
-        "icon"          7
-        "line"          8
-        "label"         9
-    }
-    array set _mapTypes {
-        "geocentric"    0
-        "projected"     1
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::constructor {args} {
-    set _tree [blt::tree create]
-    $_tree insert root -label "layers"
-    $_tree insert root -label "viewpoints"
-    setLabel "Map"
-    setType "projected"
-    setProjection "global-mercator"
-    clearExtents
-    setStyle ""
-    setCamera ""
-    if {$args == ""} {
-        set _isValid 1
-    } else {
-        set xmlobj [lindex $args 0]
-        set path [lindex $args 1]
-        if {![Rappture::library isvalid $xmlobj]} {
-            error "bad value \"$xmlobj\": should be LibraryObj"
-        }
-        parseXML $xmlobj $path
-    }
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::destructor {} {
-    if { $_tree != "" } {
-        blt::tree destroy $_tree
-    }
-}
-
-itcl::body Rappture::Map::hints { args } {
-    switch -- [llength $args] {
-        0 {
-            return [$_tree get root]
-        }
-        1 {
-            set field [lindex $args 0]
-            return [$_tree get root $field ""]
-        }
-        default {
-            error "wrong # args: should be \"hints <?name?>\""
-        }
-    }
-}
-
-#
-# parseXML --
-#
-#   Parses the map description in the XML object.
-#
-itcl::body Rappture::Map::parseXML { xmlobj path } {
-    set map [$xmlobj element -as object $path]
-    set elemType [$xmlobj element -as type $path]
-    if {$elemType != "map"} {
-        puts stderr "ERROR: Invalid map XML: \"$elemType\""
-        return
-    }
-    # If there is a <current>, use it
-    set current [$map element -as object "current"]
-    if {$current != ""} {
-        set map $current
-    }
-
-    # Set global map properties
-    setLabel [$map get "about.label"]
-    setDescription [$map get "about.description"]
-    setAttribution [$map get "about.attribution"]
-
-    set mapType [$map get "type"]
-    if { $mapType != "" } {
-        if {[catch {setType $mapType} msg] != 0} {
-            puts stderr "ERROR: $msg"
-            return
-        }
-    }
-
-    set projection [$map get "projection"]
-    set extents    [$map get "extents"]
-    if { $projection  == "" } {
-        if { $extents != "" } {
-            puts stderr "ERROR: cannot specify extents without a projection"
-            set extents ""
-        }
-        set projection "global-mercator"; # Default projection.
-    } elseif { $projection == "geodetic" || $projection == "global-geodetic" ||
-               $projection == "wgs84" || $projection == "epsg:4326" ||
-               $projection == "plate-carre" || $projection == "plate-carree" } {
-        # Can't use angular units in projection  
-        puts stderr "ERROR: Geodetic profile not supported as map projection.  Try using an equirectangular (epsg:32663) projection instead."
-        # FIXME: epsg:32663 not recognized?
-        #set projection "epsg:32663"
-        set projection "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
-    } elseif { $projection == "equirectangular" ||
-               $projection == "eqc-wgs84" } {
-        # FIXME: epsg:32663 not recognized?
-        #set projection "epsg:32663"
-        set projection "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
-    }
-    # FIXME: Verify projection is valid.
-    setProjection $projection
-    if {$extents != ""} {
-        if {[string range $projection 0 6] == "global-"} {
-            puts stderr "ERROR: cannot specify extents for global profile"
-            clearExtents
-        } else {
-            foreach {xmin ymin xmax ymax srs} $extents {}
-            if {$srs == ""} {
-                setExtents $xmin $ymin $xmax $ymax
-            } else {
-                setExtents $xmin $ymin $xmax $ymax $srs
-            }
-        }
-    } else {
-        clearExtents
-    }
-
-    if {[catch {setStyle [$map get "style"]} msg] != 0} {
-        puts stderr "ERROR: $msg"
-    }
-
-    set camnode [$map element -as object "camera"]
-    if {$camnode != ""} {
-        # For backwards compat with camera name/value list string in CDATA
-        set caminfo [string trim [$map get "camera"]]
-        if {$caminfo == ""} {
-            # No CDATA, check for tags
-            foreach camparam {layer x y latitude longitude z heading pitch distance xmin ymin xmax ymax srs verticalDatum} {
-                # Tags can have empty content, so check for node first
-                set params [$camnode children -type $camparam]
-                foreach param $params {
-                    lappend caminfo $camparam [$camnode get $param]
-                }
-            }
-        }
-        if {[catch {setCamera $caminfo} msg] != 0} {
-            puts stderr "ERROR: $msg"
-        }
-    }
-
-    # Parse layers
-    set parent [$_tree findchild root "layers"]
-    set layers [$map element -as object "layers"]
-    set layerList [list]
-    if {$layers != ""} {
-        set layerList [$layers children -type layer]
-    }
-    foreach layer $layerList {
-        # Unique identifier for layer.
-        set name [$layers element -as id "$layer"]
-        if {[hasLayer $name]} {
-            puts stderr "ERROR: Duplicate layer ID '$name', skipping"
-            continue
-        }
-        set layerType [$layers get $layer.type]
-        if { ![info exists _layerTypes($layerType)] } {
-            puts stderr "ERROR: invalid layer type \"$layerType\": should be one of: [join [array names _layerTypes] {, }]"
-            continue
-        }
-        set child [$_tree insert $parent -label $name]
-        $_tree set $child "name" $name
-        $_tree set $child "type" $layerType
-        foreach key { label description attribution profile srs verticalDatum } {
-            $_tree set $child $key [$layers get $layer.$key]
-        }
-        # Common settings (for all layer types) with defaults
-        foreach { key defval } { visible 1 cache 1 shared 0 } {
-            $_tree set $child $key $defval
-            set val [$layers get $layer.$key]
-            if {$val != ""} {
-                $_tree set $child $key $val
-            }
-        }
-        # These are settings for which there should be no default
-        # We want to know if they have been set by the user or not
-        # Not all layer types use these
-        foreach key { coverage opacity content priority style minrange maxrange terrainPatch } {
-            set val [$layers get $layer.$key]
-            if {$val != ""} {
-                if {$key eq "coverage" && $layerType ne "image"} {
-                    puts stderr "ERROR: <coverage> is only valid for layers of type \"image\""
-                }
-                if {$key eq "content" || $key eq "priority"} {
-                    if {$layerType ne "label"} {
-                        puts stderr "ERROR: <content> and <priority> are only valid in layers of type \"label\""
-                    }
-                }
-                if {$key eq "opacity" && ($layerType eq "elevation" ||
-                    $layerType eq "mask")} {
-                    puts stderr "ERROR: <opacity> is not valid for layers of type \"elevation\" or \"mask\""
-                }
-                if {$key eq "terrainPatch" && $layerType ne "feature" &&
-                    $layerType ne "model" && $layerType ne "polygon"} {
-                    puts stderr "ERROR: <terrainPatch> is only valid for layers of type \"feature\", \"model\" or \"polygon\""
-                }
-                $_tree set $child $key $val
-            }
-        }
-        set styles [$layers element -as object $layer.styles]
-        if {$styles != ""} {
-            set val [$styles get stylesheet]
-            # Normalize whitespace
-            regsub -all "\[ \t\r\n\]+" [string trim $val] " " val
-            $_tree set $child stylesheet $val
-            set script [$styles get script]
-            if {$script != ""} {
-                regsub -all "\[\r\n\]+" [string trim $script] " " script
-                $_tree set $child script $script
-            }
-            set sparent [$_tree insert $child -label "selectors"]
-            foreach selector [$styles children -type selector] {
-                set id [$styles element -as id "$selector"]
-                set snode [$_tree insert $sparent -label $id]
-                foreach key { name style styleExpression query queryBounds queryOrderBy } {
-                    set val [$styles get $selector.$key]
-                    if {$val != ""} {
-                        $_tree set $snode $key $val
-                    }
-                }
-            }
-            rename $styles ""
-        }
-        set placard [$layers element -as object $layer.placard]
-        if {$placard != ""} {
-            if {$layerType == "image" || $layerType == "elevation"} {
-                puts stderr "ERROR: Placard not supported on image or elevation layers"
-            }
-            foreach key { attributes style padding } {
-                set $key [$placard get $key]
-            }
-            setPlacardConfig $name $attributes $style $padding
-        }
-        $_tree set $child "driver" "debug"
-        set colorramp [$layers element -as type $layer.colorramp]
-        if { $colorramp != "" } {
-            $_tree set $child "colorramp.elevdriver" "gdal"
-            $_tree set $child "colorramp.colormap" "0 0 0 0 1 1 1 1 1 1"
-            set cmap [$layers get $layer.colorramp.colormap]
-            if {$cmap != ""} {
-                # Normalize whitespace
-                regsub -all "\[ \t\r\n\]+" [string trim $cmap] " " cmap
-                $_tree set $child "colorramp.colormap" $cmap
-            }
-            foreach key { url elevdriver } {
-                set value [$layers get $layer.colorramp.$key]
-                if {$value != ""} {
-                    $_tree set $child "colorramp.$key" $value
-                }
-            }
-            set file [$layers get $layer.colorramp.file]
-            if { $file != "" } {
-                # FIXME: Add test for valid file path
-                $_tree set $child "colorramp.url" $file
-            }
-            $_tree set $child "driver" "colorramp"
-        }
-        set agglite [$layers element -as type $layer.agglite]
-        if { $agglite != "" } {
-            foreach key { url } {
-                set value [$layers get $layer.agglite.$key]
-                $_tree set $child "agglite.$key" $value
-            }
-            $_tree set $child "driver" "agglite"
-        }
-        set arcgis [$layers element -as type $layer.arcgis]
-        if { $arcgis != "" } {
-            foreach key { url token format layers } {
-                set value [$layers get $layer.arcgis.$key]
-                $_tree set $child "arcgis.$key" $value
-            }
-            $_tree set $child "driver" "arcgis"
-        }
-        set gdal [$layers element -as type $layer.gdal]
-        if { $gdal != "" } {
-            foreach key { url } {
-                set value [$layers get $layer.gdal.$key]
-                $_tree set $child "gdal.$key" $value
-            }
-            set file [$layers get $layer.gdal.file]
-            if { $file != "" } {
-                # FIXME: Add test for valid file path
-                $_tree set $child "gdal.url" $file
-            }
-            $_tree set $child "driver" "gdal"
-        }
-        set ogr [$layers element -as type $layer.ogr]
-        if { $ogr != "" } {
-            foreach key { url } {
-                set value [$layers get $layer.ogr.$key]
-                $_tree set $child "ogr.$key" $value
-            }
-            set file [$layers get $layer.ogr.file]
-            if { $file != "" } {
-                # FIXME: Add test for valid file path
-                $_tree set $child "ogr.url" $file
-            }
-            foreach key { connection geometry geometryUrl layer ogrDriver buildSpatialIndex } {
-                set value [$layers get $layer.ogr.$key]
-                if { $value != "" } {
-                    $_tree set $child "ogr.$key" $value
-                }
-            }
-            $_tree set $child "driver" "ogr"
-        }
-        set osg [$layers element -as type $layer.osg]
-        if { $osg != "" } {
-            foreach key { url } {
-                set value [$layers get $layer.osg.$key]
-                $_tree set $child "osg.$key" $value
-            }
-            set file [$layers get $layer.osg.file]
-            if { $file != "" } {
-                $_tree set $child "osg.url" $file
-            }
-            $_tree set $child "osg.x" 0.0
-            $_tree set $child "osg.y" 0.0
-            $_tree set $child "osg.z" 0.0
-            $_tree set $child "osg.rotx" 0.0
-            $_tree set $child "osg.roty" 0.0
-            $_tree set $child "osg.rotz" 0.0
-            foreach key { x y z rotx roty rotz paged } {
-                set value [$layers get $layer.osg.$key]
-                if { $value != "" } {
-                    $_tree set $child "osg.$key" $value
-                }
-            }
-            $_tree set $child "driver" "osg"
-        }
-        set tfs [$layers element -as type $layer.tfs]
-        if { $tfs != "" } {
-            foreach key { url format } {
-                set value [$layers get $layer.tfs.$key]
-                $_tree set $child "tfs.$key" $value
-            }
-            $_tree set $child "driver" "tfs"
-        }
-        set tms [$layers element -as type $layer.tms]
-        if { $tms != "" } {
-            foreach key { url tmsType format } {
-                set value [$layers get $layer.tms.$key]
-                $_tree set $child "tms.$key" $value
-            }
-            $_tree set $child "driver" "tms"
-        }
-        set wcs [$layers element -as type $layer.wcs]
-        if { $wcs != "" } {
-            foreach key { url identifier format elevationUnit rangeSubset } {
-                set value [$layers get $layer.wcs.$key]
-                $_tree set $child "wcs.$key" $value
-            }
-            $_tree set $child "driver" "wcs"
-        }
-        set wfs [$layers element -as type $layer.wfs]
-        if { $wfs != "" } {
-            foreach key { url typename format maxfeatures requestBuffer } {
-                set value [$layers get $layer.wfs.$key]
-                $_tree set $child "wfs.$key" $value
-            }
-            $_tree set $child "driver" "wfs"
-        }
-        set wms [$layers element -as type $layer.wms]
-        if { $wms != "" } {
-            foreach key { url layers format transparent } {
-                set value [$layers get $layer.wms.$key]
-                $_tree set $child "wms.$key" $value
-            }
-            # These are optional
-            foreach key { times frameSeconds } {
-                set value [$layers get $layer.wms.$key]
-                if { $value != "" } {
-                    if {$key == "times"} {
-                        # Normalize whitespace
-                        regsub -all "\[ \t\r\n\]+" [string trim $value] " " value
-                    }
-                    $_tree set $child "wms.$key" $value
-                }
-            }
-            $_tree set $child "driver" "wms"
-        }
-        set xyz [$layers element -as type $layer.xyz]
-        if { $xyz != "" } {
-            foreach key { url } {
-                set value [$layers get $layer.xyz.$key]
-                $_tree set $child "xyz.$key" $value
-            }
-            $_tree set $child "driver" "xyz"
-        }
-    }
-    if {$layers != ""} {
-        rename $layers ""
-    }
-
-    # Parse viewpoints
-    set parent [$_tree findchild root "viewpoints"]
-    set viewpoints [$map element -as object "viewpoints"]
-    if { $viewpoints != "" } {
-        foreach viewpoint [$viewpoints children -type viewpoint] {
-            set name [$viewpoints element -as id "$viewpoint"]
-            if {[hasViewpoint $name]} {
-                puts stderr "ERROR: Duplicate viewpoint ID '$name', skipping"
-                continue
-            }
-            set child [$_tree insert $parent -label $name]
-            $_tree set $child "name" $viewpoint
-            set haveX 0
-            set haveZ 0
-            set haveSRS 0
-            set haveVertDatum 0
-            foreach key { label description x y z distance heading pitch srs verticalDatum } {
-                set val [$viewpoints get $viewpoint.$key]
-                if {$val != ""} {
-                    if {$key == "x"} {
-                        set haveX 1
-                    } elseif {$key == "z"} {
-                        set haveZ 1
-                    } elseif {$key == "srs"} {
-                        set haveSRS 1
-                    } elseif {$key == "verticalDatum"} {
-                        set haveVertDatum 1
-                    }
-                    $_tree set $child $key $val
-                }
-            }
-            if {!$haveX} {
-                set lat [$viewpoints get $viewpoint.latitude]
-                set long [$viewpoints get $viewpoint.longitude]
-                $_tree set $child x $long
-                $_tree set $child y $lat
-                if {!$haveSRS} {
-                    $_tree set $child srs wgs84
-                }
-                if {!$haveVertDatum} {
-                    $_tree set $child verticalDatum ""
-                }
-            }
-            if {!$haveZ} {
-                set z [$viewpoints get $viewpoint.altitude]
-                if {$z != ""} {
-                    $_tree set $child z $z
-                }
-            }
-        }
-        rename $viewpoints ""
-    }
-
-    # Fill in tool info
-    foreach {key path} {
-        toolid          tool.id
-        toolname        tool.name
-        toolcommand     tool.execute
-        tooltitle       tool.title
-        toolrevision    tool.version.application.revision
-    } {
-        set str [$xmlobj get $path]
-        if { "" != $str } {
-            $_tree set root $key $str
-        }
-    }
-
-    rename $map ""
-    set _isValid 1
-}
-
-itcl::body Rappture::Map::setToolInfo { id name command title revision } {
-    foreach key [list id name command title revision] {
-        set str [set $key]
-        if { "" != $str } {
-            $_tree set root "tool$key" $str
-        }
-    }
-}
-
-itcl::body Rappture::Map::setType { type } {
-    if { ![info exists _mapTypes($type)] } {
-        error "unknown map type \"$type\": should be one of: [join [array names _mapTypes] {, }]"
-    }
-    $_tree set root "type" $type
-}
-
-itcl::body Rappture::Map::setProjection { projection } {
-    $_tree set root "projection" $projection
-}
-
-itcl::body Rappture::Map::clearExtents {} {
-    $_tree set root "extents" ""
-}
-
-itcl::body Rappture::Map::setExtents { xmin ymin xmax ymax {srs "wgs84"} } {
-    $_tree set root "extents" [list $xmin $ymin $xmax $ymax $srs]
-}
-
-itcl::body Rappture::Map::setLabel { label } {
-    $_tree set root "label" $label
-}
-
-itcl::body Rappture::Map::setDescription { description } {
-    $_tree set root "description" $description
-}
-
-itcl::body Rappture::Map::setAttribution { attribution } {
-    $_tree set root "attribution" $attribution
-}
-
-itcl::body Rappture::Map::setStyle { style } {
-    if {$style != "" && [llength $style] % 2 != 0} {
-        error "Bad map style, must be key/value pairs"
-    }
-    array set styleinfo $style
-    foreach key [array names styleinfo] {
-        set valid 0
-        foreach validkey {-ambient -color -edgecolor -edges -lighting -linewidth -time -vertscale -wireframe} {
-            if {$key == $validkey} {
-                set valid 1
-                break
-            }
-        }
-        if {!$valid} {
-            error "Unknown style setting: $key"
-        }
-    }
-    $_tree set root "style" $style
-}
-
-itcl::body Rappture::Map::setCamera { camera } {
-    if {$camera != "" && [llength $camera] % 2 != 0} {
-        error "Bad camera settings, must be key/value pairs"
-    }
-    array set caminfo $camera
-    foreach key [array names caminfo] {
-        set valid 0
-        foreach validkey {layer x y latitude longitude z heading pitch distance xmin ymin xmax ymax srs verticalDatum} {
-            if {$key == $validkey} {
-                set valid 1
-                break
-            }
-        }
-        if {!$valid} {
-            error "Unknown camera setting: $key"
-        }
-    }
-    if {([info exists caminfo(x)] || [info exists caminfo(y)] ||
-         [info exists caminfo(latitude)] || [info exists caminfo(longitude)] ||
-         [info exists caminfo(z)] || [info exists caminfo(distance)]) &&
-        ([info exists caminfo(xmin)] || [info exists caminfo(xmax)] ||
-         [info exists caminfo(ymin)] || [info exists caminfo(ymax)])} {
-        error "Bad camera settings: Cannot set both focal point and extents"
-    }
-    $_tree set root "camera" $camera
-}
-
-itcl::body Rappture::Map::addLayer { type name paramArray driver driverParamArray {stylesheet {}} {script {}} {selectors {}} } {
-    set id "$name"
-    if {[hasLayer $id]} {
-        error "Layer '$id' already exists"
-    }
-    if { ![info exists _layerTypes($type)] } {
-        error "Invalid layer type \"$type\": should be one of: [join [array names _layerTypes] {, }]"
-    }
-    set parent [$_tree findchild root "layers"]
-    set child [$_tree insert $parent -label $id]
-    $_tree set $child "name" $name
-    $_tree set $child "type" $type
-    array set params $paramArray
-    foreach key { label description attribution profile srs verticalDatum } {
-        if {[info exists params($key)]} {
-            $_tree set $child $key $params($key)
-        } else {
-            $_tree set $child $key ""
-        }
-    }
-    # Common settings (for all layer types) with defaults
-    foreach { key defval } { visible 1 cache 1 shared 0 } {
-        $_tree set $child $key $defval
-        if {[info exists params($key)]} {
-            set val $params($key)
-            if {$val != ""} {
-                $_tree set $child $key $val
-            }
-        }
-    }
-    # These are settings for which there should be no default
-    # We want to know if they have been set by the user or not
-    # Not all layer types use these
-    foreach key { coverage opacity content priority style minrange maxrange terrainPatch } {
-        if {[info exists params($key)]} {
-            set val $params($key)
-            if {$val != ""} {
-                if {$key eq "coverage" && $type ne "image"} {
-                    error "Coverage is only valid for layers of type \"image\""
-                }
-                if {$key eq "content" || $key eq "priority"} {
-                    if {$type ne "label"} {
-                        error "content and priority are only valid in layers of type \"label\""
-                    }
-                }
-                if {$key eq "opacity" && ($type eq "elevation" ||
-                    $type eq "mask")} {
-                    error  "opacity is not valid for layers of type \"elevation\" or \"mask\""
-                }
-                if {$key eq "terrainPatch" && $type ne "feature" &&
-                    $type ne "model" && $type ne "polygon"} {
-                    puts stderr "ERROR: <terrainPatch> is only valid for layers of type \"feature\", \"model\" or \"polygon\""
-                }
-                $_tree set $child $key $val
-            }
-        }
-    }
-    if {$stylesheet != ""} {
-        set val $stylesheet
-        # Normalize whitespace
-        regsub -all "\[ \t\r\n\]+" [string trim $val] " " val
-        $_tree set $child stylesheet $val
-    }
-    if {$script != ""} {
-        regsub -all "\[\r\n\]+" [string trim $script] " " script
-        $_tree set $child script $script
-    }
-    if {$selectors != ""} {
-        set sparent [$_tree insert $child -label "selectors"]
-        foreach selectorItem $selectors {
-            array set selector $selectorItem
-            if { [info exists selector(id)] } {
-                set selectorId $selector(id)
-            } else {
-                set selectorId "selector[incr _nextSelector]"
-            }
-            set snode [$_tree insert $sparent -label $selectorId]
-            foreach key { name style styleExpression query queryBounds queryOrderBy } {
-                if {[info exists selector($key)]} {
-                    set val $selector($key)
-                    if {$val != ""} {
-                        $_tree set $snode $key $val
-                    }
-                }
-            }
-        }
-    }
-    $_tree set $child "driver" $driver
-    switch -- $driver {
-        "agglite" {
-            array set params $driverParamArray
-            foreach key { url featuredriver format typeName } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    $_tree set $child "agglite.$key" $value
-                }
-            }
-        }
-        "arcgis" {
-            array set params $driverParamArray
-            foreach key { url token format layers } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    $_tree set $child "arcgis.$key" $value
-                }
-            }
-        }
-        "colorramp" {
-            array set params $driverParamArray
-            $_tree set $child "colorramp.elevdriver" "gdal"
-            $_tree set $child "colorramp.colormap" "0 0 0 0 1 1 1 1 1 1"
-            if {[info exists params(colormap)]} {
-                set cmap $params(colormap)
-                if {$cmap != ""} {
-                    # Normalize whitespace
-                    regsub -all "\[ \t\r\n\]+" [string trim $cmap] " " cmap
-                    $_tree set $child "colorramp.colormap" $cmap
-                }
-            }
-            foreach key { url elevdriver } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    if {$value != ""} {
-                        $_tree set $child "colorramp.$key" $value
-                    }
-                }
-            }
-        }
-        "gdal" {
-            array set params $driverParamArray
-            foreach key { url } {
-                set value $params($key)
-                $_tree set $child "gdal.$key" $value
-            }
-        }
-        "ogr" {
-            array set params $driverParamArray
-            foreach key { url } {
-                set value $params($key)
-                $_tree set $child "ogr.$key" $value
-            }
-            foreach key { connection geometry geometryUrl layer ogrDriver buildSpatialIndex } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    if { $value != "" } {
-                        $_tree set $child "ogr.$key" $value
-                    }
-                }
-            }
-        }
-        "osg" {
-            array set params $driverParamArray
-            foreach key { url } {
-                set value $params($key)
-                $_tree set $child "osg.$key" $value
-            }
-            $_tree set $child "osg.x" 0.0
-            $_tree set $child "osg.y" 0.0
-            $_tree set $child "osg.z" 0.0
-            $_tree set $child "osg.rotx" 0.0
-            $_tree set $child "osg.roty" 0.0
-            $_tree set $child "osg.rotz" 0.0
-            foreach key { x y z rotx roty rotz paged } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    if { $value != "" } {
-                        $_tree set $child "osg.$key" $value
-                    }
-                }
-            }
-        }
-        "tfs" {
-            array set params $driverParamArray
-            foreach key { url format } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    $_tree set $child "tfs.$key" $value
-                }
-            }
-        }
-        "tms" {
-            array set params $driverParamArray
-            foreach key { url tmsType format } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    $_tree set $child "tms.$key" $value
-                }
-            }
-        }
-        "wcs" {
-            array set params $driverParamArray
-            foreach key { url identifier format elevationUnit rangeSubset } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    $_tree set $child "wcs.$key" $value
-                }
-            }
-        }
-        "wfs" {
-            array set params $driverParamArray
-            foreach key { url typename format maxfeatures requestBuffer } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    $_tree set $child "wfs.$key" $value
-                }
-            }
-        }
-        "wms" {
-            array set params $driverParamArray
-            foreach key { url layers format transparent times frameSeconds } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    if {$key == "times"} {
-                        # Normalize whitespace
-                        regsub -all "\[ \t\r\n\]+" [string trim $value] " " value
-                    }
-                    $_tree set $child "wms.$key" $value
-                }
-            }
-        }
-        "xyz" {
-            array set params $driverParamArray
-            foreach key { url } {
-                if {[info exists params($key)]} {
-                    set value $params($key)
-                    $_tree set $child "xyz.$key" $value
-                }
-            }
-        }
-        default {
-            error "Unknown driver \"$driver\""
-        }
-    }
-    set _dirty($id) 1
-    return $id
-}
-
-itcl::body Rappture::Map::setPlacardConfig { layerName attrlist style padding } {
-    set id [$_tree findchild root->"layers" $layerName]
-    if { $id < 0 } {
-        error "unknown layer \"$layerName\""
-    }
-    set type [layer $layerName type]
-    if {$type == "image" || $type == "elevation"} {
-        error "Placard not supported on image or elevation layers"
-    }
-    array set placardConf {}
-    foreach key { padding } {
-        set placardConf($key) [set $key]
-    }
-    foreach key { attrlist style } {
-        # Normalize whitespace
-        set val [set $key]
-        regsub -all "\[ \t\r\n\]+" [string trim $val] " " val
-        set placardConf($key) $val
-    }
-    $_tree set $id "placard" [array get placardConf]
-}
-
-itcl::body Rappture::Map::getPlacardConfig { layerName } {
-    set id [$_tree findchild root->"layers" $layerName]
-    if { $id < 0 } {
-        error "unknown layer \"$layerName\""
-    }
-    return [$_tree get $id "placard" ""]
-}
-
-itcl::body Rappture::Map::deleteLayer { layerName } {
-    set id [$_tree findchild root->"layers" $layerName]
-    if { $id < 0 } {
-        error "unknown layer \"$layerName\""
-    }
-    $_tree delete $id
-    array unset _dirty $layerName
-}
-
-# ----------------------------------------------------------------------
-# USAGE: layers
-#
-# Returns a list of IDs for the layers in the map
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::layers {} {
-    set list {}
-    foreach node [$_tree children root->"layers"] {
-        lappend list [$_tree label $node]
-    }
-    return $list
-}
-
-# ----------------------------------------------------------------------
-# USAGE: viewpoints
-#
-# Returns a list of IDs for the viewpoints in the map
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::viewpoints {} {
-    set list {}
-    catch {
-        foreach node [$_tree children root->"viewpoints"] {
-            lappend list [$_tree label $node]
-        }
-    }
-    return $list
-}
-
-# ----------------------------------------------------------------------
-# USAGE: layer <layerName> <?prop?>
-#
-# Returns an array of settings for the named layer, or a single property
-# if specified.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::layer { layerName args } {
-    set id [$_tree findchild root->"layers" $layerName]
-    if { $id < 0 } {
-        error "unknown layer \"$layerName\""
-    }
-    switch -- [llength $args] {
-        0 {
-            return [$_tree get $id]
-        }
-        1 {
-            set prop [lindex $args 0]
-            return [$_tree get $id $prop]
-        }
-        default {
-            error "wrong # args: should be \"layer <layerName> <?prop?>\""
-        }
-    }
-}
-
-itcl::body Rappture::Map::hasLayer { layerName } {
-    set id [$_tree findchild root->"layers" $layerName]
-    if { $id < 0 } {
-        return 0
-    } else {
-        return 1
-    }
-}
-
-itcl::body Rappture::Map::setScript { layerName script } {
-    set id [$_tree findchild root->"layers" $layerName]
-    if { $id < 0 } {
-        error "unknown layer \"$layerName\""
-    }
-    $_tree set $id "script" $script
-    set _dirty($layerName) 1
-}
-
-itcl::body Rappture::Map::setStylesheet { layerName stylesheet } {
-    set id [$_tree findchild root->"layers" $layerName]
-    if { $id < 0 } {
-        error "unknown layer \"$layerName\""
-    }
-    $_tree set $id "stylesheet" $stylesheet
-    set _dirty($layerName) 1
-}
-
-itcl::body Rappture::Map::setColormap { layerName colormap } {
-    set id [$_tree findchild root->"layers" $layerName]
-    if { $id < 0 } {
-        error "unknown layer \"$layerName\""
-    }
-    $_tree set $id "colorramp.colormap" $colormap
-    set _dirty($layerName) 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: selectors
-#
-# Returns a list of IDs for the selectors in a layer
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::selectors { layerName } {
-    set list {}
-    catch {
-        foreach node [$_tree children root->"layers"->"$layerName"->"selectors"] {
-            lappend list [$_tree label $node]
-        }
-    }
-    return $list
-}
-
-# ----------------------------------------------------------------------
-# USAGE: selector
-#
-# Returns an array of settings for the named selector in the named 
-# layer
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::selector { layerName selectorName } {
-    set id [$_tree findchild root->"layers"->"$layerName"->"selectors" $selectorName]
-    if { $id < 0 } {
-        error "unknown selector \"$selectorName\""
-    }
-    return [$_tree get $id]
-}
-
-itcl::body Rappture::Map::hasSelector { layerName selectorName } {
-    set id [$_tree findchild root->"layers"->"$layerName"->"selectors" $selectorName]
-    if { $id < 0 } {
-        return 0
-    } else {
-        return 1
-    }
-}
-
-itcl::body Rappture::Map::addSelector { layerName name params } {
-    set nodeid $name
-    set layerid [$_tree findchild root->"layers" $layerName]
-    if { $layerid < 0 } {
-        error "unknown layer \"$layerName\""
-    }
-    if {[hasSelector $layerName $nodeid]} {
-        error "Selector '$nodeid' already exists"
-    }
-    set parent [$_tree findchild root->"layers"->"$layerName" "selectors"]
-    if { $parent == "" } {
-        set parent [$_tree insert $layerid -label "selectors"]
-    }
-    set child [$_tree insert $parent -label $nodeid]
-    array set info $params
-    foreach key { name style styleExpression query queryBounds queryOrderBy } {
-        if { [info exists info($key)] &&
-             $info($key) != ""} {
-            $_tree set $child $key $info($key)
-        }
-    }
-    set _dirty($layerName) 1
-}
-
-itcl::body Rappture::Map::deleteSelector { layerName selectorName } {
-    set id [$_tree findchild root->"layers"->"$layerName"->"selectors" $selectorName]
-    if { $id < 0 } {
-        error "unknown selector \"$selectorName\""
-    }
-    $_tree delete $id
-    set _dirty($layerName) 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: viewpoint <viewpointName>
-#
-# Returns an array of settings for the named viewpoint
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::viewpoint { viewpointName } {
-    set id [$_tree findchild root->"viewpoints" $viewpointName]
-    if { $id < 0 } {
-        error "unknown viewpoint \"$viewpointName\""
-    }
-    return [$_tree get $id]
-}
-
-itcl::body Rappture::Map::hasViewpoint { viewpointName } {
-    set id [$_tree findchild root->"viewpoints" $viewpointName]
-    if { $id < 0 } {
-        return 0
-    } else {
-        return 1
-    }
-}
-
-itcl::body Rappture::Map::addViewpoint { name props } {
-    set nodeid $name
-    if {[hasViewpoint $nodeid]} {
-        error "Viewpoint '$nodeid' already exists"
-    }
-    set parent [$_tree findchild root "viewpoints"]
-    set child [$_tree insert $parent -label $nodeid]
-    $_tree set $child "name" $name
-    set haveX 0
-    set haveZ 0
-    set haveSRS 0
-    set haveVertDatum 0
-    array set info $props
-    foreach key { label description x y z distance heading pitch srs verticalDatum } {
-        if {[info exists info($key)]} {
-            set val $info($key)
-            if {$key == "x"} {
-                set haveX 1
-            } elseif {$key == "z"} {
-                set haveZ 1
-            } elseif {$key == "srs"} {
-                set haveSRS 1
-            } elseif {$key == "verticalDatum"} {
-                set haveVertDatum 1
-            }
-            $_tree set $child $key $val
-        }
-    }
-    if {!$haveX} {
-        set lat $info(latitude)
-        set long $info(longitude)
-        $_tree set $child x $long
-        $_tree set $child y $lat
-        if {!$haveSRS} {
-            $_tree set $child srs wgs84
-        }
-        if {!$haveVertDatum} {
-            $_tree set $child verticalDatum ""
-        }
-    }
-    if {!$haveZ && [info exists info(altitude)]} {
-        $_tree set $child z $info(altitude)
-    }
-    set _dirty(viewpoints) 1
-}
-
-itcl::body Rappture::Map::deleteViewpoint { viewpointName } {
-    set id [$_tree findchild root->"viewpoints" $viewpointName]
-    if { $id < 0 } {
-        error "unknown viewpoint \"$viewpointName\""
-    }
-    $_tree delete $id
-    set _dirty(viewpoints) 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: isGeocentric
-#
-# Returns if the map is geocentric (1) or projected (0)
-# ----------------------------------------------------------------------
-itcl::body Rappture::Map::isGeocentric {} {
-    return [expr {[hints "type"] eq "geocentric"}]
-}
-
-itcl::body Rappture::Map::styleToCSS { layerType props {styleName "style"} } {
-    append output "$styleName { "
-    foreach {name value} $props {
-        if {[string range $name 0 0] eq "-"} {
-            set name [string range $name 1 end]
-        }
-        # These aren't really style properties
-        if {$name eq "minrange" || $name eq "maxrange" } {
-            continue
-        }
-        foreach {name value} [translateProp $layerType $name $value] {}
-        # TODO: Fix quoting
-        if {$name ne ""} {
-            append output "$name: $value; "
-        }
-    }
-    append output "}"
-    return $output
-}
-
-itcl::body Rappture::Map::colorToHTML { color } {
-    foreach {r g b} [winfo rgb . $color] break
-    return [format "#%02X%02X%02X" [expr {$r/256}] [expr {$g/256}] [expr {$b/256}]]
-}
-
-itcl::body Rappture::Map::isColorProp { prop } {
-    foreach colorprop { fill stroke point-fill text-fill text-halo } {
-        if { $prop eq $colorprop } {
-            return 1
-        }
-    }
-    return 0
-}
-
-itcl::body Rappture::Map::isBooleanProp { prop } {
-    foreach boolprop {
-        extrusion-flatten
-        skin-tiled
-        icon-declutter
-        render-depth-test
-        render-lighting
-        render-transparent
-        render-depth-offset
-        text-declutter
-    } {
-        if { $prop eq $boolprop } {
-            return 1
-        }
-    }
-    return 0
-}
-
-itcl::body Rappture::Map::isFileProp { prop } {
-    foreach fileprop {
-        icon
-        model
-    } {
-        if { $prop eq $fileprop } {
-            return 1
-        }
-    }
-    return 0
-}
-
-itcl::body Rappture::Map::fixQuotes { str } {
-    return [string map {"\{" "\"" "\}" "\""} [list $str]]
-}
-
-itcl::body Rappture::Map::fixEnum { str } {
-    return [string map {"_" "-"} $str]
-}
-
-itcl::body Rappture::Map::fixBoolean { val } {
-    if { $val } {
-        return "true"
-    } else {
-        return "false"
-    }
-}
-
-itcl::body Rappture::Map::translateProp { layerType styleProp styleValue } {
-    switch -- $layerType {
-        "icon" {
-            array set trans {
-                "align" "icon-align"
-                "clamping" "altitude-clamping"
-                "clamptechnique" "altitude-technique"
-                "declutter" "icon-declutter"
-                "library" "icon-library"
-                "minbias" "render-depth-offset-min-bias"
-                "maxbias" "render-depth-offset-max-bias"
-                "scale" "icon-scale"
-                "heading" "icon-heading"
-                "placement" "icon-placement"
-                "url" "icon"
-            }
-        }
-        "label" {
-            array set trans {
-                "align" "text-align"
-                "clamping" "altitude-clamping"
-                "clamptechnique" "altitude-technique"
-                "color" "text-fill"
-                "content" "text-content"
-                "declutter" "text-declutter"
-                "font" "text-font"
-                "fontsize" "text-size"
-                "halocolor" "text-halo"
-                "halowidth" "text-halo-offset"
-                "layout" "text-layout"
-                "minbias" "render-depth-offset-min-bias"
-                "maxbias" "render-depth-offset-max-bias"
-                "priority" "text-priority"
-                "xoffset" "text-offset-x"
-                "yoffset" "text-offset-y"
-            }
-        }
-        "line" {
-            array set trans {
-                "cap" "stroke-linecap"
-                "clamping" "altitude-clamping"
-                "clamptechnique" "altitude-technique"
-                "color" "stroke"
-                "join" "stroke-linejoin"
-                "minbias" "render-depth-offset-min-bias"
-                "maxbias" "render-depth-offset-max-bias"
-                "stipplepattern" "stroke-stipple-pattern"
-                "stipplefactor" "stroke-stipple-factor"
-                "width" "stroke-width"
-            }
-        }
-        "point" {
-             array set trans {
-                "clamping" "altitude-clamping"
-                "clamptechnique" "altitude-technique"
-                "color" "point-fill"
-                "minbias" "render-depth-offset-min-bias"
-                "maxbias" "render-depth-offset-max-bias"
-                "size" "point-size"
-            }
-        }
-        "polygon" {
-            array set trans {
-                "clamping" "altitude-clamping"
-                "clamptechnique" "altitude-technique"
-                "color" "fill"
-                "minbias" "render-depth-offset-min-bias"
-                "maxbias" "render-depth-offset-max-bias"
-                "strokecolor" "stroke"
-                "strokewidth" "stroke-width"
-            }
-        }
-        "image" - "elevation" - "feature" - "mask" - "model" {
-        }
-        default {
-            error "Unknown layer type: \"$layerType\""
-        }
-    }
-    if {[info exists trans($styleProp)]} {
-        set styleProp $trans($styleProp)
-    }
-    if {[isColorProp $styleProp]} {
-        set styleValue [colorToHTML $styleValue]
-    }
-    if {$styleProp eq "icon-scale" && $styleValue eq ""} {
-        set styleProp ""
-    }
-    if {$styleProp eq "icon-heading" && $styleValue eq ""} {
-        set styleProp ""
-    }
-    if {$styleProp eq "text-align" || $styleProp eq "icon-align"} {
-        set styleValue [fixEnum $styleValue]
-    }
-    if {[isBooleanProp $styleProp]} {
-        set styleValue [fixBoolean $styleValue]
-    }
-    set styleValue [fixQuotes $styleValue]
-    return [list $styleProp $styleValue]
-}
-
-itcl::body Rappture::Map::parseStylesheet { stylesheet } {
-    set styles [list]
-    # First split into style blocks
-    set blocks [split $stylesheet "\{\}"]
-    if {[llength $blocks] == 1} {
-        set blocks [list style $blocks]
-    }
-    foreach {styleName block} $blocks {
-        # Get name/value pairs
-        set styleName [string trim $styleName]
-        if {$styleName == ""} { set styleName "style" }
-        set block [string trim $block " \t\n\r\{\}"]
-        if {$block == ""} { continue }
-        #puts stderr "styleName: \"$styleName\""
-        #puts stderr "block: \"$block\""
-        set lines [split $block ";"]
-        array unset styleArray
-        foreach line $lines {
-            set line [string trim $line]
-            if {$line == "" || [string index $line 0] == "#"} { continue }
-            #puts stderr "line: \"$line\""
-            set delim [string first ":" $line]
-            set prop [string trim [string range $line 0 [expr {$delim-1}]]]
-            set val [string trim [string range $line [expr {$delim+1}] end]]
-            set styleArray($prop) $val
-        }
-        lappend styles $styleName [array get styleArray]
-    }
-    return $styles
-}
-
-itcl::body Rappture::Map::getFilesFromStylesheet { stylesheet } {
-    set files [list]
-    set styles [parseStylesheet $stylesheet]
-    foreach {name style} $styles {
-        #puts stderr "Style: \"$name\""
-        array unset info
-        array set info $style
-        foreach key [array names info] {
-            #puts stderr "Prop: \"$key\" Val: \"$info($key)\""
-            if {[isFileProp $key]} {
-                lappend files [string trim $info($key) "\""]
-            }
-        }
-    }
-    return $files
-}
Index: trunk/gui/scripts/mapentry.tcl
===================================================================
--- trunk/gui/scripts/mapentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,136 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: MapEntry - widget for viewing map as input control
-#
-# ======================================================================
-#  AUTHOR:  Leif Delgass, Purdue University
-#  Copyright (c) 2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::MapEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} {
-        # defined below
-    }
-    public method label {}
-    public method tooltip {}
-    public method value {args}
-
-    private variable _owner ""      ;# thing managing this control
-    private variable _path ""       ;# path in XML to this input
-    private variable _xmlobj ""
-    private variable _mapviewer ""  ;# MapViewer widget
-}
-
-itk::usual MapEntry {
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-    set _xmlobj [$_owner xml object]
-
-    itk_component add map {
-        Rappture::MapViewer $itk_interior.map
-    }
-    pack $itk_component(map) -expand yes -fill both
-    set _mapviewer $itk_component(map)
-
-    eval itk_initialize $args
-
-    value $_xmlobj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        set newval [lindex $args 0]
-
-        if {!$onlycheck && $_xmlobj != "" && $_xmlobj != $newval} {
-            # delete any existing object
-            itcl::delete object $_xmlobj
-            set _xmlobj ""
-        }
-        if {$newval != ""} {
-            if {![Rappture::library isvalid $newval]} {
-                error "bad value \"$newval\": should be Rappture::Library"
-            }
-            if {$onlycheck} {
-                return
-            }
-            set _xmlobj $newval
-        }
-        set dataobjs [$_mapviewer get]
-        $_mapviewer configure -map [Rappture::Map ::#auto $_xmlobj $_path]
-        foreach dataobj $dataobjs {
-            itcl::delete object $dataobj
-        }
-        event generate $itk_component(hull) <<Value>>
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapEntry::tooltip {} {
-    set str [string trim [$_owner xml get $_path.about.description]]
-    return $str
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::MapEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    #$_mapviewer configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/mapviewer.tcl
===================================================================
--- trunk/gui/scripts/mapviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,3483 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: mapviewer - Map object viewer
-#
-#  It connects to the GeoVis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *MapViewer.width 4i widgetDefault
-option add *MapViewer*cursor crosshair widgetDefault
-option add *MapViewer.height 4i widgetDefault
-option add *MapViewer.foreground black widgetDefault
-option add *MapViewer.controlBackground gray widgetDefault
-option add *MapViewer.controlDarkBackground #999999 widgetDefault
-option add *MapViewer.plotBackground black widgetDefault
-option add *MapViewer.plotForeground white widgetDefault
-option add *MapViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc MapViewer_init_resources {} {
-    Rappture::resources::register \
-        geovis_server Rappture::MapViewer::SetServerList
-}
-
-itcl::class Rappture::MapViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -map map Map ""
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "geovis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method clear {args}
-    public method delete {args} { eval hide $args }
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method hide {args}
-    public method isconnected {}
-    public method parameters {title args} { # do nothing }
-    public method placard {option args}
-    public method refresh {} {
-        Rebuild
-        # Temporary hack to fix one frame delay in update
-        SendCmd "imgflush"
-        SendCmd "renderer render"
-    }
-    public method scale {args}
-    public method select {option {args ""}}
-    public method setSelectCallback {cmd}
-
-    private method KeyPress { key }
-    private method KeyRelease { key }
-    private method MouseClick { button x y }
-    private method MouseDoubleClick { button x y }
-    private method MouseDrag { button x y }
-    private method MouseMotion {}
-    private method MouseRelease { button x y }
-    private method MouseScroll { direction }
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildCameraTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildHelpTab {}
-    private method BuildLayerTab {}
-    private method BuildMapTab {}
-    private method BuildTerrainTab {}
-    private method BuildViewpointsTab {}
-    private method Camera {option args}
-    private method Connect {}
-    private method ConvertTime { timeval }
-    private method CurrentLayers {args}
-    private method DisablePanningMouseBindings {}
-    private method DisableRotationMouseBindings {}
-    private method DisableZoomMouseBindings {}
-    private method Disconnect {}
-    private method DoPan {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method DoSelect {}
-    private method DoSelectCallback {option {args ""}}
-    private method DrawLegend { colormap min max }
-    private method EnablePanningMouseBindings {}
-    private method EnableRotationMouseBindings {}
-    private method EnableZoomMouseBindings {}
-    private method EventuallyHandleMotionEvent { x y }
-    private method EventuallyPan { dx dy }
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { dx dy }
-    private method EventuallySelect { x y }
-    private method GetImage { args }
-    private method GetNormalizedMouse { x y }
-    private method GoToViewpoint { dataobj viewpoint {duration 2.0} }
-    private method InitSettings { args }
-    private method MapIsGeocentric {}
-    private method Pan {option x y}
-    private method Pin {option x y}
-    private method Rebuild {}
-    private method ReceiveImage { args }
-    private method ReceiveLegend { args }
-    private method ReceiveMapInfo { args }
-    private method ReceiveScreenInfo { args }
-    private method ReceiveSelect { option {args ""} }
-    private method RequestLegend { colormap w h }
-    private method Rotate {option x y}
-    private method Select {option x y}
-    private method SendFiles { path }
-    private method SendStylesheetFiles { stylesheet }
-    private method SetHeading { {value 0} }
-    private method SetLayerOpacity { dataobj layer {value 100} }
-    private method SetLayerStyle { dataobj layer }
-    private method SetLayerVisibility { dataobj layer }
-    private method SetPitch { {value -89.999} }
-    private method SetTerrainStyle { style }
-    private method ToggleGrid {}
-    private method ToggleLighting {}
-    private method ToggleWireframe {}
-    private method UpdateLayerControls {}
-    private method UpdateViewpointControls {}
-    private method Zoom {option {x 0} {y 0}}
-
-    private variable _layersFrame "";     # Name of layers frame widget
-    private variable _viewpointsFrame ""; # Name of viewpoints frame widget
-    private variable _mapsettings;        # Global map settings
-
-    private variable _dlist "";         # list of data objects
-    private variable _hidden "";        # list of hidden data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _layers;           # Contains the names of all the
-                                        # layers in the server.
-    private variable _viewpoints;
-    private variable _selectCallback "";
-    private variable _click;            # info used for rotate operations
-    private variable _view;             # view params for 3D view
-    private variable _pan;
-    private variable _rotate;
-    private variable _select;
-    private variable _motion;
-    private variable _settings
-    private variable _opacity
-    private variable _visibility
-    private variable _reset 1;          # Indicates that server was reset and
-                                        # needs to be reinitialized.
-    private variable _initCamera 1;
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _title ""
-
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _useSidebar 1
-    private variable _useServerManip 0
-    private variable _labelCount 0
-    private variable _b1mode "pan"
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual MapViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::constructor {args} {
-    set _serverType "geovis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    if { [catch {
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Pan event
-    $_dispatcher register !pan
-    $_dispatcher dispatch $this !pan "[itcl::code $this DoPan]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    # Select event
-    $_dispatcher register !select
-    $_dispatcher dispatch $this !select "[itcl::code $this DoSelect]; list"
-
-    # <Motion> event
-    $_dispatcher register !motion
-    $_dispatcher dispatch $this !motion "[itcl::code $this MouseMotion]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image    [itcl::code $this ReceiveImage]
-    $_parser alias legend   [itcl::code $this ReceiveLegend]
-    $_parser alias map      [itcl::code $this ReceiveMapInfo]
-    $_parser alias camera   [itcl::code $this Camera]
-    $_parser alias screen   [itcl::code $this ReceiveScreenInfo]
-    $_parser alias select   [itcl::code $this ReceiveSelect]
-
-    # Settings for mouse motion events: these are required
-    # to update the Lat/Long coordinate display
-    array set _motion {
-        compress        1
-        delay           100
-        enable          1
-        pending         0
-        x               0
-        y               0
-    }
-    array set _pan {
-        compress        1
-        delay           100
-        pending         0
-        x               0
-        y               0
-    }
-    array set _rotate {
-        azimuth         0
-        compress        1
-        delay           100
-        elevation       0
-        pending         0
-    }
-    array set _select {
-        compress        1
-        delay           100
-        pending         0
-        x               0
-        y               0
-    }
-    # This array holds the Viewpoint parameters that the
-    # server sends on "camera get".
-    array set _view {
-        distance        1.0
-        heading         0.0
-        pitch           -89.9
-        srs             ""
-        verticalDatum   ""
-        x               0.0
-        y               0.0
-        z               0.0
-    }
-
-    # Note: grid types are "shader", "geodetic", "utm" and "mgrs"
-    # Currently only work in geocentric maps
-    array set _settings [subst {
-        camera-throw           0
-        coords-precision       5
-        coords-units           "latlong_decimal_degrees"
-        coords-visible         1
-        grid                   0
-        grid-type              "shader"
-        terrain-ambient        0.03
-        terrain-edges          0
-        terrain-lighting       0
-        terrain-vertscale      1.0
-        terrain-wireframe      0
-        time                   12
-    }]
-
-    set _settings(time) [ConvertTime [clock seconds]]
-
-    if {!$_useSidebar} {
-        destroy $itk_component(main)
-        itk_component add main {
-            frame $itk_interior.main
-        }
-        pack $itk_component(main) -expand yes -fill both
-        itk_component add plotarea {
-            frame $itk_component(main).plotarea -highlightthickness 0 -background black
-        } {
-            ignore -background
-        }
-        pack $itk_component(plotarea) -expand yes -fill both
-    }
-
-    DebugTrace "main: [winfo class $itk_component(main)]"
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth  -background
-    }
-
-    set c $itk_component(view)
-    bind $c <Enter> "focus %W"
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    if {$_useSidebar} {
-        set f [$itk_component(main) component controls]
-        itk_component add reset {
-            button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-                -highlightthickness 0 \
-                -image [Rappture::icon reset-view] \
-                -command [itcl::code $this Camera reset]
-        } {
-            usual
-            ignore -highlightthickness
-        }
-        pack $itk_component(reset) -side top -padx 2 -pady 2
-        Rappture::Tooltip::for $itk_component(reset) \
-            "Reset the view to the default zoom level"
-
-        itk_component add zoomin {
-            button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-                -highlightthickness 0 \
-                -image [Rappture::icon zoom-in] \
-                -command [itcl::code $this Zoom in]
-        } {
-            usual
-            ignore -highlightthickness
-        }
-        pack $itk_component(zoomin) -side top -padx 2 -pady 2
-        Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-        itk_component add zoomout {
-            button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-                -highlightthickness 0 \
-                -image [Rappture::icon zoom-out] \
-                -command [itcl::code $this Zoom out]
-        } {
-            usual
-            ignore -highlightthickness
-        }
-        pack $itk_component(zoomout) -side top -padx 2 -pady 2
-        Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-    }
-
-    if {$_useSidebar} {
-        BuildLayerTab
-        BuildViewpointsTab
-        BuildMapTab
-        BuildTerrainTab
-        BuildCameraTab
-        BuildHelpTab
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth 10000
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    bind $itk_component(view) <Configure> \
-        [itcl::code $this EventuallyResize %w %h]
-
-    set _useServerManip 1
-    EnablePanningMouseBindings
-    EnableRotationMouseBindings
-    EnableZoomMouseBindings
-    set _useServerManip 0
-
-    if {$_useServerManip} {
-        # Bindings for keyboard events
-        bind $itk_component(view) <KeyPress> \
-            [itcl::code $this KeyPress %N]
-        bind $itk_component(view) <KeyRelease> \
-            [itcl::code $this KeyRelease %N]
-
-        # Zoom to point
-        bind $itk_component(view) <Double-1> \
-            [itcl::code $this MouseDoubleClick 1 %x %y]
-        bind $itk_component(view) <Double-3> \
-            [itcl::code $this MouseDoubleClick 3 %x %y]
-
-        # Unused
-        bind $itk_component(view) <Double-2> \
-            [itcl::code $this MouseDoubleClick 2 %x %y]
-
-        # Binding for mouse motion events
-        if {$_motion(enable)} {
-            bind $itk_component(view) <Motion> \
-                [itcl::code $this EventuallyHandleMotionEvent %x %y]
-        }
-    } else {
-        # Zoom to point
-        bind $itk_component(view) <Double-1> \
-            [itcl::code $this Camera go %x %y 0.4]
-        # Travel to point (no zoom)
-        bind $itk_component(view) <Shift-Double-1> \
-            [itcl::code $this Camera go %x %y 1.0]
-        # Zoom out centered on point
-        bind $itk_component(view) <Double-3> \
-            [itcl::code $this Camera go %x %y 2.5]
-
-        # Pin placemark annotations
-        bind $itk_component(view) <Control-ButtonPress-1> \
-            [itcl::code $this Pin add %x %y]
-        bind $itk_component(view) <Control-ButtonPress-3> \
-            [itcl::code $this Pin delete %x %y]
-
-        # Draw selection rectangle
-        bind $itk_component(view) <Shift-ButtonPress-1> \
-            [itcl::code $this Select click %x %y]
-        bind $itk_component(view) <B1-Motion> \
-            +[itcl::code $this Select drag %x %y]
-        bind $itk_component(view) <Shift-ButtonRelease-1> \
-            [itcl::code $this Select release %x %y]
-
-        # Update coordinate readout
-        bind $itk_component(view) <ButtonPress-1> \
-            +[itcl::code $this SendCmd "map setpos %x %y"]
-        bind $itk_component(view) <Double-3> \
-            +[itcl::code $this SendCmd "map setpos %x %y"]
-
-        # Bindings for panning via keyboard
-        bind $itk_component(view) <KeyPress-Left> \
-            [itcl::code $this Pan set 10 0]
-        bind $itk_component(view) <KeyPress-Right> \
-            [itcl::code $this Pan set -10 0]
-        bind $itk_component(view) <KeyPress-Up> \
-            [itcl::code $this Pan set 0 -10]
-        bind $itk_component(view) <KeyPress-Down> \
-            [itcl::code $this Pan set 0 10]
-
-        bind $itk_component(view) <Shift-KeyPress-Left> \
-            [itcl::code $this Pan set 2 0]
-        bind $itk_component(view) <Shift-KeyPress-Right> \
-            [itcl::code $this Pan set -2 0]
-        bind $itk_component(view) <Shift-KeyPress-Up> \
-            [itcl::code $this Pan set 0 -2]
-        bind $itk_component(view) <Shift-KeyPress-Down> \
-            [itcl::code $this Pan set 0 2]
-
-        # Bindings for rotation via keyboard
-        bind $itk_component(view) <Control-Left> \
-            [itcl::code $this Rotate set 10 0]
-        bind $itk_component(view) <Control-Right> \
-            [itcl::code $this Rotate set -10 0]
-        bind $itk_component(view) <Control-Up> \
-            [itcl::code $this Rotate set 0 -10]
-        bind $itk_component(view) <Control-Down> \
-            [itcl::code $this Rotate set 0 10]
-
-        bind $itk_component(view) <Control-Shift-Left> \
-            [itcl::code $this Rotate set 2 0]
-        bind $itk_component(view) <Control-Shift-Right> \
-            [itcl::code $this Rotate set -2 0]
-        bind $itk_component(view) <Control-Shift-Up> \
-            [itcl::code $this Rotate set 0 -2]
-        bind $itk_component(view) <Control-Shift-Down> \
-            [itcl::code $this Rotate set 0 2]
-
-        # Bindings for zoom via keyboard
-        bind $itk_component(view) <KeyPress-Prior> \
-            [itcl::code $this Zoom out]
-        bind $itk_component(view) <KeyPress-Next> \
-            [itcl::code $this Zoom in]
-        bind $itk_component(view) <KeyPress-Home> \
-            [itcl::code $this Camera reset]
-
-        # Keyboard shortcuts
-        # Reset heading to North
-        bind $itk_component(view) <n> \
-            [itcl::code $this SetHeading]
-        # Reset pitch to top-down (2D) view
-        bind $itk_component(view) <p> \
-            [itcl::code $this SetPitch]
-        bind $itk_component(view) <g> \
-            [itcl::code $this ToggleGrid]
-        bind $itk_component(view) <l> \
-            [itcl::code $this ToggleLighting]
-        bind $itk_component(view) <w> \
-            [itcl::code $this ToggleWireframe]
-
-        # Binding for mouse motion events
-        set _motion(compress) 1
-        if {$_motion(enable)} {
-            bind $itk_component(view) <Motion> \
-                [itcl::code $this EventuallyHandleMotionEvent %x %y]
-        }
-        #bind $itk_component(view) <Motion> \
-        #    +[itcl::code $this SendCmd "map pin hover %x %y"]
-    }
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        if {$_useServerManip} {
-            bind $itk_component(view) <4> [itcl::code $this MouseScroll up]
-            bind $itk_component(view) <5> [itcl::code $this MouseScroll down]
-        } else {
-            bind $itk_component(view) <4> [itcl::code $this Zoom out]
-            bind $itk_component(view) <5> [itcl::code $this Zoom in]
-        }
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-    Connect
-} errs] != 0 } {
-        puts stderr errs=$errs
-    }
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::destructor {} {
-    Disconnect
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    image delete $_image(plot)
-    image delete $_image(download)
-}
-
-itcl::body Rappture::MapViewer::DoResize {} {
-    set sendResize 1
-    if { $_width < 2 } {
-        set _width 500
-        set sendResize 0
-    }
-    if { $_height < 2 } {
-        set _height 500
-        set sendResize 0
-    }
-    #set _start [clock clicks -milliseconds]
-    if {$sendResize} {
-        SendCmd "screen size $_width $_height"
-    }
-    set _resizePending 0
-}
-
-itcl::body Rappture::MapViewer::DoRotate {} {
-    SendCmd "camera rotate $_rotate(azimuth) $_rotate(elevation)"
-    set _rotate(azimuth) 0
-    set _rotate(elevation) 0
-    set _rotate(pending) 0
-}
-
-itcl::body Rappture::MapViewer::DoSelect {} {
-    SendCmd "map box update $_select(x) $_select(y)"
-    set _select(x) 0
-    set _select(y) 0
-    set _select(pending) 0
-}
-
-itcl::body Rappture::MapViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 200 !resize
-    }
-}
-
-itcl::body Rappture::MapViewer::DoPan {} {
-    SendCmd "camera pan $_pan(x) $_pan(y)"
-    set _pan(x) 0
-    set _pan(y) 0
-    set _pan(pending) 0
-}
-
-itcl::body Rappture::MapViewer::EventuallyPan { dx dy } {
-    set _pan(x) [expr $_pan(x) + $dx]
-    set _pan(y) [expr $_pan(y) + $dy]
-    if { !$_pan(compress) } {
-        DoPan
-        return
-    }
-    if { !$_pan(pending) } {
-        set _pan(pending) 1
-        $_dispatcher event -after $_pan(delay) !pan
-    }
-}
-
-itcl::body Rappture::MapViewer::EventuallyRotate { dx dy } {
-    set _rotate(azimuth) [expr $_rotate(azimuth) + $dx]
-    set _rotate(elevation) [expr $_rotate(elevation) + $dy]
-    if { !$_rotate(compress) } {
-        DoRotate
-        return
-    }
-    if { !$_rotate(pending) } {
-        set _rotate(pending) 1
-        $_dispatcher event -after $_rotate(delay) !rotate
-    }
-}
-
-itcl::body Rappture::MapViewer::EventuallySelect { x y } {
-    set _select(x) $x
-    set _select(y) $y
-    if { !$_select(compress) } {
-        DoSelect
-        return
-    }
-    if { !$_select(pending) } {
-        set _select(pending) 1
-        $_dispatcher event -after $_select(delay) !select
-    }
-}
-
-itcl::body Rappture::MapViewer::DrawLegend { colormap min max } {
-    if { [info exists itk_component(legend-$colormap) ] } {
-        $itk_component(legend-$colormap-min) configure -text $min
-        $itk_component(legend-$colormap-max) configure -text $max
-        $itk_component(legend-$colormap) configure -image $_image(legend-$colormap)
-    }
-}
-
-itcl::body Rappture::MapViewer::RequestLegend { colormap w h } {
-    SendCmd "legend $colormap $w $h 0 [Color2RGB #d9d9d9]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::add {dataobj {settings ""}} {
-    DebugTrace "Enter"
-    array set params {
-        -brightness 0
-        -color auto
-        -description ""
-        -linestyle solid
-        -param ""
-        -raise 0
-        -simulation 0
-        -type ""
-        -width 1
-    }
-    array set params $settings
-    set params(-description) ""
-    set params(-param) ""
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    # Add to display list
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        #if {[llength $_dlist] > 0} {
-        #    error "Can't add more than 1 map to mapviewer"
-        #}
-        lappend _dlist $dataobj
-    }
-    # Remove from hidden list
-    set pos [lsearch -exact $_hidden $dataobj]
-    if {$pos >= 0} {
-        set _hidden [lreplace $_hidden $pos $pos]
-    }
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hide ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to hide a dataobj from the plot.  If no dataobjs are
-# specified, then all dataobjs are hidden.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::hide {args} {
-    DebugTrace "Enter"
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Mark all specified dataobjs as hidden
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        # Add to hidden list
-        set pos [lsearch -exact $_hidden $dataobj]
-        if {$pos < 0} {
-            lappend _hidden $dataobj
-        }
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: clear ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to permanently clear a dataobj from the plot and the
-# render server.  If no dataobjs are specified, then all dataobjs are 
-# cleared.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::clear {args} {
-    DebugTrace "Enter"
-    if { [llength $args] == 0} {
-        set args [concat $_dlist $_hidden]
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set found 0
-        set dpos [lsearch -exact $_dlist $dataobj]
-        if { $dpos >= 0 } {
-            set found 1
-        }
-        set hpos [lsearch -exact $_hidden $dataobj]
-        if { $hpos >= 0 } {
-            set found 1
-        }
-        if { !$found } {
-            continue
-        }
-        foreach tag [array names _layers -glob $dataobj-*] {
-            SendCmd "map layer delete $tag"
-        }
-        if { [info commands $dataobj] == $dataobj } {
-            # Remove the layers from the client and server.
-            foreach layer [$dataobj layers] {
-                if { ![$dataobj layer $layer shared] } {
-                    # Remove shared layer if no other objects have it?
-                }
-            }
-        }
-        if { $dpos >= 0 } {
-            # Remove it from the dataobj list.
-            set _dlist [lreplace $_dlist $dpos $dpos]
-        }
-        if { $hpos >= 0 } {
-            # Remove it from the hidden list.
-            set _hidden [lreplace $_hidden $hpos $hpos]
-        }
-        array unset _obj2ovride $dataobj-*
-        array unset _layers $dataobj-*
-        array unset _opacity $dataobj-*
-        array unset _visibility $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-# USAGE: get ?-image legend <dataobj> <layer>?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![$dataobj isvalid] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-hidden" {
-            set dlist {}
-            foreach dataobj $_hidden {
-                if { [info commands $dataobj] != $dataobj } {
-                    # dataobj was deleted, remove from list
-                    set pos [lsearch -exact $_hidden $dataobj]
-                    if {$pos >= 0} {
-                        set _hidden [lreplace $_hidden $pos $pos]
-                    }
-                    continue
-                }
-                if { ![$dataobj isvalid] } {
-                    continue
-                }
-                if { [info exists _obj2ovride($dataobj-raise)] } {
-                    puts stderr "ERROR: object on hidden list is visible"
-                }
-                lappend dlist $dataobj
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![$dataobj isvalid] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] < 2} {
-                error "wrong # args: should be \"get -image view|legend\""
-            }
-            switch -- [lindex $args 1] {
-                legend {
-                    if {[llength $args] < 4} {
-                        error "wrong # args: should be \"get -image legend <dataobj> <layer>\""
-                    }
-                    set dataobj [lindex $args 2]
-                    set layer [lindex $args 3]
-                    set colormap $layer
-                    if {![$dataobj layer $layer shared]} {
-                        set colormap $dataobj-$layer
-                        set colormap "[regsub -all {::} ${colormap} {}]"
-                        set colormap "[regsub -all {\-} ${colormap} {_}]"
-                    }
-                    return $_image(legend-$colormap)
-                }
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args 1]\": should be view|legend"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -hidden, -visible or -image"
-        }
-    }
-}
-
-itcl::body Rappture::MapViewer::MapIsGeocentric {} {
-    if { [info exists _mapsettings(type)] } {
-        return [expr {$_mapsettings(type) eq "geocentric"}]
-    } else {
-        return 0
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::scale {args} {
-    DebugTrace "Enter"
-    array unset _mapsettings
-
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue
-        }
-        # Global map view settings are taken from the first dataobj
-        array unset settings
-        array set settings [$dataobj hints]
-        if { [array size _mapsettings] == 0 } {
-            set _mapsettings(label) $settings(label)
-            set _mapsettings(style) $settings(style)
-            set _mapsettings(type) $settings(type)
-            set _mapsettings(projection) $settings(projection)
-            set _mapsettings(extents) $settings(extents)
-            set _mapsettings(camera) $settings(camera)
-        }
-        # If dataobj has the same type and projection as view, expand extents
-        if { $settings(extents) != "" &&
-             $settings(type) == $_mapsettings(type) &&
-             $settings(projection) == $_mapsettings(projection)} {
-            foreach {xmin ymin xmax ymax} $settings(extents) break
-            if { $_mapsettings(extents) == $settings(extents) } {
-                set _mapsettings(xmin) $xmin
-                set _mapsettings(ymin) $ymin
-                set _mapsettings(xmax) $xmax
-                set _mapsettings(ymax) $ymax
-            } else {
-                if { $xmin < $_mapsettings(xmin) } {
-                    set _mapsettings(xmin) $xmin
-                    #set _reset 1
-                }
-                if { $ymin < $_mapsettings(ymin) } {
-                    set _mapsettings(ymin) $ymin
-                    #set _reset 1
-                }
-                if { $xmax > $_mapsettings(xmax) } {
-                    set _mapsettings(xmax) $xmax
-                    #set _reset 1
-                }
-                if { $ymax > $_mapsettings(ymax) } {
-                    set _mapsettings(ymax) $ymax
-                    #set _reset 1
-                }
-            }
-        }
-        foreach viewpoint [$dataobj viewpoints] {
-            set _viewpoints($viewpoint) [$dataobj viewpoint $viewpoint]
-            if {$_debug} {
-                array set vp $_viewpoints($viewpoint)
-                foreach key { label description x y z distance heading pitch srs verticalDatum } {
-                    if { [info exists vp($key)] } {
-                        DebugTrace "vp: $viewpoint $key $vp($key)"
-                    }
-                }
-            }
-        }
-    }
-    #if { $_reset } {
-    #    $_dispatcher event -idle !rebuild
-    #}
-}
-
-itcl::body Rappture::MapViewer::setSelectCallback {cmd} {
-    set _selectCallback $cmd
-}
-
-itcl::body Rappture::MapViewer::DoSelectCallback {option {args ""}} {
-    if { $_selectCallback != "" } {
-        set cmd [concat $_selectCallback $option $args]
-        uplevel #0 $cmd
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveSelect clear
-# USAGE: ReceiveSelect feature <args...>
-# USAGE: ReceiveSelect annotation <args...>
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::ReceiveSelect {option {args ""}} {
-    DebugTrace "Enter"
-    eval DoSelectCallback $option $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: select clear
-# USAGE: select feature add|delete|set <featureIDList> <layerName>
-# USAGE: select mode <boolean>
-#
-# Clients use this method to notify the map widget of a selection event
-# originating from outside the map
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::select {option {args ""}} {
-    switch $option {
-        "clear" {
-            if {[llength $args] > 0} {
-                error "wrong # args: should be \"select clear\""
-            }
-            SendCmd "select clear"
-        }
-        "feature" {
-            if {[llength $args] != 3} {
-                error "wrong #args: should be \"select feature <op> <featureIDList> <layerName>\""
-            }
-            set op [lindex $args 0]
-            set layer [lindex $args end]
-            if {![info exists _layers($layer)]} {
-                puts stderr "Unknown layer \"$layer\""
-                return
-            }
-            switch $op {
-                "add" {
-                    SendCmd "select fadd [lrange $args 1 end]"
-                }
-                "delete" {
-                    SendCmd "select fdelete [lrange $args 1 end]"
-                }
-                "set" {
-                    SendCmd "select feature [lrange $args 1 end]"
-                }
-                default {
-                    puts stderr "Unknown select feature op \"$op\""
-                }
-            }
-        }
-        "mode" {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"select mode <boolean>\""
-            }
-            if {![string is boolean $args]} {
-                error "argument to \"select mode\" must be boolean"
-            }
-            SendCmd "select mode $args"
-        }
-        default {
-            puts stderr "Unknown select option \"$option\""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: placard enable <state> <layerName>
-# 
-# Clients use this method to enable/disable display of a feature placard
-# when a feature is clicked/selected.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::placard {option args} {
-    switch $option {
-        enable {
-            if {[llength $args] != 2} {
-                error "wrong $ args: should be \"enable <boolean> <layerName>\""
-            }
-            set state [lindex $args 0]
-            set layerName [lindex $args 1]
-            if {![info exists _layers($layerName)]} {
-                error "Unknown layer \"$layerName\""
-            }
-            if {![string is boolean $state]} {
-                error "argument to placard enable must be boolean"
-            }
-            SendCmd "placard enable $state $layerName"
-        }
-        default {
-            error "bad option \"$option\": should be enable"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .mapviewerdownload
-            if { ![winfo exists .mapviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .mapviewerdownload
-            if {[winfo exists .mapviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::Connect {} {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    set _reset 1
-    set _hosts [GetServerList "geovis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "hub_url" [Rappture::Tool::resources -huburl]
-            lappend info "client" "mapviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-#   Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::MapViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::MapViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-#   Clients use this method to disconnect from the current rendering
-#   server.
-#
-itcl::body Rappture::MapViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    $_dispatcher cancel !pan
-    $_dispatcher cancel !motion
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    # disconnected -- no more data sitting on server
-    array unset _layers
-    array unset _layersFrame
-    global readyForNextFrame
-    set readyForNextFrame 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -type <type> -token <token> -bytes <size>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::ReceiveImage { args } {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    array set info {
-        -bytes 0
-        -token "???"
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        $_image(plot) configure -data $bytes
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-    set _waitTimeout 0
-}
-
-#
-# ReceiveLegend
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-#
-itcl::body Rappture::MapViewer::ReceiveLegend { colormap min max size } {
-    DebugTrace "ReceiveLegend colormap=$colormap range=$min,$max size=$size"
-    if { [IsConnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend-$colormap)] } {
-            set _image(legend-$colormap) [image create photo]
-        }
-        if 0 {
-            set f [open "/tmp/legend-${colormap}.ppm" "w"]
-            fconfigure $f -translation binary -encoding binary
-            puts $f $bytes
-            close $f
-        }
-        $_image(legend-$colormap) configure -data $bytes
-        #puts stderr "read $size bytes for [image width $_image(legend-$colormap)]x[image height $_image(legend-$colormap)] legend>"
-        if { [catch {DrawLegend $colormap $min $max} errs] != 0 } {
-            global errorInfo
-            puts stderr "errs=$errs errorInfo=$errorInfo"
-        }
-    }
-}
-
-#
-# ReceiveMapInfo --
-#
-itcl::body Rappture::MapViewer::ReceiveMapInfo { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set timeReceived [clock clicks -milliseconds]
-    set elapsed [expr $timeReceived - $_start]
-    set option [lindex $args 0]
-    switch -- $option {
-        "coords" {
-            set len [llength $args]
-            if {$len < 3} {
-                error "Bad map coords response"
-            } else {
-                set token [lindex $args 1]
-            }
-            foreach { x y z } [lindex $args 2] {
-                puts stderr "\[$token\] Map coords: $x $y $z"
-            }
-            if {$len > 3} {
-                set srs [lindex $args 3]
-                set vert [lindex $args 4]
-                puts stderr "\[$token\] {$srs} {$vert}"
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                puts stderr "layer: $name"
-            }
-        }
-        default {
-            error "unknown map option \"$option\" from server"
-        }
-    }
-}
-
-#
-# ReceiveScreenInfo --
-#
-itcl::body Rappture::MapViewer::ReceiveScreenInfo { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "coords" {
-            set len [llength $args]
-            if {$len < 3} {
-                error "Bad screen coords response"
-            } else {
-                set token [lindex $args 1]
-            }
-            foreach { x y z } [lindex $args 2] {
-                puts stderr "\[$token\] Screen coords: $x $y $z"
-            }
-        }
-        default {
-            error "unknown screen option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update idletasks
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to be
-    # preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_reset } {
-        set _width $w
-        set _height $h
-        DoResize
-
-        if { [info exists _mapsettings(type)] } {
-            # The map must be reset once before any layers are added.
-            # This should not be done more than once as it is very expensive.
-            if { [info exists _mapsettings(style)] } {
-                array set settings {
-                    -color white
-                }
-                array set settings $_mapsettings(style)
-            }
-            set bgcolor [Color2RGB $settings(-color)]
-            if { $_mapsettings(type) == "geocentric" } {
-                if { [info exists itk_component(grid)] } {
-                    $itk_component(grid) configure -state normal
-                }
-                if { [info exists itk_component(time)] } {
-                    $itk_component(time_l) configure -state normal
-                    $itk_component(time) configure -state normal
-                }
-                if { [info exists itk_component(pitch_slider)] } {
-                    $itk_component(pitch_slider_l) configure -state normal
-                    $itk_component(pitch_slider) configure -state normal
-                }
-                EnableRotationMouseBindings
-                SendCmd "map reset geocentric $bgcolor"
-            }  else {
-                if { [info exists itk_component(grid)] } {
-                    $itk_component(grid) configure -state disabled
-                }
-                if { [info exists itk_component(time)] } {
-                    $itk_component(time_l) configure -state disabled
-                    $itk_component(time) configure -state disabled
-                }
-                if { [info exists itk_component(pitch_slider)] } {
-                    $itk_component(pitch_slider_l) configure -state disabled
-                    $itk_component(pitch_slider) configure -state disabled
-                }
-                DisableRotationMouseBindings
-                set proj $_mapsettings(projection)
-                SendCmd "screen bgcolor $bgcolor"
-                if { $proj == "" } {
-                    SendCmd "map reset projected $bgcolor global-mercator"
-                } elseif { ![info exists _mapsettings(extents)] ||
-                           $_mapsettings(extents) == "" } {
-                    SendCmd "map reset projected $bgcolor [list $proj]"
-                } else {
-                    foreach key "xmin ymin xmax ymax" {
-                        set $key $_mapsettings($key)
-                    }
-                    SendCmd "map reset projected $bgcolor [list $proj] $xmin $ymin $xmax $ymax"
-                }
-            }
-            # XXX: Remove after implementing batch load of layers on reset
-            SendCmd "map layer delete base"
-
-            # Most terrain settings are global to the map and apply even
-            # if there is no elevation layer.  The exception is the
-            # vertical scale, which only applies if there is an elevation
-            # layer
-            if { [info exists _mapsettings(style)] } {
-                SetTerrainStyle $_mapsettings(style)
-            } else {
-                InitSettings terrain-ambient terrain-edges terrain-lighting \
-                    terrain-vertscale terrain-wireframe time
-            }
-            InitSettings coords-visible
-        } else {
-            error "No map settings on reset"
-        }
-    }
-
-    set _first ""
-    set haveTerrain 0
-    foreach dataobj [get -hidden] {
-        foreach layer [$dataobj layers] {
-            if { ![$dataobj layer $layer shared] } {
-                set tag $dataobj-$layer
-                SendCmd "map layer visible 0 $tag"
-            }
-        }
-    }
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-        }
-        foreach layer [$dataobj layers] {
-            array unset info
-            array set info [$dataobj layer $layer]
-            set tag $layer
-            if { !$info(shared) } {
-                set tag $dataobj-$layer
-            }
-            if { ![info exists _layers($tag)] } {
-                if { $_reportClientInfo }  {
-                    set cinfo {}
-                    lappend cinfo "tool_id"       [$dataobj hints toolid]
-                    lappend cinfo "tool_name"     [$dataobj hints toolname]
-                    lappend cinfo "tool_title"    [$dataobj hints tooltitle]
-                    lappend cinfo "tool_command"  [$dataobj hints toolcommand]
-                    lappend cinfo "tool_revision" [$dataobj hints toolrevision]
-                    lappend cinfo "dataset_label" [encoding convertto utf-8 $info(label)]
-                    lappend cinfo "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $cinfo]"
-                }
-                set _layers($tag) 1
-                SetLayerStyle $dataobj $layer
-            } elseif { [$dataobj dirty $layer] } {
-                # Recreate layer
-                # FIXME: retain layer order
-                SendCmd "map layer delete $tag"
-                SetLayerStyle $dataobj $layer
-            }
-            $dataobj dirty $layer 0
-            # Don't change visibility of shared/base layers
-            if { !$info(shared) } {
-                # FIXME: This is overriding data layers' initial visibility
-                if { [info exists _obj2ovride($dataobj-raise)] } {
-                    SendCmd "map layer visible 1 $tag"
-                    set _visibility($tag) 1
-                } else {
-                    SendCmd "map layer visible 0 $tag"
-                    set _visibility($tag) 0
-                }
-            }
-            if {$info(type) == "elevation"} {
-                set haveTerrain 1
-            }
-        }
-        # Search our layer list for data layers removed from map object
-        foreach tag [array names _layers -glob $dataobj-*] {
-            set layer [string range $tag [string length "$dataobj-"] end]
-            if {![$dataobj hasLayer $layer]} {
-                DebugTrace "Delete layer: tag: $tag layer: $layer"
-                SendCmd "map layer delete $tag"
-                array unset _layers $tag
-                array unset _opacity $tag
-                array unset _visibility $tag
-            }
-        }
-    }
-
-    if {$_reset} {
-        if {$_initCamera} {
-            # If this is the first Rebuild, we need to
-            # set up the initial view settings if there
-            # are any
-            Camera reset
-            set _initCamera 0
-        } else {
-            # Restore view from before reconnect
-            Camera set all
-        }
-    }
-
-    if {$_useSidebar} {
-        if ($haveTerrain) {
-            if { [info exists itk_component(vscale)] } {
-                $itk_component(vscale_l) configure -state normal
-                $itk_component(vscale) configure -state normal
-            }
-        } else {
-            if { [info exists itk_component(vscale)] } {
-                $itk_component(vscale_l) configure -state disabled
-                $itk_component(vscale) configure -state disabled
-            }
-        }
-        UpdateLayerControls
-        UpdateViewpointControls
-    }
-
-    set _reset 0
-    global readyForNextFrame
-    set readyForNextFrame 0;            # Don't advance to the next frame
-                                        # until we get an image.
-
-    # Actually write the commands to the server socket.  If it fails, we
-    # don't care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-itcl::body Rappture::MapViewer::EnablePanningMouseBindings {} {
-    if {1 || $_useServerManip} {
-        bind $itk_component(view) <ButtonPress-1> \
-            [itcl::code $this MouseClick 1 %x %y]
-        bind $itk_component(view) <B1-Motion> \
-            [itcl::code $this MouseDrag 1 %x %y]
-        bind $itk_component(view) <ButtonRelease-1> \
-            [itcl::code $this MouseRelease 1 %x %y]
-    } else {
-        bind $itk_component(view) <ButtonPress-1> \
-            [itcl::code $this Pan click %x %y]
-        bind $itk_component(view) <B1-Motion> \
-            [itcl::code $this Pan drag %x %y]
-        bind $itk_component(view) <ButtonRelease-1> \
-            [itcl::code $this Pan release %x %y]
-    }
-}
-
-itcl::body Rappture::MapViewer::DisablePanningMouseBindings {} {
-    bind $itk_component(view) <ButtonPress-1> {}
-    bind $itk_component(view) <B1-Motion> {}
-    bind $itk_component(view) <ButtonRelease-1> {}
-}
-
-itcl::body Rappture::MapViewer::EnableRotationMouseBindings {} {
-    if {1 || $_useServerManip} {
-        # Bindings for rotation via mouse
-        bind $itk_component(view) <ButtonPress-2> \
-            [itcl::code $this MouseClick 2 %x %y]
-        bind $itk_component(view) <B2-Motion> \
-            [itcl::code $this MouseDrag 2 %x %y]
-        bind $itk_component(view) <ButtonRelease-2> \
-            [itcl::code $this MouseRelease 2 %x %y]
-    } else {
-        bind $itk_component(view) <ButtonPress-2> \
-            [itcl::code $this Rotate click %x %y]
-        bind $itk_component(view) <B2-Motion> \
-            [itcl::code $this Rotate drag %x %y]
-        bind $itk_component(view) <ButtonRelease-2> \
-            [itcl::code $this Rotate release %x %y]
-    }
-}
-
-itcl::body Rappture::MapViewer::DisableRotationMouseBindings {} {
-    bind $itk_component(view) <ButtonPress-2> {}
-    bind $itk_component(view) <B2-Motion> {}
-    bind $itk_component(view) <ButtonRelease-2> {}
-}
-
-itcl::body Rappture::MapViewer::EnableZoomMouseBindings {} {
-    if {1 || $_useServerManip} {
-        bind $itk_component(view) <ButtonPress-3> \
-            [itcl::code $this MouseClick 3 %x %y]
-        bind $itk_component(view) <B3-Motion> \
-            [itcl::code $this MouseDrag 3 %x %y]
-        bind $itk_component(view) <ButtonRelease-3> \
-            [itcl::code $this MouseRelease 3 %x %y]
-    } else {
-        bind $itk_component(view) <ButtonPress-3> \
-            [itcl::code $this Zoom click %x %y]
-        bind $itk_component(view) <B3-Motion> \
-            [itcl::code $this Zoom drag %x %y]
-        bind $itk_component(view) <ButtonRelease-3> \
-            [itcl::code $this Zoom release %x %y]
-    }
-}
-
-itcl::body Rappture::MapViewer::DisableZoomMouseBindings {} {
-    bind $itk_component(view) <ButtonPress-3> {}
-    bind $itk_component(view) <B3-Motion> {}
-    bind $itk_component(view) <ButtonRelease-3> {}
-}
-# ----------------------------------------------------------------------
-# USAGE: CurrentLayers ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.
-# This is normally a single ID, but it might be a list of IDs if the
-# current data object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::CurrentLayers {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentLayers: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach layer [$dataobj layers] {
-            if { [info exists _layers($layer)] && $_layers($layer) } {
-                lappend rlist $layer
-            }
-        }
-    }
-    return $rlist
-}
-
-itcl::body Rappture::MapViewer::KeyPress {k} {
-    SendCmd "key press $k"
-}
-
-itcl::body Rappture::MapViewer::KeyRelease {k} {
-    SendCmd "key release $k"
-}
-
-itcl::body Rappture::MapViewer::GetNormalizedMouse {x y} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    set x [expr {(2.0 * double($x)/$w) - 1.0}]
-    set y [expr {(2.0 * double($y)/$h) - 1.0}]
-    return [list $x $y]
-}
-
-itcl::body Rappture::MapViewer::MouseClick {button x y} {
-    SendCmd "mouse click $button $x $y"
-}
-
-itcl::body Rappture::MapViewer::MouseDoubleClick {button x y} {
-    SendCmd "mouse dblclick $button $x $y"
-}
-
-itcl::body Rappture::MapViewer::MouseDrag {button x y} {
-    SendCmd "mouse drag $button $x $y"
-}
-
-itcl::body Rappture::MapViewer::MouseRelease {button x y} {
-    SendCmd "mouse release $button $x $y"
-}
-
-itcl::body Rappture::MapViewer::MouseMotion {} {
-    SendCmd "mouse motion $_motion(x) $_motion(y)"
-    #SendCmd "map pin hover $_motion(x) $_motion(y)"
-    set _motion(pending) 0
-}
-
-itcl::body Rappture::MapViewer::MouseScroll {direction} {
-    switch -- $direction {
-        "up" {
-            SendCmd "mouse scroll 1"
-        }
-        "down" {
-            SendCmd "mouse scroll -1"
-        }
-    }
-}
-
-#
-# EventuallyHandleMotionEvent --
-#
-#   This routine compresses (no button press) motion events.  It
-#   delivers a server mouse command once every 100 milliseconds (if a
-#   motion event is pending).
-#
-itcl::body Rappture::MapViewer::EventuallyHandleMotionEvent {x y} {
-    set _motion(x) $x
-    set _motion(y) $y
-    if { !$_motion(compress) } {
-        MouseMotion
-        return
-    }
-    if { !$_motion(pending) } {
-        set _motion(pending) 1
-        $_dispatcher event -after $_motion(delay) !motion
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#        $this Zoom click x y
-#        $this Zoom drag x y
-#        $this Zoom release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# Also implements mouse zoom.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::Zoom {option {x 0} {y 0}} {
-    switch -- $option {
-        "in" {
-            # z here is normalized mouse Y delta
-            set z -0.25
-            SendCmd "camera zoom $z"
-        }
-        "out" {
-            # z here is normalized mouse Y delta
-            set z 0.25
-            SendCmd "camera zoom $z"
-        }
-        "reset" {
-            SendCmd "camera dist $_view(distance)"
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set h [winfo height $itk_component(view)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            if {[expr (abs($dy) > 0.0)]} {
-                SendCmd "camera zoom $dy"
-            }
-        }
-        "release" {
-            Zoom drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-            set _rotate(azimuth) 0
-            set _rotate(elevation) 0
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-                set dx [expr ($x - $_click(x))/double($w)]
-                set dy [expr ($_click(y) - $y)/double($h)]
-                set _click(x) $x
-                set _click(y) $y
-                if {[expr (abs($dx) > 0.0 || abs($dy) > 0.0)]} {
-                    #SendCmd "camera rotate $dx $dy"
-                    EventuallyRotate $dx $dy
-                }
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr $x / double($w)]
-            set dy [expr $y / double($h)]
-            if {[expr (abs($dx) > 0.0 || abs($dy) > 0.0)]} {
-                EventuallyRotate $dx $dy
-            }
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::MapViewer::Select {option x y} {
-    switch -- $option {
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            set _b1mode "select"
-            SendCmd "map box init $x $y"
-        }
-        "drag" {
-            if {$_b1mode != "select"} {
-                return
-            }
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            EventuallySelect $x $y
-        }
-        "release" {
-            set _b1mode ""
-            if {![info exists _click(x)] ||
-                ![info exists _click(y)] ||
-                ($_click(x) == $x &&
-                 $_click(y) == $y)} {
-                SendCmd "map box clear"
-            } else {
-                SendCmd "map box end $x $y"
-            }
-        }
-    }
-}
-
-itcl::body Rappture::MapViewer::Pin {option x y} {
-    set _click(x) $x
-    set _click(y) $y
-    switch -- $option {
-        "add" {
-            incr _labelCount
-            set label "Label $_labelCount"
-            SendCmd [list "map" "pin" "add" $x $y [encoding convertto utf-8 $label]]
-        }
-        "delete" {
-            SendCmd "map pin delete $x $y"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan set x y
-#        $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::Pan {option x y} {
-    switch -- $option {
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            set _pan(x) 0
-            set _pan(y) 0
-            $itk_component(view) configure -cursor hand1
-            set _b1mode "pan"
-        }
-        "drag" {
-            if {$_b1mode != "pan"} {
-                return
-            }
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($x - $_click(x))/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            if {[expr (abs($dx) > 0.0 || abs($dy) > 0.0)]} {
-                EventuallyPan $dx $dy
-                #SendCmd "camera pan $dx $dy"
-            }
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-            set _b1mode ""
-        }
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            if {[expr (abs($x) > 0.0 || abs($y) > 0.0)]} {
-                SendCmd "camera pan $x $y"
-            }
-            return
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-itcl::body Rappture::MapViewer::SetHeading { {value 0} } {
-    set _view(heading) $value
-    Camera set heading
-}
-
-itcl::body Rappture::MapViewer::SetPitch { {value -89.999} } {
-    set _view(pitch) $value
-    Camera set pitch
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MapViewer::InitSettings { args } {
-    foreach setting $args {
-        AdjustSetting $setting
-    }
-}
-
-#
-# AdjustSetting --
-#
-#   Changes/updates a specific setting in the widget.  There are
-#   usually user-setable option.  Commands are sent to the render
-#   server.
-#
-itcl::body Rappture::MapViewer::AdjustSetting {what {value ""}} {
-    if { ![isconnected] } {
-        return
-    }
-    switch -- $what {
-        "coords-visible" - "coords-precision" - "coords-units" {
-            set bool $_settings(coords-visible)
-            set units $_settings(coords-units)
-            set precision $_settings(coords-precision)
-            SendCmd "map posdisp $bool $units $precision"
-        }
-        "grid" - "grid-type" {
-            set bool $_settings(grid)
-            set gridType $_settings(grid-type)
-            SendCmd "map grid $bool $gridType"
-        }
-        "camera-throw" {
-            set bool $_settings($what)
-            SendCmd "camera throw $bool"
-        }
-        "terrain-ambient" {
-            set val $_settings($what)
-            SendCmd "map terrain ambient $val"
-        }
-        "terrain-edges" {
-            set bool $_settings($what)
-            SendCmd "map terrain edges $bool"
-        }
-        "terrain-lighting" {
-            set bool $_settings($what)
-            SendCmd "map terrain lighting $bool"
-        }
-        "terrain-palette" {
-            set cmap [$itk_component(terrainpalette) value]
-            #SendCmd "map terrain colormap $cmap"
-        }
-        "terrain-vertscale" {
-            set val $_settings($what)
-            SendCmd "map terrain vertscale $val"
-        }
-        "terrain-wireframe" {
-            set bool $_settings($what)
-            SendCmd "map terrain wireframe $bool"
-        }
-        "time" {
-            set val $_settings($what)
-            SendCmd "map time $val"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::MapViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        SendCmd "screen bgcolor $rgb"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::MapViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        # FIXME: Set font foreground colors
-    }
-}
-
-itcl::body Rappture::MapViewer::BuildMapTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Map Settings" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.posdisp \
-        -text "Show Coordinate Readout" \
-        -variable [itcl::scope _settings(coords-visible)] \
-        -command [itcl::code $this AdjustSetting coords-visible] \
-        -font "Arial 9" -anchor w
-
-    itk_component add grid {
-        checkbutton $inner.grid \
-        -text "Show Graticule" \
-        -variable [itcl::scope _settings(grid)] \
-        -command [itcl::code $this AdjustSetting grid] \
-        -font "Arial 9" -anchor w
-    } {
-        ignore -font
-    }
-    Rappture::Tooltip::for $inner.grid "Toggle graticule (grid) display <g>"
-
-    checkbutton $inner.wireframe \
-        -text "Show Wireframe" \
-        -variable [itcl::scope _settings(terrain-wireframe)] \
-        -command [itcl::code $this AdjustSetting terrain-wireframe] \
-        -font "Arial 9" -anchor w
-    Rappture::Tooltip::for $inner.wireframe "Toggle wireframe rendering of terrain geometry <w>"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(terrain-lighting)] \
-        -command [itcl::code $this AdjustSetting terrain-lighting] \
-        -font "Arial 9" -anchor w
-    Rappture::Tooltip::for $inner.lighting "Toggle sky lighting of terrain <l>"
-
-    checkbutton $inner.edges \
-        -text "Show Edges" \
-        -variable [itcl::scope _settings(terrain-edges)] \
-        -command [itcl::code $this AdjustSetting terrain-edges] \
-        -font "Arial 9" -anchor w
-
-    itk_component add time_l {
-        label $inner.time_l -text "Time (UTC)" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add time {
-        ::scale $inner.time -from 0 -to 23.9 -orient horizontal \
-            -resolution 0.1 \
-            -variable [itcl::scope _settings(time)] \
-            -width 10 \
-            -showvalue on \
-            -command [itcl::code $this AdjustSetting time]
-    }
-    Rappture::Tooltip::for $inner.time \
-        "Set ephemeris time for sky lighting"
-
-    itk_component add ambient_l {
-        label $inner.ambient_l -text "Ambient min." -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add ambient {
-        ::scale $inner.ambient -from 0 -to 1.0 -orient horizontal \
-            -resolution 0.01 \
-            -variable [itcl::scope _settings(terrain-ambient)] \
-            -width 10 \
-            -showvalue on \
-            -command [itcl::code $this AdjustSetting terrain-ambient]
-    }
-    Rappture::Tooltip::for $inner.ambient \
-        "Set minimum global ambient light level"
-
-    blt::table $inner \
-        0,0 $inner.posdisp   -cspan 2 -anchor w -pady 2 \
-        1,0 $inner.grid      -cspan 2 -anchor w -pady 2 \
-        2,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \
-        3,0 $inner.lighting  -cspan 2 -anchor w -pady 2 \
-        4,0 $inner.time_l             -anchor w -pady 2 \
-        4,1 $inner.time               -fill x   -pady 2 \
-        5,0 $inner.ambient_l          -anchor w -pady 2 \
-        5,1 $inner.ambient            -fill x   -pady 2
-#        4,0 $inner.edges     -cspan 2  -anchor w -pady 2
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r6 c1 -resize expand
-}
-
-itcl::body Rappture::MapViewer::BuildTerrainTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Terrain Settings" \
-        -icon [Rappture::icon terrain]]
-    $inner configure -borderwidth 4
-
-    label $inner.palette_l -text "Palette" -font "Arial 9" -anchor w
-    itk_component add terrainpalette {
-        Rappture::Combobox $inner.palette -width 10 -editable no
-    }
-    $inner.palette choices insert end [GetColormapList]
-
-    $itk_component(terrainpalette) value "BCGYR"
-    bind $inner.palette <<Value>> \
-        [itcl::code $this AdjustSetting terrain-palette]
-
-    itk_component add vscale_l {
-        label $inner.vscale_l -text "Vertical Scale" -font "Arial 9" -anchor w
-    }
-    itk_component add vscale {
-        ::scale $inner.vscale -from 0 -to 10 -orient horizontal \
-            -variable [itcl::scope _settings(terrain-vertscale)] \
-            -width 10 \
-            -resolution 0.1 \
-            -showvalue on \
-            -command [itcl::code $this AdjustSetting terrain-vertscale]
-    }
-    $inner.vscale set $_settings(terrain-vertscale)
-    Rappture::Tooltip::for $inner.vscale \
-        "Set terrain vertical scale factor"
-
-    blt::table $inner \
-        0,0 $inner.vscale_l  -anchor w -pady 2 \
-        0,1 $inner.vscale    -fill x   -pady 2
-#        1,0 $inner.palette_l -anchor w -pady 2 \
-#        1,1 $inner.palette   -fill x   -pady 2
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r3 c1 -resize expand
-}
-
-itcl::body Rappture::MapViewer::BuildLayerTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Layers" \
-        -icon [Rappture::icon layers]]
-    $inner configure -borderwidth 4
-    set f [frame $inner.layers]
-    blt::table $inner \
-        0,0 $f -fill both
-    set _layersFrame $inner
-}
-
-itcl::body Rappture::MapViewer::BuildViewpointsTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Places" \
-        -icon [Rappture::icon placemark16]]
-    $inner configure -borderwidth 4
-    set f [frame $inner.viewpoints]
-    blt::table $inner \
-        0,0 $f -fill both
-    set _viewpointsFrame $inner
-}
-
-itcl::body Rappture::MapViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    set row 0
-
-    set labels { x y z heading pitch distance }
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view($tag)]
-        bind $inner.${tag} <KeyPress-Return> \
-            [itcl::code $this Camera set ${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this Camera set ${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    set labels { srs verticalDatum }
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view($tag)]
-        bind $inner.${tag} <KeyPress-Return> \
-            [itcl::code $this Camera set ${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this Camera set ${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-
-    if {0} {
-    button $inner.get \
-        -text "Get Camera Settings" \
-        -font "Arial 9" \
-        -command [itcl::code $this SendCmd "camera get"]
-    blt::table $inner \
-        $row,0 $inner.get -anchor w -pady 2 -cspan 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    button $inner.set \
-        -text "Apply Camera Settings" \
-        -font "Arial 9" \
-        -command [itcl::code $this Camera set all]
-    blt::table $inner \
-        $row,0 $inner.set -anchor w -pady 2 -cspan 2
-    blt::table configure $inner r$row -resize none
-    incr row
-    }
-
-    if {$_useServerManip} {
-        checkbutton $inner.throw \
-            -text "Enable Throw" \
-            -font "Arial 9" \
-            -variable [itcl::scope _settings(camera-throw)] \
-            -command [itcl::code $this AdjustSetting camera-throw]
-        blt::table $inner \
-            $row,0 $inner.throw -anchor w -pady 2 -cspan 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-
-    label $inner.heading_slider_l -text "Heading" -font "Arial 9"
-    ::scale $inner.heading_slider -font "Arial 9" \
-        -from -180 -to 180 -orient horizontal \
-        -variable [itcl::scope _view(heading)] \
-        -width 10 \
-        -showvalue on \
-        -command [itcl::code $this Camera set heading]
-
-    blt::table $inner \
-            $row,0 $inner.heading_slider_l -anchor w -pady 2
-    blt::table $inner \
-            $row,1 $inner.heading_slider -fill x -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    itk_component add pitch_slider_l {
-        label $inner.pitch_slider_l -text "Pitch" -font "Arial 9"
-    }
-    itk_component add pitch_slider {
-        ::scale $inner.pitch_slider -font "Arial 9" \
-            -from -10 -to -90 -orient horizontal \
-            -variable [itcl::scope _view(pitch)] \
-            -width 10 \
-            -showvalue on \
-            -command [itcl::code $this Camera set pitch]
-    }
-
-    blt::table $inner \
-            $row,0 $inner.pitch_slider_l -anchor w -pady 2
-    blt::table $inner \
-            $row,1 $inner.pitch_slider -fill x -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* r* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-itcl::body Rappture::MapViewer::BuildHelpTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Help" \
-        -icon [Rappture::icon question_mark12]]
-    $inner configure -borderwidth 4
-
-    set helptext {*************************
-Mouse bindings:
-*************************
-  Left - Panning
-  Middle - Rotation
-  Right - Zoom
-
-Zoom/travel:
-  Left double-click:
-    Zoom to point
-  Left shift-double:
-    Travel to point
-  Right double-click:
-    Zoom out from point
-
-Pins:
-  Ctl-Left: Drop pin
-  Ctl-Right: Delete pin
-
-Select:
-  Shift-Left click-drag
-
-*************************
-Keyboard bindings:
-*************************
-  g - Toggle graticule
-  l - Toggle lighting
-  n - Set North up
-  p - Reset pitch
-  w - Toggle wireframe
-  arrows - panning
-  Shift-arrows - fine pan
-  Ctl-arrows - rotation
-  Ctl-Shift-arrows:
-    fine rotation
-  PgUp/PgDown - zoom
-  Home - Reset camera
-*************************}
-
-    text $inner.info -width 25 -bg white
-    $inner.info insert end $helptext
-    $inner.info configure -state disabled
-    blt::table $inner \
-        0,0 $inner.info -fill both
-}
-
-#
-# camera
-#
-# This is the public camera API
-#
-itcl::body Rappture::MapViewer::camera {option args} {
-    switch -- $option {
-        "reset" {
-            Camera reset
-        }
-        "viewpoint" {
-            if {[llength $args] < 1} {
-                error "wrong # args to camera viewpoint"
-            }
-            set vpopt [lindex $args 0]
-            switch -- $vpopt {
-                "go" {
-                    if {[llength $args] < 3} {
-                        error "wrong # of args to camera viewpoint go"
-                    }
-                    foreach {dataobj viewpoint} [lrange $args 1 end] break
-                    GoToViewpoint $dataobj $viewpoint
-                }
-                default {
-                    error "Unknown camera viewpoint option \"$vpopt\""
-                }
-            }
-        }
-        "zoom" {
-            if {[llength $args] < 1} {
-                error "wrong # of args to camera zoom"
-            }
-            set zoomopt [lindex $args 0]
-            switch -- $zoomopt {
-                "extent" {
-                    if {[llength $args] < 5} {
-                        error "wrong # of args to camera zoom extent"
-                    }
-                    foreach {xmin ymin xmax ymax duration srs} [lrange $args 1 end] break
-                    foreach key {xmin ymin xmax ymax} {
-                        if {![string is double -strict [set $key]]} {
-                            error "Invalid extent: $key=[set $key]"
-                        }
-                    }
-                    if {$duration == ""} {
-                        set duration 0.0
-                    } elseif {![string is double $duration]} {
-                        error "Invalid duration \"$duration\", should be a double"
-                    }
-                    SendCmd "camera extent $xmin $ymin $xmax $ymax $duration $srs"
-                }
-                "layer" {
-                    if {[llength $args] < 3} {
-                        error "wrong # of args to camera zoom layer"
-                    }
-                    foreach {dataobj layer duration} [lrange $args 1 end] break
-                    set tag $layer
-                    if {![$dataobj layer $layer shared]} {
-                        set tag $dataobj-$layer
-                    }
-                    if {![info exists _layers($tag)]} {
-                        error "Unknown layer $layer"
-                    }
-                    if {$duration == ""} {
-                        set duration 0.0
-                    } elseif {![string is double $duration]} {
-                        error "Invalid duration \"$duration\", should be a double"
-                    }
-                    SendCmd "camera lextent $tag $duration"
-                }
-                default {
-                    error "Unknown camera zoom option \"$zoomopt\""
-                }
-            }
-        }
-        default {
-            error "Unknown camera option \"$option\""
-        }
-    }
-}
-
-#
-#  Camera --
-#
-# USAGE: Camera get
-#        This is called by the server to transfer the
-#        current Viewpoint settings
-# USAGE: Camera reset
-#        Reset the camera to the default view
-#
-itcl::body Rappture::MapViewer::Camera {option args} {
-    switch -- $option {
-        "get" {
-            # We got the camera settings from the server
-            foreach name {x y z heading pitch distance srs verticalDatum} value $args {
-                set _view($name) $value
-            }
-            #DebugTrace "view: $_view(x), $_view(y), $_view(z), $_view(heading), $_view(pitch), $_view(distance), {$_view(srs)}, {$_view(verticalDatum)}"
-        }
-        "go" {
-            SendCmd "camera go $args"
-        }
-        "reset" {
-            array set _view {
-                x               0.0
-                y               0.0
-                z               0.0
-                heading         0.0
-                pitch           -89.9
-                distance        1.0
-                srs             ""
-                verticalDatum   ""
-            }
-            if { [info exists _mapsettings(camera)] } {
-                # Check if the tool specified a default
-                set view $_mapsettings(camera)
-                if { $view != "" } {
-                    array set cam $view
-                    set duration 0.0
-                    if {[info exists cam(layer)]} {
-                        set tag $cam(layer)
-                        if {$_first != "" &&
-                            ![$_first layer $cam(layer) shared]} {
-                            set tag $_first-$cam(layer)
-                        }
-                        SendCmd [list camera lextent $tag]
-                    } elseif {[info exists cam(xmin)] &&
-                              [info exists cam(ymin)] &&
-                              [info exists cam(xmax)] &&
-                              [info exists cam(ymax)]} {
-                        set srs ""
-                        if {[info exists cam(srs)]} {
-                            set srs $cam(srs)
-                        }
-                        SendCmd [list camera extent $cam(xmin) $cam(ymin) $cam(xmax) $cam(ymax) $duration $srs]
-                    } elseif {[info exists cam(latitude)] &&
-                              [info exists cam(longitude)]} {
-                        array set _view $view
-                        set _view(x) $cam(longitude)
-                        set _view(y) $cam(latitude)
-                        set _view(srs) wgs84
-                        SendCmd [list camera set $_view(x) $_view(y) $_view(z) $_view(heading) $_view(pitch) $_view(distance) $duration $_view(srs) $_view(verticalDatum)]
-                    } else {
-                        array set _view $view
-                        SendCmd [list camera set $_view(x) $_view(y) $_view(z) $_view(heading) $_view(pitch) $_view(distance) $duration $_view(srs) $_view(verticalDatum)]
-                    }
-                } else {
-                    SendCmd "camera reset"
-                    # Retrieve the settings
-                    #SendCmd "camera get"
-                }
-            } else {
-                SendCmd "camera reset"
-                # Retrieve the settings
-                #SendCmd "camera get"
-            }
-        }
-        "set" {
-            set who [lindex $args 0]
-            if {$who != "all" && $who != "srs" && $who != "verticalDatum"} {
-                set val $_view($who)
-                set code [catch { string is double $val } result]
-                if { $code != 0 || !$result } {
-                    return
-                }
-            }
-            switch -- $who {
-                "distance" {
-                    SendCmd [list camera dist $_view(distance)]
-                }
-                "all" - "x" - "y" - "z" - "heading" - "pitch" - "srs" - "verticalDatum" {
-                    set duration 0.0
-                    SendCmd [list camera set $_view(x) $_view(y) $_view(z) $_view(heading) $_view(pitch) $_view(distance) $duration $_view(srs) $_view(verticalDatum)]
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::MapViewer::GoToViewpoint { dataobj viewpoint {duration 2.0}} {
-    array set view [subst {
-        x 0
-        y 0
-        z 0
-        heading 0
-        pitch -90
-        distance $_view(distance)
-        srs "$_view(srs)"
-        verticalDatum "$_view(verticalDatum)"
-    }]
-    array set view [$dataobj viewpoint $viewpoint]
-    foreach key {x y z heading pitch distance srs verticalDatum} {
-        if { [info exists view($key)] } {
-            set _view($key) $view($key)
-        }
-    }
-    # If map is projected, ignore pitch
-    if {![MapIsGeocentric]} {
-        set _view(pitch) -90
-    }
-    SendCmd [list camera set $_view(x) $_view(y) $_view(z) $_view(heading) $_view(pitch) $_view(distance) $duration $_view(srs) $_view(verticalDatum)]
-}
-
-itcl::body Rappture::MapViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::MapViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.image_button invoke
-    return $inner
-}
-
-itcl::body Rappture::MapViewer::ToggleGrid {} {
-    set _settings(grid) [expr !$_settings(grid)]
-    AdjustSetting grid
-}
-
-itcl::body Rappture::MapViewer::ToggleLighting {} {
-    set _settings(terrain-lighting) [expr !$_settings(terrain-lighting)]
-    AdjustSetting terrain-lighting
-}
-
-itcl::body Rappture::MapViewer::ToggleWireframe {} {
-    set _settings(terrain-wireframe) [expr !$_settings(terrain-wireframe)]
-    AdjustSetting terrain-wireframe
-}
-
-# Convert from Tcl integer epoch time value to hours as a double
-itcl::body Rappture::MapViewer::ConvertTime { timeval } {
-    set hrs [clock format $timeval -format %k -gmt 1]
-    set min [clock format $timeval -format %M -gmt 1]
-    # Strip leading zeroes
-    scan $min %d min
-    set sec [clock format $timeval -format %S -gmt 1]
-    # Strip leading zeroes
-    scan $sec %d sec
-    set val [expr {$hrs + $min/60.0 + $sec/3600.0}]
-}
-
-itcl::body Rappture::MapViewer::SetTerrainStyle { style } {
-    array set settings {
-        -ambient 0.03
-        -color white
-        -edgecolor black
-        -edges 0
-        -lighting 1
-        -linewidth 1.0
-        -time now
-        -vertscale 1.0
-        -wireframe 0
-    }
-    array set settings $style
-
-    SendCmd "map terrain ambient $settings(-ambient)"
-    set _settings(terrain-ambient) $settings(-ambient)
-    SendCmd "map terrain edges $settings(-edges)"
-    set _settings(terrain-edges) $settings(-edges)
-    SendCmd "map terrain color [Color2RGB $settings(-color)]"
-    #SendCmd "map terrain colormode constant"
-    if {$settings(-time) eq "now"} {
-        set settings(-time) [ConvertTime [clock seconds]]
-    } else {
-        set settings(-time) [ConvertTime [clock scan $settings(-time) -gmt 1]]
-    }
-    SendCmd "map time $settings(-time)"
-    set _settings(time) $settings(-time)
-    SendCmd "map terrain lighting $settings(-lighting)"
-    set _settings(terrain-lighting) $settings(-lighting)
-    SendCmd "map terrain linecolor [Color2RGB $settings(-edgecolor)]"
-    #SendCmd "map terrain linewidth $settings(-linewidth)"
-    SendCmd "map terrain vertscale $settings(-vertscale)"
-    set _settings(terrain-vertscale) $settings(-vertscale)
-    SendCmd "map terrain wireframe $settings(-wireframe)"
-    set _settings(terrain-wireframe) $settings(-wireframe)
-}
-
-itcl::body Rappture::MapViewer::SendStylesheetFiles { stylesheet } {
-    set files [Rappture::Map::getFilesFromStylesheet $stylesheet]
-    foreach file $files {
-        SendFiles $file
-    }
-}
-
-itcl::body Rappture::MapViewer::SendFiles { path } {
-    set isRelative [expr {[string first "://" $path] < 0 &&
-                          [string index $path 0] != "/"}]
-    if {[string range $path 0 7] != "local://" &&
-        !$isRelative} {
-        return
-    }
-    DebugTrace "Local path: $path"
-    if {!$isRelative} {
-        set path [string range $path 8 end]
-    }
-    set basename [file rootname $path]
-    if {[catch {set files [glob -path $basename .*]} err] != 0} {
-        puts stderr "File not found: $path"
-        return
-    }
-    foreach file $files {
-        set name $file
-        set type [file type $file]
-        set size [file size $file]
-        set f [open $file "r"]
-        fconfigure $f -translation binary -encoding binary
-        set data [read $f]
-        close $f
-        SendCmd [list file put $name $type $size]
-        SendData $data
-    }
-}
-
-itcl::body Rappture::MapViewer::SetLayerStyle { dataobj layer } {
-    array set info [$dataobj layer $layer]
-    set tag $layer
-    if { !$info(shared) } {
-        set tag $dataobj-$layer
-    }
-    if { [info exists info(visible)] &&
-         !$info(visible) } {
-        set _visibility($tag) 0
-    } else {
-        set _visibility($tag) 1
-    }
-
-    switch -- $info(type) {
-        "image" {
-            array set style {
-                -minlevel 0
-                -maxlevel 23
-                -opacity 1.0
-            }
-            if { [info exists info(style)] } {
-                DebugTrace "layer style: $info(style)"
-                array set style $info(style)
-            }
-            if { [info exists info(opacity)] } {
-                set style(-opacity) $info(opacity)
-                set _opacity($tag) $info(opacity)
-            }
-            set _opacity($tag) [expr $style(-opacity) * 100]
-            set coverage 0
-            if { [info exists info(coverage)] } {
-                set coverage $info(coverage)
-            }
-            switch -- $info(driver) {
-                "arcgis" {
-                    SendCmd [list map layer add $tag image arcgis \
-                                 $info(arcgis.url) $info(cache) $coverage $info(arcgis.token)]
-                }
-                "colorramp" {
-                    set cmapName "[regsub -all {::} ${tag} {}]"
-                    set cmapName "[regsub -all {\-} ${cmapName} {_}]"
-                    SendFiles $info(colorramp.url)
-                    SendCmd [list colormap define $cmapName $info(colorramp.colormap)]
-                    SendCmd [list map layer add $tag image colorramp \
-                                 $info(colorramp.url) $info(cache) $coverage $info(colorramp.elevdriver) $info(profile)  \
-                                 $cmapName]
-                }
-                "debug" {
-                    SendCmd [list map layer add $tag image debug]
-                }
-                "gdal" {
-                    SendFiles $info(gdal.url)
-                    SendCmd [list map layer add $tag image gdal \
-                                 $info(gdal.url) $info(cache) $coverage]
-                }
-                "tms" {
-                    SendCmd [list map layer add $tag image tms \
-                                 $info(tms.url) $info(cache) $coverage]
-                }
-                "wms" {
-                    if {[info exists info(wms.times)]} {
-                        SendCmd [list map layer add $tag image wms \
-                                     $info(wms.url) $info(cache) $coverage \
-                                     $info(wms.layers) \
-                                     $info(wms.format) \
-                                     $info(wms.transparent) \
-                                     $info(wms.times) \
-                                     $info(wms.frameSeconds)]
-                    } else {
-                        SendCmd [list map layer add $tag image wms \
-                                     $info(wms.url) $info(cache) $coverage \
-                                     $info(wms.layers) \
-                                     $info(wms.format) \
-                                     $info(wms.transparent)]
-                    }
-                }
-                "xyz" {
-                    SendCmd [list map layer add $tag image xyz \
-                                 $info(xyz.url) $info(cache) $coverage]
-                }
-            }
-            SendCmd "map layer opacity $style(-opacity) $tag"
-        }
-        "elevation" {
-            array set style {
-                -minlevel 0
-                -maxlevel 23
-            }
-            if { [info exists info(style)] } {
-                array set style $info(style)
-            }
-            set verticalDatum ""
-            if {[info exists info(verticalDatum)]} {
-                set verticalDatum $info(verticalDatum)
-            }
-            switch -- $info(driver) {
-                "gdal" {
-                    SendFiles $info(gdal.url)
-                    SendCmd [list map layer add $tag elevation gdal \
-                                 $info(gdal.url) $info(cache) $verticalDatum]
-                }
-                "tms" {
-                    SendCmd [list map layer add $tag elevation tms \
-                                 $info(tms.url) $info(cache) $verticalDatum]
-                }
-                "wcs" {
-                    SendCmd [list map layer add $tag elevation wcs \
-                                 $info(wcs.url) $info(cache) $verticalDatum $info(wcs.identifier)]
-                }
-            }
-        }
-        "feature" {
-            array set style {
-                -opacity 1.0
-            }
-            if { [info exists info(style)] } {
-                DebugTrace "layer style: $info(style)"
-                array set style $info(style)
-            }
-            if { [info exists info(minrange)] } {
-                set style(-minrange) $info(minrange)
-            }
-            if { [info exists info(maxrange)] } {
-                set style(-maxrange) $info(maxrange)
-            }
-            if { [info exists info(opacity)] } {
-                set style(-opacity) $info(opacity)
-            }
-            set _opacity($tag) [expr $style(-opacity) * 100]
-            DebugTrace "stylesheet: $info(stylesheet)"
-            set script ""
-            if { [info exists info(script)] } {
-                set script $info(script)
-                DebugTrace "script: $script"
-            }
-            set selectors [list]
-            foreach selector [$dataobj selectors $layer] {
-                array set sinfo [$dataobj selector $layer $selector]
-                DebugTrace "$selector: [array get sinfo]"
-                lappend selectors [array get sinfo]
-                if {[info exists sinfo(styleExpression)]} {
-                    DebugTrace "$selector: $sinfo(styleExpression)"
-                } elseif {[info exists sinfo(query)]} {
-                    if {[info exists sinfo(queryBounds)]} {
-                        foreach {x1 y1 x2 y2} $sinfo(queryBounds) break
-                        DebugTrace "queryBounds: xmin $x1 ymin $y1 xmax $x2 ymax $y2"
-                    }
-                }
-            }
-            SendStylesheetFiles $info(stylesheet)
-            set ssSize [string length $info(stylesheet)]
-            set scriptSize [string length $script]
-            set selectorsSize [string length $selectors]
-            set terrainPatch 0
-            if {[info exists info(terrainPatch)] && $info(terrainPatch)} {
-                set terrainPatch 1
-            }
-            switch -- $info(driver) {
-                "ogr" {
-                    if {[info exists info(ogr.connection)]} {
-                        set cmd [list map layer add $tag feature db {} $info(ogr.layer) $info(ogr.connection) $info(cache) $ssSize $scriptSize $selectorsSize $terrainPatch]
-                        if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                            lappend cmd $style(-minrange) $style(-maxrange)
-                        }
-                    } elseif {[info exists info(ogr.geometryUrl)]} {
-                        set cmd [list map layer add $tag feature wkt_file {} {} $info(ogr.geometryUrl) $info(cache) $ssSize $scriptSize $selectorsSize $terrainPatch]
-                        if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                            lappend cmd $style(-minrange) $style(-maxrange)
-                        }
-                        SendFiles $info(ogr.geometryUrl)
-                    } else {
-                        set cmd [list map layer add $tag feature $info(driver) {} {} $info(ogr.url) $info(cache) $ssSize $scriptSize $selectorsSize $terrainPatch]
-                        if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                            lappend cmd $style(-minrange) $style(-maxrange)
-                        }
-                        SendFiles $info(ogr.url)
-                    }
-                }
-                "tfs" {
-                    set format "json"
-                    if {[info exists info(tfs.format)]} {
-                        set format $info(tfs.format)
-                    }
-                    set cmd [list map layer add $tag feature $info(driver) $format {} $info(tfs.url) $info(cache) $ssSize $scriptSize $selectorsSize $terrainPatch]
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        lappend cmd $style(-minrange) $style(-maxrange)
-                    }
-                }
-                "wfs" {
-                    set format "json"
-                    if {[info exists info(wfs.format)]} {
-                        set format $info(wfs.format)
-                    }
-                    set wfsType ""
-                    if {[info exists info(wfs.typename)]} {
-                        set wfsType $info(wfs.typename)
-                    }
-                    set cmd [list map layer add $tag feature $info(driver) $format $wfsType $info(wfs.url) $info(cache) $ssSize $scriptSize $selectorsSize $terrainPatch]
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        lappend cmd $style(-minrange) $style(-maxrange)
-                    }
-                }
-            }
-            SendCmd $cmd
-            if { $ssSize > 0 }        { SendData $info(stylesheet) }
-            if { $scriptSize > 0 }    { SendData $script }
-            if { $selectorsSize > 0 } { SendData $selectors }
-            SendCmd "map layer opacity $style(-opacity) $tag"
-        }
-        "mask"  {
-            set minLOD 0
-            switch -- $info(driver) {
-                "ogr" {
-                    if {[info exists info(ogr.connection)]} {
-                        SendCmd [list map layer add $tag mask db {} $info(ogr.layer) $info(ogr.connection) $minLOD]
-                    } elseif {[info exists info(ogr.geometryUrl)]} {
-                        SendFiles $info(ogr.geometryUrl)
-                        SendCmd [list map layer add $tag mask wkt_file {} {} $info(ogr.geometryUrl) $minLOD]
-                    } elseif {[info exists info(ogr.geometry)]} {
-                        set len [string length $info(ogr.geometry)]
-                        SendCmd [list map layer add $tag mask wkt {} {} $len $minLOD]
-                        if {$len > 0} { SendData $info(ogr.geometry) }
-                    } else {
-                        SendFiles $info(ogr.url)
-                        SendCmd [list map layer add $tag mask $info(driver) {} {} $info(ogr.url) $minLOD]
-                    }
-                }
-                "tfs" {
-                    set format "json"
-                    if {[info exists info(tfs.format)]} {
-                        set format $info(tfs.format)
-                    }
-                    SendCmd [list map layer add $tag mask $info(driver) $format {} $info(tfs.url) $minLOD]
-                }
-                "wfs" {
-                    set format "json"
-                    if {[info exists info(wfs.format)]} {
-                        set format $info(wfs.format)
-                    }
-                    set wfsType ""
-                    if {[info exists info(wfs.typename)]} {
-                        set wfsType $info(wfs.typename)
-                    }
-                    SendCmd [list map layer add $tag mask $info(driver) $format $wfsType $info(wfs.url) $minLOD]
-                }
-            }
-        }
-        "model" {
-            set terrainPatch 0
-            if {[info exists info(terrainPatch)] && $info(terrainPatch)} {
-                set terrainPatch 1
-            }
-            switch -- $info(driver) {
-                "osg" {
-                    SendFiles $info(osg.url)
-                    SendCmd [list map layer add $tag model simple $info(osg.url) $info(osg.x) $info(osg.y) $info(osg.z) $info(osg.rotx) $info(osg.roty) $info(osg.rotz) $terrainPatch]
-                }
-            }
-        }
-        "line" {
-            array set style {
-                -cap "flat"
-                -clamping terrain
-                -clamptechnique gpu
-                -color black
-                -join "mitre"
-                -minbias 1000
-                -opacity 1.0
-                -stipplepattern 0
-                -stipplefactor 1
-                -width 1
-            }
-            if { [info exists info(style)] } {
-                array set style $info(style)
-            }
-            if { [info exists info(opacity)] } {
-                set style(-opacity) $info(opacity)
-            }
-            set _opacity($tag) [expr $style(-opacity) * 100]
-            foreach {r g b} [Color2RGB $style(-color)] {}
-            switch -- $info(driver) {
-                "ogr" {
-                    SendFiles $info(ogr.url)
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag line ogr {} {} $info(ogr.url) $info(cache) $r $g $b $style(-width) $style(-cap) $style(-join) $style(-stipplepattern) $style(-stipplefactor) $style(-clamping) $style(-clamptechnique) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag line ogr {} {} $info(ogr.url) $info(cache) $r $g $b $style(-width) $style(-cap) $style(-join) $style(-stipplepattern) $style(-stipplefactor) $style(-clamping) $style(-clamptechnique)]
-                    }
-                }
-                "tfs" {
-                    set format "json"
-                    if {[info exists info(tfs.format)]} {
-                        set format $info(tfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag line tfs $format {} $info(tfs.url) $info(cache) $r $g $b $style(-width) $style(-cap) $style(-join) $style(-stipplepattern) $style(-stipplefactor) $style(-clamping) $style(-clamptechnique) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag line tfs $format {} $info(tfs.url) $info(cache) $r $g $b $style(-width) $style(-cap) $style(-join) $style(-stipplepattern) $style(-stipplefactor) $style(-clamping) $style(-clamptechnique)]
-                    }
-                }
-                "wfs" {
-                    set format "json"
-                    if {[info exists info(wfs.format)]} {
-                        set format $info(wfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag line wfs $format $info(wfs.typename) $info(wfs.url) $info(cache) $r $g $b $style(-width) $style(-cap) $style(-join) $style(-stipplepattern) $style(-stipplefactor) $style(-clamping) $style(-clamptechnique) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag line wfs $format $info(wfs.typename) $info(wfs.url) $info(cache) $r $g $b $style(-width) $style(-cap) $style(-join) $style(-stipplepattern) $style(-stipplefactor) $style(-clamping) $style(-clamptechnique)]
-                    }
-                }
-            }
-            SendCmd "map layer opacity $style(-opacity) $tag"
-        }
-        "point" {
-            array set style {
-                -color black
-                -minbias 1000
-                -opacity 1.0
-                -size 1
-            }
-            if { [info exists info(style)] } {
-                array set style $info(style)
-            }
-            if { [info exists info(opacity)] } {
-                set style(-opacity) $info(opacity)
-            }
-            set _opacity($tag) [expr $style(-opacity) * 100]
-            foreach {r g b} [Color2RGB $style(-color)] {}
-            switch -- $info(driver) {
-                "ogr" {
-                    SendFiles $info(ogr.url)
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag point ogr {} {} $info(ogr.url) $info(cache) $r $g $b $style(-size) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag point ogr {} {} $info(ogr.url) $info(cache) $r $g $b $style(-size)]
-                    }
-                }
-                "tfs" {
-                    set format "json"
-                    if {[info exists info(tfs.format)]} {
-                        set format $info(tfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag point tfs $format {} $info(ogr.url) $info(cache) $r $g $b $style(-size) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag point tfs $format {} $info(ogr.url) $info(cache) $r $g $b $style(-size)]
-                    }
-                }
-                "wfs" {
-                    set format "json"
-                    if {[info exists info(wfs.format)]} {
-                        set format $info(wfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag point wfs $format $info(wfs.typename) $info(ogr.url) $info(cache) $r $g $b $style(-size) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag point wfs $format $info(wfs.typename) $info(ogr.url) $info(cache) $r $g $b $style(-size)]
-                    }
-                }
-            }
-            SendCmd "map layer opacity $style(-opacity) $tag"
-        }
-        "icon" {
-            array set style {
-                -align "center_bottom"
-                -declutter 1
-                -heading {}
-                -icon pin
-                -minbias 1000
-                -opacity 1.0
-                -placement "vertex"
-                -scale {}
-            }
-            if { [info exists info(style)] } {
-                array set style $info(style)
-            }
-            if { [info exists info(opacity)] } {
-                set style(-opacity) $info(opacity)
-            }
-            set _opacity($tag) [expr $style(-opacity) * 100]
-            switch -- $info(driver) {
-                "ogr" {
-                    SendFiles $info(ogr.url)
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag icon ogr {} {} $info(ogr.url) $info(cache) $style(-icon) $style(-scale) $style(-heading) $style(-declutter) $style(-placement) $style(-align) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag icon ogr {} {} $info(ogr.url) $info(cache) $style(-icon) $style(-scale) $style(-heading) $style(-declutter) $style(-placement) $style(-align)]
-                    }
-                }
-                "tfs" {
-                    set format "json"
-                    if {[info exists info(tfs.format)]} {
-                        set format $info(tfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag icon tfs $format {} $info(tfs.url) $info(cache) $style(-icon) $style(-scale) $style(-heading) $style(-declutter) $style(-placement) $style(-align) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag icon tfs $format {} $info(tfs.url) $info(cache) $style(-icon) $style(-scale) $style(-heading) $style(-declutter) $style(-placement) $style(-align)]
-                    }
-                }
-                "wfs" {
-                    set format "json"
-                    if {[info exists info(wfs.format)]} {
-                        set format $info(wfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag icon wfs $format $info(wfs.typename) $info(wfs.url) $info(cache) $style(-icon) $style(-scale) $style(-heading) $style(-declutter) $style(-placement) $style(-align) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag icon wfs $format $info(wfs.typename) $info(wfs.url) $info(cache) $style(-icon) $style(-scale) $style(-heading) $style(-declutter) $style(-placement) $style(-align)]
-                    }
-                }
-            }
-            SendCmd "map layer opacity $style(-opacity) $tag"
-        }
-        "polygon" {
-            array set style {
-                -clamping terrain
-                -clamptechnique drape
-                -color white
-                -minbias 1000
-                -opacity 1.0
-                -strokecolor black
-                -strokewidth 0.0
-            }
-            if { [info exists info(style)] } {
-                array set style $info(style)
-            }
-            if { [info exists info(opacity)] } {
-                set style(-opacity) $info(opacity)
-            }
-            set _opacity($tag) [expr $style(-opacity) * 100]
-            foreach {r g b} [Color2RGB $style(-color)] {}
-            foreach {strokeR strokeG strokeB} [Color2RGB $style(-strokecolor)] {}
-            set terrainPatch 0
-            if {[info exists info(terrainPatch)] && $info(terrainPatch)} {
-                set terrainPatch 1
-            }
-            switch -- $info(driver) {
-                "ogr" {
-                    SendFiles $info(ogr.url)
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag polygon ogr {} {} $info(ogr.url) $info(cache) $r $g $b $style(-strokewidth) $strokeR $strokeG $strokeB $style(-clamping) $style(-clamptechnique) $terrainPatch $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag polygon ogr {} {} $info(ogr.url) $info(cache) $r $g $b $style(-strokewidth) $strokeR $strokeG $strokeB $style(-clamping) $style(-clamptechnique) $terrainPatch]
-                    }
-                }
-                "tfs" {
-                    set format "json"
-                    if {[info exists info(tfs.format)]} {
-                        set format $info(tfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag polygon tfs $format {} $info(tfs.url) $info(cache) $r $g $b $style(-strokewidth) $strokeR $strokeG $strokeB $style(-clamping) $style(-clamptechnique) $terrainPatch $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag polygon tfs $format {} $info(tfs.url) $info(cache) $r $g $b $style(-strokewidth) $strokeR $strokeG $strokeB $style(-clamping) $style(-clamptechnique) $terrainPatch]
-                    }
-                }
-                "wfs" {
-                    set format "json"
-                    if {[info exists info(wfs.format)]} {
-                        set format $info(wfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag polygon wfs $format $info(wfs.typename) $info(wfs.url) $info(cache) $r $g $b $style(-strokewidth) $strokeR $strokeG $strokeB $style(-clamping) $style(-clamptechnique) $terrainPatch $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag polygon wfs $format $info(wfs.typename) $info(wfs.url) $info(cache) $r $g $b $style(-strokewidth) $strokeR $strokeG $strokeB $style(-clamping) $style(-clamptechnique) $terrainPatch]
-                    }
-                }
-            }
-            SendCmd "map layer opacity $style(-opacity) $tag"
-        }
-        "label" {
-            array set style {
-                -align "left_baseline"
-                -color black
-                -declutter 1
-                -font Arial
-                -fontsize 16.0
-                -halocolor white
-                -halowidth 2.0
-                -layout "left_to_right"
-                -minbias 1000
-                -opacity 1.0
-                -xoffset 0
-                -yoffset 0
-            }
-            if { [info exists info(style)] } {
-                array set style $info(style)
-            }
-            if { [info exists info(opacity)] } {
-                set style(-opacity) $info(opacity)
-            }
-            set _opacity($tag) [expr $style(-opacity) * 100]
-            set contentExpr $info(content)
-            if {[info exists info(priority)]} {
-                set priorityExpr $info(priority)
-            } else {
-                set priorityExpr ""
-            }
-            foreach {fgR fgG fgB} [Color2RGB $style(-color)] {}
-            foreach {bgR bgG bgB} [Color2RGB $style(-halocolor)] {}
-            switch -- $info(driver) {
-                "ogr" {
-                    SendFiles $info(ogr.url)
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag text ogr {} {} $info(ogr.url) $info(cache) $contentExpr $priorityExpr $fgR $fgG $fgB $bgR $bgG $bgB $style(-halowidth) $style(-fontsize) $style(-declutter) $style(-align) $style(-xoffset) $style(-yoffset) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag text ogr {} {} $info(ogr.url) $info(cache) $contentExpr $priorityExpr $fgR $fgG $fgB $bgR $bgG $bgB $style(-halowidth) $style(-fontsize) $style(-declutter) $style(-align) $style(-xoffset) $style(-yoffset)]
-                    }
-                }
-                "tfs" {
-                    set format "json"
-                    if {[info exists info(tfs.format)]} {
-                        set format $info(tfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag text tfs $format {} $info(tfs.url) $info(cache) $contentExpr $priorityExpr $fgR $fgG $fgB $bgR $bgG $bgB $style(-halowidth) $style(-fontsize) $style(-declutter) $style(-align) $style(-xoffset) $style(-yoffset) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag text tfs $format {} $info(tfs.url) $info(cache) $contentExpr $priorityExpr $fgR $fgG $fgB $bgR $bgG $bgB $style(-halowidth) $style(-fontsize) $style(-declutter) $style(-align) $style(-xoffset) $style(-yoffset)]
-                    }
-                }
-                "wfs" {
-                    set format "json"
-                    if {[info exists info(wfs.format)]} {
-                        set format $info(wfs.format)
-                    }
-                    if {[info exists style(-minrange)] && [info exists style(-maxrange)]} {
-                        SendCmd [list map layer add $tag text wfs $format $info(wfs.typename) $info(wfs.url) $contentExpr $priorityExpr $fgR $fgG $fgB $bgR $bgG $bgB $style(-halowidth) $style(-fontsize) $style(-declutter) $style(-align) $style(-xoffset) $style(-yoffset) $style(-minrange) $style(-maxrange)]
-                    } else {
-                        SendCmd [list map layer add $tag text wfs $format $info(wfs.typename) $info(wfs.url) $contentExpr $priorityExpr $fgR $fgG $fgB $bgR $bgG $bgB $style(-halowidth) $style(-fontsize) $style(-declutter) $style(-align) $style(-xoffset) $style(-yoffset)]
-                    }
-                }
-            }
-            SendCmd "map layer opacity $style(-opacity) $tag"
-        }
-    }
-
-    if {[info exists info(placard)]} {
-        if {$info(type) == "image" || $info(type) == "elevation"} {
-            error "Placard not supported on image or elevation layers"
-        }
-        array set placard [$dataobj getPlacardConfig $layer]
-        SendCmd [list placard config $placard(attrlist) $placard(style) $placard(padding) $tag]
-    }
-
-    SendCmd "map layer visible $_visibility($tag) $tag"
-}
-
-itcl::body Rappture::MapViewer::SetLayerOpacity { dataobj layer {value 100}} {
-    set tag $layer
-    if {![$dataobj layer $layer shared]} {
-        set tag $dataobj-$layer
-    }
-    set val $_opacity($tag)
-    set sval [expr { 0.01 * double($val) }]
-    SendCmd "map layer opacity $sval $tag"
-}
-
-itcl::body Rappture::MapViewer::SetLayerVisibility { dataobj layer } {
-    set tag $layer
-    if {![$dataobj layer $layer shared]} {
-        set tag $dataobj-$layer
-    }
-    set bool $_visibility($tag)
-    SendCmd "map layer visible $bool $tag"
-}
-
-itcl::body Rappture::MapViewer::UpdateLayerControls {} {
-    set row 0
-    set inner $_layersFrame
-    if { [winfo exists $inner.layers] } {
-        foreach w [winfo children $inner.layers] {
-            destroy $w
-        }
-    }
-    set f $inner.layers
-    set attrib [list]
-    set imgIdx 0
-    # FIXME: This order may not match stacking order in server
-    foreach dataobj [get -objects] {
-        foreach layer [$dataobj layers] {
-            array unset info
-            array set info [$dataobj layer $layer]
-            set tag $layer
-            set ctlname $layer
-            if {!$info(shared)} {
-                set tag $dataobj-$layer
-                set ctlname "[regsub -all {::} ${tag} {}]"
-                set ctlname "[regsub -all {\-} ${ctlname} {_}]"
-            }
-
-            set tooltip [list $info(description)]
-            if { [info exists info(attribution)] &&
-                 $info(attribution) != ""} {
-                lappend tooltip $info(attribution)
-            }
-
-            button $f.${ctlname}_zoom \
-                -borderwidth 1 -padx 1 -pady 1 \
-                -highlightthickness 0 \
-                -image [Rappture::icon zoom-extent] \
-                -command [itcl::code $this camera zoom layer $dataobj $layer 1.0]
-            blt::table $f $row,0 $f.${ctlname}_zoom -anchor w -pady 2
-            Rappture::Tooltip::for $f.${ctlname}_zoom \
-                "Zoom to extent for $info(label)"
-
-            if { $info(type) == "mask" } {
-                label $f.${ctlname}_lbl \
-                    -text $info(label) \
-                    -font "Arial 9" -anchor w
-                blt::table $f $row,1 $f.${ctlname}_lbl -anchor w -pady 2
-                Rappture::Tooltip::for $f.${ctlname}_lbl [join $tooltip \n]
-            } else {
-                checkbutton $f.${ctlname}_visible \
-                    -text $info(label) \
-                    -font "Arial 9" -anchor w \
-                    -variable [itcl::scope _visibility($tag)] \
-                    -command [itcl::code $this \
-                                  SetLayerVisibility $dataobj $layer]
-                blt::table $f $row,1 $f.${ctlname}_visible -anchor w -pady 2
-                Rappture::Tooltip::for $f.${ctlname}_visible [join $tooltip \n]
-            }
-            incr row
-            if { $info(type) == "image" } {
-                incr imgIdx
-                if { $info(driver) == "colorramp" } {
-                    set colormap $ctlname
-                    set f2 $f.cmap_$ctlname
-                    frame $f2
-                    if { ![info exists _image(legend-$colormap)] } {
-                        set _image(legend-$colormap) [image create photo]
-                    }
-                    itk_component add legend-$colormap-min {
-                        label $f2.legend-$colormap-min -text 0
-                    }
-                    itk_component add legend-$colormap-max {
-                        label $f2.legend-$colormap-max -text 1
-                    }
-                    itk_component add legend-$colormap {
-                        label $f2.legend-$colormap -image $_image(legend-$colormap)
-                    }
-                    blt::table $f2 0,0 $f2.legend-$colormap-min -anchor w -pady 0
-                    blt::table $f2 0,1 $f2.legend-$colormap-max -anchor e -pady 0
-                    blt::table $f2 1,0 $f2.legend-$colormap -anchor w -pady 2 -cspan 2
-
-                    blt::table $f $row,0 $f2 -anchor w -pady 0 -cspan 2
-                    incr row
-                    RequestLegend $colormap 256 16
-                }
-            }
-            if { $info(type) != "elevation" &&
-                 $info(type) != "mask" &&
-                ($info(type) != "image" || $imgIdx > 1) } {
-                set f2 $f.op_$ctlname
-                frame $f2
-                label $f2.${ctlname}_opacity_l -text "Opacity" -font "Arial 9"
-                ::scale $f2.${ctlname}_opacity -from 0 -to 100 \
-                    -orient horizontal -showvalue off \
-                    -variable [itcl::scope _opacity($tag)] \
-                    -width 10 \
-                    -command [itcl::code $this \
-                                  SetLayerOpacity $dataobj $layer]
-                Rappture::Tooltip::for $f2.${ctlname}_opacity "Set opacity of $info(label) layer"
-                blt::table $f2 0,0 $f2.${ctlname}_opacity_l -anchor w -pady 2
-                blt::table $f2 0,1 $f2.${ctlname}_opacity -anchor w -pady 2
-
-                blt::table $f $row,0 $f2 -anchor w -pady 0 -cspan 2
-                incr row
-            }
-        }
-        set mapAttrib [$dataobj hints "attribution"]
-        if { $mapAttrib != "" } {
-            lappend attrib $mapAttrib
-        }
-    }
-    SendCmd "[list map attrib [encoding convertto utf-8 [join $attrib ,]]]"
-    label $f.map_attrib -text [join $attrib \n] -font "Arial 9"
-    blt::table $f $row,0 $f.map_attrib -anchor sw -pady 2 -cspan 2
-    #incr row
-    if { $row > 0 } {
-        blt::table configure $f r* c* -resize none
-        blt::table configure $f r$row c1 -resize expand
-    }
-}
-
-itcl::body Rappture::MapViewer::UpdateViewpointControls {} {
-    set row 0
-    set inner $_viewpointsFrame
-    if { [winfo exists $inner.viewpoints] } {
-        foreach w [winfo children $inner.viewpoints] {
-            destroy $w
-        }
-    }
-    set f $inner.viewpoints
-    foreach dataobj [get -objects] {
-        foreach viewpoint [$dataobj viewpoints] {
-            array unset info
-            array set info [$dataobj viewpoint $viewpoint]
-            button $f.${viewpoint}_go \
-                -relief flat -compound left \
-                -image [Rappture::icon placemark16] \
-                -text $info(label) \
-                -font "Arial 9" -anchor w \
-                -command [itcl::code $this \
-                              GoToViewpoint $dataobj $viewpoint]
-            label $f.${viewpoint}_label \
-                -text $info(label) \
-                -font "Arial 9" -anchor w
-            blt::table $f $row,0 $f.${viewpoint}_go -anchor w -pady 2 -cspan 2
-            #blt::table $f $row,1 $f.${viewpoint}_label -anchor w -pady 2
-            if {[info exists info(description)]} {
-                Rappture::Tooltip::for $f.${viewpoint}_go $info(description)
-            }
-            incr row
-        }
-    }
-    if { $row > 0 } {
-        blt::table configure $f r* c* -resize none
-        blt::table configure $f r$row c1 -resize expand
-    }
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -map
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::MapViewer::map {
-    if {$itk_option(-map) != "" } {
-        if {[catch {$itk_option(-map) isa Rappture::Map} valid] != 0 || !$valid} {
-            error "bad value \"$itk_option(-map)\": should be Rappture::Map object"
-        }
-        $this clear
-        $this add $itk_option(-map)
-        $this scale $itk_option(-map)
-    } else {
-        $this clear
-    }
-
-    if { [isconnected] } {
-        $_dispatcher event -idle !rebuild
-    }
-}
Index: trunk/gui/scripts/mesh.tcl
===================================================================
--- trunk/gui/scripts/mesh.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1551 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: mesh - represents a structured mesh for a device
-#
-#  This object represents a mesh in an XML description of simulator
-#  output.  A mesh is a structured arrangement of points, as elements
-#  composed of nodes representing coordinates.  This is a little
-#  different from a cloud, which is an unstructured arrangement
-#  (shotgun blast) of points.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-
-namespace eval Rappture {
-    # forward declaration
-}
-
-itcl::class Rappture::Mesh {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method points {}
-    public method elements {}
-    public method mesh {{-type "vtk"}}
-    public method dimensions {}
-    public method limits {which}
-    public method units { axis }
-    public method label { axis }
-    public method hints {{key ""}}
-    public method isvalid {} {
-        return $_isValid
-    }
-    public proc fetch {xmlobj path}
-    public proc release {obj}
-    public method vtkdata {{what -partial}}
-    public method type {} {
-        return $_type
-    }
-    public method numpoints {} {
-        return $_numPoints
-    }
-    public method numcells {} {
-        return $_numCells
-    }
-
-    private method ReadNodesElements {path}
-    private method GetDimension { path }
-    private method GetDouble { path }
-    private method GetInt { path }
-    private method InitHints {}
-    private method ReadGrid { path }
-    private method ReadUnstructuredGrid { path }
-    private method ReadVtk { path }
-    private method WriteTriangles { path xv yv zv triangles }
-    private method WriteQuads { path xv yv zv quads }
-    private method WriteVertices { path xv yv zv vertices }
-    private method WriteLines { path xv yv zv lines }
-    private method WritePolygons { path xv yv zv polygons }
-    private method WriteTriangleStrips { path xv yv zv trianglestrips }
-    private method WriteTetrahedrons { path xv yv zv tetrahedrons }
-    private method WriteHexahedrons { path xv yv zv hexhedrons }
-    private method WriteWedges { path xv yv zv wedges }
-    private method WritePyramids { path xv yv zv pyramids }
-    private method WriteHybridCells { path xv yv zv cells celltypes }
-    private method WritePointCloud { path xv yv zv }
-    private method GetCellType { name }
-    private method GetNumIndices { type }
-
-    private variable _xmlobj "";        # Ref to XML obj with device data
-    private variable _mesh "";          # Lib obj representing this mesh
-    private variable _dim 0;            # Dimension of mesh (1, 2, or 3)
-    private variable _type "";          # Indicates the type of mesh.
-    private variable _axis2units;       # System of units for x, y, z
-    private variable _axis2labels;      #
-    private variable _hints
-    private variable _limits;           # Array of mesh limits. Keys are
-                                        # xmin, xmax, ymin, ymax, ...
-    private variable _numPoints 0;      # Number of points in mesh
-    private variable _numCells 0;       # Number of cells in mesh
-    private variable _vtkdata "";       # Mesh in vtk file format.
-    private variable _isValid 0;        # Indicates if the mesh is valid.
-
-    private common _xp2obj;             # used for fetch/release ref counting
-    private common _obj2ref;            # used for fetch/release ref counting
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::Mesh::fetch <xmlobj> <path>
-#
-# Clients use this instead of a constructor to fetch the Mesh for
-# a particular <path> in the <xmlobj>.  When the client is done with
-# the mesh, he calls "release" to decrement the reference count.
-# When the mesh is no longer needed, it is cleaned up automatically.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::fetch {xmlobj path} {
-    set handle "$xmlobj|$path"
-    if {[info exists _xp2obj($handle)]} {
-        set obj $_xp2obj($handle)
-        incr _obj2ref($obj)
-        return $obj
-    }
-    set obj [Rappture::Mesh ::#auto $xmlobj $path]
-    set _xp2obj($handle) $obj
-    set _obj2ref($obj) 1
-    return $obj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::Mesh::release <obj>
-#
-# Clients call this when they're no longer using a Mesh fetched
-# previously by the "fetch" proc.  This decrements the reference
-# count for the mesh and destroys the object when it is no longer
-# in use.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::release {obj} {
-    if {[info exists _obj2ref($obj)]} {
-        incr _obj2ref($obj) -1
-        if {$_obj2ref($obj) <= 0} {
-            unset _obj2ref($obj)
-            foreach handle [array names _xp2obj] {
-                if {$_xp2obj($handle) == $obj} {
-                    unset _xp2obj($handle)
-                }
-            }
-            itcl::delete object $obj
-        }
-    } else {
-        error "can't find reference count for $obj"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::constructor {xmlobj path} {
-    package require vtk
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be Rappture::library"
-    }
-    set _xmlobj $xmlobj
-    set _mesh [$xmlobj element -as object $path]
-
-    # Initialize mesh bounds to empty
-    foreach axis {x y z} {
-        set _limits($axis) ""
-    }
-    set units [$_mesh get units]
-    set first [lindex $units 0]
-    foreach u $units axis { x y z } {
-        if { $u != "" } {
-            set _axis2units($axis) $u
-        } else {
-            set _axis2units($axis) $first
-        }
-    }
-    foreach label [$_mesh get labels] axis { x y z } {
-        if { $label != "" } {
-            set _axis2labels($axis) $label
-        } else {
-            set _axis2labels($axis) [string toupper $axis]
-        }
-    }
-
-    # Meshes comes in a variety of flavors
-    #
-    # Dimensionality is determined from the <dimension> tag.
-    #
-    # <vtk> described mesh
-    # <element> +  <node> definitions
-    # <grid>            rectangular mesh
-    # <unstructured>    homogeneous cell type mesh.
-
-    # Check that only one mesh type was defined.
-    set subcount 0
-    foreach cname [$_mesh children] {
-        foreach type { vtk grid unstructured } {
-            if { $cname == $type } {
-                incr subcount
-                break
-            }
-        }
-    }
-    if {[$_mesh element "node"] != "" ||
-        [$_mesh element "element"] != ""} {
-        incr subcount
-    }
-
-    if { $subcount == 0 } {
-        puts stderr "WARNING: no mesh specified for \"$path\"."
-        return
-    }
-    if { $subcount > 1 } {
-        puts stderr "WARNING: too many mesh types specified for \"$path\"."
-        return
-    }
-    set result 0
-    if { [$_mesh element "vtk"] != ""} {
-        set result [ReadVtk $path]
-    } elseif {[$_mesh element "grid"] != "" } {
-        set result [ReadGrid $path]
-    } elseif {[$_mesh element "unstructured"] != "" } {
-        set result [ReadUnstructuredGrid $path]
-    } elseif {[$_mesh element "node"] != "" && [$_mesh element "element"] != ""} {
-        puts stderr "WARNING: <node>/<element> mesh is deprecated.  Please use an unstructured mesh instead."
-        set result [ReadNodesElements $path]
-    }
-    set _isValid $result
-    InitHints
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::destructor {} {
-    # don't destroy the _xmlobj! we don't own it!
-    itcl::delete object $_mesh
-}
-
-#
-# vtkdata --
-#
-#        This is called by the field object to generate a VTK file to send to
-#        the remote render server.  Returns the vtkDataSet object containing
-#        (at this point) just the mesh.  The field object doesn't know (or
-#        care) what type of mesh is used.  The field object will add field
-#        arrays before generating output to send to the remote render server.
-#
-itcl::body Rappture::Mesh::vtkdata {{what -partial}} {
-    if {$what == "-full"} {
-        append out "# vtk DataFile Version 3.0\n"
-        append out "[hints label]\n"
-        append out "ASCII\n"
-        append out $_vtkdata
-        return $out
-    } else {
-        return $_vtkdata
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: points
-#
-# Returns the vtk object containing the points for this mesh.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::points {} {
-    return ""
-}
-
-#
-# units --
-#
-#       Returns the units of the given axis.
-#
-itcl::body Rappture::Mesh::units { axis } {
-    if { ![info exists _axis2units($axis)] } {
-        return ""
-    }
-    return $_axis2units($axis)
-}
-
-#
-# label --
-#
-#       Returns the label of the given axis.
-#
-itcl::body Rappture::Mesh::label { axis } {
-    if { ![info exists _axis2labels($axis)] } {
-        return ""
-    }
-    return $_axis2labels($axis)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: elements
-#
-# Returns a list of the form {plist r plist r ...} for each element
-# in this mesh.  Each plist is a list of {x y x y ...} coordinates
-# for the mesh.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::elements {} {
-    # build a map for region number => region type
-    foreach comp [$_mesh children -type region] {
-        set id [$_mesh element -as id $comp]
-        set regions($id) [$_mesh get $comp]
-    }
-    set regions() "unknown"
-
-    set rlist ""
-    foreach comp [$_mesh children -type element] {
-        set rid [$_mesh get $comp.region]
-
-        #
-        # HACK ALERT!
-        #
-        # Prophet puts out nodes in a funny "Z" shaped order,
-        # not in proper clockwise fashion.  Switch the last
-        # two nodes for now to make them correct.
-        #
-        set nlist [$_mesh get $comp.nodes]
-        set n2 [lindex $nlist 2]
-        set n3 [lindex $nlist 3]
-        set nlist [lreplace $nlist 2 3 $n3 $n2]
-        lappend nlist [lindex $nlist 0]
-
-        set plist ""
-        foreach nid $nlist {
-            eval lappend plist [$_mesh get node($nid)]
-        }
-        lappend rlist $plist $regions($rid)
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: mesh
-#
-# Returns the vtk object representing the mesh.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::mesh { {type "vtk"} } {
-    switch $type {
-        "vtk" {
-            return ""
-        }
-        default {
-            error "Requested mesh type \"$type\" is unknown."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: dimensions
-#
-# Returns the number of dimensions for this object: 1, 2, or 3.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::dimensions {} {
-    return $_dim
-}
-
-# ----------------------------------------------------------------------
-# USAGE: limits x|y|z
-#
-# Returns the {min max} coords for the limits of the specified axis.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::limits {axis} {
-    if {![info exists _limits($axis)]} {
-        error "bad axis \"$which\": should be x, y, z"
-    }
-    return $_limits($axis)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this field.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::hints {{keyword ""}} {
-    if {$keyword != ""} {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
-        }
-        return ""
-    }
-    return [array get _hints]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitHints
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this mesh.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::InitHints {} {
-    foreach {key path} {
-        camera       camera.position
-        color        about.color
-        label        about.label
-        style        about.style
-        units        units
-    } {
-        set str [$_mesh get $path]
-        if {"" != $str} {
-            set _hints($key) $str
-        }
-    }
-    foreach {key path} {
-        toolid          tool.id
-        toolname        tool.name
-        toolcommand     tool.execute
-        tooltitle       tool.title
-        toolrevision    tool.version.application.revision
-    } {
-        set str [$_xmlobj get $path]
-        if { "" != $str } {
-            set _hints($key) $str
-        }
-    }
-}
-
-itcl::body Rappture::Mesh::GetDimension { path } {
-    set string [$_xmlobj get $path.dim]
-    if { $string == "" } {
-        puts stderr "WARNING: no tag <dim> found in mesh \"$path\"."
-        return 0
-    }
-    if { [scan $string "%d" _dim] == 1 } {
-        if { $_dim == 1 || $_dim == 2 || $_dim == 3 } {
-            return 1
-        }
-    }
-    puts stderr "WARNING: bad <dim> tag value \"$string\": should be 1, 2 or 3."
-    return 0
-}
-
-itcl::body Rappture::Mesh::GetDouble { path } {
-    set string [$_xmlobj get $path]
-    if { [scan $string "%g" value] != 1 } {
-        puts stderr "ERROR: can't get double value \"$string\" of \"$path\""
-        return 0.0
-    }
-    return $value
-}
-
-itcl::body Rappture::Mesh::GetInt { path } {
-    set string [$_xmlobj get $path]
-    if { [scan $string "%d" value] != 1 } {
-        puts stderr "ERROR: can't get integer value \"$string\" of \"$path\""
-        return 0.0
-    }
-    return $value
-}
-
-itcl::body Rappture::Mesh::ReadVtk { path } {
-    set _type "vtk"
-
-    if { ![GetDimension $path] } {
-        return 0
-    }
-    # Create a VTK file with the mesh in it.
-    set _vtkdata [$_xmlobj get $path.vtk]
-    append out "# vtk DataFile Version 3.0\n"
-    append out "mesh\n"
-    append out "ASCII\n"
-    append out "$_vtkdata\n"
-
-     # Write the contents to a file just in case it's binary.
-    set tmpfile file[pid].vtk
-    set f [open "$tmpfile" "w"]
-    fconfigure $f -translation binary -encoding binary
-    puts $f $out
-    close $f
-
-    # Read the data back into a vtk dataset and query the bounds.
-    set reader $this-datasetreader
-    vtkDataSetReader $reader
-    $reader SetFileName $tmpfile
-    $reader Update
-    set output [$reader GetOutput]
-    set _numPoints [$output GetNumberOfPoints]
-    set _numCells [$output GetNumberOfCells]
-    foreach { xmin xmax ymin ymax zmin zmax } [$output GetBounds] break
-    set _limits(x) [list $xmin $xmax]
-    set _limits(y) [list $ymin $ymax]
-    set _limits(z) [list $zmin $zmax]
-    file delete $tmpfile
-    rename $output ""
-    rename $reader ""
-    return 1
-}
-
-itcl::body Rappture::Mesh::ReadGrid { path } {
-    set _type "grid"
-
-    if { ![GetDimension $path] } {
-        return 0
-    }
-    set numUniform 0
-    set numRectilinear 0
-    set numCurvilinear 0
-    foreach axis { x y z } {
-        set min    [$_xmlobj get "$path.grid.${axis}axis.min"]
-        set max    [$_xmlobj get "$path.grid.${axis}axis.max"]
-        set num    [$_xmlobj get "$path.grid.${axis}axis.numpoints"]
-        set coords [$_xmlobj get "$path.grid.${axis}coords"]
-        set dim    [$_xmlobj get "$path.grid.${axis}dim"]
-        if { $min != "" && $max != "" && $num != "" && $num > 0 } {
-            set ${axis}Min $min
-            set ${axis}Max $max
-            set ${axis}Num $num
-            if {$min > $max} {
-                puts stderr "ERROR: grid $axis axis minimum larger than maximum"
-                return 0
-            }
-            incr numUniform
-        } elseif { $coords != "" } {
-            incr numRectilinear
-            set ${axis}Coords $coords
-        } elseif { $dim != "" } {
-            set ${axis}Num $dim
-            incr numCurvilinear
-        }
-    }
-    set _dim [expr $numRectilinear + $numUniform + $numCurvilinear]
-    if { $_dim == 0 } {
-        # No data found.
-        puts stderr "WARNING: bad grid \"$path\": no data found"
-        return 0
-    }
-    if { $numCurvilinear > 0 } {
-        # This is the 2D/3D curilinear case. We found <xdim>, <ydim>, or <zdim>
-        if { $numRectilinear > 0 || $numUniform > 0 } {
-            puts stderr "WARNING: bad grid \"$path\": can't mix curvilinear and rectilinear grids."
-            return 0
-        }
-        set points [$_xmlobj get $path.grid.points]
-        if { $points == "" } {
-            puts stderr "WARNING: bad grid \"$path\": no <points> found."
-            return 0
-        }
-        if { ![info exists xNum] } {
-            puts stderr "WARNING: bad grid \"$path\": invalid dimensions for curvilinear grid: missing <xdim> from grid description."
-            return 0
-        }
-        set all [blt::vector create \#auto]
-        set xv [blt::vector create \#auto]
-        set yv [blt::vector create \#auto]
-        set zv [blt::vector create \#auto]
-        $all set $points
-        set numCoords [$all length]
-        if { [info exists zNum] } {
-            if { ![info exists yNum] || ![info exists xNum] } {
-                puts stderr "WARNING: bad grid \"$path\": missing grid dimension"
-                blt::vector destroy $all $xv $yv $zv
-                return 0
-            }
-            set _dim 3
-            set _numPoints [expr $xNum * $yNum * $zNum]
-            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
-            if { ($_numPoints*3) != $numCoords } {
-                puts stderr "WARNING: bad grid \"$path\": invalid grid: \# of points does not match dimensions <xdim> * <ydim> * <zdim>"
-                blt::vector destroy $all $xv $yv $zv
-                return 0
-            }
-            if { ($numCoords % 3) != 0 } {
-                puts stderr "WARNING: bad grid \"$path\": wrong \# of coordinates for 3D grid"
-                blt::vector destroy $all $xv $yv $zv
-                return 0
-            }
-            $all split $xv $yv $zv
-            foreach axis {x y z} {
-                set vector [set ${axis}v]
-                set _limits($axis) [$vector limits]
-            }
-            append out "DATASET STRUCTURED_GRID\n"
-            append out "DIMENSIONS $xNum $yNum $zNum\n"
-            append out "POINTS $_numPoints double\n"
-            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-                append out "$x $y $z\n"
-            }
-            set _vtkdata $out
-        } elseif { [info exists yNum] } {
-            if { ![info exists xNum] } {
-                puts stderr "WARNING: bad grid \"$path\": missing grid dimension"
-                blt::vector destroy $all $xv $yv $zv
-                return 0
-            }
-            set _dim 2
-            set _numPoints [expr $xNum * $yNum]
-            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
-            if { ($_numPoints*2) != $numCoords } {
-                puts stderr "WARNING: bad grid \"$path\": \# of points does not match dimensions <xdim> * <ydim>"
-                blt::vector destroy $all $xv $yv $zv
-                return 0
-            }
-            if { ($numCoords % 2) != 0 } {
-                puts stderr "WARNING: bad grid \"$path\": wrong \# of coordinates for 2D grid"
-                blt::vector destroy $all $xv $yv $zv
-                return 0
-            }
-            $all split $xv $yv
-            foreach axis {x y} {
-                set vector [set ${axis}v]
-                set _limits($axis) [$vector limits]
-            }
-            set _limits(z) [list 0 0]
-            $zv seq 0 0 [$xv length]
-            $all merge $xv $yv $zv
-            append out "DATASET STRUCTURED_GRID\n"
-            append out "DIMENSIONS $xNum $yNum 1\n"
-            append out "POINTS $_numPoints double\n"
-            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-                append out "$x $y $z\n"
-            }
-            set _vtkdata $out
-        } else {
-            set _dim 1
-            set _numPoints $xNum
-            set _numCells [expr $xNum - 1]
-            if { $_numPoints != $numCoords } {
-                puts stderr "WARNING: bad grid \"$path\": \# of points does not match <xdim>"
-                blt::vector destroy $all $xv $yv $zv
-                return 0
-            }
-            $all dup $xv
-            set _limits(x) [$xv limits]
-            set _limits(y) [list 0 0]
-            set _limits(z) [list 0 0]
-            $yv seq 0 0 [$xv length]
-            $zv seq 0 0 [$xv length]
-            $all merge $xv $yv $zv
-            append out "DATASET STRUCTURED_GRID\n"
-            append out "DIMENSIONS $xNum 1 1\n"
-            append out "POINTS $_numPoints double\n"
-            foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-                append out "$x $y $z\n"
-            }
-            set _vtkdata $out
-        }
-        blt::vector destroy $all $xv $yv $zv
-        return 1
-    }
-    if { $numRectilinear == 0 && $numUniform > 0} {
-        # This is the special case where all axes 2D/3D are uniform.
-        # This results in a STRUCTURED_POINTS
-        if { $_dim == 1 } {
-            if {$xNum == 1} {
-                set xSpace 0
-            } else {
-                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
-            }
-            set _numPoints $xNum
-            set _numCells [expr $xNum - 1]
-            append out "DATASET STRUCTURED_POINTS\n"
-            append out "DIMENSIONS $xNum 1 1\n"
-            append out "ORIGIN $xMin 0 0\n"
-            append out "SPACING $xSpace 0 0\n"
-            set _vtkdata $out
-            set _limits(x) [list $xMin $xMax]
-            set _limits(y) [list 0 0]
-            set _limits(z) [list 0 0]
-        } elseif { $_dim == 2 } {
-            if {$xNum == 1} {
-                set xSpace 0
-            } else {
-                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
-            }
-            if {$yNum == 1} {
-                set ySpace 0
-            } else {
-                set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
-            }
-            set _numPoints [expr $xNum * $yNum]
-            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
-            append out "DATASET STRUCTURED_POINTS\n"
-            append out "DIMENSIONS $xNum $yNum 1\n"
-            append out "ORIGIN $xMin $yMin 0\n"
-            append out "SPACING $xSpace $ySpace 0\n"
-            set _vtkdata $out
-            foreach axis {x y} {
-                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
-            }
-            set _limits(z) [list 0 0]
-        } elseif { $_dim == 3 } {
-            if {$xNum == 1} {
-                set xSpace 0
-            } else {
-                set xSpace [expr ($xMax - $xMin) / double($xNum - 1)]
-            }
-            if {$yNum == 1} {
-                set ySpace 0
-            } else {
-                set ySpace [expr ($yMax - $yMin) / double($yNum - 1)]
-            }
-            if {$zNum == 1} {
-                set zSpace 0
-            } else {
-                set zSpace [expr ($zMax - $zMin) / double($zNum - 1)]
-            }
-            set _numPoints [expr $xNum * $yNum * $zNum]
-            set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
-            append out "DATASET STRUCTURED_POINTS\n"
-            append out "DIMENSIONS $xNum $yNum $zNum\n"
-            append out "ORIGIN $xMin $yMin $zMin\n"
-            append out "SPACING $xSpace $ySpace $zSpace\n"
-            set _vtkdata $out
-            foreach axis {x y z} {
-                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
-            }
-        } else {
-            puts stderr "WARNING: bad grid \"$path\": bad dimension \"$_dim\""
-            return 0
-        }
-        return 1
-    }
-    # This is the hybrid case.  Some axes are uniform, others are nonuniform.
-    set xv [blt::vector create \#auto]
-    if { [info exists xMin] } {
-        $xv seq $xMin $xMax $xNum
-    } else {
-        $xv set [$_xmlobj get $path.grid.xcoords]
-        set xMin [$xv min]
-        set xMax [$xv max]
-        set xNum [$xv length]
-    }
-    set yv [blt::vector create \#auto]
-    if { $_dim > 1 } {
-        if { [info exists yMin] } {
-            $yv seq $yMin $yMax $yNum
-        } else {
-            $yv set [$_xmlobj get $path.grid.ycoords]
-            set yMin [$yv min]
-            set yMax [$yv max]
-            set yNum [$yv length]
-        }
-    } else {
-        set yNum 1
-    }
-    set zv [blt::vector create \#auto]
-    if { $_dim == 3 } {
-        if { [info exists zMin] } {
-            $zv seq $zMin $zMax $zNum
-        }  else {
-            $zv set [$_xmlobj get $path.grid.zcoords]
-            set zMin [$zv min]
-            set zMax [$zv max]
-            set zNum [$zv length]
-        }
-    } else {
-        set zNum 1
-    }
-    if { $_dim == 3 } {
-        set _numPoints [expr $xNum * $yNum * $zNum]
-        set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1) * ($zNum > 1 ? ($zNum - 1) : 1)]
-        append out "DATASET RECTILINEAR_GRID\n"
-        append out "DIMENSIONS $xNum $yNum $zNum\n"
-        append out "X_COORDINATES $xNum double\n"
-        append out [$xv range 0 end]
-        append out "\n"
-        append out "Y_COORDINATES $yNum double\n"
-        append out [$yv range 0 end]
-        append out "\n"
-        append out "Z_COORDINATES $zNum double\n"
-        append out [$zv range 0 end]
-        append out "\n"
-        set _vtkdata $out
-        foreach axis {x y z} {
-            if { [info exists ${axis}Min] } {
-                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
-            }
-        }
-    } elseif { $_dim == 2 } {
-        set _numPoints [expr $xNum * $yNum]
-        set _numCells [expr ($xNum > 1 ? ($xNum - 1) : 1) * ($yNum > 1 ? ($yNum - 1) : 1)]
-        append out "DATASET RECTILINEAR_GRID\n"
-        append out "DIMENSIONS $xNum $yNum 1\n"
-        append out "X_COORDINATES $xNum double\n"
-        append out [$xv range 0 end]
-        append out "\n"
-        append out "Y_COORDINATES $yNum double\n"
-        append out [$yv range 0 end]
-        append out "\n"
-        append out "Z_COORDINATES 1 double\n"
-        append out "0\n"
-        foreach axis {x y} {
-            if { [info exists ${axis}Min] } {
-                set _limits($axis) [list [set ${axis}Min] [set ${axis}Max]]
-            }
-        }
-        set _limits(z) [list 0 0]
-        set _vtkdata $out
-    } elseif { $_dim == 1 } {
-        set _numPoints $xNum
-        set _numCells [expr $xNum - 1]
-        append out "DATASET RECTILINEAR_GRID\n"
-        append out "DIMENSIONS $xNum 1 1\n"
-        append out "X_COORDINATES $xNum double\n"
-        append out [$xv range 0 end]
-        append out "\n"
-        append out "Y_COORDINATES 1 double\n"
-        append out "0\n"
-        append out "Z_COORDINATES 1 double\n"
-        append out "0\n"
-        if { [info exists xMin] } {
-            set _limits(x) [list $xMin $xMax]
-        }
-        set _limits(y) [list 0 0]
-        set _limits(z) [list 0 0]
-        set _vtkdata $out
-    } else {
-        puts stderr "WARNING: bad grid \"$path\": invalid dimension \"$_dim\""
-        return 0
-    }
-    blt::vector destroy $xv $yv $zv
-    return 1
-}
-
-itcl::body Rappture::Mesh::WritePointCloud { path xv yv zv } {
-    set _type "cloud"
-    set _numPoints [$xv length]
-    append out "DATASET POLYDATA\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    set _vtkdata $out
-    set _limits(x) [$xv limits]
-    if { $_dim > 1 } {
-        set _limits(y) [$yv limits]
-    } else {
-        set _limits(y) [list 0 0]
-    }
-    if { $_dim == 3 } {
-        set _limits(z) [$zv limits]
-    } else {
-        set _limits(z) [list 0 0]
-    }
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteTriangles { path xv yv zv triangles } {
-    set _type "triangles"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set celltypes {}
-    foreach { a b c } $triangles {
-        append data "3 $a $b $c\n"
-        append celltypes "5\n"
-        incr _numCells
-    }
-    append out "DATASET UNSTRUCTURED_GRID\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    set count [expr $_numCells * 4]
-    append out "CELLS $_numCells $count\n"
-    append out $data
-    append out "CELL_TYPES $_numCells\n"
-    append out $celltypes
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    if { $_dim == 3 } {
-        set _limits(z) [$zv limits]
-    } else {
-        set _limits(z) [list 0 0]
-    }
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteQuads { path xv yv zv quads } {
-    set _type "quads"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set celltypes {}
-    foreach { a b c d } $quads {
-        append data "4 $a $b $c $d\n"
-        append celltypes "9\n"
-        incr _numCells
-    }
-    append out "DATASET UNSTRUCTURED_GRID\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    set count [expr $_numCells * 5]
-    append out "CELLS $_numCells $count\n"
-    append out $data
-    append out "CELL_TYPES $_numCells\n"
-    append out $celltypes
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    if { $_dim == 3 } {
-        set _limits(z) [$zv limits]
-    } else {
-        set _limits(z) [list 0 0]
-    }
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteVertices { path xv yv zv vertices } {
-    set _type "vertices"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set lines [split $vertices \n]
-    set count 0
-    foreach { line } $lines {
-        set numIndices [llength $line]
-        if { $numIndices == 0 } {
-            continue
-        }
-        append data "$numIndices $line\n"
-        incr _numCells
-        set count [expr $count + $numIndices + 1]
-    }
-    append out "DATASET POLYDATA\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    append out "VERTICES $_numCells $count\n"
-    append out $data
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    if { $_dim == 3 } {
-        set _limits(z) [$zv limits]
-    } else {
-        set _limits(z) [list 0 0]
-    }
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteLines { path xv yv zv polylines } {
-    set _type "lines"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set lines [split $polylines \n]
-    set count 0
-    foreach { line } $lines {
-        set numIndices [llength $line]
-        if { $numIndices == 0 } {
-            continue
-        }
-        append data "$numIndices $line\n"
-        incr _numCells
-        set count [expr $count + $numIndices + 1]
-    }
-    append out "DATASET POLYDATA\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    append out "LINES $_numCells $count\n"
-    append out $data
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    if { $_dim == 3 } {
-        set _limits(z) [$zv limits]
-    } else {
-        set _limits(z) [list 0 0]
-    }
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WritePolygons { path xv yv zv polygons } {
-    set _type "polygons"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set lines [split $polygons \n]
-    set count 0
-    foreach { line } $lines {
-        set numIndices [llength $line]
-        if { $numIndices == 0 } {
-            continue
-        }
-        append data "$numIndices $line\n"
-        incr _numCells
-        set count [expr $count + $numIndices + 1]
-    }
-    append out "DATASET POLYDATA\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    append out "POLYGONS $_numCells $count\n"
-    append out $data
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    if { $_dim == 3 } {
-        set _limits(z) [$zv limits]
-    } else {
-        set _limits(z) [list 0 0]
-    }
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteTriangleStrips { path xv yv zv trianglestrips } {
-    set _type "trianglestrips"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set lines [split $trianglestrips \n]
-    set count 0
-    foreach { line } $lines {
-        set numIndices [llength $line]
-        if { $numIndices == 0 } {
-            continue
-        }
-        append data "$numIndices $line\n"
-        incr _numCells
-        set count [expr $count + $numIndices + 1]
-    }
-    append out "DATASET POLYDATA\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    append out "TRIANGLE_STRIPS $_numCells $count\n"
-    append out $data
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    if { $_dim == 3 } {
-        set _limits(z) [$zv limits]
-    } else {
-        set _limits(z) [list 0 0]
-    }
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteTetrahedrons { path xv yv zv tetras } {
-    set _type "tetrahedrons"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set celltypes {}
-    foreach { a b c d } $tetras {
-        append data "4 $a $b $c $d\n"
-        append celltypes "10\n"
-        incr _numCells
-    }
-    append out "DATASET UNSTRUCTURED_GRID\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    set count [expr $_numCells * 5]
-    append out "CELLS $_numCells $count\n"
-    append out $data
-    append out "CELL_TYPES $_numCells\n"
-    append out $celltypes
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    set _limits(z) [$zv limits]
-
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteHexahedrons { path xv yv zv hexas } {
-    set _type "hexahedrons"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set celltypes {}
-    foreach { a b c d e f g h } $hexas {
-        append data "8 $a $b $c $d $e $f $g $h\n"
-        append celltypes "12\n"
-        incr _numCells
-    }
-    append out "DATASET UNSTRUCTURED_GRID\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    set count [expr $_numCells * 9]
-    append out "CELLS $_numCells $count\n"
-    append out $data
-    append out "CELL_TYPES $_numCells\n"
-    append out $celltypes
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    set _limits(z) [$zv limits]
-
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteWedges { path xv yv zv wedges } {
-    set _type "wedges"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set celltypes {}
-    foreach { a b c d e f } $wedges {
-        append data "6 $a $b $c $d $e $f\n"
-        append celltypes "13\n"
-        incr _numCells
-    }
-    append out "DATASET UNSTRUCTURED_GRID\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    set count [expr $_numCells * 7]
-    append out "CELLS $_numCells $count\n"
-    append out $data
-    append out "CELL_TYPES $_numCells\n"
-    append out $celltypes
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    set _limits(z) [$zv limits]
-
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WritePyramids { path xv yv zv pyramids } {
-    set _type "pyramids"
-    set _numPoints [$xv length]
-    set _numCells 0
-    set data {}
-    set celltypes {}
-    foreach { a b c d e } $pyramids {
-        append data "5 $a $b $c $d $e\n"
-        append celltypes "14\n"
-        incr _numCells
-    }
-    append out "DATASET UNSTRUCTURED_GRID\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    set count [expr $_numCells * 6]
-    append out "CELLS $_numCells $count\n"
-    append out $data
-    append out "CELL_TYPES $_numCells\n"
-    append out $celltypes
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    set _limits(z) [$zv limits]
-
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::WriteHybridCells { path xv yv zv cells celltypes } {
-    set _type "unstructured"
-    set lines [split $cells \n]
-    set numCellTypes [llength $celltypes]
-    if { $numCellTypes == 1 } {
-        set celltype [GetCellType $celltypes]
-    }
-
-    set _numPoints [$xv length]
-    set data {}
-    set count 0
-    set _numCells 0
-    set celltypesout {}
-    foreach line $lines {
-        set length [llength $line]
-        if { $length == 0 } {
-            continue
-        }
-        if { $numCellTypes > 1 } {
-            set celltype [GetCellType [lindex $celltypes $_numCells]]
-        }
-        set numIndices [GetNumIndices $celltype]
-        if { $numIndices > 0 && $numIndices != $length } {
-            puts stderr "WARNING: bad unstructured grid \"$path\": wrong \# of indices specified for celltype $celltype on line \"$line\""
-            return 0
-        } else {
-            set numIndices $length
-        }
-        append data "$numIndices $line\n"
-        append celltypesout "$celltype\n"
-        incr count $length;         # Include the indices
-        incr count;                 # and the number of indices
-        incr _numCells
-    }
-    append out "DATASET UNSTRUCTURED_GRID\n"
-    append out "POINTS $_numPoints double\n"
-    foreach x [$xv range 0 end] y [$yv range 0 end] z [$zv range 0 end] {
-        append out "$x $y $z\n"
-    }
-    append out "CELLS $_numCells $count\n"
-    append out $data
-    append out "CELL_TYPES $_numCells\n"
-    append out $celltypesout
-    set _limits(x) [$xv limits]
-    set _limits(y) [$yv limits]
-    if { $_dim < 3 } {
-        set _limits(z) [list 0 0]
-    } else {
-        set _limits(z) [$zv limits]
-    }
-
-    set _vtkdata $out
-    return 1
-}
-
-itcl::body Rappture::Mesh::ReadUnstructuredGrid { path } {
-    set _type "unstructured"
-
-    if { ![GetDimension $path] } {
-        return 0
-    }
-    # Step 1: Verify that there's only one cell tag of any kind.
-    set numCells 0
-    foreach type {
-        cells
-        hexahedrons
-        lines
-        polygons
-        pyramids
-        quads
-        tetrahedrons
-        triangles
-        trianglestrips
-        vertices
-        wedges
-    } {
-        set data [$_xmlobj get $path.unstructured.$type]
-        if { $data != "" } {
-            incr numCells
-        }
-    }
-    # The generic <cells> tag requires there be a <celltypes> tag too.
-    set celltypes [$_xmlobj get $path.unstructured.celltypes]
-    if { $numCells == 0 && $celltypes != "" } {
-        puts stderr "WARNING: bad unstuctured grid \"$path\": no <cells> description found."
-        return 0
-    }
-    if { $numCells > 1 } {
-        puts stderr "WARNING: bad unstructured grid \"$path\": too many <cells>, <triangles>, <quads>... descriptions found: should be only one."
-        return 0
-    }
-    foreach type {
-        cells
-        hexahedrons
-        lines
-        polygons
-        pyramids
-        quads
-        tetrahedrons
-        triangles
-        trianglestrips
-        vertices
-        wedges
-    } {
-        set data [$_xmlobj get $path.unstructured.$type]
-        if { $data != "" } {
-            break
-        }
-    }
-    # Step 2: Allow points to be specified as <points> or
-    #         <xcoords>, <ycoords>, <zcoords>.  Split and convert into
-    #         3 vectors, one for each coordinate.
-    if { $_dim == 1 } {
-        set xcoords [$_xmlobj get $path.unstructured.xcoords]
-        set ycoords [$_xmlobj get $path.unstructured.ycoords]
-        set zcoords [$_xmlobj get $path.unstructured.zcoords]
-        set data    [$_xmlobj get $path.unstructured.points]
-        if { $ycoords != "" } {
-            put stderr "can't specify <ycoords> with a 1D mesh"
-            return 0
-        }
-        if { $zcoords != "" } {
-            put stderr "can't specify <zcoords> with a 1D mesh"
-            return 0
-        }
-        if { $xcoords != "" } {
-            set xv [blt::vector create \#auto]
-            $xv set $xcoords
-        } elseif { $data != "" } {
-            Rappture::ReadPoints $data dim points
-            if { $points == "" } {
-                puts stderr "WARNING: bad unstructured grid \"$path\": no <points> found."
-                return 0
-            }
-            if { $dim != 1 } {
-                puts stderr "WARNING: bad unstructured grid \"$path\": \# of coordinates per point is \"$dim\": does not agree with dimension specified for mesh \"$_dim\""
-                return 0
-            }
-            set xv [blt::vector create \#auto]
-            $xv set $points
-        } else {
-            puts stderr "WARNING: bad unstructured grid \"$path\": no points specified."
-            return 0
-        }
-        set yv [blt::vector create \#auto]
-        set zv [blt::vector create \#auto]
-        $yv seq 0 0 [$xv length];       # Make an all zeroes vector.
-        $zv seq 0 0 [$xv length];       # Make an all zeroes vector.
-    } elseif { $_dim == 2 } {
-        set xcoords [$_xmlobj get $path.unstructured.xcoords]
-        set ycoords [$_xmlobj get $path.unstructured.ycoords]
-        set zcoords [$_xmlobj get $path.unstructured.zcoords]
-        set data    [$_xmlobj get $path.unstructured.points]
-        if { $zcoords != "" } {
-            put stderr "can't specify <zcoords> with a 2D mesh"
-            return 0
-        }
-        if { $xcoords != "" && $ycoords != "" } {
-            set xv [blt::vector create \#auto]
-            set yv [blt::vector create \#auto]
-            $xv set $xcoords
-            $yv set $ycoords
-        } elseif { $data != "" } {
-            Rappture::ReadPoints $data dim points
-            if { $points == "" } {
-                puts stderr "WARNING: bad unstructured grid \"$path\": no <points> found."
-                return 0
-            }
-            if { $dim != 2 } {
-                puts stderr "WARNING: bad unstructured grid \"$path\": \# of coordinates per point is \"$dim\": does not agree with dimension specified for mesh \"$_dim\""
-                return 0
-            }
-            set all [blt::vector create \#auto]
-            set xv [blt::vector create \#auto]
-            set yv [blt::vector create \#auto]
-            $all set $points
-            $all split $xv $yv
-            blt::vector destroy $all
-        } else {
-            puts stderr "WARNING: bad unstructured grid \"$path\": no points specified."
-            return 0
-        }
-        set zv [blt::vector create \#auto]
-        $zv seq 0 0 [$xv length];       # Make an all zeroes vector.
-    } elseif { $_dim == 3 } {
-        set xcoords [$_xmlobj get $path.unstructured.xcoords]
-        set ycoords [$_xmlobj get $path.unstructured.ycoords]
-        set zcoords [$_xmlobj get $path.unstructured.zcoords]
-        set data    [$_xmlobj get $path.unstructured.points]
-        if { $xcoords != "" && $ycoords != "" && $zcoords != "" } {
-            set xv [blt::vector create \#auto]
-            set yv [blt::vector create \#auto]
-            set zv [blt::vector create \#auto]
-            $xv set $xcoords
-            $yv set $ycoords
-            $zv set $zcoords
-        } elseif { $data != "" }  {
-            Rappture::ReadPoints $data dim points
-            if { $points == "" } {
-                puts stderr "WARNING: bad unstructured grid \"$path\": no <points> found."
-                return 0
-            }
-            if { $dim != 3 } {
-                puts stderr "WARNING: bad unstructured grid \"$path\": \# of coordinates per point is \"$dim\": does not agree with dimension specified for mesh \"$_dim\""
-                return 0
-            }
-            set all [blt::vector create \#auto]
-            set xv [blt::vector create \#auto]
-            set yv [blt::vector create \#auto]
-            set zv [blt::vector create \#auto]
-            $all set $points
-            $all split $xv $yv $zv
-            blt::vector destroy $all
-        } else {
-            puts stderr "WARNING: bad unstructured grid \"$path\": no points specified."
-            return 0
-        }
-    }
-    set _numPoints [$xv length]
-
-    # Step 3: Write the points and cells as vtk data.
-    if { $numCells == 0 } {
-        set result [WritePointCloud $path $xv $yv $zv]
-    } elseif { $type == "cells" } {
-        set cells [$_xmlobj get $path.unstructured.cells]
-        if { $cells == "" } {
-            puts stderr "WARNING: bad unstructured grid \"$path\": no cells found."
-            return 0
-        }
-        set result [WriteHybridCells $path $xv $yv $zv $cells $celltypes]
-    } else {
-        set cmd "Write[string totitle $type]"
-        set cells [$_xmlobj get $path.unstructured.$type]
-        if { $cells == "" } {
-            puts stderr "WARNING: bad unstructured grid \"$path\": no cells found."
-            return 0
-        }
-        set result [$cmd $path $xv $yv $zv $cells]
-    }
-    # Clean up.
-    blt::vector destroy $xv $yv $zv
-    return $result
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReadNodesElements <path>
-#
-# Used internally to build a mesh representation based on nodes and
-# elements stored in the XML.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Mesh::ReadNodesElements {path} {
-    set _type "nodeselements"
-    set count 0
-
-    # Scan for nodes.  Each node represents a vertex.
-    set data {}
-    foreach cname [$_xmlobj children -type node $path] {
-        append data "[$_xmlobj get $path.$cname]\n"
-    }
-    Rappture::ReadPoints $data _dim points
-    if { $_dim == 2 } {
-        set all [blt::vector create \#auto]
-        set xv [blt::vector create \#auto]
-        set yv [blt::vector create \#auto]
-        set zv [blt::vector create \#auto]
-        $all set $points
-        $all split $xv $yv
-        set _numPoints [$xv length]
-        set _limits(x) [$xv limits]
-        set _limits(y) [$yv limits]
-        set _limits(z) [list 0 0]
-        # 2D Dataset. All Z coordinates are 0
-        $zv seq 0.0 0.0 $_numPoints
-        $all merge $xv $yv $zv
-        set points [$all range 0 end]
-        blt::vector destroy $all $xv $yv $zv
-    } elseif { $_dim == 3 } {
-        set all [blt::vector create \#auto]
-        set xv [blt::vector create \#auto]
-        set yv [blt::vector create \#auto]
-        set zv [blt::vector create \#auto]
-        $all set $points
-        $all split $xv $yv $zv
-        set _numPoints [$xv length]
-        set _limits(x) [$xv limits]
-        set _limits(y) [$yv limits]
-        set _limits(z) [$zv limits]
-        set points [$all range 0 end]
-        blt::vector destroy $all $xv $yv $zv
-    } else {
-        error "bad dimension \"$_dim\" for nodes mesh"
-    }
-    array set node2celltype {
-        3 5
-        4 9
-        8 12
-        6 13
-        5 14
-    }
-    set count 0
-    set _numCells 0
-    set celltypes {}
-    set data {}
-    # Next scan for elements.  Each element represents a cell.
-    foreach cname [$_xmlobj children -type element $path] {
-        set nodeList [$_mesh get $cname.nodes]
-        set numNodes [llength $nodeList]
-        if { ![info exists node2celltype($numNodes)] } {
-            puts stderr "WARNING: bad node/element mesh \$path\": unknown number of nodes \"$numNodes\": should be 3, 4, 5, 6, or 8"
-            return 0
-        }
-        set celltype $node2celltype($numNodes)
-        if { $_dim == 3 && $numNodes == 4 } {
-            # If mesh is 3D, assume a tetrahedron (default is quad)
-            # XXX: Does prophet output tets, and if so what is the node order?
-            set celltype 10
-        }
-        append celltypes "$celltype\n"
-        if { $celltype == 9 } {
-            # Fix the node order for quad cells
-            # (this converts from PROPHET convention to VTK convention)
-            set newList {}
-            foreach i { 0 1 3 2 } {
-                lappend newList [lindex $nodeList $i]
-            }
-            set nodeList $newList
-        } elseif { $celltype == 12 } {
-            # Fix the node order for hexahedron cells
-            # (this converts from PROPHET convention to VTK convention)
-            set newList {}
-            foreach i { 0 1 3 2 4 5 7 6 } {
-                lappend newList [lindex $nodeList $i]
-            }
-            set nodeList $newList
-        }
-        append data "$numNodes $nodeList\n"
-        incr _numCells
-        incr count $numNodes
-        incr count;                        # One extra for the VTK celltype id.
-    }
-
-    append out "DATASET UNSTRUCTURED_GRID\n"
-    append out "POINTS $_numPoints double\n"
-    append out $points
-    append out "\n"
-    append out "CELLS $_numCells $count\n"
-    append out $data
-    append out "CELL_TYPES $_numCells\n"
-    append out $celltypes
-    set _vtkdata $out
-    set _isValid 1
-}
-
-itcl::body Rappture::Mesh::GetCellType { name } {
-    array set name2type {
-        "vertex"          1
-        "polyvertex"      2
-        "line"            3
-        "polyline"        4
-        "triangle"        5
-        "trianglestrip"   6
-        "polygon"         7
-        "pixel"           8
-        "quad"            9
-        "tetrahedron"     10
-        "voxel"           11
-        "hexahedron"      12
-        "wedge"           13
-        "pyramid"         14
-        "pentagonalprism" 15
-        "hexagonalprism"  16
-    }
-    if { [info exists name2type($name)] } {
-        return $name2type($name)
-    }
-    if { [string is int $name] == 1 && $name >= 1 && $name <= 16 } {
-        return $name
-    }
-    error "invalid celltype \"$name\""
-}
-
-itcl::body Rappture::Mesh::GetNumIndices { type } {
-    array set type2indices {
-        1       1
-        2       0
-        3       2
-        4       0
-        5       3
-        6       0
-        7       0
-        8       4
-        9       4
-        10      4
-        11      8
-        12      8
-        13      6
-        14      5
-        15      10
-        16      12
-    }
-    if { [info exists type2indices($type)] } {
-        return $type2indices($type)
-    }
-    error "invalid celltype \"$type\""
-}
Index: trunk/gui/scripts/meshresult.tcl
===================================================================
--- trunk/gui/scripts/meshresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,514 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: meshresult - mesh plot in a ResultSet
-#
-#  This widget is a mesh plot, meant to view grid structures produced
-#  as output from the run of a Rappture tool.  Use the "add" and
-#  "delete" methods to control the meshes showing on the plot.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *MeshResult.width 4i widgetDefault
-option add *MeshResult.height 4i widgetDefault
-option add *MeshResult.gridColor #d9d9d9 widgetDefault
-option add *MeshResult.regionColors {green yellow orange red magenta} widgetDefault
-option add *MeshResult.controlBackground gray widgetDefault
-option add *MeshResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::MeshResult {
-    inherit itk::Widget
-
-    itk_option define -gridcolor gridColor GridColor ""
-    itk_option define -regioncolors regionColors RegionColors ""
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} { # do nothing }
-    public method download {option args}
-
-    protected method _rebuild {}
-    protected method _fixLimits {}
-    protected method _zoom {option args}
-    protected method _hilite {state x y}
-
-    private variable _dlist ""     ;# list of dataobj objects
-    private variable _dobj2color   ;# maps dataobj => plotting color
-    private variable _dobj2width   ;# maps dataobj => line width
-    private variable _dobj2dashes  ;# maps dataobj => BLT -dashes list
-    private variable _dobj2raise   ;# maps dataobj => raise flag 0/1
-    private variable _mrkr2tip     ;# maps graph element => tooltip
-    private variable _xmin ""      ;# autoscale min for x-axis
-    private variable _xmax ""      ;# autoscale max for x-axis
-    private variable _ymin ""      ;# autoscale min for y-axis
-    private variable _ymax ""      ;# autoscale max for y-axis
-}
-
-itk::usual MeshResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::constructor {args} {
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add controls {
-        frame $itk_interior.cntls
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    pack $itk_component(controls) -side right -fill y
-
-    itk_component add reset {
-        button $itk_component(controls).reset \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -bitmap [Rappture::icon reset] \
-            -command [itcl::code $this _zoom reset]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground Background
-    }
-    pack $itk_component(reset) -padx 4 -pady 4
-    Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level"
-
-    itk_component add plot {
-        blt::graph $itk_interior.plot \
-            -highlightthickness 0 -plotpadx 0 -plotpady 0 \
-            -rightmargin 10 -invertxy 1
-    } {
-        keep -background -foreground -cursor -font
-    }
-    pack $itk_component(plot) -expand yes -fill both
-
-    # special pen for highlighting active traces
-    $itk_component(plot) marker bind all <Enter> \
-        [itcl::code $this _hilite on %x %y]
-    $itk_component(plot) marker bind all <Leave> \
-        [itcl::code $this _hilite off %x %y]
-
-    bind $itk_component(plot) <Leave> \
-        [list Rappture::Tooltip::tooltip cancel]
-
-    Blt_ZoomStack $itk_component(plot)
-    $itk_component(plot) legend configure -hide yes
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a dataobj to the plot.  The optional <settings>
-# are used to configure the plot.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-
-    # convert -linestyle to BLT -dashes
-    switch -- $params(-linestyle) {
-        dashed { set params(-linestyle) {4 4} }
-        dotted { set params(-linestyle) {2 4} }
-        default { set params(-linestyle) {} }
-    }
-
-    # if -brightness is set, then update the color
-    if {$params(-brightness) != 0} {
-        set params(-color) [Rappture::color::brightness \
-            $params(-color) $params(-brightness)]
-    }
-
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-        set _dobj2color($dataobj) $params(-color)
-        set _dobj2width($dataobj) $params(-width)
-        set _dobj2dashes($dataobj) $params(-linestyle)
-        #set _dobj2raise($dataobj) $params(-raise)
-        set _dobj2raise($dataobj) 0
-
-        after cancel [itcl::code $this _rebuild]
-        after idle [itcl::code $this _rebuild]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-    foreach obj $dlist {
-        if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} {
-            set i [lsearch -exact $dlist $obj]
-            if {$i >= 0} {
-                set dlist [lreplace $dlist $i $i]
-                lappend dlist $obj
-            }
-        }
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj> <dataobj> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            catch {unset _dobj2color($dataobj)}
-            catch {unset _dobj2width($dataobj)}
-            catch {unset _dobj2dashes($dataobj)}
-            catch {unset _dobj2raise($dataobj)}
-            set changed 1
-        }
-    }
-
-    # if anything changed, then rebuild the plot
-    if {$changed} {
-        after cancel [itcl::code $this _rebuild]
-        after idle [itcl::code $this _rebuild]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all dataobjs--even those not showing on the screen.
-# Because of this, the limits are appropriate for all dataobjs as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::scale {args} {
-    set _xmin ""
-    set _xmax ""
-    set _ymin ""
-    set _ymax ""
-    foreach obj $args {
-        foreach axis {x y} {
-            foreach {min max} [$obj limits $axis] break
-            if {"" != $min && "" != $max} {
-                if {"" == [set _${axis}min]} {
-                    set _${axis}min $min
-                    set _${axis}max $max
-                } else {
-                    if {$min < [set _${axis}min]} {
-                        set _${axis}min $min
-                    }
-                    if {$max > [set _${axis}max]} {
-                        set _${axis}max $max
-                    }
-                }
-            }
-        }
-    }
-    _fixLimits
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            # no controls for this download yet
-            return ""
-        }
-        now {
-            set psdata [$itk_component(plot) postscript output -maxpect 1]
-
-            set cmds {
-                set fout "mesh[pid].pdf"
-                exec ps2pdf - $fout << $psdata
-
-                set fid [open $fout r]
-                fconfigure $fid -translation binary -encoding binary
-                set pdfdata [read $fid]
-                close $fid
-
-                file delete -force $fout
-            }
-            if {[catch $cmds result] == 0} {
-                return [list .pdf $pdfdata]
-            }
-            return [list .ps $psdata]
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::_rebuild {} {
-    set g $itk_component(plot)
-    blt::busy hold [winfo toplevel $g]
-
-    # first clear out the widget
-    eval $g marker delete [$g marker names]
-    $g axis configure x -min "" -max "" -loose yes -checklimits no \
-        -descending yes
-    $g axis configure y -min "" -max "" -loose yes -checklimits no
-
-    # extract axis information from the first dataobj
-    set dlist [get]
-    set xydata [lindex $dlist 0]
-    if {$xydata != ""} {
-        set legend [$xydata hints legend]
-        if {"" != $legend} {
-            if {$legend == "off"} {
-                $g legend configure -hide yes
-            } else {
-                $g legend configure -hide no \
-                    -position plotarea -anchor $legend -borderwidth 0
-            }
-        }
-
-        set xlabel [$xydata hints xlabel]
-        if {"" != $xlabel} {
-            $g xaxis configure -title $xlabel
-        }
-
-        set ylabel [$xydata hints ylabel]
-        if {"" != $ylabel} {
-            $g yaxis configure -title $ylabel
-        }
-    }
-
-    set multiple [expr {[llength $dlist] > 1}]
-    catch {unset _mrkr2tip}
-
-    # plot all of the dataobjs
-    set count 0
-    foreach xydata $dlist {
-        if {$multiple} {
-            if {[info exists _dobj2color($xydata)]} {
-                set color $_dobj2color($xydata)
-            } else {
-                set color [$xydata hints color]
-                if {"" == $color} {
-                    set color black
-                }
-            }
-
-            if {[info exists _dobj2width($xydata)]} {
-                set lwidth $_dobj2width($xydata)
-            } else {
-                set lwidth 2
-            }
-        } else {
-            set color black
-            set lwidth 1
-        }
-
-        if {[info exists _dobj2dashes($xydata)]} {
-            set dashes $_dobj2dashes($xydata)
-        } else {
-            set dashes ""
-        }
-
-        foreach {plist r} [$xydata elements] {
-            if {$count == 0} {
-                if {$r == "unknown"} {
-                    set fill gray
-                } elseif {![info exists colors($r)]} {
-                    set i [array size colors]
-                    set fill [lindex $itk_option(-regioncolors) $i]
-                    set colors($r) $fill
-                } else {
-                    set fill $colors($r)
-                }
-                set mrkr [$g marker create polygon -coords $plist -fill $fill]
-                set _mrkr2tip($mrkr) $r
-            }
-            set mrkr [$g marker create line -coords $plist \
-                -linewidth $lwidth -outline $color -dashes $dashes]
-            set _mrkr2tip($mrkr) $r
-        }
-        incr count
-    }
-
-    _fixLimits
-    blt::busy release [winfo toplevel $g]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixLimits
-#
-# Used internally to apply automatic limits to the axes for the
-# current plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::_fixLimits {} {
-    set g $itk_component(plot)
-
-    #
-    # HACK ALERT!
-    # Use this code to fix up the y-axis limits for the BLT graph.
-    # The auto-limits don't always work well.  We want them to be
-    # set to a "nice" number slightly above or below the min/max
-    # limits.
-    #
-    if {$_xmin != $_xmax} {
-        $g axis configure x -min $_xmin -max $_xmax
-    } else {
-        $g axis configure x -min "" -max ""
-    }
-
-    if {"" != $_ymin && "" != $_ymax} {
-        set min $_ymin
-        set max $_ymax
-        set log [$g axis cget y -logscale]
-        if {$log} {
-            if {$min == $max} {
-                set min [expr {0.9*$min}]
-                set max [expr {1.1*$max}]
-            }
-            set min [expr {pow(10.0,floor(log10($min)))}]
-            set max [expr {pow(10.0,ceil(log10($max)))}]
-        } else {
-            if {$min > 0} {
-                set min [expr {0.95*$min}]
-            } else {
-                set min [expr {1.05*$min}]
-            }
-            if {$max > 0} {
-                set max [expr {1.05*$max}]
-            } else {
-                set max [expr {0.95*$max}]
-            }
-        }
-        if {$min != $max} {
-            $g axis configure y -min $min -max $max
-        } else {
-            $g axis configure y -min "" -max ""
-        }
-    } else {
-        $g axis configure y -min "" -max ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::_zoom {option args} {
-    switch -- $option {
-        reset {
-            _fixLimits
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _hilite <state> <x> <y>
-#
-# Called automatically when the user brushes one of the elements
-# on the plot.  Causes the element to highlight and a tooltip to
-# pop up with element info.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MeshResult::_hilite {state x y} {
-    set mrkr [$itk_component(plot) marker get current]
-    if {$state} {
-        #
-        # Highlight ON:
-        # - pop up tooltip about data
-        #
-        set tip ""
-        if {[info exists _mrkr2tip($mrkr)]} {
-            set tip $_mrkr2tip($mrkr)
-        }
-        if {"" != $tip} {
-            set x [expr {$x+4}]  ;# move the tooltip over a bit
-            set y [expr {$y+4}]
-            Rappture::Tooltip::text $itk_component(plot) $tip
-            Rappture::Tooltip::tooltip show $itk_component(plot) +$x,$y
-        }
-    } else {
-        #
-        # Highlight OFF:
-        # - take down tooltip
-        #
-        Rappture::Tooltip::tooltip cancel
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -gridcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::MeshResult::gridcolor {
-    if {"" == $itk_option(-gridcolor)} {
-        $itk_component(plot) grid off
-    } else {
-        $itk_component(plot) grid configure -color $itk_option(-gridcolor)
-        $itk_component(plot) grid on
-    }
-}
Index: trunk/gui/scripts/molvisviewer.tcl
===================================================================
--- trunk/gui/scripts/molvisviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,2180 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: molvisviewer - view a molecule in 3D
-#
-#  This widget brings up a 3D representation of a molecule
-#  It connects to the Molvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2015  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-package require Img
-
-option add *MolvisViewer.width 4i widgetDefault
-option add *MolvisViewer.height 4i widgetDefault
-option add *MolvisViewer.foreground black widgetDefault
-option add *MolvisViewer.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc MolvisViewer_init_resources {} {
-    Rappture::resources::register \
-        molvis_server Rappture::MolvisViewer::SetServerList
-}
-
-itcl::class Rappture::MolvisViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -device device Device ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "pymol" $namelist
-    }
-    public method Connect {}
-    public method Disconnect {}
-    public method ResetView {}
-    public method add {dataobj {options ""}}
-    public method delete {args}
-    public method download {option args}
-    public method get {}
-    public method isconnected {}
-    public method labels {option {model "all"}}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method snap { w h }
-
-    protected method Map {}
-    protected method Pan {option x y}
-    protected method Rebuild {}
-    protected method Rotate {option x y}
-    protected method Rotate.old {option x y}
-    protected method SendCmd { string }
-    protected method Unmap {}
-    protected method Vmouse {option b m x y}
-    protected method Zoom {option {factor 10}}
-
-    private method AddImageControls { frame widget }
-    private method BuildSettingsTab {}
-    private method CartoonTrace {option {model "all"}}
-    private method Cell {option}
-    private method ComputeParallelepipedVertices { dataobj }
-    private method DoResize {}
-    private method DoRotate {}
-    private method DoUpdate {}
-    private method EventuallyChangeSettings { args }
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { a b c }
-    private method GetImage { widget }
-    private method Opacity {option}
-    private method OrthoProjection {option}
-    private method ReceiveImage { size cacheid frame rock }
-    private method Representation { {option ""} }
-    private method Rock {option}
-    private method SetWaitVariable { value } {
-        set _getimage $value
-    }
-    private method SphereScale {option {models "all"} }
-    private method StickRadius {option {models "all"} }
-    private method UpdateState { args }
-    private method WaitForResponse {} {
-        tkwait variable [itcl::scope _getimage]
-        return $_getimage
-    }
-    private method WaitIcon { option widget }
-
-    private variable _icon 0
-    private variable _getimage 0
-    private variable _mevent;           # info used for mouse event operations
-    private variable _rocker;           # info used for rock operations
-    private variable _dlist "";         # list of dataobj objects
-    private variable _dataobjs;         # data objects on server
-    private variable _dobj2transparency;# maps dataobj => transparency
-    private variable _dobj2raise;       # maps dataobj => raise flag 0/1
-
-    private variable _active;           # array of active models.
-    private variable _obj2models;       # array containing list of models
-                                        # for each data object.
-    private variable _view
-    private variable _click
-
-    private variable _model
-    private variable _mlist
-    private variable _mrep "ballnstick"
-
-    private variable _imagecache
-    private variable _state
-    private variable _labels "default"
-    private variable _cacheid ""
-    private variable _cacheimage ""
-    private variable _first ""
-
-    private variable _initialized
-
-    private variable _pdbdata;          # PDB data from run file sent to pymol
-    private variable _nextToken 0
-    private variable _resizePending 0;
-    private variable _updatePending 0;
-    private variable _rotatePending 0;
-    private variable _width
-    private variable _height
-    private variable _reset 1;          # Restore camera settings
-    private variable _cell 0;           # Is there a parallelepiped unit cell?
-
-    private common _settings;           # Array of settings for all known
-                                        # widgets
-    private common _downloadPopup;      # Download options from popup
-    private common _hardcopy
-    private common _useVmouseEvents 0;  # Flag to enable virtual mouse events
-}
-
-itk::usual MolvisViewer {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::constructor {args} {
-    set _serverType "pymol"
-
-    #DebugOn
-
-    # Register events to the dispatcher.  Base class expects !rebuild
-    # event to be registered.
-
-    # Rebuild
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Update state event
-    $_dispatcher register !update
-    $_dispatcher dispatch $this !update "[itcl::code $this DoUpdate]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    # Rocker
-    $_dispatcher register !rocker
-    $_dispatcher dispatch $this !rocker "[itcl::code $this Rock step]; list"
-
-    # Mouse Event
-    $_dispatcher register !mevent
-    $_dispatcher dispatch $this !mevent "[itcl::code $this _mevent]; list"
-
-    $_dispatcher register !pngtimeout
-    $_dispatcher register !waiticon
-
-    array set _downloadPopup {
-        format draft
-    }
-
-    # Populate the slave interpreter with commands to handle responses from
-    # the visualization server.
-    $_parser alias image [itcl::code $this ReceiveImage]
-
-    set _rocker(dir) 1
-    set _rocker(client) 0
-    set _rocker(server) 0
-    set _rocker(on) 0
-    set _state(server) 1
-    set _state(client) 1
-    set _reset 1
-
-    array set _view {
-        theta   45
-        phi     45
-        psi     0
-        vx      0
-        vy      0
-        vz      0
-        mx      0
-        my      0
-        mz      0
-        xpan    0
-        ypan    0
-        zoom    0
-    }
-
-    # Setup default settings for widget.
-    array set _settings [subst {
-        $this-spherescale 0.25
-        $this-stickradius 0.14
-        $this-cartoontrace no
-        $this-model     ballnstick
-        $this-modelimg  [Rappture::icon ballnstick]
-        $this-opacity   1.0
-        $this-ortho     no
-        $this-rock      no
-        $this-showlabels no
-        $this-showcell  yes
-        $this-showlabels-initialized no
-    }]
-
-    itk_component add view {
-        label $itk_component(plotarea).view -image $_image(plot) \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth  -background
-    }
-    bind $itk_component(view) <Control-F1> [itcl::code $this ToggleConsole]
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this ResetView]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -padx 1 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add labels {
-        Rappture::PushButton $f.labels \
-            -onimage [Rappture::icon molvis-labels-view] \
-            -offimage [Rappture::icon molvis-labels-view] \
-            -command [itcl::code $this labels update] \
-            -variable [itcl::scope _settings($this-showlabels)]
-    }
-    $itk_component(labels) deselect
-    Rappture::Tooltip::for $itk_component(labels) \
-        "Show/hide the labels on atoms"
-    pack $itk_component(labels) -padx 2 -pady {6 2}
-
-    itk_component add rock {
-        Rappture::PushButton $f.rock \
-            -onimage [Rappture::icon molvis-rock-view] \
-            -offimage [Rappture::icon molvis-rock-view] \
-            -command [itcl::code $this Rock toggle] \
-            -variable [itcl::scope _settings($this-rock)]
-    }
-    pack $itk_component(rock) -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(rock) "Rock model back and forth"
-
-    itk_component add ortho {
-        label $f.ortho -borderwidth 1 -padx 1 -pady 1 \
-            -relief "raised" -image [Rappture::icon molvis-3dpers]
-    }
-    pack $itk_component(ortho) -padx 2 -pady 2 -ipadx 1 -ipady 1
-    Rappture::Tooltip::for $itk_component(ortho) \
-        "Use orthoscopic projection"
-
-    bind $itk_component(ortho) <ButtonPress> \
-        [itcl::code $this OrthoProjection toggle]
-
-    BuildSettingsTab
-
-    # HACK ALERT. Initially force a requested width of the view label.
-
-    # It's a chicken-and-the-egg problem.  The size of the view label is set
-    # from the size of the image retrieved from the server.  But the size of
-    # the image is specified by the viewport which is the size of the label.
-    # The fly-in-the-ointment is that it takes a non-trival amount of time to
-    # get the first image back from the server.  In the meantime the idletasks
-    # have already kicked in.  We end up with a 1x1 viewport and image.
-
-    # So the idea is to force a ridiculously big requested width on the label
-    # (that's why we're using the blt::table to manage the geometry).  It has
-    # to be big, because we don't know how big the user may want to stretch
-    # the window.  This at least forces the sidebarframe to give the view
-    # the maximum size available, which is perfect for an initially closed
-    # sidebar.
-
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth 10000
-    #
-    # RENDERING AREA
-    #
-
-    set _image(id) ""
-
-    if { $_useVmouseEvents } {
-        # set up bindings to bridge mouse events to server
-        bind $itk_component(view) <ButtonPress> \
-            [itcl::code $this Vmouse click %b %s %x %y]
-        bind $itk_component(view) <ButtonRelease> \
-            [itcl::code $this Vmouse release %b %s %x %y]
-        bind $itk_component(view) <B1-Motion> \
-            [itcl::code $this Vmouse drag 1 %s %x %y]
-        bind $itk_component(view) <B2-Motion> \
-            [itcl::code $this Vmouse drag 2 %s %x %y]
-        bind $itk_component(view) <B3-Motion> \
-            [itcl::code $this Vmouse drag 3 %s %x %y]
-        bind $itk_component(view) <Motion> \
-            [itcl::code $this Vmouse move 0 %s %x %y]
-    } else {
-        # set up bindings for rotation with mouse
-        bind $itk_component(view) <ButtonPress-1> \
-            [itcl::code $this Rotate click %x %y]
-        bind $itk_component(view) <B1-Motion> \
-            [itcl::code $this Rotate drag %x %y]
-        bind $itk_component(view) <ButtonRelease-1> \
-            [itcl::code $this Rotate release %x %y]
-
-        # set up bindings for panning with mouse
-        bind $itk_component(view) <ButtonPress-2> \
-            [itcl::code $this Pan click %x %y]
-        bind $itk_component(view) <B2-Motion> \
-            [itcl::code $this Pan drag %x %y]
-        bind $itk_component(view) <ButtonRelease-2> \
-            [itcl::code $this Pan release %x %y]
-
-        # scroll wheel zoom
-        if {[string equal "x11" [tk windowingsystem]]} {
-            bind $itk_component(view) <4> [itcl::code $this Zoom out 2]
-            bind $itk_component(view) <5> [itcl::code $this Zoom in 2]
-        }
-    }
-
-    # Set up bindings for panning with keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -50 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 50 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -50]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 50]
-
-    # Set up bindings for zoom with keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out 2]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in 2]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    bind $itk_component(view) <Configure> \
-        [itcl::code $this EventuallyResize %w %h]
-    bind $itk_component(view) <Unmap> \
-        [itcl::code $this Unmap]
-    bind $itk_component(view) <Map> \
-        [itcl::code $this Map]
-
-    eval itk_initialize $args
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::destructor {} {
-    VisViewer::Disconnect
-
-    image delete $_image(plot)
-    array unset _settings $this-*
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise. Only
-# -brightness and -raise do anything.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::add { dataobj {options ""}} {
-    array set params {
-        -color          auto
-        -brightness     0
-        -width          1
-        -raise          0
-        -linestyle      solid
-        -description    ""
-        -param          ""
-    }
-    array set params $options
-
-    set pos [lsearch -exact $_dlist $dataobj]
-
-    if {$pos < 0} {
-        if {![Rappture::library isvalid $dataobj]} {
-            error "bad value \"$dataobj\": should be Rappture::library object"
-        }
-
-        if { !$_settings($this-showlabels-initialized) } {
-            set showlabels [$dataobj get components.molecule.about.emblems]
-            if { $showlabels != "" && [string is boolean $showlabels] } {
-                set _settings($this-showlabels) $showlabels
-            }
-        }
-
-        lappend _dlist $dataobj
-        if { $params(-brightness) >= 0.5 } {
-            set _dobj2transparency($dataobj) "ghost"
-        } else {
-            set _dobj2transparency($dataobj) "normal"
-        }
-        set _dobj2raise($dataobj) $params(-raise)
-        DebugTrace "setting parameters for $dataobj"
-
-        if { [isconnected] } {
-            $_dispatcher event -idle !rebuild
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj> <dataobj> ...?
-#
-# Clients use this to delete a dataobj from the plot. If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::delete { args } {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            if { [info exists _obj2models($dataobj)] } {
-                foreach model $_obj2models($dataobj) {
-                    array unset _active $model
-                }
-            }
-            array unset _obj2models $dataobj
-            array unset _dobj2transparency $dataobj
-            array unset _dobj2color $dataobj
-            array unset _dobj2width $dataobj
-            array unset _dobj2dashes $dataobj
-            array unset _dobj2raise $dataobj
-            set changed 1
-        }
-    }
-
-    # if anything changed, then rebuild the plot
-    if {$changed} {
-        if { [isconnected] } {
-            $_dispatcher event -idle !rebuild
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-    foreach obj $dlist {
-        if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} {
-            set i [lsearch -exact $dlist $obj]
-            if {$i >= 0} {
-                set dlist [lreplace $dlist $i $i]
-                lappend dlist $obj
-            }
-        }
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::download {option args} {
-    switch $option {
-        coming {}
-        controls {
-            set popup .molvisviewerdownload
-            if {![winfo exists $popup]} {
-                # if we haven't created the popup yet, do it now
-                Rappture::Balloon $popup \
-                    -title "[Rappture::filexfer::label downloadWord] as..."
-                set inner [$popup component inner]
-                label $inner.summary -text "" -anchor w
-                radiobutton $inner.pdb \
-                    -text "PDB Protein Data Bank Format File" \
-                    -variable [itcl::scope _downloadPopup(format)] \
-                    -font "Arial 10 " \
-                    -value pdb
-                Rappture::Tooltip::for $inner.pdb \
-                    "Save as PDB Protein Data Bank format file."
-                radiobutton $inner.image -text "Image (PNG/JPEG/GIF)" \
-                    -variable [itcl::scope _downloadPopup(format)] \
-                    -font "Arial 10 " \
-                    -value image
-                Rappture::Tooltip::for $inner.image \
-                    "Save as image."
-                set f [frame $inner.frame]
-                button $f.ok -text "Save" \
-                    -highlightthickness 0 -pady 3 -padx 3 \
-                    -command [lindex $args 0] \
-                    -compound left \
-                    -image [Rappture::icon download]
-                button $f.cancel -text "Cancel" \
-                    -highlightthickness 0 -pady 3 -padx 3 \
-                    -command [list $popup deactivate] \
-                    -compound left \
-                    -image [Rappture::icon cancel]
-                blt::table $f \
-                    0,0 $f.ok \
-                    0,1 $f.cancel
-                blt::table $inner \
-                    0,0 $inner.summary -anchor w \
-                    1,0 $inner.pdb -anchor w \
-                    2,0 $inner.image -anchor w \
-                    3,0 $f -fill x -pady 4
-                $inner.pdb select
-            } else {
-                set inner [$popup component inner]
-            }
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks ;          # Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .molvisviewerdownload
-            if {[winfo exists $popup]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "pdb" {
-                    return [list .pdb $_pdbdata]
-                }
-                "image" {
-                    set popup .molvisviewerimage
-                    if { ![winfo exists $popup] } {
-                        # Create the balloon popup and and the print image
-                        # dialog widget to it.
-                        Rappture::Balloon $popup -title "Save as image..." \
-                            -deactivatecommand \
-                            [itcl::code $this SetWaitVariable 0]
-                        set inner [$popup component inner]
-                        # Add image controls to the ballon popup
-                        AddImageControls $inner [lindex $args 0]
-                    } else {
-                        set inner [$popup component inner]
-                    }
-                    update
-                    # Activate the popup and call for the output.
-                    foreach { widget toolName plotName } $args break
-                    SetWaitVariable 0
-                    $popup activate $widget left
-                    set bool [WaitForResponse]
-                    $popup deactivate
-                    if { $bool } {
-                        return [GetImage $widget]
-                    }
-                    return ""
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-#
-# isconnected --
-#
-#       Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::MolvisViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# Connect --
-#
-#       Establishes a connection to a new visualization server.
-#
-itcl::body Rappture::MolvisViewer::Connect {} {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    if { [isconnected] } {
-        return 1
-    }
-    set hosts [GetServerList "pymol"]
-    if { "" == $hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "molvisviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        $_dispatcher event -idle !rebuild
-    }
-    return $result
-}
-
-#
-# Disconnect --
-#
-#       Clients use this method to disconnect from the current rendering
-#       server.
-#
-itcl::body Rappture::MolvisViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    # disconnected -- no more data sitting on server
-    catch { after cancel $_rocker(afterid) }
-    catch { after cancel $_mevent(afterid) }
-    array unset _dataobjs
-    array unset _model
-    array unset _mlist
-    array unset _imagecache
-
-    set _state(server) 1
-    set _state(client) 1
-    global readyForNextFrame
-    set readyForNextFrame 1
-    set _reset 1
-}
-
-itcl::body Rappture::MolvisViewer::SendCmd { cmd } {
-    DebugTrace "cmd: ($cmd)"
-
-    if { $_state(server) != $_state(client) } {
-        VisViewer::SendCmd "frame -defer $_state(client)"
-        set _state(server) $_state(client)
-    }
-    if { $_rocker(server) != $_rocker(client) } {
-        VisViewer::SendCmd "rock -defer $_rocker(client)"
-        set _rocker(server) $_rocker(client)
-    }
-    VisViewer::SendCmd "$cmd"
-}
-
-#
-# ReceiveImage -bytes <size>
-#
-#     Invoked automatically whenever the "image" command comes in from
-#     the rendering server.  Indicates that binary image data with the
-#     specified <size> will follow.
-#
-set count 0
-itcl::body Rappture::MolvisViewer::ReceiveImage { size cacheid frame rock } {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    set tag "$frame,$rock"
-    global count
-    incr count
-    if { $cacheid != $_cacheid } {
-        array unset _imagecache
-        set _cacheid $cacheid
-    }
-    set data [ReceiveBytes $size]
-    #DebugTrace "success: reading $size bytes from proxy"
-    if { [string match "print*" $cacheid] } {
-        # $frame is the token that we sent to the proxy.
-        set _hardcopy($this-$cacheid) $data
-        puts stderr "setting _hardcopy($this-$cacheid)"
-    } else {
-        set _imagecache($tag) $data
-        #DebugTrace "CACHED: $tag,$cacheid"
-        $_image(plot) configure -data $data
-        set _image(id) $tag
-    }
-}
-
-itcl::body Rappture::MolvisViewer::BuildSettingsTab {} {
-    set fg [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Settings" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    label $inner.pict -image $_settings($this-modelimg)
-
-    label $inner.rep_l -text "Molecule Representation" \
-        -font "Arial 9"
-
-    itk_component add representation {
-        Rappture::Combobox $inner.rep -width 20 -editable no
-    }
-    $inner.rep choices insert end \
-        "ballnstick"  "ball and stick" \
-        "spheres"     "spheres"         \
-        "sticks"      "sticks"          \
-        "lines"       "lines"           \
-        "cartoon"     "cartoon"
-
-    bind $inner.rep <<Value>> [itcl::code $this Representation]
-    $inner.rep value "ball and stick"
-
-    scale $inner.spherescale -width 10 -font "Arial 9" \
-        -from 0.1 -to 2.0 -resolution 0.05 -label "Sphere Scale" \
-        -showvalue true -orient horizontal \
-        -command [itcl::code $this EventuallyChangeSettings] \
-        -variable Rappture::MolvisViewer::_settings($this-spherescale)
-    $inner.spherescale set $_settings($this-spherescale)
-    Rappture::Tooltip::for $inner.spherescale \
-        "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."
-
-    scale $inner.stickradius -width 10 -font "Arial 9" \
-        -from 0.1 -to 1.0 -resolution 0.025 -label "Stick Radius" \
-        -showvalue true -orient horizontal \
-        -command [itcl::code $this EventuallyChangeSettings] \
-        -variable Rappture::MolvisViewer::_settings($this-stickradius)
-    Rappture::Tooltip::for $inner.stickradius \
-        "Adjust scale of bonds (sticks)."
-    $inner.stickradius set $_settings($this-stickradius)
-
-    checkbutton $inner.labels -text "Show labels on atoms" \
-        -command [itcl::code $this labels update] \
-        -variable [itcl::scope _settings($this-showlabels)] \
-        -font "Arial 9"
-    Rappture::Tooltip::for $inner.labels \
-        "Display atom symbol and serial number."
-
-    checkbutton $inner.rock -text "Rock model back and forth" \
-        -command [itcl::code $this Rock toggle] \
-        -variable Rappture::MolvisViewer::_settings($this-rock) \
-        -font "Arial 9"
-    Rappture::Tooltip::for $inner.rock \
-        "Rotate the object back and forth around the y-axis."
-
-    checkbutton $inner.ortho -text "Orthoscopic projection" \
-        -command [itcl::code $this OrthoProjection update] \
-        -variable Rappture::MolvisViewer::_settings($this-ortho) \
-         -font "Arial 9"
-    Rappture::Tooltip::for $inner.ortho \
-        "Toggle between orthoscopic/perspective projection modes."
-
-    checkbutton $inner.cartoontrace -text "Cartoon Trace" \
-        -command [itcl::code $this CartoonTrace update] \
-        -variable [itcl::scope _settings($this-cartoontrace)] \
-        -font "Arial 9"
-    Rappture::Tooltip::for $inner.cartoontrace \
-        "Set cartoon representation of bonds (sticks)."
-
-    checkbutton $inner.cell -text "Parallelepiped" \
-        -command [itcl::code $this Cell toggle] \
-        -font "Arial 9"
-    $inner.cell select
-
-    label $inner.spacer
-    blt::table $inner \
-        0,0 $inner.labels -anchor w -pady {1 0} \
-        1,0 $inner.rock -anchor w -pady {1 0} \
-        2,0 $inner.ortho -anchor w -pady {1 0} \
-        3,0 $inner.cartoontrace -anchor w -pady {1 0} \
-        4,0 $inner.cell -anchor w  -pady {1 0} \
-        5,0 $inner.rep_l -anchor w -pady { 2 0 } \
-        6,0 $inner.rep -anchor w  \
-        7,0 $inner.spherescale -fill x -pady {3 0} \
-        8,0 $inner.stickradius -fill x -pady {1 0} \
-
-    blt::table configure $inner r* -resize none
-    blt::table configure $inner r10 -resize expand
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Rebuild {} {
-    DebugTrace "Enter"
-    set changed 0
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (that automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-    set _cell 0
-
-    if { $_reset } {
-        set _rocker(server) 0
-        set _cacheid 0
-
-        SendCmd "raw -defer {set auto_color,0}"
-        SendCmd "raw -defer {set auto_show_lines,0}"
-    }
-    set _first ""
-    set dlist [get]
-    foreach dataobj $dlist {
-        if { $_first == "" } {
-            set _first $dataobj
-        }
-        set model [$dataobj get components.molecule.model]
-        if {"" == $model } {
-            set model "molecule"
-            scan $dataobj "::libraryObj%d" suffix
-            set model $model$suffix
-        }
-        lappend _obj2models($dataobj) $model
-        set state [$dataobj get components.molecule.state]
-        if {"" == $state} {
-            set state $_state(server)
-        }
-        if { ![info exists _mlist($model)] } {  # new, turn on
-            set _mlist($model) 2
-        } elseif { $_mlist($model) == 1 } {     # on, leave on
-            set _mlist($model) 3
-        } elseif { $_mlist($model) == 0 } {     # off, turn on
-            set _mlist($model) 2
-        }
-        if { ![info exists _dataobjs($model-$state)] } {
-            set data1      ""
-            set serial    1
-
-            foreach _atom [$dataobj children -type atom components.molecule] {
-                set symbol [$dataobj get components.molecule.$_atom.symbol]
-                set xyz [$dataobj get components.molecule.$_atom.xyz]
-                regsub {,} $xyz {} xyz
-                scan $xyz "%f %f %f" x y z
-                set recname  "ATOM  "
-                set altLoc   ""
-                set resName  ""
-                set chainID  ""
-                set Seqno    ""
-                set occupancy  1
-                set tempFactor 0
-                set recID      ""
-                set segID      ""
-                set element    ""
-                set charge     ""
-                set atom $symbol
-                set line [format "%6s%5d %4s%1s%3s %1s%5s   %8.3f%8.3f%8.3f%6.2f%6.2f%8s\n" $recname $serial $atom $altLoc $resName $chainID $Seqno $x $y $z $occupancy $tempFactor $recID]
-                append data1 $line
-                incr serial
-            }
-            if { $_reportClientInfo }  {
-                set parent [$dataobj parent -as object]
-                while { $parent != "" } {
-                    set xmlobj $parent
-                    set parent [$parent parent -as object]
-                }
-            }
-            if {"" != $data1} {
-                # Save the PDB data in case the user wants to later save it.
-                set _pdbdata $data1
-                set numBytes [string length $data1]
-
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"      [$xmlobj get tool.id]
-                    lappend info "tool_name"    [$xmlobj get tool.name]
-                    lappend info "tool_title"   [$xmlobj get tool.title]
-                    lappend info "tool_command" [$xmlobj get tool.execute]
-                    lappend info "tool_revision" \
-                        [$xmlobj get tool.version.application.revision]
-                    lappend info "dataset_type" "molecule-xml"
-                    lappend info "dataset_size"  $numBytes
-                    lappend info "dataset_tag"   $model-$state
-                    SendCmd "clientinfo [list $info]"
-                }
-
-                # We know we're buffered here, so append the "loadpdb" command
-                # with the data payload immediately afterwards.
-                SendCmd "loadpdb -defer follows $model $state $numBytes"
-                SendData $data1
-                set _dataobjs($model-$state)  1
-            }
-            # note that pdb files always overwrite xyz files
-            set data2 [$dataobj get components.molecule.pdb]
-            if {"" != $data2} {
-                # Save the PDB data in case the user wants to later save it.
-                set _pdbdata $data2
-                set numBytes [string length $data2]
-
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"      [$xmlobj get tool.id]
-                    lappend info "tool_name"    [$xmlobj get tool.name]
-                    lappend info "tool_title"   [$xmlobj get tool.title]
-                    lappend info "tool_command" [$xmlobj get tool.execute]
-                    lappend info "tool_revision" \
-                        [$xmlobj get tool.version.application.revision]
-                    lappend info "dataset_type" "pdb"
-                    lappend info "dataset_size"  $numBytes
-                    lappend info "dataset_tag"   $model-$state
-                    SendCmd "clientinfo [list $info]"
-                }
-
-                # We know we're buffered here, so append the "loadpdb" command
-                # with the data payload immediately afterwards.
-                SendCmd "loadpdb -defer follows $model $state $numBytes"
-                SendData $data2
-                set _dataobjs($model-$state)  1
-            }
-            # lammps dump file overwrites pdb file (change this?)
-            set lammpsdata [$dataobj get components.molecule.lammps]
-            if {"" != $lammpsdata} {
-                set lammpstypemap [$dataobj get components.molecule.lammpstypemap]
-                set data3 ""
-                set modelcount 0
-                foreach lammpsline [split $lammpsdata "\n"] {
-                    if {[scan $lammpsline "%d %d %f %f %f" id type x y z] == 5} {
-                        set recname  "ATOM  "
-                        set altLoc   ""
-                        set resName  ""
-                        set chainID  ""
-                        set Seqno    ""
-                        set occupancy  1
-                        set tempFactor 0
-                        set recID      ""
-                        set segID      ""
-                        set element    ""
-                        set charge     ""
-                        if { "" == $lammpstypemap} {
-                            set atom $type
-                        } else {
-                            set atom [lindex $lammpstypemap [expr {$type - 1}]]
-                            if { "" == $atom} {
-                              set atom $type
-                            }
-                        }
-                        set pdbline [format "%6s%5d %4s%1s%3s %1s%5s   %8.3f%8.3f%8.3f%6.2f%6.2f%8s\n" $recname $id $atom $altLoc $resName $chainID $Seqno $x $y $z $occupancy $tempFactor $recID]
-                        append data3 $pdbline
-                    }
-                    # only read first model
-                    if {[regexp "^ITEM: ATOMS" $lammpsline]} {
-                      incr modelcount
-                      if {$modelcount > 1} {
-                        break
-                      }
-                    }
-                }
-                if {"" != $data3} {
-                    # Save the PDB data in case the user wants to later save it.
-                    set _pdbdata $data3
-                    set numBytes [string length $data3]
-
-                    if { $_reportClientInfo }  {
-                        set info {}
-                        lappend info "tool_id"      [$xmlobj get tool.id]
-                        lappend info "tool_name"    [$xmlobj get tool.name]
-                        lappend info "tool_title"   [$xmlobj get tool.title]
-                        lappend info "tool_command" [$xmlobj get tool.execute]
-                        lappend info "tool_revision" \
-                            [$xmlobj get tool.version.application.revision]
-                        lappend info "dataset_type" "lammps"
-                        lappend info "dataset_size"  $numBytes
-                        lappend info "dataset_tag"   $model-$state
-                        SendCmd "clientinfo [list $info]"
-                    }
-
-                    # We know we're buffered here, so append the "loadpdb"
-                    # command with the data payload immediately afterwards.
-                    SendCmd "loadpdb -defer follows $model $state $numBytes"
-                    SendData $data3
-                }
-                set _dataobjs($model-$state) 1
-            }
-        }
-        if { ![info exists _model($model-transparency)] } {
-            set _model($model-transparency) ""
-        }
-        if { ![info exists _model($model-rep)] } {
-            set _model($model-rep) ""
-            set _model($model-newrep) $_mrep
-        }
-        if { $_model($model-transparency) != $_dobj2transparency($dataobj) } {
-            set _model($model-newtransparency) $_dobj2transparency($dataobj)
-        }
-        if { $_dobj2transparency($dataobj) == "ghost"} {
-            array unset _active $model
-        } else {
-            set _active($model) $dataobj
-        }
-        set vector [$dataobj get components.parallelepiped.vector]
-        if { $vector != "" } {
-            set vertices [ComputeParallelepipedVertices $dataobj]
-            SendCmd "raw -defer {verts = \[$vertices\]\n}"
-            SendCmd "raw -defer {run \$PYMOL_SITE_PATH/rappture/box.py\n}"
-            SendCmd "raw -defer {draw_box(verts)\n}"
-            set _cell 1
-        }
-    }
-
-    # enable/disable models as required (0=off->off, 1=on->off, 2=off->on,
-    # 3=on->on)
-
-    foreach model [array names _mlist] {
-        if { $_mlist($model) == 1 } {
-            SendCmd "disable -defer $model"
-            set _mlist($model) 0
-            set changed 1
-        } elseif { $_mlist($model) == 2 } {
-            set _mlist($model) 1
-            SendCmd "enable -defer $model"
-            set changed 1
-        } elseif { $_mlist($model) == 3 } {
-            set _mlist($model) 1
-        }
-        if { $_mlist($model) == 1 } {
-            if {  [info exists _model($model-newtransparency)] ||
-                  [info exists _model($model-newrep)] } {
-                if { ![info exists _model($model-newrep)] } {
-                    set _model($model-newrep) $_model($model-rep)
-                }
-                if { ![info exists _model($model-newtransparency)] } {
-                    set _model($model-newtransparency) $_model($model-transparency)
-                }
-                set rep $_model($model-newrep)
-                set transp $_model($model-newtransparency)
-                SendCmd "representation -defer -model $model $rep"
-                set changed 1
-                set _model($model-transparency) $_model($model-newtransparency)
-                set _model($model-rep) $_model($model-newrep)
-                catch {
-                    unset _model($model-newtransparency)
-                    unset _model($model-newrep)
-                }
-            }
-        }
-
-    }
-
-    if { $changed } {
-        array unset _imagecache
-    }
-    if { $dlist == "" } {
-        set _state(server) 1
-        set _state(client) 1
-        SendCmd "frame 1"
-        set flush 1
-    } elseif { ![info exists _imagecache($state,$_rocker(client))] } {
-        set _state(server) $state
-        set _state(client) $state
-        SendCmd "frame $state"
-        set flush 1
-    } else {
-        set _state(client) $state
-        UpdateState
-        set flush 0
-    }
-    if { $_reset } {
-        # Set or restore viewing parameters.  We do this for the first
-        # model and assume this works for everything else.
-        set w  [winfo width $itk_component(view)]
-        set h  [winfo height $itk_component(view)]
-        SendCmd "reset"
-        SendCmd "screen $w $h"
-        SendCmd "rotate $_view(mx) $_view(my) $_view(mz)"
-        SendCmd "pan $_view(xpan) $_view(ypan)"
-        SendCmd "zoom $_view(zoom)"
-        DebugTrace "rotate $_view(mx) $_view(my) $_view(mz)"
-
-        SendCmd "raw -defer {zoom complete=1}"
-        set _reset 0
-    }
-    if { $changed } {
-        # Default settings for all models.
-        SphereScale update
-        StickRadius update
-        labels update
-        Opacity update
-        CartoonTrace update
-        Cell update
-        OrthoProjection update
-        Representation update
-    }
-    set inner [$itk_component(main) panel "Settings"]
-    if { $_cell } {
-        $inner.cell configure -state normal
-    } else {
-        $inner.cell configure -state disabled
-    }
-    if { $flush } {
-        global readyForNextFrame
-        set readyForNextFrame 0;        # Don't advance to the next frame
-                                        # until we get an image.
-        #SendCmd "ppm";                 # Flush the results.
-    }
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-
-    DebugTrace "Exit"
-}
-
-itcl::body Rappture::MolvisViewer::Unmap { } {
-    # Pause rocking loop while unmapped (saves CPU time)
-    Rock pause
-
-    # Blank image, mark current image dirty
-    # This will force reload from cache, or remain blank if cache is cleared
-    # This prevents old image from briefly appearing when a new result is added
-    # by result viewer
-
-    #$_image(plot) blank
-    set _image(id) ""
-}
-
-itcl::body Rappture::MolvisViewer::Map { } {
-    if { [isconnected] } {
-        # Resume rocking loop if it was on
-        Rock unpause
-        # Rebuild image if modified, or redisplay cached image if not
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-itcl::body Rappture::MolvisViewer::DoResize { } {
-    SendCmd "screen $_width $_height"
-    $_image(plot) configure -width $_width -height $_height
-    # Immediately invalidate cache, defer update until mapped
-    array unset _imagecache
-    set _resizePending 0
-}
-
-itcl::body Rappture::MolvisViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    if { !$_resizePending } {
-        $_dispatcher event -after 400 !resize
-        set _resizePending 1
-    }
-}
-
-itcl::body Rappture::MolvisViewer::DoRotate {} {
-    SendCmd "rotate $_view(a) $_view(b) $_view(c)"
-    array unset _imagecache
-    set _rotatePending 0
-}
-
-itcl::body Rappture::MolvisViewer::EventuallyRotate { a b c } {
-    set _view(a) $a
-    set _view(b) $b
-    set _view(c) $c
-    if { !$_rotatePending } {
-        $_dispatcher event -after 100 !rotate
-        set _rotatePending 1
-    }
-}
-
-itcl::body Rappture::MolvisViewer::DoUpdate { } {
-    array unset _imagecache
-    set models [array names _mlist]
-    SphereScale $_settings($this-spherescale) $models
-    StickRadius $_settings($this-stickradius) $models
-    set _updatePending 0
-}
-
-itcl::body Rappture::MolvisViewer::EventuallyChangeSettings { args } {
-    if { !$_updatePending } {
-        $_dispatcher event -after 400 !update
-        set _updatePending 1
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Pan {option x y} {
-    if { $option == "set" } {
-        set dx $x
-        set dy $y
-        set _view(xpan) [expr $_view(xpan) + $dx]
-        set _view(ypan) [expr $_view(ypan) + $dy]
-        array unset _imagecache
-        SendCmd "pan $dx $dy"
-        return
-    }
-    if { ![info exists _mevent(x)] } {
-        set option "click"
-    }
-    if { $option == "click" } {
-        $itk_component(view) configure -cursor hand1
-    }
-    if { $option == "drag" || $option == "release" } {
-        set dx [expr $x - $_mevent(x)]
-        set dy [expr $y - $_mevent(y)]
-        set _view(xpan) [expr $_view(xpan) + $dx]
-        set _view(ypan) [expr $_view(ypan) + $dy]
-        array unset _imagecache
-        SendCmd "pan $dx $dy"
-    }
-    set _mevent(x) $x
-    set _mevent(y) $y
-    if { $option == "release" } {
-        $itk_component(view) configure -cursor ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Zoom {option {factor 10}} {
-    switch -- $option {
-        "in" {
-            set _view(zoom) [expr $_view(zoom) + $factor]
-            SendCmd "zoom $factor"
-        }
-        "out" {
-            set _view(zoom) [expr $_view(zoom) - $factor]
-            SendCmd "zoom -$factor"
-        }
-        "reset" {
-            set _view(zoom) 0
-            SendCmd "reset"
-        }
-    }
-    array unset _imagecache
-}
-
-itcl::body Rappture::MolvisViewer::UpdateState { args } {
-    set tag "$_state(client),$_rocker(client)"
-    if { $_image(id) != "$tag" } {
-        if { [info exists _imagecache($tag)] } {
-            $_image(plot) configure -data $_imagecache($tag)
-            set _image(id) "$tag"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rock on|off|toggle
-# USAGE: Rock pause|unpause|step
-#
-# Used to control the "rocking" model for the molecule being displayed.
-# Clients should use only the on/off/toggle options; the rest are for
-# internal control of the rocking motion.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Rock { option } {
-    # cancel any pending rocks
-    if { [info exists _rocker(afterid)] } {
-        after cancel $_rocker(afterid)
-        unset _rocker(afterid)
-    }
-    if { ![winfo viewable $itk_component(view)] } {
-        return
-    }
-    set _rocker(on) $_settings($this-rock)
-    if { $option == "step"} {
-        if { $_rocker(client) >= 10 } {
-            set _rocker(dir) -1
-        } elseif { $_rocker(client) <= -10 } {
-            set _rocker(dir) 1
-        }
-        set _rocker(client) [expr {$_rocker(client) + $_rocker(dir)}]
-        if { ![info exists _imagecache($_state(server),$_rocker(client))] } {
-            set _rocker(server) $_rocker(client)
-            SendCmd "rock $_rocker(client)"
-        }
-        UpdateState
-    }
-    if { $_rocker(on) && $option != "pause" } {
-         set _rocker(afterid) [after 200 [itcl::code $this Rock step]]
-    }
-}
-
-#
-# Send virtual mouse events using the vmouse command
-#
-itcl::body Rappture::MolvisViewer::Vmouse {option b m x y} {
-    set now [clock clicks -milliseconds]
-    set vButton [expr $b - 1]
-    set vModifier 0
-    set vState 1
-
-    if { $m & 1 }      { set vModifier [expr $vModifier | 1 ] }
-    if { $m & 4 }      { set vModifier [expr $vModifier | 2 ] }
-    if { $m & 131072 } { set vModifier [expr $vModifier | 4 ] }
-
-    if { $option == "click"   } { set vState 0 }
-    if { $option == "release" } { set vState 1 }
-    if { $option == "drag"    } { set vState 2 }
-    if { $option == "move"    } { set vState 3 }
-
-    if { $vState == 2 || $vState == 3} {
-        set diff 0
-
-        catch { set diff [expr $now - $_mevent(time)] }
-        if {$diff < 75} { # 75ms between motion updates
-            return
-        }
-    }
-    SendCmd "vmouse $vButton $vModifier $vState $x $y"
-    set _mevent(time) $now
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Rotate {option x y} {
-    set now  [clock clicks -milliseconds]
-    # cancel any pending delayed dragging events
-    if { [info exists _mevent(afterid)] } {
-        after cancel $_mevent(afterid)
-        unset _mevent(afterid)
-    }
-
-    if { ![info exists _mevent(x)] } {
-        set option "click"
-    }
-    if { $option == "click" } {
-        $itk_component(view) configure -cursor fleur
-    }
-    if { $option == "drag" || $option == "release" } {
-        set diff 0
-        catch { set diff [expr $now - $_mevent(time) ] }
-        if {$diff < 25 && $option == "drag" } { # 75ms between motion updates
-            set _mevent(afterid) [after [expr 25 - $diff] [itcl::code $this Rotate drag $x $y]]
-            return
-        }
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        if {$w <= 0 || $h <= 0} {
-            return
-        }
-        set x1 [expr double($w) / 3]
-        set x2 [expr $x1 * 2]
-        set y1 [expr double($h) / 3]
-        set y2 [expr $y1 * 2]
-        set dx [expr $x - $_mevent(x)]
-        set dy [expr $y - $_mevent(y)]
-        set mx 0
-        set my 0
-        set mz 0
-
-        if { $_mevent(x) < $x1 } {
-            set mz $dy
-        } elseif { $_mevent(x) < $x2 } {
-            set mx $dy
-        } else {
-            set mz [expr -$dy]
-        }
-
-        if { $_mevent(y) < $y1 } {
-            set mz [expr -$dx]
-        } elseif { $_mevent(y) < $y2 } {
-            set my $dx
-        } else {
-            set mz $dx
-        }
-        # Accumlate movements
-        set _view(mx) [expr {$_view(mx) + $mx}]
-        set _view(my) [expr {$_view(my) + $my}]
-        set _view(mz) [expr {$_view(mz) + $mz}]
-        #SendCmd "rotate $mx $my $mz"
-        EventuallyRotate $mx $my $mz
-        DebugTrace "rotate $_view(mx) $_view(my) $_view(mz)"
-    }
-    set _mevent(x) $x
-    set _mevent(y) $y
-    set _mevent(time) $now
-    if { $option == "release" } {
-        $itk_component(view) configure -cursor ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate.old click <x> <y>
-# USAGE: Rotate.old drag <x> <y>
-# USAGE: Rotate.old release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Rotate.old {option x y} {
-    set now  [clock clicks -milliseconds]
-    #update idletasks
-    # cancel any pending delayed dragging events
-    if { [info exists _mevent(afterid)] } {
-        after cancel $_mevent(afterid)
-        unset _mevent(afterid)
-    }
-    switch -- $option {
-        click {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-            set _click(theta) $_view(theta)
-            set _click(phi) $_view(phi)
-        }
-        drag {
-            if {[array size _click] == 0} {
-                Rotate.old click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-                #set diff 0
-                #catch { set diff [expr $now - $_mevent(time) ] }
-                #if {$diff < 75 && $option == "drag" } { # 75ms between motion updates
-                #    set _mevent(afterid) [after [expr 75 - $diff] [itcl::code $this Rotate.old drag $x $y]]
-                #    return
-                #}
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-
-                #
-                # Rotate the camera in 3D
-                #
-                if {$_view(psi) > 90 || $_view(psi) < -90} {
-                    # when psi is flipped around, theta moves backwards
-                    set dy [expr {-$dy}]
-                }
-                set theta [expr {$_view(theta) - $dy*180}]
-                while {$theta < 0} { set theta [expr {$theta+180}] }
-                while {$theta > 180} { set theta [expr {$theta-180}] }
-
-                if {abs($theta) >= 30 && abs($theta) <= 160} {
-                    set phi [expr {$_view(phi) - $dx*360}]
-                    while {$phi < 0} { set phi [expr {$phi+360}] }
-                    while {$phi > 360} { set phi [expr {$phi-360}] }
-                    set psi $_view(psi)
-                } else {
-                    set phi $_view(phi)
-                    set psi [expr {$_view(psi) - $dx*360}]
-                    while {$psi < -180} { set psi [expr {$psi+360}] }
-                    while {$psi > 180} { set psi [expr {$psi-360}] }
-                }
-                array set _view [subst {
-                    theta $theta
-                    phi $phi
-                    psi $psi
-                }]
-                foreach { vx vy vz } [Euler2XYZ $theta $phi $psi] break
-                set a [expr $vx - $_view(vx)]
-                set a [expr -$a]
-                set b [expr $vy - $_view(vy)]
-                set c [expr $vz - $_view(vz)]
-                array set _view [subst {
-                    vx $vx
-                    vy $vy
-                    vz $vz
-                }]
-                EventuallyRotate $a $b $c
-                #SendCmd "rotate $a $b $c"
-                DebugTrace "x,y: $x $y: rotate $_view(vx) $_view(vy) $_view(vz)"
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        release {
-            Rotate.old drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-    set _mevent(time) $now
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Representation spheres|ballnstick|lines|sticks
-#
-# Used internally to change the molecular representation used to render
-# our scene.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Representation { { option "" } } {
-    if { $option == "" } {
-        set value [$itk_component(representation) value]
-        set option [$itk_component(representation) translate $value]
-    }
-    if { $option == $_mrep } {
-        return
-    }
-    if { $option == "update" } {
-        set option $_settings($this-model)
-    }
-    array unset _imagecache
-    if { $option == "sticks" } {
-        set _settings($this-modelimg) [Rappture::icon lines]
-    }  else {
-        set _settings($this-modelimg) [Rappture::icon $option]
-    }
-    set inner [$itk_component(main) panel "Settings"]
-    $inner.pict configure -image $_settings($this-modelimg)
-
-    # Save the current option to set all radiobuttons -- just in case.
-    # This method gets called without the user clicking on a radiobutton.
-    set _settings($this-model) $option
-    set _mrep $option
-
-    foreach model [array names _mlist] {
-        if { [info exists _model($model-rep)] } {
-            if { $_model($model-rep) != $option } {
-                set _model($model-newrep) $option
-            } else {
-                catch { unset _model($model-newrep) }
-            }
-        }
-    }
-    if { [isconnected] } {
-        SendCmd "representation -model $model $option"
-        #$_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: OrthoProjection on|off|toggle
-# USAGE: OrthoProjection update
-#
-# Used internally to turn labels associated with atoms on/off, and to
-# update the positions of the labels so they sit on top of each atom.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::OrthoProjection {option} {
-    array unset _imagecache
-    switch -- $option {
-        "orthoscopic" {
-            set ortho 1
-        }
-        "perspective" {
-            set ortho 0
-        }
-        "toggle" {
-            set ortho [expr {$_settings($this-ortho) == 0}]
-        }
-        "update" {
-            set ortho $_settings($this-ortho)
-        }
-        default {
-            error "bad option \"$option\": should be on, off, toggle, or update"
-        }
-    }
-    if { $ortho == $_settings($this-ortho) && $option != "update"} {
-        # nothing to do
-        return
-    }
-    if { $ortho } {
-        $itk_component(ortho) configure -image [Rappture::icon molvis-3dorth]
-        Rappture::Tooltip::for $itk_component(ortho) \
-            "Use perspective projection"
-        set _settings($this-ortho) 1
-        SendCmd "orthoscopic on"
-    } else {
-        $itk_component(ortho) configure -image [Rappture::icon molvis-3dpers]
-        Rappture::Tooltip::for $itk_component(ortho) \
-            "Use orthoscopic projection"
-        set _settings($this-ortho) 0
-        SendCmd "orthoscopic off"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Cell on|off|toggle
-#
-# Used internally to turn labels associated with atoms on/off, and to
-# update the positions of the labels so they sit on top of each atom.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Cell {option} {
-    switch -- $option {
-        "on" - "off" {
-            set cell $option
-        }
-        "toggle" {
-            set cell [expr {$_settings($this-showcell) == 0}]
-        }
-        "update" {
-            set cell $_settings($this-showcell)
-        }
-        default {
-            error "bad option \"$option\": should be on, off, toggle, or update"
-        }
-    }
-    if { $cell == $_settings($this-showcell) && $option != "update"} {
-        # nothing to do
-        return
-    }
-    array unset _imagecache
-    if { $cell } {
-        Rappture::Tooltip::for $itk_component(ortho) \
-            "Hide the cell."
-        set _settings($this-showcell) 1
-        SendCmd "raw {show everything,unitcell}"
-    } else {
-        Rappture::Tooltip::for $itk_component(ortho) \
-            "Show the cell."
-        set _settings($this-showcell) 0
-        SendCmd "raw {hide everything,unitcell}"
-    }
-}
-
-#
-# ResetView
-#
-itcl::body Rappture::MolvisViewer::ResetView {} {
-    array set _view {
-        theta   45
-        phi     45
-        psi     0
-        mx      0
-        my      0
-        mz      0
-        xpan    0
-        ypan    0
-        zoom    0
-    }
-    SendCmd "reset"
-    DoResize
-    SendCmd "rotate $_view(mx) $_view(my) $_view(mz)"
-    DebugTrace "rotate $_view(mx) $_view(my) $_view(mz)"
-    SendCmd "pan $_view(xpan) $_view(ypan)"
-    SendCmd "zoom $_view(zoom)"
-}
-
-itcl::body Rappture::MolvisViewer::WaitIcon { option widget } {
-    switch -- $option {
-        "start" {
-            $_dispatcher dispatch $this !waiticon \
-                "[itcl::code $this WaitIcon "next" $widget] ; list"
-            set _icon 0
-            $widget configure -image [Rappture::icon bigroller${_icon}]
-            $_dispatcher event -after 100 !waiticon
-        }
-        "next" {
-            incr _icon
-            if { $_icon >= 8 } {
-                set _icon 0
-            }
-            $widget configure -image [Rappture::icon bigroller${_icon}]
-            $_dispatcher event -after 100 !waiticon
-        }
-        "stop" {
-            $_dispatcher cancel !waiticon
-        }
-    }
-}
-
-itcl::body Rappture::MolvisViewer::GetImage { widget } {
-    set token "print[incr _nextToken]"
-    set var ::Rappture::MolvisViewer::_hardcopy($this-$token)
-    set $var ""
-
-    set controls $_downloadPopup(image_controls)
-    set combo $controls.size
-    set size [$combo translate [$combo value]]
-    switch -- $size {
-        "standard" {
-            set width 1200
-            set height 1200
-        }
-        "highquality" {
-            set width 2400
-            set height 2400
-        }
-        "draft" {
-            set width 400
-            set height 400
-        }
-        default {
-            error "unknown image size [$combo value]"
-        }
-    }
-    # Setup an automatic timeout procedure.
-    $_dispatcher dispatch $this !pngtimeout "set $var {} ; list"
-
-    set popup .molvisviewerimagedownload
-    if { ![winfo exists $popup] } {
-        Rappture::Balloon $popup -title "Generating file..."
-        set inner [$popup component inner]
-        label $inner.title -text "Generating hardcopy." -font "Arial 10 bold"
-        label $inner.please -text "This may take a minute." -font "Arial 10"
-        label $inner.icon -image [Rappture::icon bigroller0]
-        button $inner.cancel -text "Cancel" -font "Arial 10 bold" \
-            -command [list set $var ""]
-        blt::table $inner \
-            0,0 $inner.title -cspan 2 \
-            1,0 $inner.please -anchor w \
-            1,1 $inner.icon -anchor e  \
-            2,0 $inner.cancel -cspan 2
-        blt::table configure $inner r0 -pady 4
-        blt::table configure $inner r2 -pady 4
-        bind $inner.cancel <Return> [list $inner.cancel invoke]
-        bind $inner.cancel <KP_Enter> [list $inner.cancel invoke]
-    } else {
-        set inner [$popup component inner]
-    }
-    set combo $controls.bgcolor
-    set bgcolor [$combo translate [$combo value]]
-
-    $_dispatcher event -after 60000 !pngtimeout
-    WaitIcon start $inner.icon
-    grab set $inner
-    focus $inner.cancel
-
-    SendCmd "print $token $width $height $bgcolor"
-
-    $popup activate $widget below
-    # We wait here for either
-    #  1) the png to be delivered or
-    #  2) timeout or
-    #  3) user cancels the operation.
-    tkwait variable $var
-
-    # Clean up.
-    $_dispatcher cancel !pngtimeout
-    WaitIcon stop $inner.icon
-    grab release $inner
-    $popup deactivate
-    update
-
-    if { $_hardcopy($this-$token) != "" } {
-        set combo $controls.format
-        set fmt [$combo translate [$combo value]]
-        switch -- $fmt {
-            "jpg" {
-                set img [image create photo -data $_hardcopy($this-$token)]
-                set bytes [$img data -format "jpeg -quality 100"]
-                set bytes [Rappture::encoding::decode -as b64 $bytes]
-                return [list .jpg $bytes]
-            }
-            "gif" {
-                set img [image create photo -data $_hardcopy($this-$token)]
-                set bytes [$img data -format "gif"]
-                set bytes [Rappture::encoding::decode -as b64 $bytes]
-                return [list .gif $bytes]
-            }
-            "png" {
-                return [list .png $_hardcopy($this-$token)]
-            }
-        }
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: SphereScale radius ?model?
-#        SphereScale update ?model?
-#
-# Used internally to change the molecular atom scale used to render
-# our scene.
-#
-# Note: Only sets the specified radius for active models.  If the model
-#       is inactive, then it overridden with the value "0.1".
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::SphereScale { option {models "all"} } {
-    if { $option == "update" } {
-        set radius $_settings($this-spherescale)
-    } elseif { [string is double $option] } {
-        set radius $option
-        if { ($radius < 0.1) || ($radius > 2.0) } {
-            error "bad atom size \"$radius\""
-        }
-    } else {
-        error "bad option \"$option\""
-    }
-    set _settings($this-spherescale) $radius
-    if { $models == "all" } {
-        SendCmd "spherescale -model all $radius"
-        return
-    }
-    set overrideradius [expr $radius * 0.8]
-    SendCmd "spherescale -model all $overrideradius"
-    foreach model $models {
-        if { [info exists _active($model)] } {
-            SendCmd "spherescale -model $model $radius"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: StickRadius radius ?models?
-#        StickRadius update ?models?
-#
-# Used internally to change the stick radius used to render
-# our scene.
-#
-# Note: Only sets the specified radius for active models.  If the model
-#       is inactive, then it overridden with the value "0.25".
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::StickRadius { option {models "all"} } {
-    if { $option == "update" } {
-        set radius $_settings($this-stickradius)
-    } elseif { [string is double $option] } {
-        set radius $option
-        if { ($radius < 0.1) || ($radius > 2.0) } {
-            error "bad stick radius \"$radius\""
-        }
-    } else {
-        error "bad option \"$option\""
-    }
-    set _settings($this-stickradius) $radius
-    if { $models == "all" } {
-        SendCmd "stickradius -model all $radius"
-        return
-    }
-    set overrideradius [expr $radius * 0.8]
-    SendCmd "stickradius -model all $overrideradius"
-    foreach model $models {
-        if { [info exists _active($model)] } {
-            SendCmd "stickradius -model $model $radius"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Opacity value ?models?
-#        Opacity update ?models?
-#
-# Used internally to change the opacity (transparency) used to render
-# our scene.
-#
-# Note: Only sets the specified transparency for active models.  If the model
-#       is inactive, then it overridden with the value "0.75".
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::Opacity { option } {
-    array unset _imagecache
-    if { $option == "update" } {
-        set opacity $_settings($this-opacity)
-    } elseif { [string is double $option] } {
-        set opacity $option
-        if { ($opacity < 0.0) || ($opacity > 1.0) } {
-            error "bad opacity \"$opacity\""
-        }
-    } else {
-        error "bad option \"$option\""
-    }
-    set _settings($this-opacity) $opacity
-    set transparency [expr 1.0 - $opacity]
-    set models [array names _active]
-    if { [llength $models] == 0 } {
-        SendCmd "transparency -model all $transparency"
-        return
-    }
-    set overridetransparency 0.60
-    SendCmd "transparency -model all $overridetransparency"
-    foreach model $models {
-        SendCmd "transparency -model $model $transparency"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: labels on|off|toggle
-# USAGE: labels update
-#
-# Used internally to turn labels associated with atoms on/off, and to
-# update the positions of the labels so they sit on top of each atom.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::labels {option {models "all"}} {
-    set showlabels $_settings($this-showlabels)
-    if { $option == "update" } {
-        set showlabels $_settings($this-showlabels)
-    } elseif { [string is boolean $option] } {
-        set showlabels $option
-    } else {
-        error "bad option \"$option\""
-    }
-    # Clear the image cache
-    array unset _imagecache
-    set _settings($this-showlabels) $showlabels
-    if { $models == "all" } {
-        SendCmd "label -model all $showlabels"
-        return
-    }
-    SendCmd "label -model all off"
-    if { $showlabels } {
-        foreach model $models {
-            if { [info exists _active($model)] } {
-                SendCmd "label -model $model $showlabels"
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CartoonTrace on|off|toggle
-# USAGE: CartoonTrace update
-#
-# Used internally to turn labels associated with atoms on/off, and to
-# update the positions of the labels so they sit on top of each atom.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MolvisViewer::CartoonTrace {option {models "all"}} {
-    array unset _imagecache
-    set trace $_settings($this-cartoontrace)
-    if { $option == "update" } {
-        set trace $_settings($this-cartoontrace)
-    } elseif { [string is boolean $option] } {
-        set trace $option
-    } else {
-        error "bad option \"$option\""
-    }
-    set _settings($this-cartoontrace) $trace
-    if { $models == "all" } {
-        SendCmd "cartoontrace -model all $trace"
-        return
-    }
-    SendCmd "cartoontrace -model all off"
-    if { $trace } {
-        foreach model $models {
-            if { [info exists _active($model)] } {
-                SendCmd "cartoontrace -model $model $trace"
-            }
-        }
-    }
-}
-
-itcl::body Rappture::MolvisViewer::AddImageControls { inner widget } {
-    label $inner.size_l -text "Size:" -font "Arial 9"
-    set _downloadPopup(image_controls) $inner
-    set img $_image(plot)
-    set res "[image width $img]x[image height $img]"
-    Rappture::Combobox $inner.size -width 30 -editable no
-    $inner.size choices insert end \
-        "draft"  "Draft (400x400)"         \
-        "standard"  "Standard (1200x1200)"          \
-        "highquality"  "High Quality (2400x2400)"
-
-    label $inner.bgcolor_l -text "Background:" -font "Arial 9"
-    Rappture::Combobox $inner.bgcolor -width 30 -editable no
-    $inner.bgcolor choices insert end \
-        "black"  "Black" \
-        "white"  "White" \
-        "none"  "Transparent (PNG only)"
-
-    label $inner.format_l -text "Format:" -font "Arial 9"
-    Rappture::Combobox $inner.format -width 30 -editable no
-    $inner.format choices insert end \
-        "png"  "PNG (Portable Network Graphics format)" \
-        "jpg"  "JPEG (Joint Photographic Experts Group format)" \
-        "gif"  "GIF (GIF Graphics Interchange Format)"
-
-    set f [frame $inner.frame]
-    button $f.ok -text "Save" \
-        -highlightthickness 0 -pady 3 -padx 3 \
-        -command [itcl::code $this SetWaitVariable 1] \
-        -compound left \
-        -image [Rappture::icon download
-]
-    button $f.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 3 -padx 3 \
-        -command [itcl::code $this SetWaitVariable 0] \
-        -compound left \
-        -image [Rappture::icon cancel]
-    blt::table $f \
-        0,0 $f.ok  \
-        0,1 $f.cancel
-
-    blt::table $inner \
-        0,0 $inner.format_l -anchor e \
-        0,1 $inner.format -anchor w -fill x  \
-        1,0 $inner.size_l -anchor e \
-        1,1 $inner.size -anchor w -fill x \
-        2,0 $inner.bgcolor_l -anchor e \
-        2,1 $inner.bgcolor -anchor w -fill x \
-        3,0 $f -cspan 2 -fill x
-    blt::table configure $inner r0 r1 r2 r3 -pady { 4 0 }
-    blt::table configure $inner r3 -pady { 4 4 }
-    $inner.bgcolor value "Black"
-    $inner.size value "Draft (400x400)"
-    $inner.format value  "PNG (Portable Network Graphics format)"
-}
-
-itcl::body Rappture::MolvisViewer::snap { w h } {
-    if { $w <= 0 || $h <= 0 } {
-        set w [image width $_image(plot)]
-        set h [image height $_image(plot)]
-    }
-    set tag "$_state(client),$_rocker(client)"
-    if { $_image(id) != "$tag" } {
-        while { ![info exists _imagecache($tag)] } {
-            update idletasks
-            update
-            after 100
-        }
-        if { [info exists _imagecache($tag)] } {
-            $_image(plot) configure -data $_imagecache($tag)
-            set _image(id) "$tag"
-        }
-    }
-    set img [image create picture -width $w -height $h]
-    $img resample $_image(plot)
-    return $img
-}
-
-# FIXME: Handle 2D vectors
-itcl::body Rappture::MolvisViewer::ComputeParallelepipedVertices { dataobj } {
-    # Create a vector for every 3D point
-    blt::vector point0(3) point1(3) point2(3) point3(3) point4(3) point5(3) \
-        point6(3) point7(3) origin(3) scale(3)
-
-    set count 0
-    set parent [$dataobj element -as object "components.parallelepiped"]
-    foreach child [$parent children] {
-        if { ![string match "vector*" $child] } {
-            continue
-        }
-        incr count
-        set values [$parent get $child]
-        regexp -all {,} $values { } values
-        point$count set $values
-    }
-    itcl::delete object $parent
-    if { $count < 1 || $count > 3 } {
-        error "bad number of vectors supplied to parallelepiped"
-    }
-    point0 set { 0.0 0.0 0.0 }
-    point4 expr {point2 + point1}
-    point5 expr {point4 + point3}
-    point6 expr {point2 + point3}
-    point7 expr {point1 + point3}
-
-    set values [$dataobj get components.parallelepiped.scale]
-    set n [llength $values]
-    scale set { 1.0 1.0 1.0 }
-    if { $n == 1 } {
-        set scale(0:2) [lindex $values 0]
-    } elseif { $n == 2 } {
-        set scale(0:1) [lindex $values 0]
-    } elseif { $n == 3 } {
-        scale set $values
-    }
-    set values [$dataobj get components.parallelepiped.origin]
-    set n [llength $values]
-    origin set { 0.0 0.0 0.0 }
-    if { $n == 1 } {
-        set origin(0) [lindex $values 0]
-    } elseif { $n == 2 } {
-        set origin(0) [lindex $values 0]
-        set origin(1) [lindex $values 1]
-    } elseif { $n == 3 } {
-        origin set $values
-    }
-
-    # Scale and translate points
-    for { set i 0 } { $i < 8 } { incr i } {
-        point${i} expr "(point${i} * scale) + origin"
-    }
-
-    # Generate vertices as a string for PyMOL
-    set vertices ""
-    foreach n { 0 1 0 2 0 3 1 4 2 4 2 6 1 7 3 7 5 7 4 5 3 6 5 } {
-        set values [point${n} range 0 end]
-        append vertices "\[ [join $values {, }] \], \\\n"
-    }
-    set values [point6 range 0 end]
-    append vertices "\[ [join $values {, }] \]  \\\n"
-    blt::vector destroy point0 point1 point2 point3 point4 point5 point6 \
-        point7 origin scale
-    return $vertices
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -device
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::MolvisViewer::device {
-    if {$itk_option(-device) != "" } {
-        if {![Rappture::library isvalid $itk_option(-device)]} {
-            error "bad value \"$itk_option(-device)\": should be Rappture::library object"
-        }
-        $this delete
-        $this add $itk_option(-device)
-    } else {
-        $this delete
-    }
-
-    if { [isconnected] } {
-        $_dispatcher event -idle !rebuild
-    }
-}
Index: trunk/gui/scripts/multichoiceentry.tcl
===================================================================
--- trunk/gui/scripts/multichoiceentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,327 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: MultiChoiceEntry - widget for entering a choice of strings
-#
-#  This widget represents a <multichoice> entry on a control panel.
-#  It is used to choose one of several mutually-exclusive strings.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::MultiChoiceEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-    destructor { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _rebuild {}
-    protected method _newValue {}
-    protected method _tooltip {}
-    protected method _log {}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-    private variable _str2val     ;# maps option label => option value
-}
-
-itk::usual MultiChoiceEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    itk_component add choice {
-        Rappture::Combochecks $itk_interior.choice -editable no \
-            -interactcommand [itcl::code $this _log]
-    }
-    pack $itk_component(choice) -expand yes -fill both
-    bind $itk_component(choice) <<Value>> [itcl::code $this _newValue]
-
-    eval itk_initialize $args
-
-    _rebuild
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::destructor {} {
-    $_owner notify remove $this
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [lindex $args 0]
-        if {[info exists _str2val($newval)]} {
-            # this is a label -- use it directly
-            $itk_component(choice) value $newval
-            set newval $_str2val($newval)  ;# report the actual value
-        } else {
-            # this is a value -- search for corresponding label
-            foreach str [array names _str2val] {
-                if {$_str2val($str) eq $newval} {
-                    $itk_component(choice) value $str
-                    break
-                }
-            }
-        }
-        return $newval
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    set result ""
-    set str [$itk_component(choice) value]
-    regsub -all {, } $str {,} str
-    foreach lbl [split $str {,}] {
-        if {[info exists _str2val($lbl)]} {
-            set lbl $_str2val($lbl)
-        }
-        lappend result $lbl
-    }
-    return [join $result {, }]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {"" == $label} {
-        set label "MultiChoice"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::tooltip {} {
-    # query tooltip on-demand based on current choice
-    return "@[itcl::code $this _tooltip]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _rebuild
-#
-# Used internally to rebuild the contents of this choice widget
-# whenever something that it depends on changes.  Scans through the
-# information in the XML spec and builds a list of choices for the
-# widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::_rebuild {} {
-    # get rid of any existing choices
-    $itk_component(choice) choices delete 0 end
-    catch {unset _str2val}
-
-    #
-    # Plug in the various options for the choice.
-    #
-    set max 10
-    foreach cname [$_owner xml children -type option $_path] {
-        set path [string trim [$_owner xml get $_path.$cname.path]]
-        if {"" != $path} {
-            # look for the input element controlling this path
-            set found 0
-            foreach cntl [Rappture::entities [$_owner xml object] "input"] {
-                set len [string length $cntl]
-                if {[string equal -length $len $cntl $path]} {
-                    set found 1
-                    break
-                }
-            }
-            if {$found} {
-                #
-                # Choice comes from a list of matching entities at
-                # a particular XML path.  Use the <label> as a template
-                # for each item on the path.
-                #
-                $_owner notify add $this $cntl [itcl::code $this _rebuild]
-
-                set label \
-                    [string trim [$_owner xml get $_path.$cname.about.label]]
-                if {"" == $label} {
-                    set label "%type #%n"
-                }
-
-                set ppath [Rappture::LibraryObj::path2list $path]
-                set leading [join [lrange $ppath 0 end-1] .]
-                set tail [lindex $ppath end]
-                set n 1
-                foreach ccname [$_owner xml children $leading] {
-                    if {[string match $tail $ccname]} {
-                        set subst(%n) $n
-                        set subst(%type) [$_owner xml element -as type $leading.$ccname]
-                        set subst(%id) [$_owner xml element -as id $leading.$ccname]
-                        foreach detail [$_owner xml children $leading.$ccname] {
-                            set subst(%$detail) \
-                                [$_owner xml get $leading.$ccname.$detail]
-                        }
-                        set str [string map [array get subst] $label]
-                        $itk_component(choice) choices insert end \
-                            $leading.$ccname $str
-                        incr n
-                    }
-                }
-                $itk_component(choice) value ""
-            } else {
-                puts "can't find controlling entity for path \"$path\""
-            }
-        } else {
-            #
-            # Choice is an ordinary LABEL.
-            # Add the label as-is into the list of choices.
-            #
-            set val [string trim [$_owner xml get $_path.$cname.value]]
-            set str [string trim [$_owner xml get $_path.$cname.about.label]]
-            if {"" == $val} {
-                set val $str
-            }
-            if {"" != $str} {
-                set _str2val($str) $val
-                $itk_component(choice) choices insert end $_path.$cname $str
-                set len [string length $str]
-                if {$len > $max} { set max $len }
-            }
-        }
-    }
-    $itk_component(choice) configure -width $max
-
-    #
-    # Assign the default value to this widget, if there is one.
-    #
-    set defvallist [$_owner xml get $_path.default]
-    if {"" != $defvallist} {
-        set v {}
-        foreach defval [split $defvallist {,}] {
-            set defval [string trim $defval]
-            if {[info exists _str2val($defval)]} {
-                lappend v $defval
-            } else {
-                foreach str [array names _str2val] {
-                    if {$_str2val($str) == $defval} {
-                        lappend v $str
-                        break
-                    }
-                }
-            }
-        }
-        if {[llength $v] > 0} {
-            $itk_component(choice) value $v
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _newValue
-#
-# Invoked automatically whenever the value in the choice changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::_newValue {} {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _tooltip
-#
-# Returns the tooltip for this widget, given the current choice in
-# the selector.  This is normally called by the Rappture::Tooltip
-# facility whenever it is about to pop up a tooltip for this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::_tooltip {} {
-    set tip [string trim [$_owner xml get $_path.about.description]]
-
-    # get the description for the current choice, if there is one
-    set str [$itk_component(choice) value]
-    set path [$itk_component(choice) translate $str]
-    set desc ""
-    if {$path != ""} {
-        set desc [string trim [$_owner xml get $path.about.description]]
-    }
-
-    if {[string length $str] > 0 && [string length $desc] > 0} {
-        append tip "\n\n$str:\n$desc"
-    }
-    return $tip
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _log
-#
-# Used internally to send info to the logging mechanism.  Calls the
-# Rappture::Logger mechanism to log the change to this input.
-# ----------------------------------------------------------------------
-itcl::body Rappture::MultiChoiceEntry::_log {} {
-    Rappture::Logger::log input $_path [$itk_component(choice) value]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::MultiChoiceEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(choice) configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/nanovisviewer.tcl
===================================================================
--- trunk/gui/scripts/nanovisviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,2186 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: nanovisviewer - 3D volume rendering
-#
-#  This widget performs volume rendering on 3D scalar/vector datasets.
-#  It connects to the Nanovis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-package require Img
-
-option add *NanovisViewer.width 4i widgetDefault
-option add *NanovisViewer*cursor crosshair widgetDefault
-option add *NanovisViewer.height 4i widgetDefault
-option add *NanovisViewer.foreground black widgetDefault
-option add *NanovisViewer.controlBackground gray widgetDefault
-option add *NanovisViewer.controlDarkBackground #999999 widgetDefault
-option add *NanovisViewer.plotBackground black widgetDefault
-option add *NanovisViewer.plotForeground white widgetDefault
-option add *NanovisViewer.plotOutline gray widgetDefault
-option add *NanovisViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc NanovisViewer_init_resources {} {
-    Rappture::resources::register \
-        nanovis_server Rappture::NanovisViewer::SetServerList
-}
-
-itcl::class Rappture::NanovisViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-    itk_option define -plotoutline plotOutline PlotOutline ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "nanovis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method limits { tf }
-    public method overMarker { m x }
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method removeDuplicateMarker { m x }
-    public method scale {args}
-    public method updateTransferFunctions {}
-
-    # The following methods are only used by this class.
-    private method AddIsoMarker { x y }
-    private method AdjustSetting {what {value ""}}
-    private method BuildCameraTab {}
-    private method BuildCutplanesTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildViewTab {}
-    private method BuildVolumeTab {}
-    private method ComputeTransferFunction { tf }
-    private method Connect {}
-    private method CurrentDatasets {{what -all}}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DrawLegend { tf }
-    private method EventuallyRedrawLegend { }
-    private method EventuallyResize { w h }
-    private method FixLegend {}
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method NameTransferFunction { dataobj comp }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method ParseLevelsOption { tf levels }
-    private method ParseMarkersOption { tf markers }
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveData { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { tf vmin vmax size }
-    private method ResetColormap { color }
-    private method Rotate {option x y}
-    private method SendTransferFunctions {}
-    private method SetOrientation { side }
-    private method Slice {option args}
-    private method SlicerTip {axis}
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _serverDatasets;   # contains all the dataobj-component
-                                        # to volumes in the server
-    private variable _recvdDatasets;    # list of data objs to send to server
-    private variable _dataset2style;    # maps dataobj-component to transfunc
-    private variable _style2datasets;   # maps tf back to list of
-                                        # dataobj-components using the tf.
-
-    private variable _reset 1;          # Connection to server has been reset.
-    private variable _click;            # Info used for rotate operations.
-    private variable _limits;           # Autoscale min/max for all axes
-    private variable _view;             # View params for 3D view
-    private variable _isomarkers;       # array of isosurface level values 0..1
-    # Array of transfer functions in server.  If 0 the transfer has been
-    # defined but not loaded.  If 1 the transfer function has been named
-    # and loaded.
-    private variable _activeTfs
-    private variable _settings
-    private variable _first "";         # This is the topmost volume.
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _resizeLegendPending 0
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual NanovisViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::constructor {args} {
-    set _serverType "nanovis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list"
-
-    # Send transfer functions event
-    $_dispatcher register !send_transfunc
-    $_dispatcher dispatch $this !send_transfunc \
-        "[itcl::code $this SendTransferFunctions]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias data [itcl::code $this ReceiveData]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    set _limits(vmin) 0.0
-    set _limits(vmax) 1.0
-
-    array set _settings [subst {
-        -axesvisible            1
-        -background             black
-        -colormap               "BCGYR"
-        -cutplanesvisible       0
-        -gridvisible            0
-        -isosurfaceshading      0
-        -legendvisible          1
-        -light                  40
-        -light2side             1
-        -opacity                50
-        -outlinevisible         0
-        -qw                     $_view(-qw)
-        -qx                     $_view(-qx)
-        -qy                     $_view(-qy)
-        -qz                     $_view(-qz)
-        -thickness              350
-        -volume                 1
-        -xcutplaneposition      50
-        -xcutplanevisible       0
-        -xpan                   $_view(-xpan)
-        -ycutplaneposition      50
-        -ycutplanevisible       0
-        -ypan                   $_view(-ypan)
-        -zcutplaneposition      50
-        -zcutplanevisible       0
-        -zoom                   $_view(-zoom)
-    }]
-
-    itk_component add view {
-        label $itk_component(plotarea).view -image $_image(plot) \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-    bind $itk_component(view) <Control-F1> [itcl::code $this ToggleConsole]
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add volume {
-        Rappture::PushButton $f.volume \
-            -onimage [Rappture::icon volume-on] \
-            -offimage [Rappture::icon volume-off] \
-            -variable [itcl::scope _settings(-volume)] \
-            -command [itcl::code $this AdjustSetting -volume]
-    }
-    $itk_component(volume) select
-    Rappture::Tooltip::for $itk_component(volume) \
-        "Toggle the volume cloud on/off"
-    pack $itk_component(volume) -padx 2 -pady 2
-
-    itk_component add cutplane {
-        Rappture::PushButton $f.cutplane \
-            -onimage [Rappture::icon cutbutton] \
-            -offimage [Rappture::icon cutbutton] \
-            -variable [itcl::scope _settings(-cutplanesvisible)] \
-            -command [itcl::code $this AdjustSetting -cutplanesvisible]
-    }
-    Rappture::Tooltip::for $itk_component(cutplane) \
-        "Show/Hide cutplanes"
-    #pack $itk_component(cutplane) -padx 2 -pady 2
-
-    if { [catch {
-        BuildViewTab
-        BuildVolumeTab
-        BuildCutplanesTab
-        BuildCameraTab
-    } errs] != 0 } {
-        global errorInfo
-        puts stderr "errs=$errs errorInfo=$errorInfo"
-    }
-
-    # Legend
-    set _image(legend) [image create photo]
-    itk_component add legend {
-        canvas $itk_component(plotarea).legend -height 50 -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -plotbackground plotBackground Background
-    }
-    bind $itk_component(legend) <Configure> \
-        [itcl::code $this EventuallyRedrawLegend]
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w \
-        1,0 $itk_component(legend) -fill x
-    blt::table configure $itk_component(plotarea) r1 -resize none
-
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-    bind $itk_component(view) <Configure> \
-        [itcl::code $this EventuallyResize %w %h]
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::destructor {} {
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !send_transfunc
-    $_dispatcher cancel !resize
-    image delete $_image(plot)
-    image delete $_image(legend)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-    array unset _settings
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::add {dataobj {settings ""}} {
-    if { ![$dataobj isvalid] } {
-        return;                         # Object doesn't contain valid data.
-    }
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-        set _obj2ovride($dataobj-color) $params(-color)
-        set _obj2ovride($dataobj-width) $params(-width)
-        set _obj2ovride($dataobj-raise) $params(-raise)
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-image view|legend?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist $_dlist
-            foreach dataobj $dlist {
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set i [lsearch -exact $dlist $dataobj]
-                    if {$i >= 0} {
-                        set dlist [lreplace $dlist $i $i]
-                        lappend dlist $dataobj
-                    }
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view|legend\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                legend {
-                    return $_image(legend)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view or legend"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos >= 0 } {
-            set _dlist [lreplace $_dlist $pos $pos]
-            array unset _obj2ovride $dataobj-*
-            set changed 1
-        }
-    }
-    # If anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::scale {args} {
-    foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} {
-        set _limits($val) ""
-    }
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                     # Object doesn't contain valid data.
-        }
-        foreach axis {x y z v} {
-            foreach { min max } [$dataobj limits $axis] break
-            if {"" != $min && "" != $max} {
-                if {"" == $_limits(${axis}min)} {
-                    set _limits(${axis}min) $min
-                    set _limits(${axis}max) $max
-                } else {
-                    if {$min < $_limits(${axis}min)} {
-                        set _limits(${axis}min) $min
-                    }
-                    if {$max > $_limits(${axis}max)} {
-                        set _limits(${axis}max) $max
-                    }
-                }
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .nanovisviewerdownload
-            if { ![winfo exists $popup] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            # FIXME: we only support download of current active component
-            #set num [llength [get]]
-            #set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set num "current field component"
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .nanovisviewerdownload
-            if { [winfo exists $popup] } {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-                default {
-                    error "bad download format \"$_downloadPopup(format)\""
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::Connect {} {
-    set _hosts [GetServerList "nanovis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "nanovisviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::NanovisViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::NanovisViewer::disconnect {} {
-    Disconnect
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::NanovisViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    # disconnected -- no more data sitting on server
-    array unset _serverDatasets
-}
-
-# ----------------------------------------------------------------------
-# USAGE: SendTransferFunctions
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::SendTransferFunctions {} {
-    if { $_first == "" } {
-        puts stderr "first not set"
-        return
-    }
-    # Ensure that the global thickness setting (in the slider
-    # settings widget) is used for the active transfer-function.  Update
-    # the value in the _settings variable.
-    # Scale values between 0.00001 and 0.01000
-    set thickness [expr {double($_settings(-thickness)) * 0.0001}]
-
-    foreach tag [CurrentDatasets] {
-        if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } {
-            # The volume hasn't reached the server yet.  How did we get
-            # here?
-            puts stderr "Don't have $tag in _serverDatasets"
-            continue
-        }
-        if { ![info exists _dataset2style($tag)] } {
-            puts stderr "don't have style for volume $tag"
-            continue;                        # How does this happen?
-        }
-        set tf $_dataset2style($tag)
-        set _settings($tf-thickness) $thickness
-        ComputeTransferFunction $tf
-        # FIXME: Need to the send information as to what transfer functions
-        #        to update so that we only update the transfer function
-        #        as necessary.  Right now, all transfer functions are
-        #        updated. This makes moving the isomarker slider chunky.
-        if { ![info exists _activeTfs($tf)] || !$_activeTfs($tf) } {
-            set _activeTfs($tf) 1
-        }
-        SendCmd "volume shading transfunc $tf $tag"
-    }
-    FixLegend
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::ReceiveImage { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    switch -- $info(-type) {
-        "image" {
-            #puts stderr "received image [image width $_image(plot)]x[image height $_image(plot)]"
-            $_image(plot) configure -data $bytes
-        }
-        "print" {
-            set tag $this-print-$info(-token)
-            set _hardcopy($tag) $bytes
-        }
-        default {
-            puts stderr "unknown image type $info(-type)"
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-itcl::body Rappture::NanovisViewer::DrawLegend { tf } {
-    set c $itk_component(legend)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set lx 10
-    set ly [expr {$h - 1}]
-    if {"" == [$c find withtag colorbar]} {
-        $c create image 10 10 -anchor nw \
-            -image $_image(legend) -tags colorbar
-        $c create text $lx $ly -anchor sw \
-            -fill $itk_option(-plotforeground) -tags "limits text vmin"
-        $c create text [expr {$w-$lx}] $ly -anchor se \
-            -fill $itk_option(-plotforeground) -tags "limits text vmax"
-        $c create text [expr {$w/2}] $ly -anchor s \
-            -fill $itk_option(-plotforeground) -tags "title text"
-        $c lower colorbar
-        $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y]
-    }
-
-    # Display the markers used by the current transfer function.
-    array set limits [limits $tf]
-    $c itemconfigure vmin -text [format %g $limits(min)]
-    $c coords vmin $lx $ly
-
-    $c itemconfigure vmax -text [format %g $limits(max)]
-    $c coords vmax [expr {$w-$lx}] $ly
-
-    if { $_first == "" } {
-        return
-    }
-    set title [$_first hints label]
-    set units [$_first hints units]
-    if { $units != "" } {
-        set title "$title ($units)"
-    }
-    $c itemconfigure title -text $title
-    $c coords title [expr {$w/2}] $ly
-
-    if { [info exists _isomarkers($tf)] } {
-        # The "visible" isomarker method below implicitly calls "absval".
-        # It uses the screen position of the marker to compute the absolute
-        # value.  So make sure the window size has been computed before
-        # calling "visible".
-        update idletasks
-        update 
-        foreach m $_isomarkers($tf) {
-            $m visible yes
-        }
-    }
-
-    # The colormap may have changed. Resync the slicers with the colormap.
-    set datasets [CurrentDatasets -cutplanes]
-    SendCmd "volume data state $_settings(-volume) $datasets"
-
-    # Adjust the cutplane for only the first component in the topmost volume
-    # (i.e. the first volume designated in the field).
-    set tag [lindex $datasets 0]
-    foreach axis {x y z} {
-        # Turn off cutplanes for all volumes
-        SendCmd "cutplane state 0 $axis"
-        if { $_settings(-${axis}cutplanevisible) } {
-            # Turn on cutplane for this particular volume and set the position
-            SendCmd "cutplane state 1 $axis $tag"
-            set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}]
-            SendCmd "cutplane position $pos $axis $tag"
-        }
-    }
-}
-
-#
-# ReceiveLegend --
-#
-# The procedure is the response from the render server to each "legend"
-# command.  The server sends back a "legend" command invoked our
-# the slave interpreter.  The purpose is to collect data of the image
-# representing the legend in the canvas.  In addition, the
-# active transfer function is displayed.
-#
-itcl::body Rappture::NanovisViewer::ReceiveLegend { tf vmin vmax size } {
-    if { ![isconnected] } {
-        return
-    }
-    set bytes [ReceiveBytes $size]
-    $_image(legend) configure -data $bytes
-    ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-
-    DrawLegend $tf
-}
-
-#
-# ReceiveData --
-#
-# The procedure is the response from the render server to each "data
-# follows" command.  The server sends back a "data" command invoked our
-# the slave interpreter.  The purpose is to collect the min/max of the
-# volume sent to the render server.  Since the client (nanovisviewer)
-# doesn't parse 3D data formats, we rely on the server (nanovis) to
-# tell us what the limits are.  Once we've received the limits to all
-# the data we've sent (tracked by _recvdDatasets) we can then determine
-# what the transfer functions are for these volumes.
-#
-#
-#       Note: There is a considerable tradeoff in having the server report
-#             back what the data limits are.  It means that much of the code
-#             having to do with transfer-functions has to wait for the data
-#             to come back, since the isomarkers are calculated based upon
-#             the data limits.  The client code is much messier because of
-#             this.  The alternative is to parse any of the 3D formats on the
-#             client side.
-#
-itcl::body Rappture::NanovisViewer::ReceiveData { args } {
-    if { ![isconnected] } {
-        return
-    }
-
-    # Arguments from server are name value pairs. Stuff them in an array.
-    array set info $args
-
-    set tag $info(tag)
-    set parts [split $tag -]
-
-    #
-    # Volumes don't exist until we're told about them.
-    #
-    set dataobj [lindex $parts 0]
-    set _serverDatasets($tag) 1
-    if { $_settings(-volume) && $dataobj == $_first } {
-        SendCmd "volume state 1 $tag"
-    }
-    set _limits($tag-min)  $info(min);  # Minimum value of the volume.
-    set _limits($tag-max)  $info(max);  # Maximum value of the volume.
-    set _limits(vmin)      $info(vmin); # Overall minimum value.
-    set _limits(vmax)      $info(vmax); # Overall maximum value.
-
-    unset _recvdDatasets($tag)
-    if { [array size _recvdDatasets] == 0 } {
-        # The active transfer function is by default the first component of
-        # the first data object.  This assumes that the data is always
-        # successfully transferred.
-        updateTransferFunctions
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    # Hide all the isomarkers. Can't remove them. Have to remember the
-    # settings since the user may have created/deleted/moved markers.
-
-    # The "visible" isomarker method below implicitly calls "absval".  It
-    # uses the screen position of the marker to compute the absolute value.
-    # So make sure the window size has been computed before calling
-    # "visible".
-    update idletasks
-    update 
-    foreach tf [array names _isomarkers] {
-        foreach m $_isomarkers($tf) {
-            $m visible no
-        }
-    }
-
-    if { $_width != $w || $_height != $h || $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-    }
-    if { $_reset } {
-        InitSettings -background -axesvisible -gridvisible
-    }
-    foreach dataobj [get] {
-        foreach cname [$dataobj components] {
-            set tag $dataobj-$cname
-            if { ![info exists _serverDatasets($tag)] } {
-                # Send the data as one huge base64-encoded mess -- yuck!
-                if { [$dataobj type] == "dx" } {
-                    set data [$dataobj blob $cname]
-                } else {
-                    set data [$dataobj vtkdata $cname]
-                    if 0 {
-                        set f [open "/tmp/volume.vtk" "w"]
-                        fconfigure $f -translation binary -encoding binary
-                        puts -nonewline $f $data
-                        close $f
-                    }
-                }
-                set nbytes [string length $data]
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $nbytes
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "volume data follows $nbytes $tag"
-                SendData $data
-                set _recvdDatasets($tag) 1
-                set _serverDatasets($tag) 0
-            }
-            NameTransferFunction $dataobj $cname
-        }
-    }
-    set _first [lindex [get] 0]
-    # Outline seems to need to be reset every update.
-    InitSettings -outlinevisible ;#-cutplanesvisible
-    if { $_reset } {
-        #
-        # Reset the camera and other view parameters
-        #
-        set _settings(-qw)    $_view(-qw)
-        set _settings(-qx)    $_view(-qx)
-        set _settings(-qy)    $_view(-qy)
-        set _settings(-qz)    $_view(-qz)
-        set _settings(-xpan)  $_view(-xpan)
-        set _settings(-ypan)  $_view(-ypan)
-        set _settings(-zoom)  $_view(-zoom)
-
-        set q [ViewToQuaternion]
-        $_arcball quaternion $q
-        SendCmd "camera orient $q"
-        SendCmd "camera reset"
-        PanCamera
-        SendCmd "camera zoom $_view(-zoom)"
-
-        # Turn off cutplanes for all volumes
-        foreach axis {x y z} {
-            SendCmd "cutplane state 0 $axis"
-        }
-
-        InitSettings -opacity -light2side -isosurfaceshading \
-            -light \
-            -xcutplanevisible -ycutplanevisible -zcutplanevisible
-
-        if {"" != $_first} {
-            set axis [$_first hints updir]
-            if { "" != $axis } {
-                SendCmd "up $axis"
-            }
-            set location [$_first hints camera]
-            if { $location != "" } {
-                array set _view $location
-            }
-        }
-        set _reset 0
-    }
-
-    # nothing to send -- activate the proper ivol
-    SendCmd "volume state 0"
-    if {"" != $_first} {
-        set datasets [array names _serverDatasets $_first-*]
-        if { $datasets != "" } {
-            SendCmd "volume state 1 $datasets"
-        }
-        # If the first volume already exists on the server, then make sure
-        # we display the proper transfer function in the legend.
-        set cname [lindex [$_first components] 0]
-        if { [info exists _serverDatasets($_first-$cname)] } {
-            updateTransferFunctions
-        }
-    }
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-cutplanes?
-#
-# Returns a list of volume server IDs for the current volume being
-# displayed.  This is normally a single ID, but it might be a list
-# of IDs if the current data object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::CurrentDatasets {{what -all}} {
-    set rlist ""
-    if { $_first == "" } {
-        return
-    }
-    foreach cname [$_first components] {
-        set tag $_first-$cname
-        if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } {
-            array set style {
-                -cutplanes 1
-            }
-            array set style [lindex [$_first components -style $cname] 0]
-            if { $what != "-cutplanes" || $style(-cutplanes) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            set _settings(-zoom) $_view(-zoom)
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            set _settings(-zoom) $_view(-zoom)
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            set q [ViewToQuaternion]
-            $_arcball quaternion $q
-            SendCmd "camera orient $q"
-            SendCmd "camera reset"
-            set _settings(-qw)    $_view(-qw)
-            set _settings(-qx)    $_view(-qx)
-            set _settings(-qy)    $_view(-qy)
-            set _settings(-qz)    $_view(-qz)
-            set _settings(-xpan)  $_view(-xpan)
-            set _settings(-ypan)  $_view(-ypan)
-            set _settings(-zoom)  $_view(-zoom)
-        }
-    }
-}
-
-itcl::body Rappture::NanovisViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::Rotate {option x y} {
-    switch -- $option {
-        click {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        drag {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                QuaternionToView $q
-                set _settings(-qw) $_view(-qw)
-                set _settings(-qx) $_view(-qx)
-                set _settings(-qy) $_view(-qy)
-                set _settings(-qz) $_view(-qz)
-                SendCmd "camera orient $q"
-
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        release {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::Pan {option x y} {
-    # Experimental stuff
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $option == "set" } {
-        set x [expr $x / double($w)]
-        set y [expr $y / double($h)]
-        set _view(-xpan) [expr $_view(-xpan) + $x]
-        set _view(-ypan) [expr $_view(-ypan) + $y]
-        PanCamera
-        set _settings(-xpan) $_view(-xpan)
-        set _settings(-ypan) $_view(-ypan)
-        return
-    }
-    if { $option == "click" } {
-        set _click(x) $x
-        set _click(y) $y
-        $itk_component(view) configure -cursor hand1
-    }
-    if { $option == "drag" || $option == "release" } {
-        set dx [expr ($_click(x) - $x)/double($w)]
-        set dy [expr ($_click(y) - $y)/double($h)]
-        set _click(x) $x
-        set _click(y) $y
-        set _view(-xpan) [expr $_view(-xpan) - $dx]
-        set _view(-ypan) [expr $_view(-ypan) - $dy]
-        PanCamera
-        set _settings(-xpan) $_view(-xpan)
-        set _settings(-ypan) $_view(-ypan)
-    }
-    if { $option == "release" } {
-        $itk_component(view) configure -cursor ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::InitSettings { args } {
-    foreach arg $args {
-        AdjustSetting $arg
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: AdjustSetting <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::AdjustSetting {what {value ""}} {
-    if {![isconnected]} {
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            SendCmd "axis visible $_settings($what)"
-        }
-        "-background" {
-            set bgcolor [$itk_component(background) value]
-            array set fgcolors {
-                "black" "white"
-                "white" "black"
-                "grey"  "black"
-            }
-            configure -plotbackground $bgcolor \
-                -plotforeground $fgcolors($bgcolor)
-            #DrawLegend $_current
-        }
-        "-colormap" {
-            set color [$itk_component(colormap) value]
-            set _settings($what) $color
-            # Only set the colormap on the first volume. Ignore the others.
-            #ResetColormap $color
-        }
-        "-cutplanesvisible" {
-            set bool $_settings($what)
-            # We only set cutplanes on the first dataset.
-            set datasets [CurrentDatasets -cutplanes]
-            set tag [lindex $datasets 0]
-            SendCmd "cutplane visible $bool $tag"
-        }
-        "-gridvisible" {
-            SendCmd "grid visible $_settings($what)"
-        }
-        "-isosurfaceshading" {
-            set val $_settings($what)
-            SendCmd "volume shading isosurface $val"
-        }
-        "-legendvisible" {
-            if { $_settings($what) } {
-                blt::table $itk_component(plotarea) \
-                    0,0 $itk_component(view) -fill both \
-                    1,0 $itk_component(legend) -fill x
-                blt::table configure $itk_component(plotarea) r1 -resize none
-            } else {
-                blt::table forget $itk_component(legend)
-            }
-        }
-        "-light" {
-            set val $_settings($what)
-            set diffuse [expr {0.01*$val}]
-            set ambient [expr {1.0-$diffuse}]
-            set specularLevel 0.3
-            set specularExp 90.0
-            SendCmd "volume shading ambient $ambient"
-            SendCmd "volume shading diffuse $diffuse"
-            SendCmd "volume shading specularLevel $specularLevel"
-            SendCmd "volume shading specularExp $specularExp"
-        }
-        "-light2side" {
-            set val $_settings($what)
-            SendCmd "volume shading light2side $val"
-        }
-        "-opacity" {
-            set val $_settings($what)
-            set sval [expr { 0.01 * double($val) }]
-            SendCmd "volume shading opacity $sval"
-        }
-        "-outlinevisible" {
-            SendCmd "volume outline state $_settings($what)"
-        }
-        "-thickness" {
-            if { [array names _activeTfs] > 0 } {
-                set val $_settings($what)
-                # Scale values between 0.00001 and 0.01000
-                set sval [expr {0.0001*double($val)}]
-                foreach tf [array names _activeTfs] {
-                    set _settings($tf${what}) $sval
-                    set _activeTfs($tf) 0
-                }
-                updateTransferFunctions
-            }
-        }
-        "-volume" {
-            set datasets [CurrentDatasets -cutplanes]
-            SendCmd "volume data state $_settings($what) $datasets"
-        }
-        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
-            set axis [string range $what 1 1]
-            set pos [expr $_settings($what) * 0.01]
-            # We only set cutplanes on the first dataset.
-            set datasets [CurrentDatasets -cutplanes]
-            set tag [lindex $datasets 0]
-            SendCmd "cutplane position $pos $axis $tag"
-        }
-        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
-            set axis [string range $what 1 1]
-            set bool $_settings($what)
-            # We only set cutplanes on the first dataset.
-            set datasets [CurrentDatasets -cutplanes]
-            set tag [lindex $datasets 0]
-            SendCmd "cutplane state $bool $axis $tag"
-            if { $bool } {
-                $itk_component(${axis}CutScale) configure -state normal \
-                    -troughcolor white
-            } else {
-                $itk_component(${axis}CutScale) configure -state disabled \
-                    -troughcolor grey82
-            }
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: FixLegend
-#
-# Used internally to update the legend area whenever it changes size
-# or when the field changes.  Asks the server to send a new legend
-# for the current field.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::FixLegend {} {
-    set _resizeLegendPending 0
-    set lineht [font metrics $itk_option(-font) -linespace]
-    set w [expr {$_width-20}]
-    set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
-    if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } {
-        set tag [lindex [CurrentDatasets] 0]
-        if { [info exists _dataset2style($tag)] } {
-            SendCmd "legend $_dataset2style($tag) $w $h"
-        }
-    }
-}
-
-#
-# NameTransferFunction --
-#
-# Creates a transfer function name based on the <style> settings in the
-# library run.xml file. This placeholder will be used later to create
-# and send the actual transfer function once the data info has been sent
-# to us by the render server. [We won't know the volume limits until the
-# server parses the 3D data and sends back the limits via ReceiveData.]
-#
-#       FIXME: The current way we generate transfer-function names completely
-#              ignores the -markers option.  The problem is that we are forced
-#              to compute the name from an increasing complex set of values:
-#              color, levels, markers.
-#
-itcl::body Rappture::NanovisViewer::NameTransferFunction { dataobj cname } {
-    array set style {
-        -color BCGYR
-        -levels 6
-    }
-    set tag $dataobj-$cname
-    array set style [lindex [$dataobj components -style $cname] 0]
-    set tf "$style(-color):$style(-levels)"
-    set _dataset2style($tag) $tf
-    lappend _style2datasets($tf) $tag
-    return $tf
-}
-
-#
-# ComputeTransferFunction --
-#
-# Computes and sends the transfer function to the render server.  It's
-# assumed that the volume data limits are known and that the global
-# transfer-functions slider values have been set up.  Both parts are
-# needed to compute the relative value (location) of the marker, and
-# the alpha map of the transfer function.
-#
-itcl::body Rappture::NanovisViewer::ComputeTransferFunction { tf } {
-    array set style {
-        -color BCGYR
-        -levels 6
-    }
-
-    foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break
-    array set style [lindex [$dataobj components -style $cname] 0]
-
-    # We have to parse the style attributes for a volume using this
-    # transfer-function *once*.  This sets up the initial isomarkers for the
-    # transfer function.  The user may add/delete markers, so we have to
-    # maintain a list of markers for each transfer-function.  We use the one
-    # of the volumes (the first in the list) using the transfer-function as a
-    # reference.
-    #
-    # FIXME: The current way we generate transfer-function names completely
-    #        ignores the -markers option.  The problem is that we are forced
-    #        to compute the name from an increasing complex set of values:
-    #        color, levels, markers.
-    if { ![info exists _isomarkers($tf)] } {
-        # Have to defer creation of isomarkers until we have data limits
-        if { [info exists style(-markers)] &&
-             [llength $style(-markers)] > 0 } {
-            ParseMarkersOption $tf $style(-markers)
-        } else {
-            ParseLevelsOption $tf $style(-levels)
-        }
-    }
-    set cmap [ColorsToColormap $style(-color)]
-
-    # Transfer function should be normalized with [0,1] range
-    # The volume shading opacity setting is used to scale opacity
-    # in the volume shader.
-    set max 1.0
-
-    set isovalues {}
-    foreach m $_isomarkers($tf) {
-        lappend isovalues [$m relval]
-    }
-    # Sort the isovalues
-    set isovalues [lsort -real $isovalues]
-
-    if { ![info exists _settings($tf-thickness)]} {
-        set _settings($tf-thickness) 0.005
-    }
-    set delta $_settings($tf-thickness)
-
-    set first [lindex $isovalues 0]
-    set last [lindex $isovalues end]
-    set amap ""
-    if { $first == "" || $first != 0.0 } {
-        lappend amap 0.0 0.0
-    }
-    foreach x $isovalues {
-        set x1 [expr {$x-$delta-0.00001}]
-        set x2 [expr {$x-$delta}]
-        set x3 [expr {$x+$delta}]
-        set x4 [expr {$x+$delta+0.00001}]
-        if { $x1 < 0.0 } {
-            set x1 0.0
-        } elseif { $x1 > 1.0 } {
-            set x1 1.0
-        }
-        if { $x2 < 0.0 } {
-            set x2 0.0
-        } elseif { $x2 > 1.0 } {
-            set x2 1.0
-        }
-        if { $x3 < 0.0 } {
-            set x3 0.0
-        } elseif { $x3 > 1.0 } {
-            set x3 1.0
-        }
-        if { $x4 < 0.0 } {
-            set x4 0.0
-        } elseif { $x4 > 1.0 } {
-            set x4 1.0
-        }
-        # add spikes in the middle
-        lappend amap $x1 0.0
-        lappend amap $x2 $max
-        lappend amap $x3 $max
-        lappend amap $x4 0.0
-    }
-    if { $last == "" || $last != 1.0 } {
-        lappend amap 1.0 0.0
-    }
-    SendCmd "transfunc define $tf { $cmap } { $amap }"
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::NanovisViewer::plotbackground {
-    if { [isconnected] } {
-        set color $itk_option(-plotbackground)
-        set rgb [Color2RGB $color]
-        SendCmd "screen bgcolor $rgb"
-        $itk_component(legend) configure -background $color
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::NanovisViewer::plotforeground {
-    if { [isconnected] } {
-        set color $itk_option(-plotforeground)
-        set rgb [Color2RGB $color]
-        SendCmd "volume outline color $rgb"
-        SendCmd "grid axiscolor $rgb"
-        SendCmd "grid linecolor $rgb"
-        $itk_component(legend) itemconfigure text -fill $color
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotoutline
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::NanovisViewer::plotoutline {
-    # Must check if we are connected because this routine is called from the
-    # class body when the -plotoutline itk_option is defined.  At that point
-    # the NanovisViewer class constructor hasn't been called, so we can't
-    # start sending commands to visualization server.
-    if { [isconnected] } {
-        if {"" == $itk_option(-plotoutline)} {
-            SendCmd "volume outline state off"
-        } else {
-            SendCmd "volume outline state on"
-            SendCmd "volume outline color [Color2RGB $itk_option(-plotoutline)]"
-        }
-    }
-}
-
-#
-# The -levels option takes a single value that represents the number
-# of evenly distributed markers based on the current data range. Each
-# marker is a relative value from 0.0 to 1.0.
-#
-itcl::body Rappture::NanovisViewer::ParseLevelsOption { tf levels } {
-    set c $itk_component(legend)
-    regsub -all "," $levels " " levels
-    if {[string is int $levels]} {
-        for {set i 1} { $i <= $levels } {incr i} {
-            set x [expr {double($i)/($levels+1)}]
-            set m [Rappture::IsoMarker \#auto $c $this $tf]
-            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-            $m relval $x
-            lappend _isomarkers($tf) $m
-        }
-    } else {
-        foreach x $levels {
-            set m [Rappture::IsoMarker \#auto $c $this $tf]
-            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-            $m relval $x
-            lappend _isomarkers($tf) $m
-        }
-    }
-}
-
-#
-# The -markers option takes a list of zero or more values (the values
-# may be separated either by spaces or commas) that have the following
-# format:
-#
-#   N%  Percent of current total data range.  Converted to
-#       to a relative value between 0.0 and 1.0.
-#   N   Absolute value of marker.  If the marker is outside of
-#       the current range, it will be displayed on the outer
-#       edge of the legends, but it range it represents will
-#       not be seen.
-#
-itcl::body Rappture::NanovisViewer::ParseMarkersOption { tf markers } {
-    set c $itk_component(legend)
-    regsub -all "," $markers " " markers
-    foreach marker $markers {
-        set n [scan $marker "%g%s" value suffix]
-        if { $n == 2 && $suffix == "%" } {
-            # ${n}% : Set relative value.
-            set value [expr {$value * 0.01}]
-            set m [Rappture::IsoMarker \#auto $c $this $tf]
-            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-            $m relval $value
-            lappend _isomarkers($tf) $m
-        } else {
-            # ${n} : Set absolute value.
-            set m [Rappture::IsoMarker \#auto $c $this $tf]
-            $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-            $m absval $value
-            lappend _isomarkers($tf) $m
-        }
-    }
-}
-
-itcl::body Rappture::NanovisViewer::updateTransferFunctions {} {
-    $_dispatcher event -idle !send_transfunc
-}
-
-itcl::body Rappture::NanovisViewer::AddIsoMarker { x y } {
-    if { $_first == "" } {
-        error "active transfer function isn't set"
-    }
-    set tag [lindex [CurrentDatasets] 0]
-    set tf $_dataset2style($tag)
-    set c $itk_component(legend)
-    set m [Rappture::IsoMarker \#auto $c $this $tf]
-    $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground)
-    set w [winfo width $c]
-    $m relval [expr {double($x-10)/($w-20)}]
-    lappend _isomarkers($tf) $m
-    updateTransferFunctions
-    return 1
-}
-
-itcl::body Rappture::NanovisViewer::removeDuplicateMarker { marker x } {
-    set tf [$marker transferfunc]
-    set bool 0
-    if { [info exists _isomarkers($tf)] } {
-        set list {}
-        set marker [namespace tail $marker]
-        foreach m $_isomarkers($tf) {
-            set sx [$m screenpos]
-            if { $m != $marker } {
-                if { $x >= ($sx-3) && $x <= ($sx+3) } {
-                    $marker relval [$m relval]
-                    itcl::delete object $m
-                    bell
-                    set bool 1
-                    continue
-                }
-            }
-            lappend list $m
-        }
-        set _isomarkers($tf) $list
-        updateTransferFunctions
-    }
-    return $bool
-}
-
-itcl::body Rappture::NanovisViewer::overMarker { marker x } {
-    set tf [$marker transferfunc]
-    if { [info exists _isomarkers($tf)] } {
-        set marker [namespace tail $marker]
-        foreach m $_isomarkers($tf) {
-            set sx [$m screenpos]
-            if { $m != $marker } {
-                set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }]
-                $m activate $bool
-            }
-        }
-    }
-    return ""
-}
-
-itcl::body Rappture::NanovisViewer::limits { tf } {
-    set _limits(min) 0.0
-    set _limits(max) 1.0
-    if { ![info exists _style2datasets($tf)] } {
-        return [array get _limits]
-    }
-    set min ""; set max ""
-    foreach tag $_style2datasets($tf) {
-        if { ![info exists _serverDatasets($tag)] } {
-            continue
-        }
-        if { ![info exists _limits($tag-min)] } {
-            continue
-        }
-        if { $min == "" || $min > $_limits($tag-min) } {
-            set min $_limits($tag-min)
-        }
-        if { $max == "" || $max < $_limits($tag-max) } {
-            set max $_limits($tag-max)
-        }
-    }
-    if { $min != "" } {
-        set _limits(min) $min
-    }
-    if { $max != "" } {
-        set _limits(max) $max
-    }
-    return [array get _limits]
-}
-
-itcl::body Rappture::NanovisViewer::BuildViewTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "View Settings" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.axes \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.grid \
-        -text "Grid" \
-        -variable [itcl::scope _settings(-gridvisible)] \
-        -command [itcl::code $this AdjustSetting -gridvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.outline \
-        -text "Outline" \
-        -variable [itcl::scope _settings(-outlinevisible)] \
-        -command [itcl::code $this AdjustSetting -outlinevisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.legend \
-        -text "Legend" \
-        -variable [itcl::scope _settings(-legendvisible)] \
-        -command [itcl::code $this AdjustSetting -legendvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.volume \
-        -text "Volume" \
-        -variable [itcl::scope _settings(-volume)] \
-        -command [itcl::code $this AdjustSetting -volume] \
-        -font "Arial 9"
-
-    label $inner.background_l -text "Background" -font "Arial 9"
-    itk_component add background {
-        Rappture::Combobox $inner.background -width 10 -editable no
-    }
-    $inner.background choices insert end \
-        "black" "black" \
-        "white" "white" \
-        "grey"  "grey"
-
-    $itk_component(background) value $_settings(-background)
-    bind $inner.background <<Value>> \
-        [itcl::code $this AdjustSetting -background]
-
-    blt::table $inner \
-        0,0 $inner.axes -cspan 2 -anchor w \
-        1,0 $inner.grid -cspan 2 -anchor w \
-        2,0 $inner.outline -cspan 2 -anchor w \
-        3,0 $inner.volume -cspan 2 -anchor w \
-        4,0 $inner.legend -cspan 2 -anchor w \
-        5,0 $inner.background_l -anchor e -pady 2 \
-        5,1 $inner.background -fill x
-
-    blt::table configure $inner r* -resize none
-    blt::table configure $inner r6 -resize expand
-}
-
-itcl::body Rappture::NanovisViewer::BuildVolumeTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Volume Settings" \
-        -icon [Rappture::icon volume-on]]
-    $inner configure -borderwidth 4
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    checkbutton $inner.vol -text "Show volume" -font $fg \
-        -variable [itcl::scope _settings(-volume)] \
-        -command [itcl::code $this AdjustSetting -volume]
-    label $inner.shading -text "Shading:" -font $fg
-
-    checkbutton $inner.isosurface -text "Isosurface shading" -font $fg \
-        -variable [itcl::scope _settings(-isosurfaceshading)] \
-        -command [itcl::code $this AdjustSetting -isosurfaceshading]
-
-    checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \
-        -variable [itcl::scope _settings(-light2side)] \
-        -command [itcl::code $this AdjustSetting -light2side]
-
-    label $inner.dim -text "Glow" -font $fg
-    ::scale $inner.light -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-light)] \
-        -width 10 \
-        -showvalue off -command [itcl::code $this AdjustSetting -light]
-    label $inner.bright -text "Surface" -font $fg
-
-    # Opacity
-    label $inner.clear -text "Clear" -font $fg
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-opacity)] \
-        -width 10 \
-        -showvalue off -command [itcl::code $this AdjustSetting -opacity]
-    label $inner.opaque -text "Opaque" -font $fg
-
-    # Tooth thickness
-    label $inner.thin -text "Thin" -font $fg
-    ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \
-        -variable [itcl::scope _settings(-thickness)] \
-        -width 10 \
-        -showvalue off -command [itcl::code $this AdjustSetting -thickness]
-    label $inner.thick -text "Thick" -font $fg
-
-    # Colormap
-    label $inner.colormap_l -text "Colormap" -font "Arial 9"
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable no
-    }
-
-    $inner.colormap choices insert end [GetColormapList -includeNone]
-    $itk_component(colormap) value "BCGYR"
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -colormap]
-
-    blt::table $inner \
-        0,0 $inner.vol -cspan 4 -anchor w -pady 2 \
-        1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \
-        2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \
-        3,0 $inner.dim -anchor e -pady 2 \
-        3,1 $inner.light -cspan 2 -pady 2 -fill x \
-        3,3 $inner.bright -anchor w -pady 2 \
-        4,0 $inner.clear -anchor e -pady 2 \
-        4,1 $inner.opacity -cspan 2 -pady 2 -fill x \
-        4,3 $inner.opaque -anchor w -pady 2 \
-        5,0 $inner.thin -anchor e -pady 2 \
-        5,1 $inner.thickness -cspan 2 -pady 2 -fill x\
-        5,3 $inner.thick -anchor w -pady 2
-
-    blt::table configure $inner c0 c1 c3 r* -resize none
-    blt::table configure $inner r6 -resize expand
-}
-
-itcl::body Rappture::NanovisViewer::BuildCutplanesTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Cutplane Settings" \
-        -icon [Rappture::icon cutbutton]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Show Cutplanes" \
-        -variable [itcl::scope _settings(-cutplanesvisible)] \
-        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
-        -font "Arial 9"
-
-    # X-value slicer...
-    itk_component add xCutButton {
-        Rappture::PushButton $inner.xbutton \
-            -onimage [Rappture::icon x-cutplane] \
-            -offimage [Rappture::icon x-cutplane] \
-            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
-            -variable [itcl::scope _settings(-xcutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(xCutButton) \
-        "Toggle the X cut plane on/off"
-    #$itk_component(xCutButton) select
-
-    itk_component add xCutScale {
-        ::scale $inner.xval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue off \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move x] \
-            -variable [itcl::scope _settings(-xcutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(xCutScale) set 50
-    $itk_component(xCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(xCutScale) \
-        "@[itcl::code $this SlicerTip x]"
-
-    # Y-value slicer...
-    itk_component add yCutButton {
-        Rappture::PushButton $inner.ybutton \
-            -onimage [Rappture::icon y-cutplane] \
-            -offimage [Rappture::icon y-cutplane] \
-            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
-            -variable [itcl::scope _settings(-ycutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(yCutButton) \
-        "Toggle the Y cut plane on/off"
-    #$itk_component(yCutButton) select
-
-    itk_component add yCutScale {
-        ::scale $inner.yval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue off \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move y] \
-            -variable [itcl::scope _settings(-ycutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    Rappture::Tooltip::for $itk_component(yCutScale) \
-        "@[itcl::code $this SlicerTip y]"
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(yCutScale) set 50
-    $itk_component(yCutScale) configure -state disabled
-
-    # Z-value slicer...
-    itk_component add zCutButton {
-        Rappture::PushButton $inner.zbutton \
-            -onimage [Rappture::icon z-cutplane] \
-            -offimage [Rappture::icon z-cutplane] \
-            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
-            -variable [itcl::scope _settings(-zcutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(zCutButton) \
-        "Toggle the Z cut plane on/off"
-    #$itk_component(zCutButton) select
-
-    itk_component add zCutScale {
-        ::scale $inner.zval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue off \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move z] \
-            -variable [itcl::scope _settings(-zcutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    $itk_component(zCutScale) set 50
-    $itk_component(zCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(zCutScale) \
-        "@[itcl::code $this SlicerTip z]"
-
-    blt::table $inner \
-        0,1 $itk_component(xCutScale) \
-        0,2 $itk_component(yCutScale) \
-        0,3 $itk_component(zCutScale) \
-        1,1 $itk_component(xCutButton) \
-        1,2 $itk_component(yCutButton) \
-        1,3 $itk_component(zCutButton)
-
-    #    0,1 $inner.visible -anchor w -pady 2 -cspan 4 \
-
-    blt::table configure $inner r0 r1 r2 c* -resize none
-    blt::table configure $inner r3 c4 -resize expand
-    blt::table configure $inner c0 -width 2
-    blt::table configure $inner c1 c2 c3 -padx 2
-}
-
-itcl::body Rappture::NanovisViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set row 1
-    set labels { qw qx qy qz xpan ypan zoom }
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _settings(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Slice move x|y|z <newval>
-#
-# Called automatically when the user drags the slider to move the
-# cut plane that slices 3D data.  Gets the current value from the
-# slider and moves the cut plane to the appropriate point in the
-# data set.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::Slice {option args} {
-    switch -- $option {
-        move {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Slice move x|y|z newval\""
-            }
-            set axis [lindex $args 0]
-            set newval [lindex $args 1]
-
-            set newpos [expr {0.01*$newval}]
-            set datasets [CurrentDatasets -cutplanes]
-            set tag [lindex $datasets 0]
-            SendCmd "cutplane position $newpos $axis $tag"
-        }
-        default {
-            error "bad option \"$option\": should be axis, move, or volume"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: SlicerTip <axis>
-#
-# Used internally to generate a tooltip for the x/y/z slicer controls.
-# Returns a message that includes the current slicer value.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::SlicerTip {axis} {
-    set val [$itk_component(${axis}CutScale) get]
-    return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
-}
-
-itcl::body Rappture::NanovisViewer::DoResize {} {
-    $_arcball resize $_width $_height
-    SendCmd "screen size $_width $_height"
-    set _resizePending 0
-}
-
-itcl::body Rappture::NanovisViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        $_dispatcher event -idle !resize
-        set _resizePending 1
-    }
-}
-
-itcl::body Rappture::NanovisViewer::EventuallyRedrawLegend {} {
-    if { !$_resizeLegendPending } {
-        $_dispatcher event -idle !legend
-        set _resizeLegendPending 1
-    }
-}
-
-#  camera --
-#
-itcl::body Rappture::NanovisViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_settings($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                set _settings($what) $_view($what)
-                return
-            }
-            switch -- $what {
-                "-xpan" - "-ypan" {
-                    set _view($what) $_settings($what)
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set _view($what) $_settings($what)
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    SendCmd "camera orient $q"
-                }
-                "-zoom" {
-                    set _view($what) $_settings($what)
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::NanovisViewer::GetVtkData { args } {
-    # FIXME: We can only put one component of one dataset in a single
-    # VTK file.  To download all components/results, we would need
-    # to put them in an archive (e.g. zip or tar file)
-    if { $_first != ""} {
-        set cname [lindex [$_first components] 0]
-        set bytes [$_first vtkdata $cname]
-        return [list .vtk $bytes]
-    }
-    puts stderr "Failed to get vtkdata"
-    return ""
-}
-
-itcl::body Rappture::NanovisViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::NanovisViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::NanovisViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-    set _settings(-xpan) $_view(-xpan)
-    set _settings(-ypan) $_view(-ypan)
-    set _settings(-zoom) $_view(-zoom)
-}
Index: trunk/gui/scripts/note.tcl
===================================================================
--- trunk/gui/scripts/note.tcl	(revision 6716)
+++ 	(revision )
@@ -1,209 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Note - widget for displaying HTML notes
-#
-#  This widget represents an entry on a control panel that displays
-#  information to the user.  It is not an input; it helps to describe
-#  the interface.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require http
-
-itcl::class Rappture::Note {
-    inherit itk::Widget
-
-    # need this only to be like other controls
-    itk_option define -state state State ""
-
-    constructor {owner path args} { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _setContents {info}
-    protected method _escapeChars {text}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this note
-}
-
-itk::usual Note {
-    keep -cursor
-    keep -foreground -background
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Note::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    itk_component add scroller {
-        Rappture::Scroller $itk_interior.scroller \
-            -xscrollmode auto -yscrollmode auto
-    }
-    pack $itk_component(scroller) -expand yes -fill both
-
-    itk_component add html {
-        Rappture::HTMLviewer $itk_component(scroller).html
-    }
-    $itk_component(scroller) contents $itk_component(html)
-
-    eval itk_initialize $args
-
-    _setContents [string trim [$_owner xml get $_path.contents]]
-    set w [string trim [$_owner xml get $_path.width]]
-    if { $w != "" } {
-        $itk_component(html) configure -width $w
-    }
-    set h [string trim [$_owner xml get $_path.height]]
-    if { $h != "" } {
-        $itk_component(html) configure -height $h
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Note::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [lindex $args 0]
-        _setContents $newval
-        return $newval
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    error "don't know how to check value of <note>"
-    return
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Note::label {} {
-    error "can't get label"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Note::tooltip {} {
-    error "can't get tooltip"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _setContents <info>
-#
-# Used internally to load HTML info into the display area for this
-# widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Note::_setContents {info} {
-    switch -regexp -- $info {
-        ^https?:// {
-            if {[catch {http::geturl $info} token] == 0} {
-                set html [http::data $token]
-                http::cleanup $token
-            } else {
-                set html "<html><body><h1>Oops! Internal Error</h1><p>[_escapeChars $token]</p></body></html>"
-            }
-            $itk_component(html) load $html
-        }
-        ^file:// {
-            set file [string range $info 7 end]
-            if {[file pathtype $file] != "absolute"} {
-                # find the file on a search path
-                set dir [[$_owner tool] installdir]
-                set searchlist [list $dir [file join $dir docs]]
-                foreach dir $searchlist {
-                    if {[file readable [file join $dir $file]]} {
-                        set file [file join $dir $file]
-                        break
-                    }
-                }
-            }
-
-            # load the contents of the file
-            set cmds {
-                set fid [open $file r]
-                set html [read $fid]
-                close $fid
-            }
-            if {[catch $cmds result]} {
-                set html "<html><body><h1>Oops! File Not Found</h1><p>[_escapeChars $result]</p></body></html>"
-            }
-
-            # not HTML? then escape nasty characters and display it.
-            if {![regexp {<html>.*</html>} $html]} {
-                set html "<html><body><p>[_escapeChars $html]</p></body></html>"
-            }
-            $itk_component(html) load $html -in $file
-        }
-        default {
-            set html "<html><body><p>[_escapeChars $info]</p></body></html>"
-            $itk_component(html) load $html
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _escapeChars <info>
-#
-# Used internally to escape HTML characters in ordinary text.  Used
-# when trying to display ordinary text, which may have things like
-# "<b>" or "x < 2" embedded within it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Note::_escapeChars {info} {
-    regsub -all & $info \001 info
-    regsub -all \" $info {\&quot;} info
-    regsub -all < $info {\&lt;} info
-    regsub -all > $info {\&gt;} info
-    regsub -all \001 $info {\&amp;} info
-    return $info
-}
Index: trunk/gui/scripts/notebook.tcl
===================================================================
--- trunk/gui/scripts/notebook.tcl	(revision 6716)
+++ trunk/gui/scripts/notebook.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: notebook - series of pages, but only one packed at a time
@@ -9,8 +8,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -37,10 +33,9 @@
 
     private variable _count 0       ;# counter for unique names
-    private variable _dispatcher "" ;# dispatcher for !events
     private variable _pages ""      ;# list of page frames
     private variable _name2page     ;# maps name => frame for page
     private variable _current ""    ;# page currently shown
 }
-
+                                                                                
 itk::usual Notebook {
     keep -background -cursor
@@ -52,10 +47,12 @@
 itcl::body Rappture::Notebook::constructor {args} {
     pack propagate $itk_component(hull) no
-
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !fixsize
-    $_dispatcher dispatch $this !fixsize "[itcl::code $this _fixSize]; list"
-
     eval itk_initialize $args
+}
+
+# ----------------------------------------------------------------------
+# DESTRUCTOR
+# ----------------------------------------------------------------------
+itcl::body Rappture::Notebook::destructor {} {
+    after cancel [itcl::code $this _fixSize]
 }
 
@@ -80,6 +77,8 @@
         set _name2page($name) $itk_component($pname)
 
-        bind $itk_component($pname) <Configure> \
-            [itcl::code $_dispatcher event -after 100 !fixsize]
+        bind $itk_component($pname) <Configure> [itcl::code $this _fixSize]
+
+        after cancel [itcl::code $this _fixSize]
+        after idle [itcl::code $this _fixSize]
 
         lappend rlist $itk_component($pname)
@@ -140,10 +139,10 @@
 
 # ----------------------------------------------------------------------
-# USAGE: current ?<name>|next>|<back?
+# USAGE: current ?<name>|next>>|<<prev?
 #
 # Used to query/set the current page in the notebook.  With no args,
 # it returns the name of the current page.  Otherwise, it sets the
-# current page.  The special token "next>" is used to set the notebook
-# to the next logical page, and "<back" sets to the previous.
+# current page.  The special token "next>>" is used to set the notebook
+# to the next logical page, and "<<prev" sets to the previous.
 # ----------------------------------------------------------------------
 itcl::body Rappture::Notebook::current {args} {
@@ -155,5 +154,5 @@
             set name [lindex $args 0]
             set index 0
-            if {$name == "next>"} {
+            if {$name == "next>>"} {
                 if {$_current == ""} {
                     set index 0
@@ -165,5 +164,5 @@
                     }
                 }
-            } elseif {$name == "<back"} {
+            } elseif {$name == "<<prev"} {
                 if {$_current == ""} {
                     set index end
@@ -190,5 +189,5 @@
         }
         default {
-            error "wrong # args: should be \"current name|next>|<back\""
+            error "wrong # args: should be \"current name|next>>|<<prev\""
         }
     }
@@ -231,5 +230,6 @@
 # ----------------------------------------------------------------------
 itcl::configbody Rappture::Notebook::width {
-    $_dispatcher event -idle !fixsize
+    after cancel [itcl::code $this _fixSize]
+    after idle [itcl::code $this _fixSize]
 }
 
@@ -238,4 +238,5 @@
 # ----------------------------------------------------------------------
 itcl::configbody Rappture::Notebook::height {
-    $_dispatcher event -idle !fixsize
-}
+    after cancel [itcl::code $this _fixSize]
+    after idle [itcl::code $this _fixSize]
+}
Index: trunk/gui/scripts/numberentry.tcl
===================================================================
--- trunk/gui/scripts/numberentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,243 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: NumberEntry - widget for entering numeric values
-#
-#  This widget represents a <number> entry on a control panel.
-#  It is used to enter numeric values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::NumberEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-    protected method _newValue {}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-}
-
-itk::usual NumberEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberEntry::constructor {owner path args} {
-    set varname [lindex [split $path ()] end-1]
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    #
-    # Figure out what sort of control to create
-    #
-    set presets ""
-    foreach pre [$_owner xml children -type preset $path] {
-        set value [string trim [$_owner xml get $path.$pre.value]]
-        set label [string trim [$_owner xml get $path.$pre.label]]
-        lappend presets $value $label
-    }
-
-    set class Rappture::Gauge
-    set units [string trim [$_owner xml get $path.units]]
-    if {$units != ""} {
-        set desc [Rappture::Units::description $units]
-        if {[string match temperature* $desc]} {
-            set class Rappture::TemperatureGauge
-        }
-    }
-
-    # check for number UQ flag
-    set use_uq [$_owner xml get $path.uq]
-    if {$use_uq == ""} {
-        # check for global UQ flag
-        set use_uq [[$_owner tool] xml get tool.uq]
-    }
-
-    if {$use_uq == ""} {
-        set use_uq no
-    } else {
-        set use_uq [string trim $use_uq]
-    }
-
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    itk_component add gauge {
-        $class $itk_interior.gauge -uq $use_uq -units $units -presets $presets \
-            -log $path -varname $varname -label [label]
-    }
-    pack $itk_component(gauge) -expand yes -fill both
-    bind $itk_component(gauge) <<Value>> [itcl::code $this _newValue]
-
-    set min [string trim [$_owner xml get $path.min]]
-    if {$min ne ""} {
-        $itk_component(gauge) configure -minvalue $min
-    }
-
-    set max [string trim [$_owner xml get $path.max]]
-    if {$max ne ""} {
-        $itk_component(gauge) configure -maxvalue $max
-    }
-
-    if {$class == "Rappture::Gauge" && $min ne "" && $max ne ""} {
-        set color [string trim [$_owner xml get $path.about.color]]
-        if {$color == ""} {
-            # deprecated.  Color should be in "about"
-            set color [string trim [$_owner xml get $path.color]]
-        }
-        if {$color != ""}  {
-            if {$units != ""} {
-                set min [Rappture::Units::convert $min -to $units -units off]
-                set max [Rappture::Units::convert $max -to $units -units off]
-            }
-            # For compatibility. If only one color use white for min
-            if {[llength $color] == 1} {
-                set color [list $min white $max $color]
-            }
-            $itk_component(gauge) configure \
-                -spectrum [Rappture::Spectrum ::\#auto $color -units $units]
-        }
-    }
-
-    # if the control has an icon, plug it in
-    set str [string trim [$_owner xml get $path.about.icon]]
-    if {$str ne ""} {
-        $itk_component(gauge) configure -image [image create photo -data $str]
-    }
-    eval itk_initialize $args
-
-    #
-    # Assign the default value to this widget, if there is one.
-    #
-    set str [string trim [$_owner xml get $path.default]]
-    if {$str ne ""} {
-        $itk_component(gauge) value $str
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [string trim [lindex $args 0]]
-        $itk_component(gauge) value $newval
-        return $newval
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    return [$itk_component(gauge) value]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {"" == $label} {
-        set label "Number"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberEntry::tooltip {} {
-    set str   [string trim [$_owner xml get $_path.about.description]]
-
-    set units [string trim [$_owner xml get $_path.units]]
-    set min   [string trim [$_owner xml get $_path.min]]
-    set max   [string trim [$_owner xml get $_path.max]]
-
-    if {$units != "" || $min != "" || $max != ""} {
-        append str "\n\nEnter a number"
-
-        if {$min != "" && $max != ""} {
-            append str " between $min and $max"
-        } elseif {$min != ""} {
-            append str " greater than $min"
-        } elseif {$max != ""} {
-            append str " less than $max"
-        }
-
-        if {$units != ""} {
-            set desc [Rappture::Units::description $units]
-            append str " with units of $desc"
-        }
-    }
-    return [string trim $str]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _newValue
-#
-# Invoked automatically whenever the value in the gauge changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberEntry::_newValue {} {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::NumberEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(gauge) configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/numberresult.tcl
===================================================================
--- trunk/gui/scripts/numberresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1567 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: numberresult - plot of numbers in a ResultSet
-#
-#  This widget is an X/Y plot, meant to points produced as <number>
-#  or <integer> outputs from the run of a Rappture tool.  Use the
-#  "add" and "delete" methods to control the points showing on the
-#  plot.  One interesting thing that this result does is configure
-#  the x-axis according to the current result control (simulation
-#  number or other active parameter).
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-set autocolors {
-    #0000cd
-    #cd0000
-    #00cd00
-    #3a5fcd
-    #cdcd00
-    #cd1076
-    #009acd
-    #00c5cd
-    #a2b5cd
-    #7ac5cd
-    #66cdaa
-    #a2cd5a
-    #cd9b9b
-    #cdba96
-    #cd3333
-    #cd6600
-    #cd8c95
-    #cd00cd
-    #9a32cd
-    #6ca6cd
-    #9ac0cd
-    #9bcd9b
-    #00cd66
-    #cdc673
-    #cdad00
-    #cd5555
-    #cd853f
-    #cd7054
-    #cd5b45
-    #cd6889
-    #cd69c9
-    #551a8b
-}
-
-option add *NumberResult.width 3i widgetDefault
-option add *NumberResult.height 3i widgetDefault
-option add *NumberResult.gridColor #d9d9d9 widgetDefault
-option add *NumberResult.activeColor blue widgetDefault
-option add *NumberResult.dimColor gray widgetDefault
-option add *NumberResult.controlBackground gray widgetDefault
-option add *NumberResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-option add *NumberResult.autoColors $autocolors widgetDefault
-option add *NumberResult*Balloon*Entry.background white widgetDefault
-
-itcl::class Rappture::NumberResult {
-    inherit itk::Widget
-
-    itk_option define -gridcolor gridColor GridColor ""
-    itk_option define -activecolor activeColor ActiveColor ""
-    itk_option define -dimcolor dimColor DimColor ""
-    itk_option define -autocolors autoColors AutoColors ""
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args}
-    public method download {option args}
-
-    protected method Rebuild {}
-    protected method ResetLimits {}
-    protected method Zoom {option args}
-    protected method Hilite {state x y}
-    protected method Axis {option args}
-    protected method GetAxes {dataobj}
-    protected method GetValue {dataobj {which both}}
-    protected method GetInfo {what dataobj {which both}}
-    private method ResetLegend {}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-
-    private variable _dlist ""     ;# list of data objects
-    private variable _dataobj2color   ;# maps data object => plotting color
-    private variable _dataobj2width   ;# maps data object => line width
-    private variable _dataobj2raise   ;# maps data object => raise flag 0/1
-    private variable _dataobj2desc    ;# maps data object => description of data
-    private variable _dataobj2param   ;# maps data object => x-axis value
-    private variable _elem2dataobj    ;# maps graph element => data object
-    private variable _label2axis   ;# maps axis label => axis ID
-    private variable _params ""    ;# complete description of x-axis
-    private variable _xval2label   ;# maps x-axis value => tick label
-    private variable _xlabels 0    ;# non-zero => use _xval2label
-    private variable _limits       ;# axis limits:  x-min, x-max, etc.
-
-    private variable _hilite       ;# info for element currently highlighted
-    private variable _axis         ;# info for axis manipulations
-    private variable _axisPopup    ;# info for axis being edited in popup
-    common _downloadPopup          ;# download options from popup
-}
-
-itk::usual NumberResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    array set _downloadPopup {
-        format csv
-    }
-
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add main {
-        Rappture::SidebarFrame $itk_interior.main
-    }
-    pack $itk_component(main) -expand yes -fill both
-    set f [$itk_component(main) component controls]
-
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(reset) -padx 4 -pady 2 -anchor e
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    set f [$itk_component(main) component frame]
-    itk_component add plot {
-        blt::graph $f.plot \
-            -highlightthickness 0 -plotpadx 0 -plotpady 4 \
-            -rightmargin 10
-    } {
-        keep -background -foreground -cursor -font
-    }
-    pack $itk_component(plot) -expand yes -fill both
-
-    $itk_component(plot) pen configure activeLine \
-        -symbol square -pixels 3 -linewidth 2 \
-        -outline black -fill red -color black
-
-    # Add bindings so you can mouse over points to see values:
-    bind $itk_component(plot) <Motion> \
-        [itcl::code $this Hilite at %x %y]
-    bind $itk_component(plot) <Leave> \
-        [itcl::code $this Hilite off %x %y]
-
-    #
-    # Add support for editing axes:
-    #
-    Rappture::Balloon $itk_component(hull).axes -title "Axis Options"
-    set inner [$itk_component(hull).axes component inner]
-
-    label $inner.labell -text "Label:"
-    entry $inner.label -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.labell -row 1 -column 0 -sticky e
-    grid $inner.label -row 1 -column 1 -sticky ew -pady 4
-
-    label $inner.minl -text "Minimum:"
-    entry $inner.min -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.minl -row 2 -column 0 -sticky e
-    grid $inner.min -row 2 -column 1 -sticky ew -pady 4
-
-    label $inner.maxl -text "Maximum:"
-    entry $inner.max -width 15 -highlightbackground $itk_option(-background)
-    grid $inner.maxl -row 3 -column 0 -sticky e
-    grid $inner.max -row 3 -column 1 -sticky ew -pady 4
-
-    label $inner.formatl -text "Format:"
-    Rappture::Combobox $inner.format -width 15 -editable no
-    $inner.format choices insert end \
-        "%.6g"  "Auto"         \
-        "%.0f"  "X"          \
-        "%.1f"  "X.X"          \
-        "%.2f"  "X.XX"         \
-        "%.3f"  "X.XXX"        \
-        "%.6f"  "X.XXXXXX"     \
-        "%.1e"  "X.Xe+XX"      \
-        "%.2e"  "X.XXe+XX"     \
-        "%.3e"  "X.XXXe+XX"    \
-        "%.6e"  "X.XXXXXXe+XX"
-    grid $inner.formatl -row 4 -column 0 -sticky e
-    grid $inner.format -row 4 -column 1 -sticky ew -pady 4
-
-    label $inner.scalel -text "Scale:"
-    frame $inner.scales
-    radiobutton $inner.scales.linear -text "Linear" \
-        -variable [itcl::scope _axisPopup(scale)] -value "linear"
-    pack $inner.scales.linear -side left
-    radiobutton $inner.scales.log -text "Logarithmic" \
-        -variable [itcl::scope _axisPopup(scale)] -value "log"
-    pack $inner.scales.log -side left
-    grid $inner.scalel -row 5 -column 0 -sticky e
-    grid $inner.scales -row 5 -column 1 -sticky ew -pady 4
-
-    foreach axis {x y} {
-        set _axisPopup(format-$axis) "%.6g"
-    }
-    Axis scale x linear
-    Axis scale y linear
-
-    $itk_component(plot) legend configure -hide yes
-
-    #
-    # Add legend for editing hidden/elements:
-    #
-    set inner [$itk_component(main) insert end \
-        -title "Legend" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    itk_component add legend {
-        Rappture::XyLegend $inner.legend $itk_component(plot)
-    }
-    pack $itk_component(legend) -expand yes -fill both
-    after idle [itcl::code $this ResetLegend]
-
-    # quick-and-dirty zoom functionality, for now...
-    Blt_ZoomStack $itk_component(plot)
-    eval itk_initialize $args
-    set _hilite(elem) ""
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -type "line"
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    # if type is set to "scatter", then override the width
-    if {"scatter" == $params(-type)} {
-        set params(-width) 0
-    }
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        set params(-color) #0000ff
-    }
-
-    # if -brightness is set, then update the color
-    if {$params(-brightness) != 0} {
-        set params(-color) [Rappture::color::brightness \
-            $params(-color) $params(-brightness)]
-
-        set bg [$itk_component(plot) cget -plotbackground]
-        foreach {h s v} [Rappture::color::RGBtoHSV $bg] break
-        if {$v > 0.5} {
-            set params(-color) [Rappture::color::brightness_max \
-                $params(-color) 0.8]
-        } else {
-            set params(-color) [Rappture::color::brightness_min \
-                $params(-color) 0.2]
-        }
-    }
-
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-        set _dataobj2color($dataobj) $params(-color)
-        set _dataobj2width($dataobj) $params(-width)
-        set _dataobj2raise($dataobj) $params(-raise)
-        set _dataobj2desc($dataobj) $params(-description)
-        set _dataobj2param($dataobj) $params(-param)
-
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-    foreach obj $dlist {
-        if {[info exists _dataobj2raise($obj)] && $_dataobj2raise($obj)} {
-            set i [lsearch -exact $dlist $obj]
-            if {$i >= 0} {
-                set dlist [lreplace $dlist $i $i]
-                lappend dlist $obj
-            }
-        }
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj2> <dataobj2> ...?
-#
-# Clients use this to delete a data object from the plot.  If no
-# objects are specified, then all objects are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified data objects
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            catch {unset _dataobj2color($dataobj)}
-            catch {unset _dataobj2width($dataobj)}
-            catch {unset _dataobj2raise($dataobj)}
-            catch {unset _dataobj2desc($dataobj)}
-            catch {unset _dataobj2param($dataobj)}
-            foreach elem [array names _elem2dataobj] {
-                if {$_elem2dataobj($elem) == $dataobj} {
-                    unset _elem2dataobj($elem)
-                }
-            }
-            set changed 1
-        }
-    }
-
-    # if anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-    # Nothing left? then start over with auto colors
-    if {[llength $_dlist] == 0} {
-        set _autoColorI 0
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given data objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::scale {args} {
-    set allx [$itk_component(plot) x2axis use]
-    lappend allx x  ;# fix main x-axis too
-    foreach axis $allx {
-        Axis scale $axis linear
-    }
-
-    set ally [$itk_component(plot) y2axis use]
-    lappend ally y  ;# fix main y-axis too
-    foreach axis $ally {
-        Axis scale $axis linear
-    }
-
-    catch {unset _limits}
-    foreach dataobj $args {
-        # find the axes for this data object (e.g., {x y2})
-        foreach {map(x) map(y)} [GetAxes $dataobj] break
-
-        foreach axis {x y} {
-            # get defaults for both linear and log scales
-            foreach type {lin log} {
-                # store results -- ex: _limits(x2log-min)
-                set id $map($axis)$type
-                if {$axis == "x"} {
-                    set min [set max ""]
-                    foreach {xlab xval} [lrange $_params 1 end] {
-                        if {$type == "log"} {
-                            set xval [expr {abs($xval)}]
-                            if {$xval == 0} {
-                                continue
-                            }
-                        }
-                        if {"" == $min} {
-                            set min [set max $xval]
-                        } else {
-                            if {$xval < $min} { set min $xval }
-                            if {$xval > $max} { set max $xval }
-                        }
-                    }
-                } else {
-                    set min [set max [GetValue $dataobj y]]
-                }
-
-                if {"" != $min && "" != $max} {
-                    if {![info exists _limits($id-min)]} {
-                        set _limits($id-min) $min
-                        set _limits($id-max) $max
-                    } else {
-                        if {$min < $_limits($id-min)} {
-                            set _limits($id-min) $min
-                        }
-                        if {$max > $_limits($id-max)} {
-                            set _limits($id-max) $max
-                        }
-                    }
-                }
-            }
-        }
-    }
-    ResetLimits
-}
-
-# ----------------------------------------------------------------------
-# USAGE: parameters <title> <label1> <value1> <label2> <value2> ...
-#
-# Called when the resultset changes to convey information about the
-# current set of results being displayed.  The <title> is the name
-# of the parameter being explored, and each <label>/<value> represents
-# a data point.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::parameters {args} {
-    set _params $args
-
-    #
-    # Fix up the x-axis limits for the primary axis.
-    #
-    foreach type {lin log} {
-        # store results -- ex: _limits(x2log-min)
-        set id x$type
-
-        set min [set max ""]
-        foreach {xlab xval} [lrange $_params 1 end] {
-            if {$type == "log"} {
-                set xval [expr {abs($xval)}]
-                if {$xval == 0} {
-                    continue
-                }
-            }
-            if {"" == $min} {
-                set min [set max $xval]
-            } else {
-                if {$xval < $min} { set min $xval }
-                if {$xval > $max} { set max $xval }
-            }
-        }
-
-        if {"" != $min && "" != $max} {
-            set _limits($id-min) $min
-            set _limits($id-max) $max
-        }
-    }
-    ResetLimits
-
-    #
-    # Figure out a good set of ticks for the x-axis.
-    # If this is a numeric axis, then labels will be like
-    #   0.3V <=> 0.3, 0.4V <=> 0.4, etc.
-    # Otherwise, they will be more like
-    #   red <=> 0, green <=> 1, etc.
-    #
-    set havenums 1
-    catch {unset _xval2label}
-    foreach {xlab xval} [lrange $_params 1 end] {
-        set _xval2label($xval) $xlab
-        if {![string match $xval* $xlab]} {
-            set havenums 0
-        }
-    }
-    if {$havenums} {
-        set _xlabels 0
-        $itk_component(plot) xaxis configure -command "" -majorticks ""
-        if {![$itk_component(plot) axis cget x -logscale]} {
-            $itk_component(plot) xaxis configure \
-                -command [itcl::code $this Axis format x]
-        }
-    } else {
-        set _xlabels 1
-        $itk_component(plot) xaxis configure \
-            -command [itcl::code $this Axis format x] \
-            -majorticks [lsort -real [array names _xval2label]]
-    }
-
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            set popup .numberresultdownload
-            if {![winfo exists .numberresultdownload]} {
-                # if we haven't created the popup yet, do it now
-                Rappture::Balloon $popup \
-                    -title "[Rappture::filexfer::label downloadWord] as..."
-                set inner [$popup component inner]
-                label $inner.summary -text "" -anchor w
-                pack $inner.summary -side top
-                radiobutton $inner.csv -text "Data as Comma-Separated Values" \
-                    -variable Rappture::NumberResult::_downloadPopup(format) \
-                    -value csv
-                pack $inner.csv -anchor w
-                radiobutton $inner.image -text "Image (PS/PDF/PNG/JPEG)" \
-                    -variable Rappture::NumberResult::_downloadPopup(format) \
-                    -value image
-                pack $inner.image -anchor w
-                button $inner.go -text [Rappture::filexfer::label download] \
-                    -command [lindex $args 0]
-                pack $inner.go -pady 4
-            } else {
-                set inner [$popup component inner]
-            }
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:"
-            update idletasks ;# fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .numberresultdownload
-            if {[winfo exists .numberresultdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                csv {
-                    # March through the values in order and report
-                    # all data points
-                    set csvdata ""
-                    set xtitle [$itk_component(plot) xaxis cget -title]
-                    set ytitle [$itk_component(plot) yaxis cget -title]
-
-                    set desc ""
-                    set dataobj [lindex [get] end]
-
-                    # the "Simulation" axis shows all values
-                    # -- no need for assumptions
-                    if {$xtitle != "Simulation"
-                        && [info exists _dataobj2desc($dataobj)]} {
-                        foreach line [split $_dataobj2desc($dataobj) \n] {
-                            # skip the current axis and the Simulation axis
-                            # Other values show assumptions about values reported
-                            if {[string match "$xtitle =*" $line]
-                                || [string match "Simulation =*" $line]} {
-                                continue
-                            }
-                            set indent [expr {("" == $desc) ? "for:" : "    "}]
-                            append desc " $indent $line\n"
-                        }
-                    }
-                    if {[string length $desc] > 0} {
-                        append csvdata "[string repeat - 60]\n"
-                        append csvdata $desc
-                        append csvdata "[string repeat - 60]\n"
-                    }
-
-                    append csvdata "$xtitle, $ytitle\n"
-                    foreach xval [lsort -real [array names _xval2label]] {
-                        set dataobj ""
-                        set param [list $_xval2label($xval) $xval]
-                        foreach obj $_dlist {
-                            if {[info exists _dataobj2param($obj)]
-                                && [string equal $_dataobj2param($obj) $param]} {
-                                set dataobj $obj
-                                break
-                            }
-                        }
-                        if {"" != $dataobj} {
-                            set yval [$dataobj get current]
-                            append csvdata "$_xval2label($xval), $yval\n"
-                        }
-                    }
-                    return [list .txt $csvdata]
-                }
-                image {
-                    set popup .numberresultprintdownload
-                    if { ![winfo exists $popup] } {
-                        # Create a popup for the print dialog
-                        Rappture::Balloon $popup -title "Save as image..."
-                        set inner [$popup component inner]
-                        # Create the print dialog widget and add it to the
-                        # the balloon popup.
-                        Rappture::XyPrint $inner.print
-                        $popup configure \
-                            -deactivatecommand [list $inner.print reset]
-                        blt::table $inner 0,0 $inner.print -fill both
-                    }
-                    update
-                    # Activate the popup and call for the output.
-                    foreach { widget toolName plotName } $args break
-                    $popup activate $widget left
-                    set inner [$popup component inner]
-                    set output [$inner.print print $itk_component(plot) \
-                                    $toolName $plotName]
-                    $popup deactivate
-                    return $output
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::Rebuild {} {
-    set g $itk_component(plot)
-
-    # first clear out the widget
-    eval $g element delete [$g element names]
-    eval $g marker delete [$g marker names]
-    foreach axis [$g axis names] {
-        $g axis configure $axis -hide yes -checklimits no
-    }
-    # Presumably you want at least an X-axis and Y-axis displayed.
-    $g xaxis configure -hide no
-    $g yaxis configure -hide no
-    catch {unset _label2axis}
-
-    #
-    # Scan through all objects and create a list of all axes.
-    # The first x-axis gets mapped to "x".  The second, to "x2".
-    # Beyond that, we must create new axes "x3", "x4", etc.
-    # We do the same for y.
-    #
-    set anum(x) 0
-    set anum(y) 0
-    foreach dataobj [get] {
-        foreach ax {x y} {
-            set label [GetInfo about.label $dataobj ${ax}]
-            if {"" != $label} {
-                if {![info exists _label2axis($ax-$label)]} {
-                    switch [incr anum($ax)] {
-                        1 { set axis $ax }
-                        2 { set axis ${ax}2 }
-                        default {
-                            set axis $ax$anum($ax)
-                            catch {$g axis create $axis}
-                        }
-                    }
-                    $g axis configure $axis -title $label -hide no \
-                        -checklimits no
-                    set _label2axis($ax-$label) $axis
-
-                    # if this axis has a description, add it as a tooltip
-                    set desc [string trim [GetInfo about.description $dataobj ${ax}]]
-                    Rappture::Tooltip::text $g-$axis $desc
-                }
-            }
-        }
-    }
-
-    #
-    # All of the extra axes get mapped to the x2/y2 (top/right)
-    # position.
-    #
-    set all ""
-    foreach ax {x y} {
-        lappend all $ax
-
-        set extra ""
-        for {set i 2} {$i <= $anum($ax)} {incr i} {
-            lappend extra ${ax}$i
-        }
-        eval lappend all $extra
-        $g ${ax}2axis use $extra
-        if {$ax == "y"} {
-            $g configure -rightmargin [expr {($extra == "") ? 10 : 0}]
-        }
-    }
-
-    foreach axis $all {
-        set _axisPopup(format-$axis) "%.6g"
-
-        $g axis bind $axis <Enter> \
-            [itcl::code $this Axis hilite $axis on]
-        $g axis bind $axis <Leave> \
-            [itcl::code $this Axis hilite $axis off]
-        $g axis bind $axis <ButtonPress-1> \
-            [itcl::code $this Axis click $axis %x %y]
-        $g axis bind $axis <B1-Motion> \
-            [itcl::code $this Axis drag $axis %x %y]
-        $g axis bind $axis <ButtonRelease-1> \
-            [itcl::code $this Axis release $axis %x %y]
-        $g axis bind $axis <KeyPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-    }
-
-    #
-    # Plot all of the data objects.
-    #
-    set count 0
-    foreach dataobj $_dlist {
-        set label [$dataobj get about.label]
-        foreach {mapx mapy} [GetAxes $dataobj] break
-
-        foreach {xv yv} [GetValue $dataobj] break
-
-        if {[info exists _dataobj2color($dataobj)]} {
-            set color $_dataobj2color($dataobj)
-        } else {
-            set color [$dataobj get about.color]
-            if {"" == $color} {
-                set color $itk_option(-activecolor)
-            }
-        }
-
-        set sym square
-        set pixels 6
-
-        set elem "elem[incr count]"
-        set _elem2dataobj($elem) $dataobj
-        $g element create $elem -x $xv -y $yv \
-            -symbol $sym -pixels $pixels -label $label \
-            -color $color -mapx $mapx -mapy $mapy
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ResetLimits
-#
-# Used internally to apply automatic limits to the axes for the
-# current plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::ResetLimits {} {
-    set g $itk_component(plot)
-
-    #
-    # HACK ALERT!
-    # Use this code to fix up the y-axis limits for the BLT graph.
-    # The auto-limits don't always work well.  We want them to be
-    # set to a "nice" number slightly above or below the min/max
-    # limits.
-    #
-    foreach axis [$g axis names] {
-        if {[info exists _limits(${axis}lin-min)]} {
-            set log [$g axis cget $axis -logscale]
-            if {$log} {
-                set min $_limits(${axis}log-min)
-                if {$min == 0} { set min 1 }
-                set max $_limits(${axis}log-max)
-                if {$max == 0} { set max 1 }
-
-                if {$min == $max} {
-                    set logmin [expr {floor(log10(abs(0.9*$min)))}]
-                    set logmax [expr {ceil(log10(abs(1.1*$max)))}]
-                } else {
-                    set logmin [expr {floor(log10(abs($min)))}]
-                    set logmax [expr {ceil(log10(abs($max)))}]
-                    if {[string match y* $axis]} {
-                        # add a little padding
-                        set delta [expr {$logmax-$logmin}]
-                        if {$delta == 0} { set delta 1 }
-                        set logmin [expr {$logmin-0.05*$delta}]
-                        set logmax [expr {$logmax+0.05*$delta}]
-                    }
-                }
-                if {$logmin < -300} {
-                    set min 1e-300
-                } elseif {$logmin > 300} {
-                    set min 1e+300
-                } else {
-                    set min [expr {pow(10.0,$logmin)}]
-                }
-
-                if {$logmax < -300} {
-                    set max 1e-300
-                } elseif {$logmax > 300} {
-                    set max 1e+300
-                } else {
-                    set max [expr {pow(10.0,$logmax)}]
-                }
-            } else {
-                set min $_limits(${axis}lin-min)
-                set max $_limits(${axis}lin-max)
-
-                # add a little padding
-                set delta [expr {$max-$min}]
-                set min [expr {$min-0.05*$delta}]
-                set max [expr {$max+0.05*$delta}]
-            }
-            if {$min < $max} {
-                $g axis configure $axis -min $min -max $max
-            } else {
-                $g axis configure $axis -min "" -max ""
-            }
-        } else {
-            $g axis configure $axis -min "" -max ""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::Zoom {option args} {
-    switch -- $option {
-        reset {
-            ResetLimits
-            Rappture::Logger::log number zoom -reset
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Hilite <state> <x> <y>
-#
-# Called automatically when the user brushes one of the elements
-# on the plot.  Causes the element to highlight and a tooltip to
-# pop up with element info.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::Hilite {state x y} {
-    set g $itk_component(plot)
-    set elem ""
-
-    # Peek inside of Blt_ZoomStack package to see if we're currently in the
-    # middle of a zoom selection.
-    if {[info exists ::zoomInfo($g,corner)] && $::zoomInfo($g,corner) == "B" } {
-        return;
-    }
-    set tip ""
-    if {$state == "at"} {
-        if {[$g element closest $x $y info -interpolate yes]} {
-            # for dealing with xy line plots
-            set elem $info(name)
-            # Some elements are generated dynamically and therefore will
-            # not have a data object associated with them.
-            set mapx [$g element cget $elem -mapx]
-            set mapy [$g element cget $elem -mapy]
-            if {[info exists _elem2dataobj($elem)]} {
-                foreach {mapx mapy} [GetAxes $_elem2dataobj($elem)] break
-            }
-
-            # search again for an exact point -- this time don't interpolate
-            set tip ""
-            if {[$g element closest $x $y info -interpolate no]
-                  && $info(name) == $elem} {
-                set x [$g axis transform $mapx $info(x)]
-                set y [$g axis transform $mapy $info(y)]
-
-                if {[info exists _elem2dataobj($elem)]} {
-                    set dataobj $_elem2dataobj($elem)
-                    set tip [GetInfo about.label $dataobj y]
-                    if {[info exists info(y)]} {
-                        set val [Axis format y dummy $info(y)]
-                        set units [GetInfo units $dataobj y]
-                        append tip "\n$val$units"
-
-                        if {[info exists _dataobj2param($dataobj)]} {
-                            set val [lindex $_dataobj2param($dataobj) 0]
-                            append tip " @ $val"
-                        }
-                    }
-                    set tip [string trim $tip]
-                }
-            }
-            set state 1
-        } elseif {[$g element closest $x $y info -interpolate no]} {
-            # for dealing with xy scatter plot
-            set elem $info(name)
-            foreach {mapx mapy} [GetAxes $_elem2dataobj($elem)] break
-
-            # search again for an exact point -- this time don't interpolate
-            set tip ""
-            if {$info(name) == $elem} {
-                set x [$g axis transform $mapx $info(x)]
-                set y [$g axis transform $mapy $info(y)]
-
-                if {[info exists _elem2dataobj($elem)]} {
-                    set dataobj $_elem2dataobj($elem)
-                    set tip [GetInfo about.label $dataobj y]
-                    if {[info exists info(y)]} {
-                        set val [Axis format y dummy $info(y)]
-                        set units [GetInfo units $dataobj y]
-                        append tip "\n$val$units"
-
-                        if {[info exists _dataobj2param($dataobj)]} {
-                            set val [lindex $_dataobj2param($dataobj) 0]
-                            append tip " @ $val"
-                        }
-                    }
-                    set tip [string trim $tip]
-                }
-            }
-            set state 1
-        } else {
-            set state 0
-        }
-    }
-
-    if {$state} {
-        #
-        # Highlight ON:
-        # - activate trace
-        # - multiple axes? dim other axes
-        # - pop up tooltip about data
-        if {$_hilite(elem) ne ""} {
-            $g element deactivate $_hilite(elem)
-        }
-        $g crosshairs configure -hide yes
-        Rappture::Tooltip::tooltip cancel
-
-        $g element activate $elem
-        set _hilite(elem) $elem
-
-        set dlist [$g element show]
-        set i [lsearch -exact $dlist $elem]
-        if {$i >= 0} {
-            set dlist [lreplace $dlist $i $i]
-            lappend dlist $elem
-            $g element show $dlist
-        }
-
-        foreach {mapx mapy} [GetAxes $_elem2dataobj($elem)] break
-
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;# fix main x-axis too
-            foreach axis $allx {
-                if {$axis == $mapx} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;# fix main y-axis too
-            foreach axis $ally {
-                if {$axis == $mapy} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-
-        if {"" != $tip} {
-            $g crosshairs configure -hide no -position @$x,$y
-
-            if {$x > 0.5*[winfo width $g]} {
-                if {$x < 4} {
-                    set tipx "-0"
-                } else {
-                    set tipx "-[expr {$x-4}]"  ;# move tooltip to the left
-                }
-            } else {
-                if {$x < -4} {
-                    set tipx "+0"
-                } else {
-                    set tipx "+[expr {$x+4}]"  ;# move tooltip to the right
-                }
-            }
-            if {$y > 0.5*[winfo height $g]} {
-                if {$y < 4} {
-                    set tipy "-0"
-                } else {
-                    set tipy "-[expr {$y-4}]"  ;# move tooltip to the top
-                }
-            } else {
-                if {$y < -4} {
-                    set tipy "+0"
-                } else {
-                    set tipy "+[expr {$y+4}]"  ;# move tooltip to the bottom
-                }
-            }
-            Rappture::Tooltip::text $g $tip
-            Rappture::Tooltip::tooltip show $g $tipx,$tipy
-            Rappture::Logger::log tooltip -for "number probe -- [string map [list \n " // "] $tip]"
-        }
-    } else {
-        #
-        # Highlight OFF:
-        # - deactivate (color back to normal)
-        # - put all axes back to normal color
-        # - take down tooltip
-        #
-        if {$_hilite(elem) ne ""} {
-            $g element deactivate $_hilite(elem)
-        }
-
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;           # fix main x-axis too
-            foreach axis $allx {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;           # fix main y-axis too
-            foreach axis $ally {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        $g crosshairs configure -hide yes
-
-        # only cancel in plotting area or we'll mess up axes
-        if {[$g inside $x $y]} {
-            Rappture::Tooltip::tooltip cancel
-        }
-
-        # there is no currently highlighted element
-        set _hilite(elem) ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Axis hilite <axis> <state>
-#
-# USAGE: Axis click <axis> <x> <y>
-# USAGE: Axis drag <axis> <x> <y>
-# USAGE: Axis release <axis> <x> <y>
-#
-# USAGE: Axis edit <axis>
-# USAGE: Axis changed <axis> <what>
-# USAGE: Axis format <axis> <widget> <value>
-# USAGE: Axis scale <axis> linear|log
-#
-# Used internally to handle editing of the x/y axes.  The hilite
-# operation causes the axis to light up.  The edit operation pops
-# up a panel with editing options.  The changed operation applies
-# changes from the panel.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::Axis {option args} {
-    set inner [$itk_component(hull).axes component inner]
-
-    switch -- $option {
-        hilite {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Axis hilite axis state\""
-            }
-            set g $itk_component(plot)
-            set axis [lindex $args 0]
-            set state [lindex $args 1]
-
-            if {$state} {
-                $g axis configure $axis \
-                    -color $itk_option(-activecolor) \
-                    -titlecolor $itk_option(-activecolor)
-
-                set x [expr {[winfo pointerx $g]+4}]
-                set y [expr {[winfo pointery $g]+4}]
-                Rappture::Tooltip::tooltip pending $g-$axis @$x,$y
-            } else {
-                $g axis configure $axis \
-                    -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-                Rappture::Tooltip::tooltip cancel
-            }
-        }
-        click {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis click axis x y\""
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            set g $itk_component(plot)
-
-            set _axis(moved) 0
-            set _axis(click-x) $x
-            set _axis(click-y) $y
-            foreach {min max} [$g axis limits $axis] break
-            set _axis(min0) $min
-            set _axis(max0) $max
-            Rappture::Tooltip::tooltip cancel
-        }
-        drag {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis drag axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            set g $itk_component(plot)
-
-            if {[info exists _axis(click-x)] && [info exists _axis(click-y)]} {
-                foreach {x0 y0 pw ph} [$g extents plotarea] break
-                switch -glob $axis {
-                  x* {
-                    set pix $x
-                    set pix0 $_axis(click-x)
-                    set pixmin $x0
-                    set pixmax [expr {$x0+$pw}]
-                  }
-                  y* {
-                    set pix $y
-                    set pix0 $_axis(click-y)
-                    set pixmin [expr {$y0+$ph}]
-                    set pixmax $y0
-                  }
-                }
-                set log [$g axis cget $axis -logscale]
-                set min $_axis(min0)
-                set max $_axis(max0)
-                set dpix [expr {abs($pix-$pix0)}]
-                set v0 [$g axis invtransform $axis $pixmin]
-                set v1 [$g axis invtransform $axis [expr {$pixmin+$dpix}]]
-                if {$log} {
-                    set v0 [expr {log10($v0)}]
-                    set v1 [expr {log10($v1)}]
-                    set min [expr {log10($min)}]
-                    set max [expr {log10($max)}]
-                }
-
-                if {$pix > $pix0} {
-                    set delta [expr {$v1-$v0}]
-                } else {
-                    set delta [expr {$v0-$v1}]
-                }
-                set min [expr {$min-$delta}]
-                set max [expr {$max-$delta}]
-                if {$log} {
-                    set min [expr {pow(10.0,$min)}]
-                    set max [expr {pow(10.0,$max)}]
-                }
-                $g axis configure $axis -min $min -max $max
-
-                # move axis, don't edit on release
-                set _axis(move) 1
-            }
-        }
-        release {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis release axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-
-            if {!$_axis(moved)} {
-                # small movement? then treat as click -- pop up axis editor
-                set dx [expr {abs($x-$_axis(click-x))}]
-                set dy [expr {abs($y-$_axis(click-y))}]
-                if {$dx < 2 && $dy < 2} {
-                    Axis edit $axis
-                    return
-                }
-            }
-            # one last movement
-            Axis drag $axis $x $y
-
-            # log this change
-            Rappture::Logger::log number axis $axis \
-                -drag [$itk_component(plot) axis limits $axis]
-
-            catch {unset _axis}
-        }
-        edit {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"Axis edit axis\""
-            }
-            set axis [lindex $args 0]
-            set _axisPopup(current) $axis
-
-            # apply last value when deactivating
-            $itk_component(hull).axes configure -deactivatecommand \
-                [itcl::code $this Axis changed $axis focus]
-
-            # fix axis label controls...
-            set label [$itk_component(plot) axis cget $axis -title]
-            $inner.label delete 0 end
-            $inner.label insert end $label
-            bind $inner.label <Return> \
-                [itcl::code $this Axis changed $axis label]
-            bind $inner.label <KP_Enter> \
-                [itcl::code $this Axis changed $axis label]
-            bind $inner.label <FocusOut> \
-                [itcl::code $this Axis changed $axis label]
-
-            # fix min/max controls...
-            foreach {min max} [$itk_component(plot) axis limits $axis] break
-            $inner.min delete 0 end
-            $inner.min insert end $min
-            bind $inner.min <Return> \
-                [itcl::code $this Axis changed $axis min]
-            bind $inner.min <KP_Enter> \
-                [itcl::code $this Axis changed $axis min]
-            bind $inner.min <FocusOut> \
-                [itcl::code $this Axis changed $axis min]
-
-            $inner.max delete 0 end
-            $inner.max insert end $max
-            bind $inner.max <Return> \
-                [itcl::code $this Axis changed $axis max]
-            bind $inner.max <KP_Enter> \
-                [itcl::code $this Axis changed $axis max]
-            bind $inner.max <FocusOut> \
-                [itcl::code $this Axis changed $axis max]
-
-            # fix format control...
-            set fmts [$inner.format choices get -value]
-            set i [lsearch -exact $fmts $_axisPopup(format-$axis)]
-            if {$i < 0} { set i 0 }  ;# use Auto choice
-            $inner.format value [$inner.format choices get -label $i]
-
-            bind $inner.format <<Value>> \
-                [itcl::code $this Axis changed $axis format]
-
-            # fix scale control...
-            if {[$itk_component(plot) axis cget $axis -logscale]} {
-                set _axisPopup(scale) "log"
-                $inner.format configure -state disabled
-            } else {
-                set _axisPopup(scale) "linear"
-                $inner.format configure -state normal
-            }
-            $inner.scales.linear configure \
-                -command [itcl::code $this Axis changed $axis scale]
-            $inner.scales.log configure \
-                -command [itcl::code $this Axis changed $axis scale]
-
-            #
-            # Figure out where the window should pop up.
-            #
-            set x [winfo rootx $itk_component(plot)]
-            set y [winfo rooty $itk_component(plot)]
-            set w [winfo width $itk_component(plot)]
-            set h [winfo height $itk_component(plot)]
-            foreach {x0 y0 pw ph} [$itk_component(plot) extents plotarea] break
-            switch -glob -- $axis {
-                x {
-                    set x [expr {round($x + $x0+0.5*$pw)}]
-                    set y [expr {round($y + $y0+$ph + 0.5*($h-$y0-$ph))}]
-                    set dir "above"
-                }
-                x* {
-                    set x [expr {round($x + $x0+0.5*$pw)}]
-                    set dir "below"
-                    set allx [$itk_component(plot) x2axis use]
-                    set max [llength $allx]
-                    set i [lsearch -exact $allx $axis]
-                    set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-                }
-                y {
-                    set x [expr {round($x + 0.5*$x0)}]
-                    set y [expr {round($y + $y0+0.5*$ph)}]
-                    set dir "right"
-                }
-                y* {
-                    set y [expr {round($y + $y0+0.5*$ph)}]
-                    set dir "left"
-                    set ally [$itk_component(plot) y2axis use]
-                    set max [llength $ally]
-                    set i [lsearch -exact $ally $axis]
-                    set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-                    set x [expr {round($x+$x0+$pw + ($i+0.5)*($w-$x0-$pw)/double($max))}]
-                }
-            }
-            $itk_component(hull).axes activate @$x,$y $dir
-        }
-        changed {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Axis changed axis what\""
-            }
-            set axis [lindex $args 0]
-            set what [lindex $args 1]
-            if {$what == "focus"} {
-                set what [focus]
-                if {[winfo exists $what]} {
-                    set what [winfo name $what]
-                }
-            }
-
-            switch -- $what {
-                label {
-                    set val [$inner.label get]
-                    $itk_component(plot) axis configure $axis -title $val
-                    Rappture::Logger::log number axis $axis -title $val
-                }
-                min {
-                    set val [$inner.min get]
-                    if {![string is double -strict $val]} {
-                        Rappture::Tooltip::cue $inner.min "Must be a number"
-                        bell
-                        return
-                    }
-
-                    set max [lindex [$itk_component(plot) axis limits $axis] 1]
-                    if {$val >= $max} {
-                        Rappture::Tooltip::cue $inner.min "Must be <= max ($max)"
-                        bell
-                        return
-                    }
-                    catch {
-                        # can fail in log mode
-                        $itk_component(plot) axis configure $axis -min $val
-                        Rappture::Logger::log number axis $axis -min $val
-                    }
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.min delete 0 end
-                    $inner.min insert end $min
-                }
-                max {
-                    set val [$inner.max get]
-                    if {![string is double -strict $val]} {
-                        Rappture::Tooltip::cue $inner.max "Should be a number"
-                        bell
-                        return
-                    }
-
-                    set min [lindex [$itk_component(plot) axis limits $axis] 0]
-                    if {$val <= $min} {
-                        Rappture::Tooltip::cue $inner.max "Must be >= min ($min)"
-                        bell
-                        return
-                    }
-                    catch {
-                        # can fail in log mode
-                        $itk_component(plot) axis configure $axis -max $val
-                        Rappture::Logger::log number axis $axis -max $val
-                    }
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.max delete 0 end
-                    $inner.max insert end $max
-                }
-                format {
-                    set fmt [$inner.format translate [$inner.format value]]
-                    set _axisPopup(format-$axis) $fmt
-
-                    # force a refresh
-                    $itk_component(plot) axis configure $axis -min \
-                        [$itk_component(plot) axis cget $axis -min]
-                }
-                scale {
-                    Axis scale $axis $_axisPopup(scale)
-                    Rappture::Logger::log number axis $axis -scale $_axisPopup(scale)
-
-                    if {$_axisPopup(scale) == "log"} {
-                        $inner.format configure -state disabled
-                    } else {
-                        $inner.format configure -state normal
-                    }
-
-                    foreach {min max} [$itk_component(plot) axis limits $axis] break
-                    $inner.min delete 0 end
-                    $inner.min insert end $min
-                    $inner.max delete 0 end
-                    $inner.max insert end $max
-                }
-                default {
-                    # be lenient so we can handle the "focus" case
-                }
-            }
-        }
-        format {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis format axis widget value\""
-            }
-            set axis [lindex $args 0]
-            set value [lindex $args 2]
-
-            if {$axis == "x" && $_xlabels
-                  && [info exists _xval2label($value)]} {
-                return $_xval2label($value)
-            }
-            if {[$itk_component(plot) axis cget $axis -logscale]} {
-                set fmt "%.6g"
-            } else {
-                set fmt $_axisPopup(format-$axis)
-            }
-            return [format $fmt $value]
-        }
-        scale {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Axis scale axis type\""
-            }
-            set axis [lindex $args 0]
-            set type [lindex $args 1]
-
-            if {$type == "log"} {
-                catch {$itk_component(plot) axis configure $axis -logscale 1}
-                # leave format alone in log mode
-                $itk_component(plot) axis configure $axis -command ""
-            } else {
-                catch {$itk_component(plot) axis configure $axis -logscale 0}
-                # use special formatting for linear mode
-                $itk_component(plot) axis configure $axis -command \
-                    [itcl::code $this Axis format $axis]
-            }
-        }
-        default {
-            error "bad option \"$option\": should be changed, edit, hilite, or format"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetAxes <dataobj>
-#
-# Used internally to figure out the axes used to plot the given
-# <dataobj>.  Returns a list of the form {x y}, where x is the
-# x-axis name (x, x2, x3, etc.), and y is the y-axis name.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::GetAxes {dataobj} {
-    # rebuild if needed, so we know about the axes
-    if {[$_dispatcher ispending !rebuild]} {
-        $_dispatcher cancel !rebuild
-        $_dispatcher event -now !rebuild
-    }
-
-    # what is the x axis?  x? x2? x3? ...
-    set xlabel "Simulation #"
-    if {[info exists _label2axis(x-$xlabel)]} {
-        set mapx $_label2axis(x-$xlabel)
-    } else {
-        set mapx "x"
-    }
-
-    # what is the y axis?  y? y2? y3? ...
-    set ylabel [$dataobj get about.label]
-    if {[info exists _label2axis(y-$ylabel)]} {
-        set mapy $_label2axis(y-$ylabel)
-    } else {
-        set mapy "y"
-    }
-
-    return [list $mapx $mapy]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetValue <dataobj> ?<axis>?
-#
-# Used internally to get the {x y} value from this <dataobj>.
-# Returns x, y, or {x y} in the expected units for this object.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::GetValue {dataobj {which both}} {
-    if {[info exists _dataobj2param($dataobj)]} {
-        set x [lindex $_dataobj2param($dataobj) 1]
-    } else {
-        set x 0
-    }
-
-    set y [$dataobj get current]
-    set units [$dataobj get units]
-    if {$units != ""} {
-        set y [Rappture::Units::convert $y -context $units -to $units -units off]
-    }
-    if {![string is double -strict $y]} {
-        set y 0
-    }
-
-    switch -- $which {
-        x { return $x }
-        y { return $y }
-        both { return [list $x $y] }
-        default { error "bad value \"$which\": should be x, y, both" }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetInfo <what> <dataobj> ?<axis>?
-#
-# Used internally to get the {x y} labels from this <dataobj>.
-# Returns xlabel, ylabel, or {xlabel ylabel}.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NumberResult::GetInfo {what dataobj {which both}} {
-    set x [lindex $_params 0]
-    set y [$dataobj get $what]
-    if {$what == "about.label"} {
-        set units [$dataobj get units]
-        if {"" != $units} {
-            append y " ($units)"
-        }
-    }
-
-    switch -- $which {
-        x { return $x }
-        y { return $y }
-        both { return [list $x $y] }
-        default { error "bad value \"$which\": should be x, y, both" }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -gridcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::NumberResult::gridcolor {
-    if {"" == $itk_option(-gridcolor)} {
-        $itk_component(plot) grid off
-    } else {
-        $itk_component(plot) grid configure -color $itk_option(-gridcolor)
-        $itk_component(plot) grid on
-    }
-}
-
-#
-# ResetLegend --
-#
-itcl::body Rappture::NumberResult::ResetLegend {} {
-    set g $itk_component(plot)
-    update idletasks
-    $itk_component(legend) reset [$g element show]
-}
Index: trunk/gui/scripts/page.tcl
===================================================================
--- trunk/gui/scripts/page.tcl	(revision 6716)
+++ 	(revision )
@@ -1,241 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: page - single page of widgets
-#
-#  This widget is a smart frame.  It takes the XML description for
-#  a Rappture <input> or an <input><phase> and decides how to lay
-#  out the widgets for the controls within it.  It uses various
-#  heuristics to achieve a decent layout under a variety of
-#  circumstances.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::Page {
-    inherit itk::Widget
-
-    constructor {owner path args} { # defined below }
-
-    protected method _buildGroup {frame xmlobj path}
-    protected method _link {xmlobj path widget path2}
-
-    private variable _owner ""       ;# thing managing this page
-}
-
-itk::usual Page {
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Page::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] || !$valid} {
-        error "object \"$owner\" is not a Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set xmlobj [$owner xml object]
-
-    set type [$xmlobj element -as type $path]
-    if {$type != "input" && $type != "phase"} {
-        error "bad path \"$path\" in $xmlobj: should be <input> or <input><phase>"
-    }
-
-    eval itk_initialize $args
-
-    # build all of the controls for this page
-    _buildGroup $itk_interior $xmlobj $path
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _buildGroup <frame> <xmlobj> <path>
-#
-# Used internally when this page is being constructed to build the
-# controls within the group at the specified <path> in the <xmlobj>.
-# The controls are added to the given <frame>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Page::_buildGroup {frame xmlobj path} {
-    frame $frame.results
-    pack $frame.results -side right -fill y
-
-    set deveditor ""
-
-    #
-    # Scan through all remaining input elements.  If there is an
-    # ambient group, then add its children to the device editor,
-    # if there is one.
-    #
-    set num 0
-    set clist [$xmlobj children $path]
-    while {[llength $clist] > 0} {
-        set cname [lindex $clist 0]
-        set clist [lrange $clist 1 end]
-
-        set type [$xmlobj element -as type $path.$cname]
-        if {$type == "about"} {
-            continue
-        }
-        if {$type == "loader"} {
-            #
-            # Add <loader>'s at the top of the page.
-            #
-            if {![winfo exists $frame.loaders]} {
-                frame $frame.loaders
-                pack $frame.loaders -side top -fill x
-
-                frame $frame.loaders.sep -height 2 \
-                    -borderwidth 1 -relief sunken
-                pack $frame.loaders.sep -side bottom -fill x -pady 4
-            }
-            set w "$frame.loaders.l[incr num]"
-            Rappture::Controls $w $_owner
-            pack $w -fill x
-            $w insert end $path.$cname
-        } elseif {$type == "structure"} {
-            #
-            # Add <structure>'s as the central element of the page.
-            #
-            set w "$frame.device[incr num]"
-            Rappture::DeviceEditor ::$w $_owner@$path.$cname.current
-            pack $w -expand yes -fill both
-            $_owner widgetfor $path.$cname $w
-            bind $w <<Value>> [list $_owner changed $path.$cname]
-
-            if {"" == $deveditor} {
-                set deveditor $w
-            }
-
-            # if there's a default value, load it now
-            if {"" != [$xmlobj element -as type $path.$cname.current]} {
-                set elem $path.$cname.current
-            } else {
-                set elem $path.$cname.default
-            }
-            if {"" != [$xmlobj element -as type $elem]} {
-                set val [$xmlobj get $elem]
-                if {[string length $val] > 0} {
-                    $w value $val
-                    $xmlobj put $path.$cname.current $val
-                } else {
-                    set obj [$xmlobj element -as object $elem]
-                    $w value $obj
-                    $xmlobj put $path.$cname.current $obj
-                }
-            }
-
-            # if there's a link, then set up a callback to load from it
-            set link [$xmlobj get $path.$cname.link]
-            if {"" != $link} {
-                $_owner notify add $this $link \
-                    [itcl::code $this _link $xmlobj $link $w $path.$cname]
-            }
-        } elseif {$type == "tool"} {
-            set service [Rappture::Service ::#auto $_owner $path.$cname]
-            #
-            # Scan through all extra inputs associated with this subtool
-            # and create corresponding inputs in the top-level tool.
-            # Then, add the input names to the list being processed here,
-            # so that we'll create the controls during subsequent passes
-            # through the loop.
-            #
-            set extra ""
-            foreach obj [$service input] {
-                set cname [$obj element]
-                $xmlobj copy $path.$cname from $obj ""
-                lappend extra $cname
-            }
-
-            #
-            # If there's a control for this service, then add it
-            # to the end of the extra controls added above.
-            #
-            foreach obj [$service control] {
-                set cname [$obj element]
-                $xmlobj copy $path.$cname from $obj ""
-                $xmlobj put $path.$cname.service $service
-                lappend extra $cname
-            }
-            if {[llength $extra] > 0} {
-                set clist [eval linsert [list $clist] 0 $extra]
-            }
-
-            #
-            # Scan through all outputs associated with this subtool
-            # and create any corresponding feedback widgets.
-            #
-            foreach obj [$service output] {
-                set cname [$obj element]
-                $xmlobj copy $cname from $obj ""
-
-                # pick a good size based on output type
-                set w $frame.results.result[incr num]
-                set type [$obj element -as type]
-                switch -- $type {
-                    number - integer - boolean - choice - multichoice {
-                        Rappture::ResultViewer $w -width 0 -height 0
-                        pack $w -fill x -padx 4 -pady 4
-                    }
-                    default {
-                        Rappture::ResultViewer $w -width 4i -height 4i
-                        pack $w -expand yes -fill both -padx 4 -pady 4
-                    }
-                }
-                $service output for $obj $w
-            }
-        } elseif {$type == "current"} {
-            # Don't do anything.
-        } else {
-            # create a control panel, if necessary
-            if {![winfo exists $frame.cntls]} {
-                Rappture::Controls $frame.cntls $_owner \
-                    -layout [$xmlobj get $path.about.layout]
-                pack $frame.cntls -expand yes -fill both -pady 4
-            }
-
-            # if this is a group, then build that group
-            if {[$xmlobj element -as type $path.$cname] eq "group"} {
-                if {[$xmlobj element -as id $path.$cname] eq "ambient"
-                       && $deveditor != ""} {
-                    set w [$deveditor component top]
-                } else {
-                    if {[$_owner widgetfor $path.$cname] ne ""} {
-                        # widget already created -- skip this
-                    } elseif {[catch {$frame.cntls insert end $path.$cname} c]} {
-                        global errorInfo
-                        error $c "$c\n$errorInfo\n    (while building control for $path.$cname)"
-                    } else {
-                        set gentry [$frame.cntls control $c]
-                        set w [$gentry component inner]
-                    }
-                }
-                _buildGroup $w $xmlobj $path.$cname
-            } else {
-                if {[$_owner widgetfor $path.$cname] ne ""} {
-                    # widget already created -- skip this
-                } elseif {[catch {$frame.cntls insert end $path.$cname} c]} {
-                    global errorInfo
-                    error $c "$c\n$errorInfo\n    (while building control for $path.$cname)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::Page::_link {xmlobj path w path2} {
-    if {"" != [$xmlobj element -as type $path.current]} {
-        set val [$xmlobj get $path.current]
-        if {[string length $val] > 0} {
-            $w value $val
-            $xmlobj put $path.current $val
-        } else {
-            set obj [$xmlobj element -as object $path.current]
-            $w value $obj
-            $xmlobj put $path.current $obj
-        }
-    }
-    $_owner changed $path2
-}
Index: trunk/gui/scripts/pager.tcl
===================================================================
--- trunk/gui/scripts/pager.tcl	(revision 6716)
+++ trunk/gui/scripts/pager.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: pager - notebook for displaying pages of widgets
@@ -8,43 +7,20 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
 package require BLT
 
-option add *Pager.arrangement "pages" widgetDefault
 option add *Pager.width 0 widgetDefault
 option add *Pager.height 0 widgetDefault
-option add *Pager.padding 8 widgetDefault
-option add *Pager.crumbColor black widgetDefault
-option add *Pager.crumbNumberColor white widgetDefault
-option add *Pager.dimCrumbColor gray70 widgetDefault
-option add *Pager.activeCrumbColor blue widgetDefault
-option add *Pager.crumbFont \
-    -*-helvetica-bold-r-normal-*-12-* widgetDefault
-
-blt::bitmap define Pager-arrow {
-#define arrow_width 9
-#define arrow_height 9
-static unsigned char arrow_bits[] = {
-   0x10, 0x00, 0x30, 0x00, 0x70, 0x00, 0xff, 0x00, 0xff, 0x01, 0xff, 0x00,
-   0x70, 0x00, 0x30, 0x00, 0x10, 0x00};
-}
+option add *Pager.arrangement "tabs/top" widgetDefault
+option add *Pager.tearoff 0 widgetDefault
 
 itcl::class Rappture::Pager {
     inherit itk::Widget
 
+    itk_option define -arrangement arrangement Arrangement ""
     itk_option define -width width Width 0
     itk_option define -height height Height 0
-    itk_option define -padding padding Padding 0
-    itk_option define -crumbcolor crumbColor Foreground ""
-    itk_option define -crumbnumbercolor crumbNumberColor Foreground ""
-    itk_option define -crumbfont crumbFont Font ""
-    itk_option define -dimcrumbcolor dimCrumbColor DimForeground ""
-    itk_option define -activecrumbcolor activeCrumbColor ActiveForeground ""
-    itk_option define -arrangement arrangement Arrangement ""
 
     constructor {args} { # defined below }
@@ -53,21 +29,15 @@
     public method delete {first {last ""}}
     public method index {name}
-    public method page {args}
-    public method current {args}
-
-    public method busy { bool }
+    public method get {{name ""}}
 
     protected method _layout {}
-    protected method _fixSize {}
-    protected method _drawCrumbs {how}
-
-    private variable _counter 0      ;# counter for page names
+
     private variable _dispatcher ""  ;# dispatcher for !events
     private variable _pages ""       ;# list of known pages
-    private variable _page2info      ;# maps page name => -frame,-title,-command
-    private variable _current ""     ;# page currently shown
-    public variable nosim 0
-}
-
+    private variable _page2frame     ;# maps page name => frame
+    private variable _counter 0      ;# counter for frame names
+    private variable _arrangement "" ;# last value of -arrangment
+}
+                                                                                
 itk::usual Pager {
 }
@@ -80,61 +50,35 @@
     $_dispatcher register !layout
     $_dispatcher dispatch $this !layout "[itcl::code $this _layout]; list"
-    $_dispatcher register !fixsize
-    $_dispatcher dispatch $this !fixsize "[itcl::code $this _fixSize]; list"
-
-    itk_component add controls {
-        frame $itk_interior.cntls
-    }
-
-    itk_component add next {
-        button $itk_component(controls).next -text "Next >" \
-            -command [itcl::code $this current next>]
-    }
-    pack $itk_component(next) -side right
-
-    itk_component add back {
-        button $itk_component(controls).back -text "< Back" \
-            -command [itcl::code $this current <back]
-    }
-    pack $itk_component(back) -side left
-
-    set font [$itk_component(next) cget -font]
-    set ht [font metrics $font -linespace]
-    itk_component add breadcrumbarea {
-        frame $itk_interior.bcarea
-    }
-    itk_component add breadcrumbs {
-        canvas $itk_component(breadcrumbarea).breadcrumbs \
-            -width 10 -height [expr {$ht+2}]
-    }
-    pack $itk_component(breadcrumbs) -side left -expand yes -fill both \
-        -padx 8 -pady 8
-
-    itk_component add line {
-        frame $itk_interior.line -height 2 -borderwidth 1 -relief sunken
-    }
-
+
+    itk_component add tabs {
+        blt::tabset $itk_interior.tabs -borderwidth 0 -relief flat \
+            -side bottom -selectcommand [itcl::code $this _layout]
+    } {
+        keep -activebackground -activeforeground
+        keep -background -cursor -font
+        rename -highlightbackground -background background Background
+        keep -highlightcolor -highlightthickness
+        keep -selectbackground -selectforeground
+        keep -tabbackground -tabforeground
+        keep -tearoff
+    }
+    pack $itk_component(tabs) -expand yes -fill both
 
     itk_component add inside {
-        frame $itk_interior.inside
-    }
-    pack $itk_component(inside) -expand yes -fill both
-    pack propagate $itk_component(inside) no
+        frame $itk_component(tabs).inside
+    }
+    $_dispatcher event -idle !layout
 
     eval itk_initialize $args
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# USAGE: insert <pos> ?-name <name>? ?-title <label>? ?-command <str>?
-#
-# Clients use this to insert a new page into this pager.  The page is
-# inserted into the list at position <pos>, which can be an integer
-# starting from 0 or the keyword "end".  The optional <name> can be
-# used to identify the page.  If it is not supplied, a name is created
-# for the page.  The -title and -command are other values associated
-# with the page.
-#
-# Returns the name used to identify the page.
+}
+
+# ----------------------------------------------------------------------
+# USAGE: insert <pos> <name> ?<name>...?
+#
+# Clients use this to insert one or more new pages into this pager.
+# The pages are inserted into the list at position <pos>, which can
+# be an integer starting from 0 or the keyword "end".  Each <name>
+# is the name used to identify the page.  Returns the name of a frame
+# for each page created.
 # ----------------------------------------------------------------------
 itcl::body Rappture::Pager::insert {pos args} {
@@ -145,46 +89,22 @@
     }
 
-    Rappture::getopts args params {
-        value -name page#auto
-        value -title "Page #auto"
-        value -command ""
-    }
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"insert pos ?-name n? ?-title t? ?-command c?\""
-    }
-
-    incr _counter
-    if {$_counter > 1} {
-        set subst "#$_counter"
-    } else {
-        set subst ""
-    }
-    if {[regexp {#auto} $params(-name)]} {
-        regsub -all {#auto} $params(-name) $subst params(-name)
-    }
-    if {[regexp {#auto} $params(-title)]} {
-        regsub -all {#auto} $params(-title) $subst params(-title)
-    }
-
-    # allocate the page
-    if {[info exists _page2info($params(-name)-frame)]} {
-        error "page \"$params(-name)\" already exists"
-    }
-    set win $itk_component(inside).page$_counter
-    frame $win
-    set _page2info($params(-name)-frame) $win
-    set _page2info($params(-name)-title) $params(-title)
-    set _page2info($params(-name)-command) $params(-command)
-    set _pages [linsert $_pages $pos $params(-name)]
-
-    bind $win <Configure> \
-        [itcl::code $_dispatcher event -idle !fixsize]
-
-    # the number of pages affects the arrangment -- force an update
-    configure -arrangement $itk_option(-arrangement)
-
-    $_dispatcher event -idle !layout
-
-    return $params(-name)
+    set rlist ""
+    foreach name $args {
+        if {[info exists _page2frame($name)]} {
+            error "page \"$name\" already exists"
+        }
+        set win $itk_component(inside).page[incr _counter]
+        frame $win
+        set _page2frame($name) $win
+        set _pages [linsert $_pages $pos $name]
+        lappend rlist $win
+
+        if {[string match tabs/* $_arrangement]} {
+            $itk_component(tabs) insert $pos $name
+        }
+    }
+    $_dispatcher event -idle !layout
+
+    return $rlist
 }
 
@@ -211,177 +131,42 @@
 
     foreach name [lrange $_pages $first $last] {
-        if {[info exists _page2info($name-frame)]} {
-            destroy $_page2info($name-frame)
-            unset _page2info($name-frame)
-            unset _page2info($name-title)
-            unset _page2info($name-command)
+        if {[info exists _page2frame($name)]} {
+            destroy $_page2frame($name)
+            unset _page2frame($name)
         }
     }
     set _pages [lreplace $_pages $first $last]
 
-    # the number of pages affects the arrangment -- force an update
-    configure -arrangement $itk_option(-arrangement)
-
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# USAGE: index <name>|@n
+    if {[string match tabs/* $_arrangement]} {
+        $itk_component(tabs) delete $first $last
+    }
+    $_dispatcher event -idle !layout
+}
+
+# ----------------------------------------------------------------------
+# USAGE: index <name>
 #
 # Clients use this to convert a page <name> into its corresponding
-# integer index.  Returns an error if the <name> is not recognized.
+# integer index.  Returns -1 if the <name> is not recognized.
 # ----------------------------------------------------------------------
 itcl::body Rappture::Pager::index {name} {
-    set i [lsearch $_pages $name]
-    if {$i >= 0} {
-        return $i
-    }
-    if {[regexp {^@([0-9]+)$} $name match i]} {
-        return $i
-    }
-    error "bad page name \"$name\": should be @int or one of [join [lsort $_pages] {, }]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: page
-# USAGE: page <name>|@n ?-frame|-title|-command? ?<newvalue>?
+    return [lsearch -exact $_pages $name]
+}
+
+# ----------------------------------------------------------------------
+# USAGE: get ?<name>?
 #
 # Clients use this to get information about pages.  With no args, it
-# returns a list of all page names.  Otherwise, it returns the
-# requested information for a page specified by its <name> or index
-# @n.  By default, it returns the -frame for the page, but it can
-# also return the -title and -command.  The -title and -command
-# can also be set to a <newvalue>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Pager::page {args} {
-    if {[llength $args] == 0} {
+# returns a list of all page names.  Otherwise, it returns the frame
+# associated with a page name.
+# ----------------------------------------------------------------------
+itcl::body Rappture::Pager::get {{name ""}} {
+    if {$name == ""} {
         return $_pages
     }
-    set i [index [lindex $args 0]]
-    set name [lindex $_pages $i]
-
-    set args [lrange $args 1 end]
-    Rappture::getopts args params {
-        flag what -frame default
-        flag what -title
-        flag what -command
-    }
-
-    if {[llength $args] == 0} {
-        set opt $params(what)
-        return $_page2info($name$opt)
-    } elseif {[llength $args] == 1} {
-        set val [lindex $args 0]
-        if {$params(-title)} {
-            set _page2info($name-title) $val
-        } elseif {$params(-command)} {
-            set _page2info($name-command) $val
-        }
-    } else {
-        error "wrong # args: should be \"page ?which? ?-frame|-title|-command? ?newvalue?\""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current ?<name>|next>|<back?
-#
-# Used to query/set the current page in the notebook.  With no args,
-# it returns the name of the current page.  Otherwise, it sets the
-# current page.  The special token "next>" is used to set the pager
-# to the next logical page, and "<back" sets to the previous.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Pager::current {args} {
-    switch -- [llength $args] {
-        0 {
-            return $_current
-        }
-        1 {
-            if {$itk_option(-arrangement) != "pages"} {
-                return ""
-            }
-            set name [lindex $args 0]
-            set index 0
-            if {$name == "next>"} {
-                if {$_current == ""} {
-                    set index 0
-                } else {
-                    set i [lsearch -exact $_pages $_current]
-                    set index [expr {$i+1}]
-                    if {$index >= [llength $_pages]} {
-                        set index [expr {[llength $_pages]-1}]
-                    }
-                }
-                set _current [lindex $_pages $index]
-            } elseif {$name == "<back"} {
-                if {$_current == ""} {
-                    set index end
-                } else {
-                    set i [lsearch -exact $_pages $_current]
-                    set index [expr {$i-1}]
-                    if {$index < 0} {
-                        set index 0
-                    }
-                }
-                set _current [lindex $_pages $index]
-            } else {
-                if {$name == ""} {
-                    set _current ""
-                    set index 0
-                } else {
-                    set index [lsearch -exact $_pages $name]
-                    if {$index < 0} {
-                        error "can't move to page \"$name\""
-                    }
-                    set _current [lindex $_pages $index]
-                }
-            }
-
-            foreach w [pack slaves $itk_component(inside)] {
-                pack forget $w
-            }
-            if {$_current != ""} {
-                pack $_page2info($_current-frame) -expand yes -fill both \
-                    -padx $itk_option(-padding) -pady $itk_option(-padding)
-            }
-
-            if {$index == 0} {
-                pack forget $itk_component(back)
-            } else {
-                set prev [expr {$index-1}]
-                if {$prev >= 0} {
-                    set label "< [page @$prev -title]"
-                } else {
-                    set label "< Back"
-                }
-                $itk_component(back) configure -text $label
-                pack $itk_component(back) -side left
-            }
-            if {$index == [expr {[llength $_pages]-1}]} {
-                pack forget $itk_component(next)
-            } else {
-                set next [expr {$index+1}]
-                if {$next <= [llength $_pages]} {
-                    set label "[page @$next -title] >"
-                } else {
-                    set label "Next >"
-                }
-                $itk_component(next) configure -text $label
-                pack $itk_component(next) -side right
-            }
-            _drawCrumbs current
-
-            #
-            # If this new page has a command associated with it, then
-            # invoke it now.
-            #
-            if {"" != $_current && !$nosim && 
-                  [string length $_page2info($_current-command)] > 0} {
-                uplevel #0 $_page2info($_current-command)
-            }
-        }
-        default {
-            error "wrong # args: should be \"current name|next>|<back\""
-        }
-    }
+    if {[info exists _page2frame($name)]} {
+        return $_page2frame($name)
+    }
+    return ""
 }
 
@@ -393,265 +178,111 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Pager::_layout {} {
-    if {$itk_option(-arrangement) == "pages"} {
-        if {$_current == ""} {
-            set _current [lindex $_pages 0]
-            if {$_current != ""} {
-                current $_current
-            }
-        }
-        _drawCrumbs all
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Invoked automatically whenever a page changes size or the -width
-# or -height options change.  When the -width/-height are zero, this
-# method computes the minimum size needed to accommodate all pages.
-# Otherwise, it passes the size request onto the hull.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Pager::_fixSize {} {
-    set sw [expr {[winfo screenwidth $itk_component(hull)]-200}]
-    set sh [expr {[winfo screenheight $itk_component(hull)]-200}]
-
-    update  ;# force layout changes so sizes are correct
-    switch -- $itk_option(-arrangement) {
-        pages {
-            if {$itk_option(-width) <= 0} {
-                set maxw [expr {
-                    [winfo reqwidth $itk_component(next)]
-                    + 10
-                    + [winfo reqwidth $itk_component(back)]}]
-
-                foreach name $_pages {
-                    set w [winfo reqwidth $_page2info($name-frame)]
-                    if {$w > $maxw} { set maxw $w }
-                }
-                set maxw [expr {$maxw + 2*$itk_option(-padding)}]
-                if {$maxw > $sw} { set maxw $sw }
-                $itk_component(inside) configure -width $maxw
+    #
+    # If the new arrangement doesn't match the last one, then
+    # clear the effects of the old arrangement.
+    #
+    regexp {(.*)/?} $_arrangement match oldatype
+    regexp {(.*)/?} $itk_option(-arrangement) match newatype
+
+    if {$newatype != $oldatype} {
+        switch -glob -- $_arrangement {
+            tabs/* {
+                foreach name $_pages {
+                    pack forget $_page2frame($name)
+                }
+                pack forget $itk_component(inside)
+                catch {$itk_component(tabs) delete 0 end}
+            }
+            stack {
+                foreach name $_pages {
+                    pack forget $_page2frame($name)
+                }
+            }
+        }
+        switch -glob -- $itk_option(-arrangement) {
+            tabs/* {
+                foreach name $_pages {
+                    $itk_component(tabs) insert end $name
+                }
+                if {[llength $_pages] > 0} {
+                    $itk_component(tabs) select 0
+                }
+            }
+        }
+    }
+    set _arrangement $itk_option(-arrangement)
+
+    #
+    # Apply the new arrangement.
+    #
+    switch -glob -- $itk_option(-arrangement) {
+        tabs/* {
+            set side [lindex [split $itk_option(-arrangement) /] 1]
+            if {$side == ""} { set side "top" }
+            $itk_component(tabs) configure -side $side
+
+            if {[llength $_pages] <= 1} {
+                pack $itk_component(inside) -expand yes -fill both
+                set first [lindex $_pages 0]
+                if {$first != ""} {
+                    pack $_page2frame($first) -expand yes -fill both
+                }
             } else {
-                $itk_component(inside) configure -width $itk_option(-width)
-            }
-
-            if {$itk_option(-height) <= 0} {
-                set maxh 0
-                foreach name $_pages {
-                    set h [winfo reqheight $_page2info($name-frame)]
-                    if {$h > $maxh} { set maxh $h }
-                }
-                set maxh [expr {$maxh + 2*$itk_option(-padding)}]
-                if {$maxh > $sh} { set maxh $sh }
-                $itk_component(inside) configure -height $maxh
-            } else {
-                $itk_component(inside) configure -height $itk_option(-height)
-            }
-        }
-        side-by-side {
-            if {$itk_option(-width) <= 0} {
-                set maxw [expr {
-                    [winfo reqwidth $itk_component(next)]
-                    + 10
-                    + [winfo reqwidth $itk_component(back)]}]
-
-                set wtotal 0
-                foreach name $_pages {
-                    set w [winfo reqwidth $_page2info($name-frame)]
-                    set wtotal [expr {$wtotal + $w + 2*$itk_option(-padding)}]
-                }
-                if {$wtotal > $maxw} { set maxw $wtotal }
-                if {$maxw > $sw} { set maxw $sw }
-                $itk_component(inside) configure -width $maxw
-            } else {
-                $itk_component(inside) configure -width $itk_option(-width)
-            }
-
-            if {$itk_option(-height) <= 0} {
-                set maxh 0
-                foreach name $_pages {
-                    set h [winfo reqheight $_page2info($name-frame)]
-                    if {$h > $maxh} { set maxh $h }
-                }
-                set maxh [expr {$maxh + 2*$itk_option(-padding)}]
-                if {$maxh > $sh} { set maxh $sh }
-                $itk_component(inside) configure -height $maxh
-            } else {
-                $itk_component(inside) configure -height $itk_option(-height)
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -arrangement
+                pack forget $itk_component(inside)
+                set i [$itk_component(tabs) index select]
+                if {$i != ""} {
+                    set name [$itk_component(tabs) get $i]
+                    $itk_component(tabs) tab configure $name \
+                        -window $itk_component(inside) -fill both
+                }
+
+                foreach name $_pages {
+                    pack forget $_page2frame($name)
+                }
+                if {$i != ""} {
+                    set name [lindex $_pages $i]
+                    if {$name != ""} {
+                        pack $_page2frame($name) -expand yes -fill both
+                    }
+                }
+            }
+        }
+        stack {
+            foreach name $_pages {
+                pack forget $_page2frame($name)
+            }
+            foreach name $_pages {
+                pack $_page2frame($name) -expand yes -fill both
+            }
+            pack $itk_component(inside) -expand yes -fill both
+        }
+    }
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -arrangement
 # ----------------------------------------------------------------------
 itcl::configbody Rappture::Pager::arrangement {
-    switch -- $itk_option(-arrangement) {
-        pages {
-            pack forget $itk_component(inside)
-            pack $itk_component(controls) -side bottom -fill x -padx 60 -pady 8
-            pack $itk_component(breadcrumbarea) -side top -fill x
-            pack $itk_component(line) -side top -fill x
-            pack $itk_component(inside) -expand yes -fill both
-            current [lindex $_pages 0]
-        }
-        side-by-side {
-            pack forget $itk_component(controls)
-            pack forget $itk_component(line)
-            pack forget $itk_component(breadcrumbarea)
-
-            foreach w [pack slaves $itk_component(inside)] {
-                pack forget $w
-            }
-            foreach name $_pages {
-                pack $_page2info($name-frame) -side left \
-                    -expand yes -fill both \
-                    -padx $itk_option(-padding) -pady $itk_option(-padding)
-            }
-        }
-        default {
-            error "bad value \"$itk_option(-arrangement)\": should be pages or side-by-side"
-        }
-    }
-    $_dispatcher event -now !fixsize
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -width
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Pager::width {
-    $_dispatcher event -idle !fixsize
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -height
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Pager::height {
-    $_dispatcher event -idle !fixsize
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -padding
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Pager::padding {
-    if {$_current != ""} {
-        pack $_page2info($_current-frame) -expand yes -fill both \
-            -padx $itk_option(-padding) -pady $itk_option(-padding)
-    }
-    $_dispatcher event -idle !fixsize
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _drawCrumbs all|current
-#
-# Invoked automatically whenever the pages change.  The value "all"
-# signifies that the number of pages has changed, so all should be
-# redrawn.  The value "current" means that the current page has
-# changed, so there is just a simple color change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Pager::_drawCrumbs {how} {
-    set c $itk_component(breadcrumbs)
-    set fnt $itk_option(-crumbfont)
-
-    switch -- $how {
-        all {
-            $c delete all
-
-            set x 0
-            set y [expr {[winfo reqheight $c]/2}]
-            set last [lindex $_pages end]
-
-            set num 1
-            foreach name $_pages {
-                set ht [expr {[font metrics $fnt -linespace]+2}]
-                set id [$c create oval $x [expr {$y-$ht/2}] \
-                    [expr {$x+$ht}] [expr {$y+$ht/2}] \
-                    -outline "" -fill $itk_option(-dimcrumbcolor) \
-                    -tags $name]
-                set id [$c create text [expr {$x+$ht/2}] [expr {$y+1}] \
-                    -text $num -fill $itk_option(-crumbnumbercolor) \
-                    -tags [list $name $name-num]]
-                set x [expr {$x + $ht+2}]
-
-                set id [$c create text $x [expr {$y+1}] -anchor w \
-                    -text [page $name -title] -font $fnt -tags $name]
-
-                $c bind $name <Enter> [itcl::code $this _drawCrumbs active]
-                $c bind $name <Leave> [itcl::code $this _drawCrumbs current]
-                $c bind $name <ButtonPress> [itcl::code $this current $name]
-
-                foreach {x0 y0 x1 y1} [$c bbox $id] break
-                set x [expr {$x + ($x1-$x0)+6}]
-
-                if {$name != $last} {
-                    set id [$c create bitmap $x $y -anchor w \
-                        -bitmap Pager-arrow \
-                        -foreground $itk_option(-dimcrumbcolor)]
-                    foreach {x0 y0 x1 y1} [$c bbox $id] break
-                    set x [expr {$x + ($x1-$x0)+6}]
-                }
-
-                incr num
-            }
-
-            # fix the scrollregion in case we go off screen
-            $c configure -scrollregion [$c bbox all]
-
-            _drawCrumbs current
-        }
-        current {
-            # make all crumbs dim
-            foreach name $_pages {
-                $c itemconfigure $name \
-                    -fill $itk_option(-dimcrumbcolor)
-                $c itemconfigure $name-num \
-                    -fill $itk_option(-crumbnumbercolor)
-            }
-
-            # make all the current crumb bright
-            if {$_current != ""} {
-                $c itemconfigure $_current \
-                    -fill $itk_option(-crumbcolor)
-                $c itemconfigure $_current-num \
-                    -fill $itk_option(-crumbnumbercolor)
-
-                # scroll the view to see the crumb
-                if {[$c bbox $_current] != ""} {
-                    foreach {x0 y0 x1 y1} [$c bbox $_current] break
-                    foreach {xm0 ym0 xm1 ym1} [$c bbox all] break
-                    set xm [expr {double($x0)/($xm1-$xm0)}]
-                    $c xview moveto $xm
-                }
-            } else {
-                $c xview moveto 0
-            }
-        }
-        active {
-            foreach tag [$c gettags current] {
-                if {[lsearch -exact $_pages $tag] >= 0} {
-                    $c itemconfigure $tag -fill $itk_option(-activecrumbcolor)
-                    $c itemconfigure $tag-num -fill white
-                }
-            }
-        }
-    }
-}
-
-#
-# busy --
-#
-#       If true (this indicates a simulation is occurring), the widget
-#       should prevent the user from
-#               1) clicking an item previous in the breadcrumbs, and
-#               2) using the "back" button.
-#
-itcl::body Rappture::Pager::busy { bool } {
-    if { $bool } {
-        blt::busy hold $itk_component(breadcrumbs)
-        $itk_component(back) configure -state disabled
-    } else {
-        blt::busy release $itk_component(breadcrumbs)
-        $itk_component(back) configure -state normal
-    }
-}
+    set legal {tabs/top tabs/bottom tabs/left tabs/right stack}
+    if {[lsearch -exact $legal $itk_option(-arrangement)] < 0} {
+        error "bad option \"$itk_option(-arrangement)\": should be one of [join [lsort $legal] {, }]"
+    }
+    $_dispatcher event -idle !layout
+}
+
+source dispatcher.tcl
+
+Rappture::Pager .p
+pack .p -expand yes -fill both
+
+set f [.p component inside]
+label $f.top -text "top"
+pack $f.top -fill x
+
+set f [.p insert end "Electrical"]
+label $f.l -text "Electrical" -background black -foreground white
+pack $f.l -expand yes -fill both
+
+set f [.p insert end "Doping"]
+label $f.l -text "Doping" -background black -foreground white
+pack $f.l -expand yes -fill both
Index: trunk/gui/scripts/panes.tcl
===================================================================
--- trunk/gui/scripts/panes.tcl	(revision 6716)
+++ 	(revision )
@@ -1,573 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Panes - creates a series of adjustable panes
-#
-#  This is a simple paned window with an adjustable sash.
-#  the same quantity, but for various ranges of input values.
-#  It also manages the controls to select and visualize the data.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2015  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *Panes.width 3i widgetDefault
-option add *Panes.height 3i widgetDefault
-option add *Panes.sashRelief sunken widgetDefault
-option add *Panes.sashWidth 2 widgetDefault
-option add *Panes.sashPadding 4 widgetDefault
-option add *Panes.orientation vertical widgetDefault
-
-itcl::class Rappture::Panes {
-    inherit itk::Widget
-
-    itk_option define -sashrelief sashRelief SashRelief ""
-    itk_option define -sashwidth sashWidth SashWidth 0
-    itk_option define -sashpadding sashPadding SashPadding 0
-    itk_option define -orientation orientation Orientation ""
-
-    constructor {args} { # defined below }
-
-    public method insert {pos args}
-    public method pane {pos}
-    public method visibility {pos args}
-    public method fraction {pos args}
-    public method hilite {state sash}
-    public method size {}
-
-    protected method _grab {pane X Y}
-    protected method _drag {pane X Y}
-    protected method _drop {pane X Y}
-    protected method _fixLayout {args}
-    protected method _fixSashes {args}
-
-    private variable _dispatcher ""  ;# dispatcher for !events
-    private variable _panes ""       ;# list of pane frames
-    private variable _visibility ""  ;# list of visibilities for panes
-    private variable _counter 0      ;# counter for auto-generated names
-    private variable _reqfrac 0.0    ;# requested fraction size of each pane
-    private variable _dragfrom 0     ;# starting coordinate of drag operation
-    private variable _dragfrac 0     ;# limit on fraction of drag operation
-}
-
-itk::usual Panes {
-    keep -background -cursor -sashwidth -sashrelief
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::constructor {args} {
-    itk_option add hull.width hull.height
-
-    # create a dispatcher for events
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !layout
-    $_dispatcher dispatch $this !layout [itcl::code $this _fixLayout]
-    $_dispatcher register !sashes
-    $_dispatcher dispatch $this !sashes [itcl::code $this _fixSashes]
-
-    # fix the layout whenever the window size changes
-    bind Panes <Configure> [itcl::code %W _fixLayout]
-
-    set pname "pane[incr _counter]"
-    itk_component add $pname {
-        frame $itk_interior.$pname
-    }
-
-    lappend _panes $pname
-    lappend _visibility 1
-    set _reqfrac 0.5
-
-    eval itk_initialize $args
-
-    # make sure we fix up the layout at some point
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# USAGE: insert <pos> ?-fraction f?
-#
-# Adds a new page to this widget at the given position <pos>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::insert {pos args} {
-    Rappture::getopts args params {
-        value -fraction 0.5
-    }
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"insert pos ?-fraction f?\""
-    }
-
-    set pname "pane[incr _counter]"
-    set sash "${pname}sash"
-    itk_component add $sash {
-        frame $itk_interior.$sash
-    } {
-        usual
-        ignore -cursor
-    }
-    bind $itk_component($sash) <Enter> [itcl::code $this hilite on $sash]
-    bind $itk_component($sash) <Leave> [itcl::code $this hilite off $sash]
-
-    itk_component add ${sash}ridge {
-        frame $itk_component($sash).ridge
-    } {
-        usual
-        rename -relief -sashrelief sashRelief SashRelief
-        ignore -borderwidth
-    }
-    if {$itk_option(-orientation) eq "vertical"} {
-        pack $itk_component(${sash}ridge) -fill x
-        $itk_component($sash) configure -cursor sb_v_double_arrow
-        $itk_component(${sash}ridge) configure -cursor sb_v_double_arrow
-    } else {
-        pack $itk_component(${sash}ridge) -fill y -side left
-        $itk_component($sash) configure -cursor sb_h_double_arrow
-        $itk_component(${sash}ridge) configure -cursor sb_h_double_arrow
-    }
-    foreach comp [list $sash ${sash}ridge] {
-        bind $itk_component($comp) <ButtonPress-1> \
-            [itcl::code $this _grab $pname %X %Y]
-        bind $itk_component($comp) <B1-Motion> \
-            [itcl::code $this _drag $pname %X %Y]
-        bind $itk_component($comp) <ButtonRelease-1> \
-            [itcl::code $this _drop $pname %X %Y]
-    }
-
-
-    itk_component add $pname {
-        frame $itk_interior.$pname
-    }
-    set _panes [linsert $_panes $pos $pname]
-    set _visibility [linsert $_visibility $pos 1]
-    set _reqfrac [linsert $_reqfrac $pos $params(-fraction)]
-
-    # fix sash characteristics
-    $_dispatcher event -idle !sashes
-
-    # make sure we fix up the layout at some point
-    $_dispatcher event -idle !layout
-
-    return $itk_component($pname)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: pane <pos>
-#
-# Returns the frame representing the pane at position <pos>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::pane {pos} {
-    set pname [lindex $_panes $pos]
-    if {[info exists itk_component($pname)]} {
-        return $itk_component($pname)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: visibility <pos> ?<newval>? ?<pos> <newval> ...?
-#
-# Clients use this to get/set the visibility of the pane at position
-# <pos>.  Can also be used to set the visibility for multiple panes
-# if multiple <pos>/<newval> pairs are specified in the same command.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::visibility {pos args} {
-    if {[llength $args] == 0} {
-        return [lindex $_visibility $pos]
-    }
-    if {[llength $args] % 2 == 0} {
-        error "wrong # args: should be \"visibility pos ?val pos val ...?\""
-    }
-
-    set args [linsert $args 0 $pos]
-    foreach {pos newval} $args {
-        if {![string is boolean -strict $newval]} {
-            error "bad value \"$newval\": should be boolean"
-        }
-        if {$pos eq "end" || ($pos >= 0 && $pos < [llength $_visibility])} {
-            set _visibility [lreplace $_visibility $pos $pos [expr {$newval}]]
-            $_dispatcher event -idle !layout
-        } else {
-            error "bad index \"$pos\": out of range"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: fraction <pos> ?<newval>? ?<pos> <newval> ...?
-#
-# Clients use this to get/set the fraction of real estate associated
-# with the pane at position <pos>.  Can also be used to set the
-# fractions for multiple panes if multiple <pos>/<newval> pairs
-# are specified in the same command.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::fraction {pos args} {
-    if {[llength $args] == 0} {
-        return [lindex $_reqfrac $pos]
-    }
-    if {[llength $args] % 2 == 0} {
-        error "wrong # args: should be \"fraction pos ?val pos val ...?\""
-    }
-
-    set args [linsert $args 0 $pos]
-    foreach {pos newval} $args {
-        if {![string is double -strict $newval]} {
-            error "bad value \"$newval\": should be fraction 0-1"
-        }
-        if {$pos eq "end" || ($pos >= 0 && $pos < [llength $_reqfrac])} {
-            set _reqfrac [lreplace $_reqfrac $pos $pos $newval]
-            $_dispatcher event -idle !layout
-        } else {
-            error "bad index \"$pos\": out of range"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hilite <state> <sash>
-#
-# Invoked automatically whenever the user touches a sash.  Highlights
-# the sash by changing its size or relief.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::hilite {state sash} {
-    switch -- $itk_option(-sashrelief) {
-      flat {
-        if {$state} {
-            $itk_component(${sash}ridge) configure -background black
-        } else {
-            $itk_component(${sash}ridge) configure -background $itk_option(-background)
-        }
-      }
-      sunken {
-        if {$state} {
-            $itk_component(${sash}ridge) configure -relief raised
-        } else {
-            $itk_component(${sash}ridge) configure -relief sunken
-        }
-      }
-      raised {
-        if {$state} {
-            $itk_component(${sash}ridge) configure -relief sunken
-        } else {
-            $itk_component(${sash}ridge) configure -relief raised
-        }
-      }
-      solid {
-        if {$state} {
-            $itk_component($sash) configure -background black
-        } else {
-            $itk_component($sash) configure \
-                -background $itk_option(-background)
-        }
-      }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: size
-#
-# Returns the number of panes in this widget.  That makes it easier
-# to index the various panes, since indices run from 0 to size-1.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::size {} {
-    return [llength $_panes]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _grab <pane> <X> <Y>
-#
-# Invoked automatically when the user clicks on a sash, to initiate
-# movement.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::_grab {pname X Y} {
-    set pos [lsearch $_panes $pname]
-    if {$pos < 0} return
-    set frac0 [lindex $_reqfrac [expr {$pos-1}]]
-    set frac1 [lindex $_reqfrac $pos]
-    set _dragfrac [expr {$frac0+$frac1}]
-
-    if {$itk_option(-orientation) eq "vertical"} {
-        set _dragfrom $Y
-    } else {
-        set _dragfrom $X
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _drag <pane> <X> <Y>
-#
-# Invoked automatically as the user drags a sash, to resize the panes.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::_drag {pname X Y} {
-    set pos [lsearch $_panes $pname]
-    if {$pos < 0} return
-    set frac [lindex $_reqfrac $pos]
-
-    if {$itk_option(-orientation) eq "vertical"} {
-        set delY [expr {$_dragfrom-$Y}]
-        set Ymax  [winfo height $itk_component(hull)]
-        set delta [expr {double($delY)/$Ymax}]
-        set frac [expr {$frac + $delta}]
-        set _dragfrom $Y
-    } else {
-        set delX [expr {$_dragfrom-$X}]
-        set Xmax  [winfo width $itk_component(hull)]
-        set delta [expr {double($delX)/$Xmax}]
-        set frac [expr {$frac + $delta}]
-        set _dragfrom $X
-    }
-    if {$delta == 0.0} {
-        return
-    }
-
-    # set limits so the pane can't get too large or too small
-    if {$frac < 0.05} {
-        set frac 0.05
-    }
-    if {$frac > $_dragfrac-0.05} {
-        set frac [expr {$_dragfrac-0.05}]
-    }
-
-    # replace the fractions for this pane and the one before it
-    set prevfrac [expr {$_dragfrac-$frac}]
-    set _reqfrac [lreplace $_reqfrac [expr {$pos-1}] $pos $prevfrac $frac]
-
-    # normalize all fractions and fix the layout
-    _fixLayout
-
-    return $frac
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _drop <pane> <X> <Y>
-#
-# Invoked automatically as the user drops a sash, to resize the panes.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::_drop {pname X Y} {
-    set frac [_drag $pname $X $Y]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixLayout ?<eventArgs>...?
-#
-# Used internally to update the layout of panes whenever a new pane
-# is added or a sash is moved.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::_fixLayout {args} {
-    # normalize the fractions for all panes to they add to 1.0
-    set total 0
-    foreach f $_reqfrac v $_visibility {
-        if {$v && $f > 0} {
-            set total [expr {$total + $f}]
-        }
-    }
-    if {$total == 0.0} { set total 1 }
-
-    set normfrac ""
-    foreach f $_reqfrac v $_visibility {
-        if {$v} {
-            lappend normfrac [expr {double($f)/$total}]
-        } else {
-            lappend normfrac [expr {double($f)/$total}]
-        }
-    }
-
-    # note that sash padding can be a single number or different on each side
-    if {[llength $itk_option(-sashpadding)] == 1} {
-        set pad [expr {2*$itk_option(-sashpadding)}]
-    } else {
-        set pad [expr [join $itk_option(-sashpadding) +]]
-    }
-
-    if {$itk_option(-orientation) eq "vertical"} {
-        set h [winfo height $itk_component(hull)]
-        set sh [expr {$itk_option(-sashwidth) + $pad}]
-
-        set plist ""
-        set flist ""
-        foreach p $_panes f $normfrac v $_visibility {
-            set sash ${p}sash
-            if {$v} {
-                # this pane is visible -- make room for it
-                lappend plist $p
-                lappend flist $f
-                if {[info exists itk_component($sash)]} {
-                    set h [expr {$h - $sh}]
-                }
-            } else {
-                # this pane is not visible -- remove sash
-                if {[info exists itk_component($sash)]} {
-                    place forget $itk_component($sash)
-                }
-                place forget $itk_component($p)
-            }
-        }
-
-        # lay out the various panes
-        set y 0
-        foreach p $plist f $flist {
-            set sash ${p}sash
-            if {[info exists itk_component($sash)]} {
-                place $itk_component($sash) -y $y -relx 0.5 -anchor n \
-                    -relwidth 1.0 -height $sh
-                set y [expr {$y + $sh}]
-            }
-
-            set ph [expr {$h*$f}]
-            place $itk_component($p) -y $y -relx 0.5 -anchor n \
-                -relwidth 1.0 -height $ph
-            set y [expr {$y + $ph}]
-        }
-    } else {
-        set w [winfo width $itk_component(hull)]
-        set sw [expr {$itk_option(-sashwidth) + $pad}]
-
-        set plist ""
-        set flist ""
-        foreach p $_panes f $normfrac v $_visibility {
-            set sash ${p}sash
-            if {$v} {
-                # this pane is visible -- make room for it
-                lappend plist $p
-                lappend flist $f
-                if {[info exists itk_component($sash)]} {
-                    set w [expr {$w - $sw}]
-                }
-            } else {
-                # this pane is not visible -- remove sash
-                if {[info exists itk_component($sash)]} {
-                    place forget $itk_component($sash)
-                }
-                place forget $itk_component($p)
-            }
-        }
-
-        # lay out the various panes
-        set x 0
-        foreach p $plist f $flist {
-            set sash ${p}sash
-            if {[info exists itk_component($sash)]} {
-                place $itk_component($sash) -x $x -rely 0.5 -anchor w \
-                    -relheight 1.0 -width $sw
-                set x [expr {$x + $sw}]
-            }
-
-            set pw [expr {$w*$f}]
-            place $itk_component($p) -x $x -rely 0.5 -anchor w \
-                -relheight 1.0 -width $pw
-            set x [expr {$x + $pw}]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSashes
-#
-# Used internally to fix the appearance of sashes whenever a new
-# sash appears or the controlling configuration options change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Panes::_fixSashes {args} {
-    if {$itk_option(-orientation) eq "vertical"} {
-        set ht [winfo pixels $itk_component(hull) $itk_option(-sashwidth)]
-        set bd [expr {$ht/2}]
-        foreach pane $_panes {
-            set sash "${pane}sashridge"
-            if {[info exists itk_component($sash)]} {
-                $itk_component($sash) configure -height $ht \
-                    -borderwidth $bd -relief $itk_option(-sashrelief)
-                pack $itk_component($sash) -pady $itk_option(-sashpadding) \
-                    -side top
-            }
-        }
-    } else {
-        set w [winfo pixels $itk_component(hull) $itk_option(-sashwidth)]
-        set bd [expr {$w/2}]
-        foreach pane $_panes {
-            set sash "${pane}sashridge"
-            if {[info exists itk_component($sash)]} {
-                $itk_component($sash) configure -width $w \
-                    -borderwidth $bd -relief $itk_option(-sashrelief)
-                pack $itk_component($sash) -padx $itk_option(-sashpadding) \
-                    -side left
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -sashrelief
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Panes::sashrelief {
-    $_dispatcher event -idle !sashes
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -sashwidth
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Panes::sashwidth {
-    $_dispatcher event -idle !sashes
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -sashpadding
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Panes::sashpadding {
-    set count 0
-    foreach val $itk_option(-sashpadding) {
-        if {![string is integer -strict $val]} {
-            error "bad padding value \"$val\": should be integer"
-        }
-        incr count
-    }
-    if {$count < 1 || $count > 2} {
-        error "bad padding value \"$itk_option(-sashpadding)\": should be \"#\" or \"# #\""
-    }
-    $_dispatcher event -idle !sashes
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -orientation
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Panes::orientation {
-    foreach pname $_panes {
-        set sash "${pname}sash"
-        if {$itk_option(-orientation) eq "vertical"} {
-            place $itk_component($pname) -x 0 -relx 0.5 -relwidth 1 \
-                -y 0 -rely 0 -relheight 0
-
-            if {[info exists itk_component($sash)]} {
-                place $itk_component($sash) -x 0 -relx 0.5 -relwidth 1 \
-                    -y 0 -rely 0 -relheight 0
-                $itk_component($sash) configure \
-                    -cursor sb_v_double_arrow
-
-                pack $itk_component(${sash}ridge) -fill x -side top
-                $itk_component(${sash}ridge) configure \
-                    -cursor sb_v_double_arrow
-            }
-        } else {
-            place $itk_component($pname) -y 0 -rely 0.5 -relheight 1 \
-                -x 0 -relx 0 -relwidth 0
-
-            if {[info exists itk_component($sash)]} {
-                place $itk_component($sash) -y 0 -rely 0.5 -relheight 1 \
-                    -x 0 -relx 0 -relwidth 0
-                $itk_component($sash) configure \
-                    -cursor sb_h_double_arrow
-
-                pack $itk_component(${sash}ridge) -fill y -side left
-                $itk_component(${sash}ridge) configure \
-                    -cursor sb_h_double_arrow
-            }
-        }
-    }
-
-    # fix sash characteristics
-    $_dispatcher event -idle !sashes
-
-    # make sure we fix up the layout at some point
-    $_dispatcher event -idle !layout
-}
Index: trunk/gui/scripts/periodicelement.tcl
===================================================================
--- trunk/gui/scripts/periodicelement.tcl	(revision 6716)
+++ 	(revision )
@@ -1,308 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: PeriodicElement - entry widget with a drop-down periodic
-#             table.
-#
-#  This widget is a typical periodicelement, an entry widget with a drop-down
-#  list of values.  If the -editable option is turned off, then the
-#  value can be set only from the drop-down list.  Otherwise, the
-#  drop-down is treated as a list of preset choices, but the user can
-#  type anything in the entry area.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *PeriodicElement.borderWidth 2 widgetDefault
-option add *PeriodicElement.relief sunken widgetDefault
-option add *PeriodicElement.width 10 widgetDefault
-option add *PeriodicElement.editable yes widgetDefault
-option add *PeriodicElement.textBackground white widgetDefault
-option add *PeriodicElement.textForeground black widgetDefault
-option add *PeriodicElement.disabledBackground white widgetDefault
-option add *PeriodicElement.disabledForeground gray widgetDefault
-option add *PeriodicElement.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::PeriodicElement {
-    inherit itk::Widget
-
-    itk_option define -editable editable Editable ""
-    itk_option define -state state State "normal"
-    itk_option define -width width Width 0
-    itk_option define -disabledbackground disabledBackground DisabledBackground ""
-    itk_option define -disabledforeground disabledForeground DisabledForeground ""
-
-    constructor {args} { # defined below }
-
-    public method value {args}
-    public method label {value}
-    public method element {option args}
-
-    protected method _entry {option}
-    protected method _dropdown {option}
-    protected method _fixState {}
-
-    blt::bitmap define PeriodicElementArrow {
-        #define arrow_width 8
-        #define arrow_height 4
-        static unsigned char arrow_bits[] = {
-           0xfe, 0x7c, 0x38, 0x10};
-    }
-
-    private variable _lastValue ""
-}
-
-itk::usual PeriodicElement {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElement::constructor {args} {
-    itk_option add hull.borderwidth hull.relief
-
-    itk_component add button {
-        button $itk_interior.btn -bitmap PeriodicElementArrow -padx 0 \
-            -borderwidth 1 -relief raised -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness -highlightbackground -highlightcolor
-        ignore -borderwidth -relief
-    }
-    pack $itk_component(button) -side right -fill y
-
-    itk_component add entry {
-        entry $itk_interior.entry -borderwidth 0 -relief flat
-    } {
-        usual
-        keep -width
-        rename -highlightbackground -textbackground textBackground Background
-        rename -background -textbackground textBackground Background
-        rename -foreground -textforeground textForeground Foreground
-        rename -disabledbackground -textbackground textBackground Background
-        rename -disabledforeground -textforeground textForeground Foreground
-        ignore -borderwidth -relief
-    }
-    pack $itk_component(entry) -side left -expand yes -fill both
-
-    bind $itk_component(entry) <Return> \
-        [itcl::code $this _entry apply]
-    bind $itk_component(entry) <KP_Enter> \
-        [itcl::code $this _entry apply]
-    bind $itk_component(entry) <Tab> \
-        [itcl::code $this _entry apply]
-    bind $itk_component(entry) <ButtonPress> \
-        [itcl::code $this _entry click]
-
-    itk_component add ptable {
-        Rappture::PeriodicTable $itk_component(button).ptable \
-            -postcommand [itcl::code $this _dropdown post] \
-            -unpostcommand [itcl::code $this _dropdown unpost] \
-    }
-
-    bind $itk_component(ptable) <<PeriodicTableSelect>> \
-        [itcl::code $this _dropdown select]
-
-    $itk_component(button) configure -command \
-        [list $itk_component(ptable) post $itk_component(hull) left]
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElement::value {args} {
-    if {[llength $args] == 1} {
-        set value [lindex $args 0]
-    } elseif { [llength $args] == 0 }  {
-        set value [$itk_component(entry) get]
-    } else {
-        error "wrong # args: should be \"value ?newval?\""
-    }
-    regsub -all -- "-" $value " " value
-    if { [llength $value] > 1 } {
-        set value [lindex $value 0]
-    }
-    set name [$itk_component(ptable) get -name $value]
-    if { $name == "" } {
-        set name $_lastValue
-        bell
-    }
-    set symbol [$itk_component(ptable) get -symbol $name]
-    if { $name != $_lastValue } {
-        $itk_component(ptable) select $name
-    }
-    $itk_component(entry) configure -state normal
-    $itk_component(entry) delete 0 end
-    #$itk_component(entry) insert 0 "${symbol} - ${name}"
-    $itk_component(entry) insert 0 "${name} - ${symbol}"
-    if {!$itk_option(-editable)} {
-        $itk_component(entry) configure -state disabled
-    }
-    set _lastValue $name
-    if { [llength $args] == 1 } {
-        after 10 \
-            [list catch [list event generate $itk_component(hull) <<Value>>]]
-    }
-    return $name
-}
-
-# ----------------------------------------------------------------------
-# USAGE: element include ?<elem>...?
-# USAGE: element exclude ?<elem>...?
-# USAGE: element get ?-weight|-name|-symbol|-number|-all? ?<elem>?
-#
-# Clients use this to manipulate the list of choices in the drop-down
-# list.  Each choice is represented by a (computer-friendly) value
-# and its corresponding (human-friendly) label.  The "get" option
-# returns information about options on the list, including the value,
-# the label, or both.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElement::element {option args} {
-    eval $itk_component(ptable) $option $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _entry apply
-# USAGE: _entry click
-#
-# Used internally to handle the dropdown list for this widget.  The
-# post/unpost options are invoked when the list is posted or unposted
-# to manage the relief of the controlling button.  The select option
-# is invoked whenever there is a selection from the list, to assign
-# the value back to the gauge.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElement::_entry {option} {
-    switch -- $option {
-        apply {
-            if {$itk_option(-editable) && $itk_option(-state) == "normal"} {
-                event generate $itk_component(hull) <<Value>>
-            }
-        }
-        click {
-            if {!$itk_option(-editable) && $itk_option(-state) == "normal"} {
-                $itk_component(button) configure -relief sunken
-                update idletasks; after 100
-                $itk_component(button) configure -relief raised
-
-                $itk_component(ptable) post $itk_component(hull) left
-            }
-        }
-        default {
-            error "bad option \"$option\": should be apply, click"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _dropdown post
-# USAGE: _dropdown unpost
-# USAGE: _dropdown select
-#
-# Used internally to handle the dropdown table for this widget.  The
-# post/unpost options are invoked when the list is posted or unposted
-# to manage the relief of the controlling button.  The select option
-# is invoked whenever there is a selection from the list, to assign
-# the value back to the gauge.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElement::_dropdown {option} {
-    switch -- $option {
-        post {
-            set value [$itk_component(entry) get]
-            if {$value != ""} {
-                $itk_component(ptable) select $value
-            }
-        }
-        unpost {
-            if {$itk_option(-editable)} {
-                focus $itk_component(entry)
-            }
-        }
-        select {
-            set value [$itk_component(ptable) get -name]
-            if {"" != $value} {
-                value $value
-            }
-        }
-        default {
-            error "bad option \"$option\": should be post, unpost, select"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixState
-#
-# Used internally to fix the widget state when the -editable/-state
-# options change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElement::_fixState {} {
-    if {$itk_option(-state) == "normal"} {
-        $itk_component(button) configure -state normal
-        $itk_component(entry) configure \
-            -background $itk_option(-textbackground) \
-            -foreground $itk_option(-textforeground) \
-            -disabledbackground $itk_option(-textbackground) \
-            -disabledforeground $itk_option(-textforeground)
-    } else {
-        $itk_component(button) configure -state disabled
-        $itk_component(entry) configure \
-            -background $itk_option(-disabledbackground) \
-            -foreground $itk_option(-disabledforeground) \
-            -disabledbackground $itk_option(-disabledbackground) \
-            -disabledforeground $itk_option(-disabledforeground)
-    }
-
-    if {$itk_option(-editable)} {
-        if {$itk_option(-state) == "normal"} {
-            $itk_component(entry) configure -state normal
-        } else {
-            $itk_component(entry) configure -state disabled
-        }
-    } else {
-        $itk_component(entry) configure -state disabled
-    }
-
-    if {!$itk_option(-editable) || $itk_option(-state) != "normal"} {
-        # can't keep focus here -- move it along to the next widget
-        if {[focus] == $itk_component(entry)} {
-            focus [tk_focusNext [focus]]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -editable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::PeriodicElement::editable {
-    if {![string is boolean -strict $itk_option(-editable)]} {
-        error "bad value \"$itk_option(-editable)\": should be boolean"
-    }
-    _fixState
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::PeriodicElement::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    _fixState
-}
Index: trunk/gui/scripts/periodicelemententry.tcl
===================================================================
--- trunk/gui/scripts/periodicelemententry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,198 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: PeriodicElementEntry - widget for entering a choice of strings
-#
-#  This widget represents a <element> entry on a control panel.
-#  It is used to choose one of several mutually-exclusive strings.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::PeriodicElementEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-
-    constructor {owner path args} { # defined below }
-    destructor { # defined below }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-
-    protected method _newValue {}
-    protected method _tooltip {}
-
-    private variable _owner ""    ;# thing managing this control
-    private variable _path ""     ;# path in XML to this number
-}
-
-itk::usual PeriodicElementEntry {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElementEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    set defval [string trim [$_owner xml get $_path.default]]
-    # Active and inactive are lists.  Don't need to trim.
-    set active [string trim [$_owner xml get $_path.active]]
-    set inactive [string trim [$_owner xml get $_path.inactive]]
-    #
-    # Create the widget and configure it properly based on other
-    # hints in the XML.
-    #
-    itk_component add element {
-        Rappture::PeriodicElement $itk_interior.element -editable yes
-    }
-    pack $itk_component(element) -expand yes -fill both
-    bind $itk_component(element) <<Value>> [itcl::code $this _newValue]
-
-    if { [llength $inactive] > 0 } {
-        $itk_component(element) element inactive $inactive
-    }
-    if { [llength $active] > 0 } {
-        $itk_component(element) element active $active
-    }
-    if { $defval != "" } {
-        $itk_component(element) value $defval
-    }
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElementEntry::destructor {} {
-    $_owner notify remove $this
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElementEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [lindex $args 0]
-        $itk_component(element) value $newval
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    set how [string trim [$_owner xml get $_path.returnvalue]]
-    switch -- $how {
-        weight - number - name - symbol - all {
-            set how "-$how"
-        }
-        default {
-            set how "-name"
-        }
-    }
-    set str [$itk_component(element) element get $how]
-    return $str
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElementEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {"" == $label} {
-        set label "Element"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElementEntry::tooltip {} {
-    # query tooltip on-demand based on current element
-    return "@[itcl::code $this _tooltip]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _newValue
-#
-# Invoked automatically whenever the value in the element changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElementEntry::_newValue {} {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _tooltip
-#
-# Returns the tooltip for this widget, given the current element in
-# the selector.  This is normally called by the Rappture::Tooltip
-# facility whenever it is about to pop up a tooltip for this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicElementEntry::_tooltip {} {
-    set tip [string trim [$_owner xml get $_path.about.description]]
-
-    # get the description for the current element, if there is one
-    set str [$itk_component(element) element get -all]
-    if {$_path != ""} {
-        set desc [string trim [$_owner xml get $_path.about.description]]
-    }
-
-    if {[string length $str] > 0 && [string length $desc] > 0} {
-        append tip "\n\n$str:\n$desc"
-    }
-    return $tip
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::PeriodicElementEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(element) configure -state $itk_option(-state)
-}
Index: trunk/gui/scripts/periodictable.tcl
===================================================================
--- trunk/gui/scripts/periodictable.tcl	(revision 6716)
+++ 	(revision )
@@ -1,655 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: periodictable - drop-down list of items
-#
-#  This is a drop-down listbox, which might be used in conjunction
-#  with a combobox.
-#
-# ======================================================================
-#  AUTHOR:  George Howlett, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *PeriodicTable.textBackground white widgetDefault
-option add *PeriodicTable.outline black widgetDefault
-option add *PeriodicTable.borderwidth 1 widgetDefault
-option add *PeriodicTable.relief flat widgetDefault
-option add *PeriodicTable.font "Arial 8"
-
-itcl::class Rappture::PeriodicTable {
-    inherit Rappture::Dropdown
-
-    constructor {args} { # defined below }
-
-    public method active { list }
-    public method inactive { list }
-    public method get {args}
-    public method select {name}
-    public method value { {name ""} }
-
-    public proc FindElement { string }
-    public proc ElementIsType { string args }
-
-    private variable _dispatcher ""
-    private variable _current ""
-    private variable _state
-
-    protected method _adjust {{widget ""}}
-
-    protected method _react {}
-    protected method Redraw {}
-    protected method Activate { widget id x y }
-    protected method Deactivate { widget id }
-    private common _colors
-    array set _colors {
-        actinoid-activebackground                       \#cd679a
-        actinoid-activeforeground                       white
-        actinoid-disabledbackground                     \#ff99cc
-        actinoid-disabledforeground                     \#D97DAB
-        actinoid-background                             \#ff99cc
-        actinoid-foreground                             black
-        alkali-metal-activebackground                   \#cd3434
-        alkali-metal-activeforeground                   white
-        alkali-metal-disabledbackground                 \#ff6666
-        alkali-metal-disabledforeground                 \#D04747
-        alkali-metal-background                         \#ff6666
-        alkali-metal-foreground                         black
-        alkaline-earth-metal-activebackground           \#cdac7b
-        alkaline-earth-metal-activeforeground           white
-        alkaline-earth-metal-disabledbackground         \#ffdead
-        alkaline-earth-metal-disabledforeground         \#C19A64
-        alkaline-earth-metal-background                 \#ffdead
-        alkaline-earth-metal-foreground                 black
-        halogen-activebackground                        \#cdcd67
-        halogen-activeforeground                        white
-        halogen-disabledbackground                      \#ffff99
-        halogen-disabledforeground                      \#D5D562
-        halogen-background                              \#ffff99
-        halogen-foreground                              black
-        lanthanoid-activebackground                     \#cd8dcd
-        lanthanoid-activeforeground                     white
-        lanthanoid-disabledbackground                   \#ffbfff
-        lanthanoid-disabledforeground                   \#D884D8
-        lanthanoid-background                           \#ffbfff
-        lanthanoid-foreground                           black
-        metalloid-activebackground                      \#9a9a67
-        metalloid-activeforeground                      white
-        metalloid-disabledbackground                    \#cccc99
-        metalloid-disabledforeground                    \#92922C
-        metalloid-background                            \#cccc99
-        metalloid-foreground                            black
-        noble-gas-activebackground                      \#8ecdcd
-        noble-gas-activeforeground                      white
-        noble-gas-disabledbackground                    \#c0ffff
-        noble-gas-disabledforeground                    \#7FC1C1
-        noble-gas-background                            \#c0ffff
-        noble-gas-foreground                            black
-        other-non-metal-activebackground                \#6ecd6e
-        other-non-metal-activeforeground                white
-        other-non-metal-disabledbackground              \#a0ffa0
-        other-non-metal-disabledforeground              \#6ACD6A
-        other-non-metal-background                      \#a0ffa0
-        other-non-metal-foreground                      black
-        post-transition-metal-activebackground          \#9a9a9a
-        post-transition-metal-activeforeground          white
-        post-transition-metal-disabledbackground        \#cccccc
-        post-transition-metal-disabledforeground        \#999999
-        post-transition-metal-background                \#cccccc
-        post-transition-metal-foreground                black
-        transition-metal-activebackground               \#cd8e8e
-        transition-metal-activeforeground               white
-        transition-metal-disabledbackground             \#ffc0c0
-        transition-metal-disabledforeground             \#C77E7E
-        transition-metal-background                     \#ffc0c0
-        transition-metal-foreground                     black
-        unknown-activebackground                        \#cdcdcd
-        unknown-activeforeground                        white
-        unknown-disabledbackground                      \#ffffff
-        unknown-disabledforeground                      \#B9B9B9
-        unknown-background                              \#ffffff
-        unknown-foreground                              black
-    }
-    private common _tableData {
-        Hydrogen        1  H  1.0079    1 1     other-non-metal
-        Helium          2  He 4.0026    1 18    noble-gas
-        Lithium         3  Li 6.941(2)  2 1     alkali-metal
-        Beryllium       4  Be 9.0122    2 2     alkaline-earth-metal
-        Boron           5  B  10.811(7) 2 13    metalloid
-        Carbon          6  C  12.011    2 14    other-non-metal
-        Nitrogen        7  N  14.007    2 15    other-non-metal
-        Oxygen          8  O  15.999    2 16    other-non-metal
-        Fluorine        9  F  18.998    2 17    halogen
-        Neon            10 Ne 20.180    2 18    noble-gas
-
-        Sodium          11 Na 22.990    3 1     alkali-metal
-        Magnesium       12 Mg 24.305    3 2     alkaline-earth-metal
-        Aluminium       13 Al 26.982    3 13    post-transition-metal
-        Silicon         14 Si 28.086    3 14    metalloid
-        Phosphorus      15 P  30.974    3 15    other-non-metal
-        Sulfur          16 S  32.066(6) 3 16    other-non-metal
-        Chlorine        17 Cl 35.453    3 17    halogen
-        Argon           18 Ar 39.948(1) 3 18    noble-gas
-
-        Potassium       19 K  39.098    4 1     alkali-metal
-        Calcium         20 Ca 40.078(4) 4 2     alkaline-earth-metal
-        Scandium        21 Sc 44.956    4 3     transition-metal
-        Titanium        22 Ti 47.867(1) 4 4     transition-metal
-        Vanadium        23 V  50.942(1) 4 5     transition-metal
-        Chromium        24 Cr 51.996    4 6     transition-metal
-        Manganese       25 Mn 54.938    4 7     transition-metal
-        Iron            26 Fe 55.845(2) 4 8     transition-metal
-        Cobalt          27 Co 58.933    4 9     transition-metal
-        Nickel          28 Ni 58.693    4 10    transition-metal
-        Copper          29 Cu 63.546(3) 4 11    transition-metal
-        Zinc            30 Zn 65.39(2)  4 12    transition-metal
-        Gallium         31 Ga 69.723(1) 4 13    post-transition-metal
-        Germanium       32 Ge 72.61(2)  4 14    metalloid
-        Arsenic         33 As 74.922    4 15    metalloid
-        Selenium        34 Se 78.96(3)  4 16    other-non-metal
-        Bromine         35 Br 79.904(1) 4 17    halogen
-        Krypton         36 Kr 83.80(1)  4 18    noble-gas
-
-        Rubidium        37 Rb 85.468    5 1     alkali-metal
-        Strontium       38 Sr 87.62(1)  5 2     alkaline-earth-metal
-        Yttrium         39 Y  88.906    5 3     transition-metal
-        Zirconium       40 Zr 91.224(2) 5 4     transition-metal
-        Niobium         41 Nb 92.906    5 5     transition-metal
-        Molybdenum      42 Mo 95.94(1)  5 6     transition-metal
-        Technetium      43 Tc [97.907]  5 7     transition-metal
-        Ruthenium       44 Ru 101.07(2) 5 8     transition-metal
-        Rhodium         45 Rh 102.906   5 9     transition-metal
-        Palladium       46 Pd 106.42(1) 5 10    transition-metal
-        Silver          47 Ag 107.868   5 11    transition-metal
-        Cadmium         48 Cd 112.411(8) 5 12   transition-metal
-        Indium          49 In 114.818(3) 5 13   post-transition-metal
-        Tin             50 Sn 118.710(7) 5 14   post-transition-metal
-        Antimony        51 Sb 121.760(1) 5 15   metalloid
-        Tellurium       52 Te 127.60(3) 5 16    metalloid
-        Iodine          53 I  126.904   5 17    halogen
-        Xenon           54 Xe 131.29(2) 5 18    noble-gas
-
-        Cesium          55 Cs 132.905   6 1     alkali-metal
-        Barium          56 Ba 137.327(7) 6 2    alkaline-earth-metal
-        Lanthanides     57-71 * *       6 3     lanthanoid
-        Hafnium         72 Hf 178.49(2) 6 4     transition-metal
-        Tantalum        73 Ta 180.948   6 5     transition-metal
-        Tungsten        74 W  183.84(1) 6 6     transition-metal
-        Rhenium         75 Re 186.207(1) 6 7    transition-metal
-        Osmium          76 Os 190.23(3) 6 8     transition-metal
-        Iridium         77 Ir 192.217(3) 6 9    transition-metal
-        Platinum        78 Pt 195.084(9) 6 10   transition-metal
-        Gold            79 Au 196.967 6 11      transition-metal
-        Mercury         80 Hg 200.59(2) 6 12    transition-metal
-        Thallium        81 Tl 204.383   6 13    post-transition-metal
-        Lead            82 Pb 207.2(1) 6 14     post-transition-metal
-        Bismuth         83 Bi 208.980   6 15    post-transition-metal
-        Polonium        84 Po [208.982] 6 16    metalloid
-        Astatine        85 At [209.987] 6 17    halogen
-        Radon           86 Rn [222.018] 6 18    noble-gas
-
-        Francium        87 Fr [223.020] 7 1     alkali-metal
-        Radium          88 Ra [226.0254] 7 2    alkaline-earth-metal
-        Actinides       89-103 * * 7 3          actinoid
-        Rutherfordium   104 Rf [263.113] 7 4    transition-metal
-        Dubnium         105 Db [262.114] 7 5    transition-metal
-        Seaborgium      106 Sg [266.122] 7 6    transition-metal
-        Bohrium         107 Bh [264.1247] 7 7   transition-metal
-        Hassium         108 Hs [269.134] 7 8    transition-metal
-        Meitnerium      109 Mt [268.139] 7 9    transition-metal
-        Darmstadtium    110 Ds [272.146] 7 10   transition-metal
-        Roentgenium     111 Rg [272.154] 7 11   transition-metal
-        Ununbium        112 Uub [277]   7 12    transition-metal
-        Ununtrium       113 Uut [284] 7 13      post-transition-metal
-        Ununquadium     114 Uuq [289] 7 14      post-transition-metal
-        Ununpentium     115 Uup [288] 7 15      post-transition-metal
-        Ununhexium      116 Uuh [292]  7 16     post-transition-metal
-        Ununseptium     117 Uus ? 7 17          unknown
-        Ununoctium      118 Uuo [294] 7 18      unknown
-
-        Lanthanum       57 La 138.905 8 3       lanthanoid
-        Cerium          58 Ce 140.116(1) 8 4    lanthanoid
-        Praseodymium    59 Pr 140.908 8 5       lanthanoid
-        Neodymium       60 Nd 144.242(3) 8 6    lanthanoid
-        Promethium      61 Pm [144.913] 8 7     lanthanoid
-        Samarium        62 Sm 150.36(2) 8 8     lanthanoid
-        Europium        63 Eu 151.964(1) 8 9    lanthanoid
-        Gadolinium      64 Gd 157.25(3) 8 10    lanthanoid
-        Terbium         65 Tb 158.925   8 11    lanthanoid
-        Dysprosium      66 Dy 162.500(1) 8 12   lanthanoid
-        Holmium         67 Ho 164.930 8 13      lanthanoid
-        Erbium          68 Er 167.259(3) 8 14   lanthanoid
-        Thulium         69 Tm 168.934   8 15    lanthanoid
-        Ytterbium       70 Yb 173.04(3) 8 16    lanthanoid
-        Lutetium        71 Lu 174.967(1) 8 17   lanthanoid
-
-        Actinium        89 Ac [227.027] 9 3     actinoid
-        Thorium         90 Th 232.038   9 4     actinoid
-        Protactinium    91 Pa 231.036 9 5       actinoid
-        Uranium         92 U 238.029 9 6        actinoid
-        Neptunium       93 Np [237.048] 9 7     actinoid
-        Plutonium       94 Pu [244.064] 9 8     actinoid
-        Americium       95 Am [243.061] 9 9     actinoid
-        Curium          96 Cm [247.070] 9 10    actinoid
-        Berkelium       97 Bk [247.070] 9 11    actinoid
-        Californium     98 Cf [251.080] 9 12    actinoid
-        Einsteinium     99 Es [252.083] 9 13    actinoid
-        Fermium         100 Fm [257.095] 9 14   actinoid
-        Mendelevium     101 Md [258.098] 9 15   actinoid
-        Nobelium        102 No [259.101] 9 16   actinoid
-        Lawrencium      103 Lr [262.110] 9 17   actinoid
-    }
-
-    private common _table
-    foreach { name number symbol weight row column type } $_tableData {
-        set _table($name) [list name $name number $number symbol $symbol \
-                weight $weight row $row column $column type $type]
-    }
-
-    private common _types
-    array set _types {
-        actinoid {
-            Actinides Actinium Americium Berkelium Californium Curium
-            Einsteinium Fermium Mendelevium Neptunium Plutonium Protactinium
-            Thorium Uranium Lawrencium Nobelium
-        }
-        alkali-metal {
-            Cesium Francium Lithium Potassium Rubidium Sodium
-        }
-        alkaline-earth-metal {
-            Barium Beryllium Calcium Magnesium Radium Strontium
-        }
-        halogen {
-            Astatine Bromine Chlorine Fluorine Iodine
-        }
-        lanthanoid {
-            Cerium Erbium Europium Gadolinium Holmium Lanthanides Lanthanum
-            Lutetium Neodymium Praseodymium Promethium Samarium Terbium
-            Thulium Ytterbium Dysprosium
-        }
-        metalloid {
-            Arsenic Boron Germanium Polonium Silicon Tellurium Antimony
-        }
-        noble-gas {
-            Argon Helium Krypton Neon Radon Xenon
-        }
-        other-non-metal {
-            Carbon Hydrogen Nitrogen Sulfur Oxygen Phosphorus Selenium
-        }
-        post-transition-metal {
-            Aluminium Bismuth Gallium Indium Lead Thallium Tin Ununhexium
-            Ununpentium Ununquadium Ununtrium
-        }
-        transition-metal {
-            Chromium Cobalt Copper Dubnium Gold Hafnium Hassium Iridium
-            Iron Manganese Meitnerium Mercury Molybdenum Nickel Niobium
-            Osmium Palladium Rhenium Rhodium Roentgenium Ruthenium
-            Rutherfordium Scandium Seaborgium Silver Tantalum Technetium
-            Titanium Tungsten Ununbium Vanadium Yttrium Zinc Zirconium
-            Bohrium Cadmium Darmstadtium Platinum
-        }
-        unknown {
-            Ununoctium
-            Ununseptium
-        }
-    }
-}
-
-itk::usual PeriodicTable {
-    keep -background -outline -cursor
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicTable::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Redraw]; list"
-
-    foreach name [array names _table] {
-        set _state($name) "normal"
-    }
-
-    itk_component add scroller {
-        Rappture::Scroller $itk_interior.sc \
-            -xscrollmode off -yscrollmode auto
-    }
-    pack $itk_component(scroller) -expand yes -fill both
-
-    itk_component add table {
-        canvas $itk_component(scroller).table \
-            -highlightthickness 0
-    } {
-        usual
-        rename -background -textbackground textBackground Background
-        ignore -highlightthickness -highlightbackground -highlightcolor
-        keep -relief
-    }
-    $itk_component(scroller) contents $itk_component(table)
-
-    # add bindings so the table can react to selections
-    bind RappturePeriodicTable-$this <ButtonRelease-1> [itcl::code $this _react]
-    bind RappturePeriodicTable-$this <Return> [itcl::code $this _react]
-    bind RappturePeriodicTable-$this <KP_Enter> [itcl::code $this _react]
-    bind RappturePeriodicTable-$this <space> [itcl::code $this _react]
-    bind RappturePeriodicTable-$this <Escape> [itcl::code $this unpost]
-
-    set btags [bindtags $itk_component(table)]
-    set i [lsearch $btags [winfo class $itk_component(table)]]
-    if {$i < 0} {
-        set i end
-    }
-    set btags [linsert $btags [expr {$i+1}] RappturePeriodicTable-$this]
-    bindtags $itk_component(table) $btags
-
-    eval itk_initialize $args
-    Redraw
-}
-
-#
-# active <list of elements>
-#
-#       Enables zero or more elements in the periodic table so that
-#       they can be selected.  All elements are first disabled.  Each
-#       argument can one of the following forms:
-#       1. element name.
-#       2. element symbol.
-#       3. element number.
-#       4. type of element.  The argument is expanded into all
-#          elements of that type.
-#
-itcl::body Rappture::PeriodicTable::active { list } {
-    set c $itk_component(table)
-    foreach elem [array names _table] {
-        set _state($elem) "disabled"
-        $c bind $elem <Enter> {}
-        $c bind $elem <Leave> {}
-        $c bind $elem <ButtonRelease-1> {}
-    }
-    # Expand any arguments that represent a group of elements.
-    set arglist {}
-    foreach arg $list {
-        if { [info exists _types($arg)] } {
-            set arglist [concat $arglist $_types($arg)]
-        } else {
-            lappend arglist $arg
-        }
-    }
-    foreach arg $arglist {
-        set elem [FindElement $arg]
-        if { $elem == "" } {
-            puts stderr "unknown element \"$arg\""
-        } else {
-            set _state($elem) "normal"
-            $c bind $elem <Enter> \
-                [itcl::code $this Activate %W $elem %X %Y]
-            $c bind $elem <Leave> [itcl::code $this Deactivate %W $elem]
-            $c bind $elem <ButtonRelease-1> [itcl::code $this value $elem]
-        }
-    }
-    $_dispatcher event -idle !rebuild
-}
-
-#
-# inactive <list of elements>
-#
-#       Disables zero or more elements in the periodic table so that
-#       they can't be selected.  All elements are first enabled.  Each
-#       argument can one of the following forms:
-#       1. element name.
-#       2. element symbol.
-#       3. element number.
-#       4. type of element.  The argument is expanded into all
-#          elements of that type.
-#
-itcl::body Rappture::PeriodicTable::inactive { list } {
-    set c $itk_component(table)
-    foreach elem [array names _table] {
-        set _state($elem) "normal"
-        $c bind $elem <Enter> \
-            [itcl::code $this Activate %W $elem %X %Y]
-        $c bind $elem <Leave> [itcl::code $this Deactivate %W $elem]
-        $c bind $elem <ButtonRelease-1> [itcl::code $this value $elem]
-    }
-    # Expand any arguments that represent a group of elements.
-    set arglist {}
-    foreach arg $list {
-        if { [info exists _types($arg)] } {
-            set arglist [concat $arglist $_types($arg)]
-        } else {
-            lappend arglist $arg
-        }
-    }
-    foreach arg $arglist {
-        set elem [FindElement $arg]
-        if { $elem == "" } {
-            puts stderr "unknown element \"$arg\""
-        } else {
-            set _state($elem) "disabled"
-            $c bind $elem <Enter> {}
-            $c bind $elem <Leave> {}
-            $c bind $elem <ButtonRelease-1> {}
-        }
-    }
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-symbol|-name|-all? ?name?
-#
-# Queries one or more values from the drop-down list.  With no args,
-# it returns a list of all values and labels in the list.  If the
-# index is specified, then it returns the value or label (or both)
-# for the specified index.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicTable::get { args } {
-    set first [lindex $args 0]
-    set choices {-symbol -weight -number -name -all}
-    set format "-name"
-    if {[string index $first 0] == "-"} {
-        if {[lsearch $choices $first] < 0} {
-            error "bad option \"$first\": should be [join [lsort $choices] {, }]"
-        }
-        set format $first
-        set args [lrange $args 1 end]
-    }
-    # return the whole list or just a single value
-    if {[llength $args] > 1} {
-        error "wrong # args: should be [join [lsort $choices] {, }]"
-    }
-    if {[llength $args] == 0} {
-        set name $_current
-    } else {
-        set name [lindex $args 0]
-    }
-    set elem [FindElement $name]
-    if { $elem == "" || $_state($elem) == "disabled" } {
-        if { $elem != "" } {
-            puts stderr "element $elem is disabled"
-        }
-        return ""
-    }
-    array set info $_table($elem)
-    # scan through and build up the return list
-    switch -- $format {
-        -name   { set value $info(name)   }
-        -symbol { set value $info(symbol) }
-        -weight { set value $info(weight) }
-        -number { set value $info(number) }
-        -all {
-            foreach key { symbol name number weight } {
-                lappend value $key $info($key)
-            }
-        }
-    }
-    return $value
-}
-
-# ----------------------------------------------------------------------
-# USAGE: select <name>
-#
-# Used to manipulate the selection in the table.
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicTable::select { what } {
-    set elem [FindElement $what]
-    if { $elem == "" } {
-        set elem "Hydrogen"
-    }
-    set _current $elem
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: FindElement <what>
-#
-# Checks to see if the given string <what> is recognized as an element
-# name, symbol, or number.  Returns the corresponding element name
-# or "" if the element is not recognized.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicTable::FindElement { what } {
-    foreach name [array names _table] {
-        array unset info
-        array set info $_table($name)
-        if { $what eq $info(name) || $what eq $info(number) ||
-             $what eq $info(symbol) } {
-            return $info(name)
-        }
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ElementIsType <name> <type> <type>...
-#
-# Checks to see if the given element <name> is one of the specified
-# <type> values.  Returns true if the element is one of the types
-# (logical or), or false if it is not.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicTable::ElementIsType { name args } {
-    foreach type $args {
-        if {[info exists _types($type)]} {
-            if {[lsearch -exact $_types($type) $name] >= 0} {
-                return 1
-            }
-        }
-    }
-    return 0
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _adjust ?<widget>?
-#
-# This method is invoked each time the dropdown is posted to adjust
-# its size and contents.  If the <widget> is specified, it is the
-# controlling widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicTable::_adjust {{widget ""}} {
-    chain $widget
-
-    focus $itk_component(table)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _react
-#
-# Invoked automatically when the user has selected something from
-# the listbox.  Unposts the drop-down and generates an event letting
-# the client know that the selection has changed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicTable::_react {} {
-    unpost
-    event generate $itk_component(hull) <<PeriodicTableSelect>>
-}
-
-itcl::body Rappture::PeriodicTable::Activate { canvas id x y } {
-    set c $itk_component(table)
-    array set info $_table($id)
-    set type $info(type)
-    set fg $_colors($type-activeforeground)
-    set bg $_colors($type-activebackground)
-    $c itemconfigure $id-rect -outline black -width 1 -fill $bg
-    $c itemconfigure $id-number -fill white
-    $c itemconfigure $id-symbol -fill white
-    ::Rappture::Tooltip::text $c \
-        "$info(name) ($info(symbol))\nNumber: $info(number)\nWeight: $info(weight)"
-    ::Rappture::Tooltip::tooltip pending $c @$x,$y
-}
-
-itcl::body Rappture::PeriodicTable::Deactivate { canvas id } {
-    set c $itk_component(table)
-    array set info $_table($id)
-    set type $info(type)
-    set fg $_colors($type-foreground)
-    set bg $_colors($type-background)
-    $c itemconfigure $id-rect -outline $fg -width 1 -fill $bg
-    $c itemconfigure $id-number -fill $fg
-    $c itemconfigure $id-symbol -fill $fg
-    ::Rappture::Tooltip::tooltip cancel
-}
-
-itcl::body Rappture::PeriodicTable::value {{value "" }} {
-    if { $value != "" } {
-        set _current $value
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Redraw
-#
-# Invoked automatically when the user has selected something from
-# the canvas.  Unposts the drop-down and generates an event letting
-# the client know that the selection has changed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PeriodicTable::Redraw {} {
-    set sqwidth [winfo pixels . 0.22i]
-    set sqheight [winfo pixels . 0.22i]
-set xoffset 4
-set yoffset 4
-set last ""
-    set c $itk_component(table)
-    $c delete all
-    foreach name [array names _table] {
-        array set info $_table($name)
-        set x1 [expr ($info(column)-1)*$sqwidth+$xoffset]
-        set y1 [expr ($info(row)-1)*$sqheight+$yoffset]
-        set x2 [expr ($info(column)*$sqwidth)-2+$xoffset]
-        set y2 [expr ($info(row)*$sqheight)-2+$yoffset]
-        set type $info(type)
-        if { $_state($name) == "disabled" } {
-            set fg $_colors($type-disabledforeground)
-            set bg $_colors($type-disabledbackground)
-        } else {
-            set fg $_colors($type-foreground)
-            set bg $_colors($type-background)
-        }
-        $c create rectangle $x1 $y1 $x2 $y2 -outline $fg -fill $bg \
-            -tags $info(name)-rect
-        if { $info(symbol) != "*" } {
-            $c create text [expr ($x2+$x1)/2+1] [expr ($y2+$y1)/2+4] \
-                -anchor c -fill $fg \
-                -text [string range $info(symbol) 0 4] \
-                -font "Arial 8 bold" -tags $info(name)-symbol
-            $c create text [expr $x2-2] [expr $y1+2] -anchor ne \
-                -text $info(number) -fill $fg \
-                -font "math1 6" -tags $info(name)-number
-        }
-        $c create rectangle $x1 $y1 $x2 $y2 -outline "" -fill "" \
-            -tags $info(name)
-        if { $_state($name) == "normal" } {
-        $c bind $info(name) <Enter> \
-            [itcl::code $this Activate %W $info(name) %X %Y]
-        $c bind $info(name) <Leave> [itcl::code $this Deactivate %W $info(name)]
-        $c bind $info(name) <ButtonRelease-1> [itcl::code $this value $info(name)]
-        }
-    }
-    update
-    foreach { x1 y1 x2 y2 } [$c bbox all] break
-    set width [expr $x2-$x1+$xoffset*2]
-    set height [expr $y2-$y1+$yoffset*2]
-    $c configure -height $height -width $width -background white
-}
Index: trunk/gui/scripts/postern.tcl
===================================================================
--- trunk/gui/scripts/postern.tcl	(revision 6716)
+++ 	(revision )
@@ -1,344 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: postern - a back door for debugging
-#
-#  This utility gives you a console that you can use to debug any
-#  live application.  You have to click and type the proper magic
-#  in the right spot, and a console area will appear to handle
-#  your requests.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require BLT
-package require Itk
-
-option add *Postern.size 2 widgetDefault
-option add *Postern.activeColor gray widgetDefault
-option add *Postern.popup above widgetDefault
-option add *Postern*Text.font \
-    -*-courier-medium-r-normal-*-12-* widgetDefault
-option add *Postern*Text.errorFont \
-    -*-courier-medium-o-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Postern {
-    inherit itk::Widget
-
-    itk_option define -size size Size 1
-    itk_option define -activecolor activeColor ActiveColor ""
-    itk_option define -popup popup Popup ""
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-    public method open {}
-    public method close {}
-    public method activate {args}
-    public method command {option}
-
-    public method _fake_puts {args}
-
-    private variable _active 0    ;# true when active and able to open
-    private variable _focus ""    ;# focus before this widget took over
-    private variable _afterid ""  ;# id for after event that clears activate
-
-    private variable _history ""  ;# list of recent commands
-    private variable _hpos 0      ;# current index in _history
-}
-
-itk::usual Postern {
-    keep -cursor -background
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Postern::constructor {args} {
-    global env tcl_platform
-
-    # this sequence gets things started...
-    if {$tcl_platform(os) == "Darwin"} {
-        # this works better on the Mac
-        bind $itk_component(hull) <Control-Button-1><Control-Button-1> \
-            [itcl::code $this activate on]
-    } else {
-        bind $itk_component(hull) <Button-1><Button-1><Button-3><Button-3> \
-            [itcl::code $this activate on]
-    }
-
-    #
-    # Get the magic word from the environment.
-    #
-    if {[info exists env(RAPPTURE_POSTERN)]} {
-        set event ""
-        foreach letter [split $env(RAPPTURE_POSTERN) ""] {
-            append event "<Key-$letter>"
-        }
-        bind $itk_component(hull) $event [itcl::code $this open]
-    }
-
-    #
-    # Build the debug dialog.
-    #
-    Rappture::Balloon $itk_component(hull).popup \
-        -title "Secret Command Console" \
-        -deactivatecommand [itcl::code $this activate off]
-    set inner [$itk_component(hull).popup component inner]
-
-    Rappture::Scroller $inner.area
-    pack $inner.area -expand yes -fill both
-    text $inner.area.text
-    $inner.area contents $inner.area.text
-
-    $inner.area.text tag configure error -foreground red \
-        -font [option get $inner.area.text errorFont Font]
-    $inner.area.text tag configure stderr -foreground red \
-        -font [option get $inner.area.text errorFont Font]
-    $inner.area.text tag configure stdout -foreground blue \
-        -font [option get $inner.area.text errorFont Font]
-
-    bind $inner.area.text <KeyPress> \
-        [itcl::code $this command key]
-    bind $inner.area.text <KeyPress-BackSpace> \
-        [itcl::code $this command backspace]
-    bind $inner.area.text <Control-KeyPress-h> \
-        [itcl::code $this command backspace]
-
-    bind $inner.area.text <KeyPress-Return> \
-        [itcl::code $this command execute]
-    bind $inner.area.text <KP_Enter> \
-        [itcl::code $this command execute]
-
-    bind $inner.area.text <KeyPress-Up> \
-        "[itcl::code $this command previous]; break"
-    bind $inner.area.text <Control-KeyPress-p> \
-        "[itcl::code $this command previous]; break"
-
-    bind $inner.area.text <KeyPress-Down> \
-        "[itcl::code $this command next]; break"
-    bind $inner.area.text <Control-KeyPress-n> \
-        "[itcl::code $this command next]; break"
-
-    command prompt
-
-    eval itk_initialize $args
-
-    # this makes it easier to find the magic spot
-    bind $itk_component(hull) <Alt-Enter> [list $itk_component(hull) configure -background $itk_option(-activecolor)]
-    bind $itk_component(hull) <Leave> [list $itk_component(hull) configure -background $itk_option(-background)]
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Postern::destructor {} {
-    if {"" != $_afterid} {
-        after cancel $_afterid
-        set _afterid ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: active ?on|off?
-#
-# Used to query or set the activation state of this widget.  When
-# the widget is "active", it changes color and accepts the magic
-# pass phrase that will open up the debug panel.  A short delay after
-# being activated, it deactivates itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Postern::activate {args} {
-    if {[llength $args] == 0} {
-        return $_active
-    }
-
-    if {"" != $_afterid} {
-        after cancel $_afterid
-        set _afterid ""
-    }
-
-    if {$args} {
-        component hull configure -background $itk_option(-activecolor)
-        set _focus [focus]
-        focus $itk_component(hull)
-        set _active 1
-        set _afterid [after 3000 [itcl::code $this activate off]]
-    } else {
-        focus $_focus
-        set _focus ""
-        component hull configure -background $itk_option(-background)
-
-        if {[info commands _tcl_puts] != ""} {
-            # set puts back to normal
-            rename ::puts ""
-            rename ::_tcl_puts ::puts
-        }
-        set _active 0
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: open
-#
-# Used to open the debug area.  If the widget is active, then the
-# debug area pops up near it.  Otherwise, this method does nothing.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Postern::open {} {
-    if {$_active} {
-        if {"" != $_afterid} {
-            # don't deactivate until we close
-            after cancel $_afterid
-            set _afterid ""
-        }
-
-        $itk_component(hull).popup activate \
-            $itk_component(hull) $itk_option(-popup)
-
-        set text [$itk_component(hull).popup component inner].area.text
-        focus $text
-
-        # make puts send output to this display
-        rename ::puts ::_tcl_puts
-        proc ::puts {args} [format {%s _fake_puts $args} $this]
-    }
-}
-
-itcl::body Rappture::Postern::close {} {
-    $itk_component(hull).popup deactivate
-}
-
-# ----------------------------------------------------------------------
-# USAGE: command prompt
-# USAGE: command execute
-# USAGE: command next
-# USAGE: command previous
-# USAGE: command key
-#
-# Used to handle various editing operations in the text area.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Postern::command {option} {
-    set text [$itk_component(hull).popup component inner].area.text
-
-    switch -- $option {
-        prompt {
-            if {[lindex [split [$text index end-1char] .] 1] != 0} {
-                $text insert end "\n"
-            }
-            $text insert end "% "
-            $text mark set command end-1char
-            $text mark gravity command left
-            $text mark set insert end
-            $text see insert
-        }
-        key {
-            if {[$text compare insert < command]} {
-                $text mark set insert end
-                $text see insert
-            }
-        }
-        backspace {
-            if {[catch {$text index sel.first}] == 0} {
-                if {[$text compare sel.first < command]
-                      || [$text compare sel.last < command]} {
-                    $text tag remove sel 1.0 end
-                }
-            }
-            if {[$text compare insert < command]} {
-                $text mark set insert end
-                $text see insert
-            }
-            if {[$text compare insert == command]} {
-                return -code break  ;# don't erase past start of command
-            }
-        }
-        execute {
-            set cmd [string trim [$text get command end]]
-            if {"" == $cmd} {
-                command prompt
-            } else {
-                lappend _history $cmd
-                if {[llength $_history] > 100} {
-                    set _history [lrange $_history end-100 end]
-                }
-                set _hpos [llength $_history]
-
-                $text insert end "\n"
-                if {[catch {uplevel #0 $cmd} result]} {
-                    $text insert end $result error
-                } else {
-                    $text insert end $result
-                }
-                command prompt
-            }
-            return -code break
-        }
-        next {
-            if {$_hpos < [llength $_history]} {
-                incr _hpos
-                set cmd [lindex $_history $_hpos]
-                $text delete command end
-                $text insert command $cmd
-                $text mark set insert end
-                $text see insert
-            }
-        }
-        previous {
-            if {$_hpos > 0} {
-                incr _hpos -1
-                set cmd [lindex $_history $_hpos]
-                $text delete command end
-                $text insert command $cmd
-                $text mark set insert end
-                $text see insert
-            }
-        }
-        default {
-            error "bad option \"$option\""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fake_puts {?-nonewline? ?<channel>? <string>}
-#
-# This method acts as a replacement for puts.  It sends output
-# to the postern screen, itstead of stdin/stdout.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Postern::_fake_puts {arglist} {
-    Rappture::getopts arglist params {
-        flag group -nonewline
-    }
-    switch -- [llength $arglist] {
-        1 {
-            set channel stdout
-            set string [lindex $arglist 0]
-        }
-        2 {
-            set channel [lindex $arglist 0]
-            set string [lindex $arglist 1]
-        }
-        default {
-            error "wrong # args: should be \"puts ?-nonewline? ?channel? string\""
-        }
-    }
-
-    set text [$itk_component(hull).popup component inner].area.text
-    if {$channel == "stdout" || $channel == "stderr"} {
-        $text insert end $string $channel
-        if {!$params(-nonewline)} {
-            $text insert end "\n"
-        }
-    } else {
-        eval _tcl_puts $arglist
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -size
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Postern::size {
-    component hull configure \
-        -width $itk_option(-size) \
-        -height $itk_option(-size)
-}
Index: trunk/gui/scripts/probdisteditor.tcl
===================================================================
--- trunk/gui/scripts/probdisteditor.tcl	(revision 6716)
+++ 	(revision )
@@ -1,699 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: ProbDistEditor - probability distribution editor
-#
-#  This widget displays a probability distribution and lets the user
-#  edit it in various flavors.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2010  Purdue University
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *ProbDistEditor.fillColor blue widgetDefault
-option add *ProbDistEditor*Entry.background white widgetDefault
-option add *ProbDistEditor*Entry.width 10 widgetDefault
-
-itcl::class Rappture::ProbDistEditor {
-    inherit itk::Widget
-
-    itk_option define -fillcolor fillColor FillColor ""
-
-    constructor {args} {
-        # defined below
-    }
-    public method value {{newval ""}}
-    public method mode {{newval ""}}
-    public method reset {}
-
-    protected method _redraw {}
-    protected method _axisLabels {which graph val}
-    protected method _apply {op {widget ""}}
-
-    protected variable _dispatcher "";  # dispatcher for !events
-    protected variable _mode "";        # type of distribution function
-    protected variable _value;          # data values for mode-detail
-    protected variable _uvalue;         # data values for mode-detail with units
-    protected variable _umin;           # minimum allowed value for tool with units
-    protected variable _umax;           # maximum allowed value for tool with units
-    protected variable _units;          # units for min and max
-}
-
-itk::usual ProbDistEditor {
-    keep -cursor -font -foreground -background
-    keep -fillcolor
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ProbDistEditor::constructor {min max units default} {
-    # create a dispatcher for events
-    #puts "PDE::constructor $min $max $default"
-
-    # These are the tool min and max values.  May be empty.
-    set _umin $min
-    set _umax $max
-    set _units $units
-    set _uvalue(central) $default
-
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !redraw
-    $_dispatcher dispatch $this !redraw "[itcl::code $this _redraw]; list"
-
-    itk_component add vals {
-        frame $itk_interior.vals
-    }
-    pack $itk_component(vals) -side left -fill both -padx {0 10}
-    #
-    # EXACT value options
-    #
-    itk_component add exactvals {
-        frame $itk_component(vals).exact
-    }
-    itk_component add evl {
-        label $itk_component(exactvals).l -text "Value:"
-    }
-    entry $itk_component(exactvals).val
-    _apply bindings $itk_component(exactvals).val
-    grid $itk_component(evl) -row 0 -column 0 -sticky e
-    grid $itk_component(exactvals).val -row 0 -column 1 -sticky ew -pady 2
-    grid rowconfigure $itk_component(exactvals) 1 -weight 1
-    #
-    # UNIFORM value options
-    #
-    itk_component add uniformvals {
-        frame $itk_component(vals).uniform
-    }
-    itk_component add uvl0 {
-        label $itk_component(uniformvals).l0 -text "Minimum:"
-    }
-    entry $itk_component(uniformvals).min
-    _apply bindings $itk_component(uniformvals).min
-    grid $itk_component(uvl0) -row 0 -column 0 -sticky e
-    grid $itk_component(uniformvals).min -row 0 -column 1 -sticky ew -pady 2
-
-    itk_component add uvl1 {
-        label $itk_component(uniformvals).l1 -text "Maximum:"
-    }
-    entry $itk_component(uniformvals).max
-    _apply bindings $itk_component(uniformvals).max
-    grid $itk_component(uvl1) -row 1 -column 0 -sticky e
-    grid $itk_component(uniformvals).max -row 1 -column 1 -sticky ew -pady 2
-    grid rowconfigure $itk_component(uniformvals) 2 -weight 1
-
-    #
-    # GAUSSIAN value options
-    #
-    itk_component add gaussianvals {
-        frame $itk_component(vals).gaussian
-    }
-    itk_component add gvlm {
-        label $itk_component(gaussianvals).lm -text "Mean:"
-    }
-    entry $itk_component(gaussianvals).mean
-    _apply bindings $itk_component(gaussianvals).mean
-    grid $itk_component(gvlm) -row 0 -column 0 -sticky e
-    grid $itk_component(gaussianvals).mean -row 0 -column 1 -sticky ew -pady 2
-
-    itk_component add gvls {
-        label $itk_component(gaussianvals).ls -text "Std Deviation:"
-    }
-    entry $itk_component(gaussianvals).stddev
-    _apply bindings $itk_component(gaussianvals).stddev
-    grid $itk_component(gvls) -row 1 -column 0 -sticky e
-    grid $itk_component(gaussianvals).stddev -row 1 -column 1 -sticky ew -pady 2
-
-    itk_component add gvl0 {
-        label $itk_component(gaussianvals).l0 -text "Minimum:" -state disabled
-    }
-    entry $itk_component(gaussianvals).min -state readonly
-    _apply bindings $itk_component(gaussianvals).min
-    grid $itk_component(gvl0) -row 2 -column 0 -sticky e
-    grid $itk_component(gaussianvals).min -row 2 -column 1 -sticky ew -pady 2
-
-    itk_component add gvl1 {
-        label $itk_component(gaussianvals).l1 -text "Maximum:" -state disabled
-    }
-    entry $itk_component(gaussianvals).max -state readonly
-    _apply bindings $itk_component(gaussianvals).max
-    grid $itk_component(gvl1) -row 3 -column 0 -sticky e
-    grid $itk_component(gaussianvals).max -row 3 -column 1 -sticky ew -pady 2
-    grid rowconfigure $itk_component(gaussianvals) 4 -weight 1
-
-    #
-    # Preview graph to display probability density function
-    #
-    itk_component add graph {
-        blt::graph $itk_interior.graph -width 2i -height 1i \
-            -plotborderwidth 1 -plotrelief solid -plotpadx 0 -plotpady 0 \
-            -highlightthickness 0
-    } {
-        keep -background -foreground -cursor -font
-    }
-    pack $itk_component(graph) -expand yes -fill both
-
-    $itk_component(graph) xaxis configure -ticklength 4 \
-        -command [itcl::code $this _axisLabels xaxis]
-    $itk_component(graph) yaxis configure -ticklength 4 \
-        -title "PDF" -command [itcl::code $this _axisLabels yaxis]
-    $itk_component(graph) grid off
-    $itk_component(graph) legend configure -hide yes
-
-    # start in exact mode with default values
-    mode "exact"
-
-    eval itk_initialize
-
-    #
-    # Figure out a good size for all panels of options and for the
-    # overall widget.
-    #
-    update idletasks
-    set maxw 0
-    set maxh 0
-    foreach panel {exact uniform gaussian} {
-        set w [winfo reqwidth $itk_component(${panel}vals)]
-        if {$w > $maxw} { set maxw $w }
-        set h [winfo reqheight $itk_component(${panel}vals)]
-        if {$h > $maxh} { set maxh $h }
-    }
-
-    pack propagate $itk_component(vals) off
-    $itk_component(vals) configure -width $maxw -height $maxh
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?<setValue>?
-#
-# With no arguments, this returns the current value within the widget
-# as a list of key/value pairs:
-#   mode gaussian mean xxx stddev xxx min xxx max xxx
-#
-# Each value always has a "mode" that indicates its type, and other
-# values to characterize the type.
-#
-# If the value is specified, then it is interpreted as the sort of
-# value that is passed back, but used to set the value.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ProbDistEditor::value {{newval ""}} {
-    # puts "PDE::value $newval"
-
-    #FIXME: _value has numerical values _uvalue has value with units
-    if {"" == $newval} {
-        catch {_apply finalize}  ;# apply any outstanding changes
-
-        switch -- $_mode {
-            exact {
-                return $_uvalue(central)
-            }
-            uniform {
-                return [list uniform $_uvalue(min) $_uvalue(max)]
-            }
-            gaussian {
-                return [list gaussian $_uvalue(central) $_uvalue(stddev)]
-            }
-            default {
-                error "don't know how to format value for $_mode"
-            }
-        }
-    }
-
-    set newmode [lindex $newval 0]
-    switch -- $newmode {
-        uniform {
-            foreach {utmp(min) utmp(max)} [lrange $newval 1 2] break
-            if {[catch {Rappture::Units::convert $utmp(min) -units off} tmp(min)]} {
-                set tmp(min) $utmp(min)
-            }
-            if {[catch {Rappture::Units::convert $utmp(max) -units off} tmp(max)]} {
-                set tmp(max) $utmp(max)
-            }
-        }
-        gaussian {
-            foreach {utmp(central) utmp(stddev)} [lrange $newval 1 2] break
-            if {[catch {Rappture::Units::convert $utmp(central) -units off} tmp(central)]} {
-                set tmp(central) $utmp(central)
-            }
-            if {[catch {Rappture::Units::convert $utmp(stddev) -units off} tmp(stddev)]} {
-                set tmp(stddev) $utmp(stddev)
-            }
-            set units [Rappture::Units::Search::for $utmp(central)]
-            if {"" != $_umin} {
-                if {"" != $units} {
-                    set tmp(min) [Rappture::Units::convert $_umin -to $units -context $units -units off]
-                } else {
-                    set tmp(min) $_umin
-                }
-            }
-            if {"" != $_umax} {
-                if {"" != $units} {
-                    set tmp(max) [Rappture::Units::convert $_umax -to $units -context $units -units off]
-                } else {
-                    set tmp(max) $_umax
-                }
-            }
-        }
-        exact {
-            set utmp(central) [lindex $newval 1]
-            if {[catch {Rappture::Units::convert $utmp(central) -units off} tmp(central)]} {
-                set tmp(central) $utmp(central)
-            }
-        }
-        default {
-            set newmode exact
-            set utmp(central) [lindex $newval 0]
-            if {[catch {Rappture::Units::convert $utmp(central) -units off} tmp(central)]} {
-                set tmp(central) $utmp(central)
-            }
-        }
-    }
-    array set _value [array get tmp]
-    array set _uvalue [array get utmp]
-    mode $newmode  ;# assign this mode and copy in values for editing
-}
-
-# ----------------------------------------------------------------------
-# USAGE: mode ?<setMode>?
-#
-# With no arguments, this returns a list of allowed distribution
-# modes.  Otherwise, the value sets the mode of the distribution and
-# loads default or previous values for the distribution.  Note that
-# the mode is also reported as part of the "value" returned from
-# this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ProbDistEditor::mode {{newval ""}} {
-    # puts "PDE::mode mode=$newval min=$_umin max=$_umax units=$_units"
-
-    set modes {exact uniform gaussian custom}
-    if {"" == $newval} {
-        return $modes
-    }
-
-    set check 0
-    if {$newval == "check"} {
-        set newval $_mode
-        set check 1
-    }
-
-    if {[lsearch $modes $newval] < 0} {
-        error "bad value \"$newval\": should be [join $modes {, }]"
-    }
-
-    # discard units from tool min/max
-    if {$_units == ""} {
-        set min $_umin
-        set max $_umax
-    } else {
-        if {$_umin == ""} {
-            set min ""
-        } else {
-            set min [Rappture::Units::convert $_umin -context $_units -units off]
-        }
-        if {$_umax == ""} {
-            set max ""
-        } else {
-            set max [Rappture::Units::convert $_umax -context $_units -units off]
-        }
-    }
-
-    # The mode was changed by the user.  Pick reasonable values.
-    switch -- $newval {
-        exact {
-            if {![info exists _value(central)]} {
-                if {$min != "" && $max != ""} {
-                    set _value(central) [expr {0.5*($max + $min)}]
-                } else {
-                    set _value(central) 0.5
-                }
-                set _uvalue(central) $_value(central)$_units
-            }
-        }
-        uniform {
-            if {![info exists _value(min)] || ![info exists _value(max)]} {
-                set _value(max) [expr $_value(central) * 1.1]
-                set _value(min) [expr $_value(central) * 0.9]
-                if {$_value(central) == 0.0} {
-                    set _value(max) 1.0
-                }
-                if {$min != ""} {
-                    if {$_value(min) < $min} {
-                        set $_value(min) $min
-                    }
-                }
-                if {$max != ""} {
-                    if {$_value(max) > $max} {
-                        set $_value(max) $max
-                    }
-                }
-                set _uvalue(min) $_value(min)$_units
-                set _uvalue(max) $_value(max)$_units
-            }
-        }
-        gaussian {
-            #puts "GAUSSIAN min=$min max=$max"
-            if {![info exists _value(central)]} {
-                if {[info exists _value(min)] && [info exists _value(max)]} {
-                    set _value(central) [expr {0.5*($_value(max) + $_value(min))}]
-                } else {
-                    set _value(central) [expr {0.5*($max + $min)}]
-                }
-            }
-            #puts "central=$_value(central)"
-            if {![info exists _value(stddev)]} {
-                set _value(stddev)  [expr $_value(central) * 0.10]
-            }
-            if {$_value(stddev) <= 0} {
-                set _value(stddev) 1.0
-            }
-            #puts "stddev=$_value(stddev)"
-            # lower bound is -3 deviations or tool min
-            set trunc [expr {$_value(central) - 3*$_value(stddev)}]
-            if {$min == "" || $trunc > $min} {
-                set _value(min) $trunc
-            } else {
-                set _value(min) $min
-            }
-
-            # upper bound is +3 deviations or tool max
-            set trunc [expr {$_value(central) + 3*$_value(stddev)}]
-            if {$max == "" || $trunc < $max} {
-                set _value(max) $trunc
-            } else {
-                set _value(max) $max
-            }
-
-            set _uvalue(min) $_value(min)$_units
-            set _uvalue(max) $_value(max)$_units
-            set _uvalue(central) $_value(central)$_units
-            set _uvalue(stddev) $_value(stddev)$_units
-        }
-    }
-
-    if {$check == 1} {
-        return
-    }
-    # pop up the panel of editing options for this mode
-    foreach w [pack slaves $itk_component(vals)] {
-        pack forget $w
-    }
-    pack $itk_component(${newval}vals) -expand yes -fill both
-
-    switch -- $newval {
-        exact {
-            $itk_component(exactvals).val delete 0 end
-            $itk_component(exactvals).val insert end $_uvalue(central)
-            focus $itk_component(exactvals).val
-        }
-        uniform {
-            $itk_component(uniformvals).min delete 0 end
-            $itk_component(uniformvals).min insert end $_uvalue(min)
-            $itk_component(uniformvals).max delete 0 end
-            $itk_component(uniformvals).max insert end $_uvalue(max)
-            focus $itk_component(uniformvals).min
-        }
-        gaussian {
-            $itk_component(gaussianvals).mean delete 0 end
-            $itk_component(gaussianvals).mean insert end $_uvalue(central)
-            $itk_component(gaussianvals).stddev delete 0 end
-            $itk_component(gaussianvals).stddev insert end $_uvalue(stddev)
-
-            $itk_component(gaussianvals).min configure -state normal
-            $itk_component(gaussianvals).min delete 0 end
-            $itk_component(gaussianvals).min insert end $_uvalue(min)
-            $itk_component(gaussianvals).min configure -state readonly
-
-            $itk_component(gaussianvals).max configure -state normal
-            $itk_component(gaussianvals).max delete 0 end
-            $itk_component(gaussianvals).max insert end $_uvalue(max)
-            $itk_component(gaussianvals).max configure -state readonly
-
-            focus $itk_component(gaussianvals).mean
-        }
-    }
-
-    set _mode $newval
-    $_dispatcher event -idle !redraw
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Clears all value information so that the next value application
-# starts from scratch.  Without a reset, the widget carries information
-# like the "central" value, in case the user changes modes and then
-# changes back.  Reset discards that info and starts fresh.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ProbDistEditor::reset {} {
-    set _mode ""
-    catch {unset _value}
-    catch {unset _uvalue}
-    $_dispatcher event -idle !redraw
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Used internally to reconfigure the graph to display the current
-# distribution plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ProbDistEditor::_redraw {} {
-    #puts "PDE::_redraw"
-
-    set g $itk_component(graph)
-    eval $g element delete [$g element names]
-    eval $g mark delete [$g mark names]
-    switch -- $_mode {
-        exact {
-            $g xaxis configure -majorticks {} -min 0 -max 1 -stepsize 0.1
-            $g yaxis configure -min 0 -max 1
-            $g element create delta \
-                -xdata {0 0.48 0.49 0.50 0.51 0.52 1} \
-                -ydata {0    0 0.05 0.93 0.05    0 0} \
-                -color $itk_option(-foreground) -symbol "" \
-                -areaforeground $itk_option(-fillcolor) -areapattern solid
-            # $g marker create image -anchor nw -coords {0.5 0.95} \
-                -xoffset -6 -yoffset -3 -image [Rappture::icon delta]
-        }
-        uniform {
-            $g xaxis configure -majorticks {} -min 0 -max 1 -stepsize 0.1
-            $g yaxis configure -min 0 -max 1
-
-            # uniform distribution throughout
-            $g element create uniform \
-                -xdata {-0.1 -0.1 1.1 1.1} -ydata {-0.1 0.5 0.5 -0.1} \
-                -color $itk_option(-foreground) -symbol "" \
-                -areaforeground $itk_option(-fillcolor) -areapattern solid
-
-            # left/right limits
-            $g marker create polygon \
-                -coords {-0.1 -0.1 0.1 -0.1 0.1 1.1 -0.1 1.1} \
-                -outline gray -linewidth 1 -fill gray -stipple gray25
-            $g marker create polygon \
-                -coords {1.1 -0.1 0.9 -0.1 0.9 1.1 1.1 1.1} \
-                -outline gray -linewidth 1 -fill gray -stipple gray25
-        }
-        gaussian {
-            #puts "min=$_value(min) max=$_value(max)"
-            #puts "mean=$_value(central) dev=$_value(stddev)"
-
-            set min $_value(min)
-            set max $_value(max)
-            set dx [expr {$max - $min}]
-            set realmin [expr {$min - 0.1 * $dx}]
-            set realmax [expr {$max + 0.1 * $dx}]
-            set mean $_value(central)
-            set sig2 [expr {$_value(stddev) * $_value(stddev)}]
-            $g xaxis configure -min $realmin -max $realmax \
-                -majorticks [list $min $mean $max]
-            $g yaxis configure -min 0 -max 1.1
-            set xdata ""
-            set ydata ""
-            for {set n 0} {$n <= 50} {incr n} {
-                set x [expr {($realmax - $realmin) / 50.0 * $n + $realmin}]
-                lappend xdata $x
-                set expon [expr {-0.5 * ($x - $mean) * ($x - $mean) / $sig2}]
-                if {$expon < -200} {
-                    lappend ydata 0.0
-                } else {
-                    lappend ydata [expr {exp($expon)}]
-                }
-            }
-            $g element create bellcurve \
-                -xdata $xdata -ydata $ydata \
-                -color $itk_option(-foreground) -symbol "" \
-                -areaforeground $itk_option(-fillcolor) -areapattern solid
-
-            # left/right limits
-            set x0m [expr {$min - 0.2 * $dx}]
-            set x0 $min
-            set x1 $max
-            set x1p [expr {$max + 0.2 * $dx}]
-            $g marker create polygon \
-                -coords [list $x0m -0.1 $x0 -0.1 $x0 1.2 $x0m 1.2] \
-                -outline gray -linewidth 1 -fill gray -stipple gray25
-            $g marker create polygon \
-                -coords [list $x1p -0.1 $x1 -0.1 $x1 1.2 $x1p 1.2] \
-                -outline gray -linewidth 1 -fill gray -stipple gray25
-
-            # lines for standard deviation
-            set x0 [expr {$_value(central)-$_value(stddev)}]
-            set x1 [expr {$_value(central)+$_value(stddev)}]
-            $g marker create line \
-                -coords [list $x0 -0.1 $x0 1.2] -linewidth 1 \
-                -outline gray -dashes 2
-            $g marker create line \
-                -coords [list $x1 -0.1 $x1 1.2] -linewidth 1 \
-                -outline gray -dashes 2
-        }
-        custom {
-        }
-        default {
-            error "don't know how to redraw for mode \"$_mode\""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _axisLabels <which> <graph> <val>
-#
-# Used internally to generate axis labels for the x- and y-axes of
-# the graph.  The y-axis doesn't usually have labels since the values
-# aren't meaningful.  The x-axis should show values according to the
-# current mode of input.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ProbDistEditor::_axisLabels {which graph val} {
-    switch -- $which {
-        xaxis {
-            switch -- $_mode {
-                exact {
-                    if {$val == 0.5} {
-                        return $_value(central)
-                    }
-                    return ""
-                }
-                uniform {
-                    if {$val == 0.1} {
-                        return [expr {$_value(min) < $_value(max)
-                            ? $_value(min) : $_value(max)}]
-                    } elseif {$val == 0.9} {
-                        return [expr {$_value(min) > $_value(max)
-                            ? $_value(min) : $_value(max)}]
-                    }
-                    return ""
-                }
-                gaussian {
-                    return $val
-                }
-            }
-        }
-        yaxis {
-            return ""  ;# no labels for y-axis values
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _apply bindings <widget>
-# USAGE: _apply value <widget>
-# USAGE: _apply finalize
-#
-# Called automatically whenever a value is edited to check/apply the
-# value and redraw the PDF plot.  If the value is bad, then it is
-# reloaded for editing.  Otherwise, it is applied.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ProbDistEditor::_apply {op {widget ""}} {
-    #puts "PDE::_apply $op $widget"
-    if {$op != "bindings"} {
-        # need this for value/finalize
-        array set w2uvalue [list \
-            $itk_component(exactvals).val _uvalue(central) \
-            $itk_component(uniformvals).min _uvalue(min) \
-            $itk_component(uniformvals).max _uvalue(max) \
-            $itk_component(gaussianvals).mean _uvalue(central) \
-            $itk_component(gaussianvals).stddev _uvalue(stddev) \
-            $itk_component(gaussianvals).min _uvalue(min) \
-            $itk_component(gaussianvals).max _uvalue(max) \
-        ]
-        array set w2value [list \
-            $itk_component(exactvals).val _value(central) \
-            $itk_component(uniformvals).min _value(min) \
-            $itk_component(uniformvals).max _value(max) \
-            $itk_component(gaussianvals).mean _value(central) \
-            $itk_component(gaussianvals).stddev _value(stddev) \
-            $itk_component(gaussianvals).min _value(min) \
-            $itk_component(gaussianvals).max _value(max) \
-        ]
-    }
-
-    if {$op == "finalize"} {
-        # one of our widgets has focus?
-        set widget [focus]
-        if {![info exists w2value($widget)]} {
-            # nope -- nevermind, nothing to do
-            return
-        }
-        # yes -- continue onward trying to finalize the value in that widget
-        set op "value"
-    }
-
-    switch -- $op {
-        bindings {
-            bind $widget <KeyPress-Tab> [itcl::code $this _apply value %W]
-            bind $widget <KeyPress-Return> [itcl::code $this _apply value %W]
-            bind $widget <FocusOut> [itcl::code $this _apply value %W]
-        }
-        value {
-            set var $w2value($widget)
-            set uvar $w2uvalue($widget)
-            if {$_units == ""} {
-                set newval [$widget get]
-            } else {
-                set newval [Rappture::Units::convert [$widget get] -context $_units]
-            }
-            set itk $itk_component(gaussianvals).stddev
-            if {$widget != $itk && [catch {Rappture::Units::mcheck_range $newval $_umin $_umax $_units} err]} {
-                # oops! value is bad -- edit again
-                bell
-                Rappture::Tooltip::cue $widget $err
-                $widget delete 0 end
-                $widget insert end [set $var]
-                $widget select from 0
-                $widget select to end
-                focus $widget
-                return -code break  ;# stop other bindings like tab-traversal
-            }
-            $widget delete 0 end
-            $widget insert end $newval
-            set $uvar $newval
-
-            #if {$widget == $itk_component(gaussianvals).mean} {
-                # need new min and max
-                #set $_uvalue(min)
-                #set $_uvalue(max) ...
-            #}
-
-            if {[catch {Rappture::Units::convert $newval -units off} nvar]} {
-                set nvar $newval
-            }
-            set $var $nvar
-
-            mode check
-            $_dispatcher event -idle !redraw
-        }
-        default {
-            error "bad option \"$opt\": should be bindings, value"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -fillcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::ProbDistEditor::fillcolor {
-    $_dispatcher event -idle !redraw
-}
Index: trunk/gui/scripts/progress.tcl
===================================================================
--- trunk/gui/scripts/progress.tcl	(revision 6716)
+++ 	(revision )
@@ -1,166 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: progress - progress meter for long-running apps
-#
-#  This widget acts as a progress meter for long-running applications.
-#  It accepts progress reports as a combination of a percentage and
-#  a message, and then displays the percentage on a bar 0-100%.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *Progress.borderWidth 2 widgetDefault
-option add *Progress.relief sunken widgetDefault
-option add *Progress.length 2i widgetDefault
-option add *Progress.barBackground white widgetDefault
-option add *Progress.barColor blue widgetDefault
-option add *Progress.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Progress {
-    inherit itk::Widget
-
-    itk_option define -barcolor barColor BarColor ""
-    itk_option define -barbackground barBackground BarBackground ""
-    itk_option define -length length Length 0
-
-    constructor {args} { # defined below }
-    public method settings {args}
-
-    protected method _redraw {}
-
-    private variable _message ""  ;# status message
-    private variable _percent 0   ;# status percentage
-}
-
-itk::usual Progress {
-    keep -cursor -font -foreground -background
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Progress::constructor {args} {
-    itk_component add bar {
-        canvas $itk_interior.bar -highlightthickness 0
-    } {
-        usual
-        keep -borderwidth -relief
-        ignore -highlightthickness -highlightbackground -highlightcolor
-    }
-    pack $itk_component(bar) -expand yes -fill both
-    bind $itk_component(bar) <Configure> [itcl::code $this _redraw]
-
-    itk_component add message {
-        label $itk_interior.mesg -anchor w -width 1
-    }
-
-    eval itk_initialize $args
-    component hull configure -borderwidth 0
-
-    set h [font metrics $itk_option(-font) -linespace]
-    $itk_component(bar) configure -height [expr {$h+4}]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: settings ?-percent <val>? ?-message <string>?
-#
-# Clients use this to query/set the settings shown in the progress
-# meter.  With no args, it returns a list of the form "-percent v
-# -message str".  Otherwise, it interprets the args and updates
-# the values.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Progress::settings {args} {
-    if {[llength $args] == 0} {
-        return [list -percent $_percent -message $_message]
-    }
-
-    Rappture::getopts args params {
-        value -percent ""
-        value -message "__ignore__"
-    }
-
-    set changed 0
-    if {$params(-percent) != ""} {
-        if {![string is double $params(-percent)]} {
-            error "bad value \"$params(-percent)\": should be 0-100"
-        }
-        if {$params(-percent) < 0} {
-            set params(-percent) 0
-        }
-        if {$params(-percent) > 100} {
-            set params(-percent) 100
-        }
-        set _percent $params(-percent)
-        set changed 1
-    }
-    if {$params(-message) != "__ignore__"} {
-        set _message $params(-message)
-        set changed 1
-    }
-
-    if {$changed} {
-        _redraw
-        update idletasks
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Used internally to redraw the progress meter on the internal canvas.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Progress::_redraw {} {
-    set w [winfo width $itk_component(bar)]
-    set h [winfo height $itk_component(bar)]
-
-    if {[string length $_message] > 0} {
-        $itk_component(message) configure -text $_message
-        pack $itk_component(message) -fill x
-    } else {
-        pack forget $itk_component(message)
-    }
-
-    if {[$itk_component(bar) find all] == ""} {
-        $itk_component(bar) create rectangle 0 0 1 1 \
-            -outline "" -fill $itk_option(-barbackground) -tags barbg
-        $itk_component(bar) create rectangle 0 0 1 1 \
-            -outline "" -fill $itk_option(-barcolor) -tags bar
-        $itk_component(bar) create text 0 0 \
-            -anchor center -text "" -font $itk_option(-font) -tags number
-    }
-
-    set msg [format "%3.0f%%" $_percent]
-    $itk_component(bar) itemconfigure number -text $msg
-
-    set barw [expr {0.01*$_percent*$w}]
-    $itk_component(bar) coords number [expr {$w/2}] [expr {$h/2}]
-    $itk_component(bar) coords bar 0 0 $barw $h
-    $itk_component(bar) coords barbg 0 0 $w $h
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -barcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Progress::barcolor {
-    $itk_component(bar) itemconfigure bar -fill $itk_option(-barcolor)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -barbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Progress::barbackground {
-    $itk_component(bar) itemconfigure barbg -fill $itk_option(-barbackground)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -length
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Progress::length {
-    set w [winfo pixels $itk_component(hull) $itk_option(-length)]
-    $itk_component(bar) configure -width $w
-}
Index: trunk/gui/scripts/pushbutton.tcl
===================================================================
--- trunk/gui/scripts/pushbutton.tcl	(revision 6716)
+++ 	(revision )
@@ -1,197 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: PushButton - widget for entering a choice of strings
-#
-#  This widget represents a <choice> entry on a control panel.
-#  It is used to choose one of several mutually-exclusive strings.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *PushButton.width 16 widgetDefault
-option add *PushButton.height 16 widgetDefault
-
-itcl::class Rappture::PushButton {
-    inherit itk::Widget
-
-    itk_option define -variable variable Variable "normal"
-    itk_option define -command command Command "normal"
-    itk_option define -width width Width "normal"
-    itk_option define -height height Height "normal"
-    itk_option define -onvalue onValue OnValue "normal"
-    itk_option define -offvalue offValue OffValue "normal"
-    itk_option define -onbackground onBackground OnBackground "white"
-    itk_option define -offbackground offBackground OffBackground "grey85"
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method invoke {}
-    public method deselect {}
-    public method select {}
-    public method toggle {}
-    public method disable {}
-    public method enable {}
-
-    protected method _fixValue {args}
-
-    private variable _state 0
-    private variable _enabled 1
-    public variable command "";         # Command to be invoked
-    private variable _variable "";      # Variable to be set.
-    public variable onimage "";         # Image displayed when selected
-    public variable offimage "";        # Image displayed when deselected.
-    public variable disabledimage "";   # Image displayed when deselected.
-    public variable onvalue "1";        # Value set when selected.
-    public variable offvalue "0";       # Value set when deselected.
-    public variable onbackground "white"
-    public variable offbackground "grey85"
-}
-
-itk::usual PushButton {
-    keep -cursor -font
-    keep -foreground -background
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::PushButton::constructor {args} {
-    itk_component add button {
-        label $itk_interior.button -borderwidth 1 -relief sunken
-    } {
-        usual
-        ignore -padx -pady -relief -borderwidth -background
-    }
-    bind $itk_component(button) <ButtonPress> \
-        [itcl::code $this invoke]
-    pack $itk_component(button) -expand yes -fill both -ipadx 1 -ipady 1
-    eval itk_initialize $args
-    deselect
-}
-
-itcl::body Rappture::PushButton::invoke {} {
-    if { !$_enabled } {
-        return
-    }
-    toggle
-    if { $command != "" } {
-        uplevel \#0 $command
-    }
-}
-
-itcl::body Rappture::PushButton::toggle {} {
-    if { !$_enabled } {
-        return
-    }
-    set _state [expr !$_state]
-    if { $_state } {
-        select
-    } else {
-        deselect
-    }
-}
-
-itcl::body Rappture::PushButton::disable {} {
-    if { $_enabled } {
-        set _enabled [expr !$_enabled]
-        $itk_component(button) configure -relief raise \
-            -image $disabledimage -bg grey85
-    }
-}
-
-itcl::body Rappture::PushButton::enable {} {
-    if { !$_enabled } {
-        set _enabled [expr !$_enabled]
-        _fixValue
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::PushButton::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-    if { $var != "" && [string is boolean $var] } {
-        set var [expr "$var == 1"]
-    }
-    if { $var == $onvalue } {
-        set _state 1
-        $itk_component(button) configure -relief sunken \
-            -image $onimage -bg $onbackground
-    } else {
-        set _state 0
-        $itk_component(button) configure -relief raise \
-            -image $offimage -bg $offbackground
-    }
-}
-
-itcl::body Rappture::PushButton::select {} {
-    if { !$_enabled } {
-        return
-    }
-    upvar #0 $_variable state
-    set state $onvalue
-}
-
-itcl::body Rappture::PushButton::deselect {} {
-    if { !$_enabled } {
-        return
-    }
-    upvar #0 $_variable state
-    set state $offvalue
-}
-
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::PushButton::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -width
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::PushButton::width {
-    $itk_component(button) configure -width $itk_option(-width)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -height
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::PushButton::height {
-    set _height $itk_option(-height)
-    $itk_component(button) configure -height $itk_option(-height)
-}
-
Index: trunk/gui/scripts/radiodial.tcl
===================================================================
--- trunk/gui/scripts/radiodial.tcl	(revision 6716)
+++ 	(revision )
@@ -1,836 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Radiodial - selector, like the dial on a car radio
-#
-#  This widget looks like the dial on an old-fashioned car radio.
-#  It draws a series of values along an axis, and allows a selector
-#  to move back and forth to select the values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *Radiodial.thickness 10 widgetDefault
-option add *Radiodial.length 2i widgetDefault
-option add *Radiodial.knobImage knob widgetDefault
-option add *Radiodial.knobPosition n@middle widgetDefault
-option add *Radiodial.dialOutlineColor black widgetDefault
-option add *Radiodial.dialFillColor white widgetDefault
-option add *Radiodial.lineColor gray widgetDefault
-option add *Radiodial.activeLineColor black widgetDefault
-option add *Radiodial.padding 0 widgetDefault
-option add *Radiodial.valueWidth 10 widgetDefault
-option add *Radiodial.valuePadding 0.1 widgetDefault
-option add *Radiodial.foreground black widgetDefault
-option add *Radiodial.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Radiodial {
-    inherit itk::Widget
-
-    itk_option define -min min Min ""
-    itk_option define -max max Max ""
-    itk_option define -variable variable Variable ""
-
-    itk_option define -thickness thickness Thickness 0
-    itk_option define -length length Length 0
-    itk_option define -padding padding Padding 0
-
-    itk_option define -foreground foreground Foreground "black"
-    itk_option define -dialoutlinecolor dialOutlineColor Color "black"
-    itk_option define -dialfillcolor dialFillColor Color "white"
-    itk_option define -dialprogresscolor dialProgressColor Color ""
-    itk_option define -linecolor lineColor Color "black"
-    itk_option define -activelinecolor activeLineColor Color "black"
-    itk_option define -knobimage knobImage KnobImage ""
-    itk_option define -knobposition knobPosition KnobPosition ""
-
-    itk_option define -font font Font ""
-    itk_option define -valuewidth valueWidth ValueWidth 0
-    itk_option define -valuepadding valuePadding ValuePadding 0
-
-    itk_option define -interactcommand interactCommand InteractCommand ""
-
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method add {label {value ""}}
-    public method clear {}
-    public method get {args}
-    public method current {args}
-    public method color {value}
-
-    protected method _setCurrent {val}
-    protected method _redraw {}
-    protected method _click {x y}
-    protected method _navigate {offset}
-    protected method _limits {}
-    protected method _findLabel {str}
-    protected method _fixSize {}
-    protected method _fixValue {args}
-    protected method _doInteract {}
-
-    private variable _values ""       ;# list of all values on the dial
-    private variable _val2label       ;# maps value => string label(s)
-    private variable _current ""      ;# current value (where pointer is)
-    private variable _variable ""     ;# variable associated with -variable
-
-    private variable _knob ""         ;# image for knob
-    private variable _spectrum ""     ;# width allocated for values
-    private variable _activecolor ""  ;# width allocated for values
-    private variable _vwidth 0        ;# width allocated for values
-}
-
-itk::usual Radiodial {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::constructor {args} {
-    itk_component add dial {
-        canvas $itk_interior.dial
-    }
-    pack $itk_component(dial) -expand yes -fill both
-    bind $itk_component(dial) <Configure> [itcl::code $this _redraw]
-
-    bind $itk_component(dial) <ButtonPress-1> [itcl::code $this _click %x %y]
-    bind $itk_component(dial) <B1-Motion> [itcl::code $this _click %x %y]
-    bind $itk_component(dial) <ButtonRelease-1> [itcl::code $this _click %x %y]
-
-    bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate -1]
-    bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate 1]
-
-    eval itk_initialize $args
-
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::destructor {} {
-    configure -variable ""  ;# remove variable trace
-    after cancel [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <label> ?<value>?
-#
-# Clients use this to add new values to the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::add {label {value ""}} {
-    if {"" == $value} {
-        set value [llength $_values]
-    }
-
-    # Add this value if we've never see it before
-    if {[lsearch -real $_values $value] < 0} {
-        lappend _values $value
-        set _values [lsort -real $_values]
-    }
-
-    # Keep all equivalent strings for this value.
-    # That way, we can later select either "1e18" or "1.0e+18"
-    lappend _val2label($value) $label
-
-    if {"" == $_current} {
-        _setCurrent $value
-    }
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: clear
-#
-# Clients use this to remove all existing values from the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::clear {} {
-    set _values ""
-    _setCurrent ""
-    catch {unset _val2label}
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-format what? ?current|@index?
-#
-# Clients use this to query values within this radiodial.  With no
-# args, it returns a list of all values stored in the widget.  The
-# "current" arg requests only the current value on the radiodial.
-# The @index syntax can be used to request a particular value at
-# an index within the list of values.
-#
-# By default, this method returns the label for each value.  The
-# format option can be used to request the label, the value, or
-# both.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::get {args} {
-    Rappture::getopts args params {
-        value -format "label"
-    }
-    if {[llength $args] > 1} {
-        error "wrong # args: should be \"get ?-format f? ?current|@index\""
-    }
-    set index [lindex $args 0]
-    if {"" == $index} {
-        set ilist ""
-        for {set i 0} {$i < [llength $_values]} {incr i} {
-            lappend ilist $i
-        }
-    } elseif {"current" == $index} {
-        set ilist [lsearch -exact $_values $_current]
-        if {$ilist < 0} {
-            set ilist ""
-        }
-    } elseif {[regexp {^@([0-9]+|end)$} $index match i]} {
-        set ilist $i
-    }
-    if {[llength $ilist] == 1} {
-        set op set
-    } else {
-        set op lappend
-    }
-
-    set rlist ""
-    foreach i $ilist {
-        switch -- $params(-format) {
-            label {
-                set v [lindex $_values $i]
-                $op rlist [lindex $_val2label($v) 0]
-            }
-            value {
-                $op rlist [lindex $_values $i]
-            }
-            position {
-                foreach {min max} [_limits] break
-                set v [lindex $_values $i]
-                set frac [expr {double($v-$min)/($max-$min)}]
-                $op rlist $frac
-            }
-            all {
-                set v [lindex $_values $i]
-                foreach {min max} [_limits] break
-                set frac [expr {double($v-$min)/($max-$min)}]
-                set l [lindex $_val2label($v) 0]
-                $op rlist [list $l $v $frac]
-            }
-            default {
-                error "bad value \"$v\": should be label, value, position, all"
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current ?<newval>?
-#
-# Clients use this to get/set the current value for this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::current {args} {
-    if {[llength $args] == 0} {
-        return $_current
-    } elseif {[llength $args] == 1} {
-        set newval [lindex $args 0]
-        set n [_findLabel $newval]
-
-        # Don't use expr (?:) because it evaluates the resulting string.
-        # For example, it changes -0.020 to -0.02.
-        if { $n >= 0 } {
-            set rawval [lindex $_values $n]
-        } else {
-            set rawval ""
-        }
-        _setCurrent $rawval
-
-        after cancel [itcl::code $this _redraw]
-        after idle [itcl::code $this _redraw]
-        event generate $itk_component(hull) <<Value>>
-
-        return $_current
-    }
-    error "wrong # args: should be \"current ?newval?\""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: color <value>
-#
-# Clients use this to query the color associated with a <value>
-# along the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::color {value} {
-    _findLabel $value  ;# make sure this label is recognized
-
-    if {"" != $_spectrum} {
-        foreach {min max} [_limits] break
-        set frac [expr {double($value-$min)/($max-$min)}]
-        set color [$_spectrum get $frac]
-    } else {
-        if {$value == $_current} {
-            set color $_activecolor
-        } else {
-            set color $itk_option(-linecolor)
-        }
-    }
-    return $color
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _setCurrent <value>
-#
-# Called automatically whenever the widget changes size to redraw
-# all elements within it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_setCurrent {value} {
-    set _current $value
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        if {[info exists _val2label($value)]} {
-            set var [lindex $_val2label($value) 0]
-        } else {
-            set var $value
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Called automatically whenever the widget changes size to redraw
-# all elements within it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_redraw {} {
-    set c $itk_component(dial)
-    $c delete all
-
-    set fg $itk_option(-foreground)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set p [winfo pixels $c $itk_option(-padding)]
-    set t [expr {$itk_option(-thickness)+1}]
-    set y1 [expr {$h-1}]
-
-    if {"" != $_knob} {
-        set kw [image width $_knob]
-        set kh [image height $_knob]
-
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top {
-                set extra [expr {$t-$kh}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-            n@middle - nw@middle - ne@middle {
-                set extra [expr {int(ceil($kh-0.5*$t))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-            n@bottom - nw@bottom - ne@bottom {
-                set y1 [expr {$h-$kh-1}]
-            }
-
-            e@top - w@top - center@top -
-            e@bottom - w@bottom - center@bottom {
-                set extra [expr {int(ceil(0.5*$kh))}]
-                set y1 [expr {$h-$extra-1}]
-            }
-            e@middle - w@middle - center@middle {
-                set extra [expr {int(ceil(0.5*($kh-$t)))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-
-            s@top - sw@top - se@top -
-            s@middle - sw@middle - se@middle -
-            s@bottom - sw@bottom - se@bottom {
-                set y1 [expr {$h-2}]
-            }
-        }
-    }
-    set y0 [expr {$y1-$t}]
-    set x0 [expr {$p+1}]
-    set x1 [expr {$w-$_vwidth-$p-4}]
-    foreach {min max} [_limits] break
-
-    # draw the background rectangle
-    $c create rectangle $x0 $y0 $x1 $y1 \
-        -outline $itk_option(-dialoutlinecolor) \
-        -fill $itk_option(-dialfillcolor)
-
-    # draw the optional progress bar, from start to current
-    if {"" != $itk_option(-dialprogresscolor)
-          && [llength $_values] > 0 && "" != $_current} {
-        if {$max != $min} {
-            set frac [expr {double($_current-$min)/($max-$min)}]
-        } else {
-            set frac 0.
-        }
-        set xx1 [expr {$frac*($x1-$x0) + $x0}]
-        $c create rectangle [expr {$x0+1}] [expr {$y0+3}] $xx1 [expr {$y1-2}] \
-            -outline "" -fill $itk_option(-dialprogresscolor)
-    }
-
-    # draw lines for all values
-    if {$max > $min} {
-        foreach v $_values {
-            set frac [expr {double($v-$min)/($max-$min)}]
-            if {"" != $_spectrum} {
-                set color [$_spectrum get $frac]
-            } else {
-                if {$v == $_current} {
-                    set color $_activecolor
-                } else {
-                    set color $itk_option(-linecolor)
-                }
-            }
-            set thick [expr {($v == $_current) ? 3 : 1}]
-
-            if {"" != $color} {
-                set x [expr {$frac*($x1-$x0) + $x0}]
-                $c create line $x [expr {$y0+1}] $x $y1 \
-                    -fill $color -width $thick
-            }
-        }
-
-        if {"" != $_current} {
-            set x [expr {double($_current-$min)/($max-$min)*($x1-$x0) + $x0}]
-            regexp {([nsew]+|center)@} $itk_option(-knobposition) match anchor
-            switch -glob -- $itk_option(-knobposition) {
-                *@top    { set kpos $y0 }
-                *@middle { set kpos [expr {int(ceil(0.5*($y1+$y0)))}] }
-                *@bottom { set kpos $y1 }
-            }
-            $c create image $x $kpos -anchor $anchor -image $_knob
-        }
-    }
-
-    # if the -valuewidth is > 0, then make room for the value
-    set vw $itk_option(-valuewidth)
-    if {$vw > 0 && "" != $_current} {
-        set str [lindex $_val2label($_current) 0]
-        if {[string length $str] >= $vw} {
-            set str "[string range $str 0 [expr {$vw-3}]]..."
-        }
-
-        set dy [expr {([font metrics $itk_option(-font) -linespace]
-                        - [font metrics $itk_option(-font) -ascent])/2}]
-
-        set id [$c create text [expr {$x1+4}] [expr {($y1+$y0)/2+$dy}] \
-            -anchor w -text $str -font $itk_option(-font) -foreground $fg]
-        foreach {x0 y0 x1 y1} [$c bbox $id] break
-        set x0 [expr {$x0 + 10}]
-
-        # set up a tooltip so you can mouse over truncated values
-        Rappture::Tooltip::text $c [lindex $_val2label($_current) 0]
-        $c bind $id <Enter> \
-            [list ::Rappture::Tooltip::tooltip pending %W +$x0,$y1]
-        $c bind $id <Leave> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-        $c bind $id <ButtonPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-        $c bind $id <KeyPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _click <x> <y>
-#
-# Called automatically whenever the user clicks or drags on the widget
-# to select a value.  Moves the current value to the one nearest the
-# click point.  If the value actually changes, it generates a <<Value>>
-# event to notify clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_click {x y} {
-    set c $itk_component(dial)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set x0 1
-    set x1 [expr {$w-$_vwidth-4}]
-
-    focus $itk_component(hull)
-
-    # draw lines for all values
-    foreach {min max} [_limits] break
-    if {$max > $min && $x >= $x0 && $x <= $x1} {
-        set dmin $w
-        set xnearest 0
-        set vnearest ""
-        foreach v $_values {
-            set xv [expr {double($v-$min)/($max-$min)*($x1-$x0) + $x0}]
-            if {abs($xv-$x) < $dmin} {
-                set dmin [expr {abs($xv-$x)}]
-                set xnearest $xv
-                set vnearest $v
-            }
-        }
-
-        if {$vnearest != $_current} {
-            _setCurrent $vnearest
-            _redraw
-
-            event generate $itk_component(hull) <<Value>>
-            _doInteract
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_navigate {offset} {
-    set index [lsearch -exact $_values $_current]
-    if {$index >= 0} {
-        incr index $offset
-        if {$index >= [llength $_values]} {
-            set index [expr {[llength $_values]-1}]
-        } elseif {$index < 0} {
-            set index 0
-        }
-
-        set newval [lindex $_values $index]
-        if {$newval != $_current} {
-            _setCurrent $newval
-            _redraw
-
-            event generate $itk_component(hull) <<Value>>
-            _doInteract
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _limits
-#
-# Used internally to compute the overall min/max limits for the
-# radio dial.  Returns {min max}, representing the end values for
-# the scale.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_limits {} {
-    if {[llength $_values] == 0} {
-        set min 0
-        set max 0
-    } else {
-        set min [lindex $_values 0]
-        set max $min
-        foreach v [lrange $_values 1 end] {
-            if {$v < $min} { set min $v }
-            if {$v > $max} { set max $v }
-        }
-        set del [expr {$max-$min}]
-        set min [expr {$min-$itk_option(-valuepadding)*$del}]
-        set max [expr {$max+$itk_option(-valuepadding)*$del}]
-    }
-
-    if {"" != $itk_option(-min)} {
-        set min $itk_option(-min)
-    }
-    if {"" != $itk_option(-max)} {
-        set max $itk_option(-max)
-    }
-    return [list $min $max]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _findLabel <string>
-#
-# Used internally to search for the given <string> label among the
-# known values.  Returns an index into the _values list, or throws
-# an error if the string is not recognized.  Given the null string,
-# it returns -1, indicating that the value is not in _values, but
-# it is valid.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_findLabel {str} {
-    if {"" == $str} {
-        return -1
-    }
-    for {set nv 0} {$nv < [llength $_values]} {incr nv} {
-        set v [lindex $_values $nv]
-        if {[lsearch -exact $_val2label($v) $str] >= 0} {
-            return $nv
-        }
-    }
-
-    # didn't match -- build a return string of possible values
-    set labels ""
-    foreach vlist $_values {
-        foreach v $vlist {
-            lappend labels "\"$_val2label($v)\""
-        }
-    }
-    error "bad value \"$str\": should be one of [join $labels ,]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Used internally to compute the overall size of the widget based
-# on the -thickness and -length options.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_fixSize {} {
-    set h [winfo pixels $itk_component(hull) $itk_option(-thickness)]
-
-    if {"" != $_knob} {
-        set kh [image height $_knob]
-
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top -
-            s@bottom - sw@bottom - se@bottom {
-                if {$kh > $h} { set h $kh }
-            }
-            n@middle - nw@middle - ne@middle -
-            s@middle - sw@middle - se@middle {
-                set h [expr {int(ceil(0.5*$h + $kh))}]
-            }
-            n@bottom - nw@bottom - ne@bottom -
-            s@top - sw@top - se@top {
-                set h [expr {$h + $kh}]
-            }
-            e@middle - w@middle - center@middle {
-                set h [expr {(($h > $kh) ? $h : $kh) + 1}]
-            }
-            n@middle - ne@middle - nw@middle -
-            s@middle - se@middle - sw@middle {
-                set extra [expr {int(ceil($kh-0.5*$h))}]
-                if {$extra < 0} { set extra 0 }
-                set h [expr {$h+$extra}]
-            }
-        }
-    }
-    incr h 1
-
-    set w [winfo pixels $itk_component(hull) $itk_option(-length)]
-
-    # if the -valuewidth is > 0, then make room for the value
-    if {$itk_option(-valuewidth) > 0} {
-        set charw [font measure $itk_option(-font) "n"]
-        set _vwidth [expr {$itk_option(-valuewidth)*$charw}]
-        set w [expr {$w+$_vwidth+4}]
-    } else {
-        set _vwidth 0
-    }
-
-    $itk_component(dial) configure -width $w -height $h
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-
-    set newval $var
-    set n [_findLabel $newval]
-    set rawval [expr {($n >= 0) ? [lindex $_values $n] : ""}]
-    set _current $rawval  ;# set current directly, so we don't trigger again
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _doInteract
-#
-# Used internally to call the -interactcommand code whenever the user
-# changes the value of the widget.  This is different from the <<Value>>
-# event, which gets invoked whenever the value changes for any reason,
-# including programmatic changes.  If there is no command code, then
-# this does nothing.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Radiodial::_doInteract {} {
-    if {[string length $itk_option(-interactcommand)] > 0} {
-        uplevel #0 $itk_option(-interactcommand)
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -thickness
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::thickness {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -length
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::length {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -font
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::font {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuewidth
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::valuewidth {
-    if {![string is integer $itk_option(-valuewidth)]} {
-        error "bad value \"$itk_option(-valuewidth)\": should be integer"
-    }
-    _fixSize
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -foreground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::foreground {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialoutlinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::dialoutlinecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialfillcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::dialfillcolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialprogresscolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::dialprogresscolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -linecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::linecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -activelinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::activelinecolor {
-    set val $itk_option(-activelinecolor)
-    if {[catch {$val isa ::Rappture::Spectrum} valid] == 0 && $valid} {
-        set _spectrum $val
-        set _activecolor ""
-    } elseif {[catch {winfo rgb $itk_component(hull) $val}] == 0} {
-        set _spectrum ""
-        set _activecolor $val
-    } elseif {"" != $val} {
-        error "bad value \"$val\": should be Spectrum object or color"
-    }
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobimage
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::knobimage {
-    if {[regexp {^image[0-9]+$} $itk_option(-knobimage)]} {
-        set _knob $itk_option(-knobimage)
-    } elseif {"" != $itk_option(-knobimage)} {
-        set _knob [Rappture::icon $itk_option(-knobimage)]
-    } else {
-        set _knob ""
-    }
-    _fixSize
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobposition
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::knobposition {
-    if {![regexp {^([nsew]+|center)@(top|middle|bottom)$} $itk_option(-knobposition)]} {
-        error "bad value \"$itk_option(-knobposition)\": should be anchor@top|middle|bottom"
-    }
-    _fixSize
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -padding
-# This adds padding on left/right side of dial background.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::padding {
-    if {[catch {winfo pixels $itk_component(hull) $itk_option(-padding)}]} {
-        error "bad value \"$itk_option(-padding)\": should be size in pixels"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuepadding
-# This shifts min/max limits in by a fraction of the overall size.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::valuepadding {
-    if {![string is double $itk_option(-valuepadding)]
-          || $itk_option(-valuepadding) < 0} {
-        error "bad value \"$itk_option(-valuepadding)\": should be >= 0.0"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Radiodial::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
Index: trunk/gui/scripts/response.tcl
===================================================================
--- trunk/gui/scripts/response.tcl	(revision 6716)
+++ 	(revision )
@@ -1,94 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-
-# ----------------------------------------------------------------------
-#  COMPONENT: response - extracts data from an XML description of a
-#  response surface (surrogate model).  Makes it available to the
-#  responseviewer.
-#
-# ======================================================================
-#  AUTHOR:  Martin Hunt, Purdue University
-#  Copyright (c) 2015  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture {
-    # forward declaration
-}
-
-itcl::class Rappture::Response {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method get {}
-    public method variables {}
-    public method label {}
-    public method vlabels {}
-    public method response {}
-    public method rmse {}
-
-    private variable _xmlobj "";      # ref to lib obj
-    private variable _response "";
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Response::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be LibraryObj"
-    }
-    set _xmlobj $xmlobj
-    set _response [$xmlobj element -as object $path]
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Response::destructor {} {
-    # itcl::delete object $_response
-    set _response ""
-}
-
-itcl::body Rappture::Response::variables {} {
-    return [$_response get variables]
-}
-
-itcl::body Rappture::Response::rmse {} {
-    return [$_response get rmse]
-}
-
-itcl::body Rappture::Response::response {} {
-    return [$_response get value]
-}
-
-# Get the response surface label
-itcl::body Rappture::Response::label {} {
-    set lab [$_response get about.label]
-    if {[regexp {([^\(]*)\(([^\)]+)\)} $lab match lab uq_part]} {
-        set lab [string trim $lab]
-    }
-    return $lab
-}
-
-# Get the input variable labels
-itcl::body Rappture::Response::vlabels {} {
-    return [$_response get labels]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of xml objects being plotted.
-# Currently limited to one.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Response::get {} {
-    return $_response
-}
Index: trunk/gui/scripts/responseviewer.tcl
===================================================================
--- trunk/gui/scripts/responseviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,203 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: ResponseViewer - Response Surface (surogate Model) Viewer
-#
-# Gets response data from PUQ and displayes it using vtk.
-# ======================================================================
-#  Copyright (c) 2004-2014  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *ResponseViewer.width 4i widgetDefault
-option add *ResponseViewer*cursor crosshair widgetDefault
-option add *ResponseViewer.height 4i widgetDefault
-option add *ResponseViewer.foreground black widgetDefault
-option add *ResponseViewer.controlBackground gray widgetDefault
-option add *ResponseViewer.controlDarkBackground #999999 widgetDefault
-option add *ResponseViewer.plotBackground black widgetDefault
-option add *ResponseViewer.plotForeground white widgetDefault
-option add *ResponseViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-
-itcl::class Rappture::ResponseViewer {
-    inherit itk::Widget
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method add {dataobj {settings ""}}
-    public method delete {args}
-    public method download {option args}
-
-    private variable _response
-    private variable _settings
-    private variable _label
-    private variable _dobj ""
-    private method _combobox_cb {}
-    private method _plot_response {var1 var2}
-}
-
-itk::usual ResponseViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResponseViewer::constructor {args} {
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) yes
-
-    itk_component add frame {
-        frame $itk_interior.frame
-    }
-
-    itk_component add frame2 {
-        frame $itk_interior.frame2
-    }
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResponseViewer::destructor {} {
-
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a dataobj to the plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResponseViewer::add {uqobj {settings ""}} {
-    #puts "ResponseViewer ADD $uqobj ($settings)"
-    set _response [$uqobj response]
-    set vars [$uqobj variables]
-    set labs [$uqobj vlabels]
-    set _settings $settings
-    set _label [$uqobj label]
-
-    if {[llength $vars] > 1} {
-        set cb1 [Rappture::Combobox $itk_interior.frame2.cb1 -width 10 -editable no]
-        set cb2 [Rappture::Combobox $itk_interior.frame2.cb2 -width 10 -editable no]
-
-        foreach v $vars l $labs {
-            $cb1 choices insert end $v $l
-            $cb2 choices insert end $v $l
-        }
-        $cb1 value [$cb1 label [lindex $vars 0]]
-        $cb2 value [$cb2 label [lindex $vars 1]]
-        bind $cb1 <<Value>> [itcl::code $this _combobox_cb]
-        bind $cb2 <<Value>> [itcl::code $this _combobox_cb]
-
-        set vs [label $itk_interior.frame2.desc -text "vs"]
-        grid $cb1 $vs $cb2
-    } else {
-        set label [lindex $labs 0]
-        set lab [label $itk_interior.frame2.desc -text "Response for $label"]
-        grid $lab
-    }
-
-    set rmsep [$uqobj rmse]
-    if {$rmsep > 10} {
-        set color red
-    } elseif {$rmsep > 5} {
-        set color orange
-    } elseif {$rmsep > 2} {
-        set color yellow
-    } else {
-        set color black
-    }
-    set rmse [label $itk_interior.frame2.rmse -text "RMSE: $rmsep%" -foreground $color]
-
-    grid $rmse -row 0 -column 4 -sticky e
-    grid $itk_component(frame) -row 0 -column 0 -sticky nsew
-    grid $itk_component(frame2) -row 1 -column 0 -sticky nsew
-    grid columnconfigure $itk_component(frame) 0 -weight 1
-    grid columnconfigure $itk_component(frame2) 3 -weight 1
-    grid rowconfigure $itk_component(frame) 0 -weight 1
-    grid columnconfigure $itk_component(hull) 0 -weight 1
-    grid rowconfigure $itk_component(hull) 0 -weight 1
-
-    if {[llength $vars] > 1} {
-        _combobox_cb
-    } else {
-        if {$_dobj != ""} {
-            destroy $itk_component(frame).field
-            destroy _dobj
-            set _dobj ""
-        }
-        set vname [lindex $vars 0]
-        after idle [itcl::code $this _plot_response $vname $vname]
-    }
-}
-
-itcl::body Rappture::ResponseViewer::_plot_response {var1 var2} {
-    #puts stderr "plotting $var1 vs $var2"
-    global rapptureInfo 
-    set fname [file join $rapptureInfo(cwd) "response_result.xml"]
-    if { [catch {
-        exec puq.sh get_response $fname $_response $var1 $var2 $_label
-    } res] != 0 } {
-        set fp [open "response.err" r]
-        set rdata [read $fp]
-        close $fp
-        puts stderr "Surrogate Model failed: $res\n$rdata"
-        error "Sampling of Surrogate Model failed: $res\n$rdata"
-        # FIXME: Maybe put in text box instead of error()?
-        return
-    }
-
-    set xmlobj [Rappture::library $fname]
-    #puts stderr "xmlobj=$xmlobj"
-    set w $itk_component(frame).field
-
-    if {$var1 == $var2} {
-        set path "output.curve(scatter)"
-        set _dobj [Rappture::Curve ::#auto $xmlobj $path]
-        Rappture::XyResult $w
-        $w add $_dobj {-color red}
-
-        set path "output.curve(response)"
-        set _dobj [Rappture::Curve ::#auto $xmlobj $path]
-
-    } else {
-        set path "output.field(f2d)"
-        set _dobj [Rappture::Field ::#auto $xmlobj $path]
-        Rappture::FieldResult $w -mode heightmap
-    }
-    $w add $_dobj $_settings
-    $w scale $_dobj
-    #puts "added _dobj"
-    #puts "w=$w"
-    pack $w -expand yes -fill both
-}
-
-itcl::body Rappture::ResponseViewer::_combobox_cb {} {
-    if {$_dobj != ""} {
-        destroy $itk_component(frame).field
-        destroy _dobj
-        set _dobj ""
-    }
-    set var1 [$itk_component(frame2).cb1 current]
-    set var2 [$itk_component(frame2).cb2 current]
-    _plot_response $var1 $var2
-}
-
-
-itcl::body Rappture::ResponseViewer::download {option args} {
-    $itk_component(frame).field download $option $args
-}
Index: trunk/gui/scripts/resultselector.tcl
===================================================================
--- trunk/gui/scripts/resultselector.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1358 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: ResultSelector - controls for a ResultSet
-#
-#  This widget displays a collection of results stored in a ResultSet
-#  object.  It manages the controls to select and visualize the data.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *ResultSelector.width 4i widgetDefault
-option add *ResultSelector.height 4i widgetDefault
-option add *ResultSelector.missingData skip widgetDefault
-option add *ResultSelector.controlbarBackground gray widgetDefault
-option add *ResultSelector.controlbarForeground white widgetDefault
-option add *ResultSelector.activeControlBackground #ffffcc widgetDefault
-option add *ResultSelector.activeControlForeground black widgetDefault
-option add *ResultSelector.controlActiveForeground blue widgetDefault
-option add *ResultSelector.toggleBackground gray widgetDefault
-option add *ResultSelector.toggleForeground white widgetDefault
-option add *ResultSelector.textFont \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-option add *ResultSelector.boldFont \
-    -*-helvetica-bold-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::ResultSelector {
-    inherit itk::Widget
-
-    itk_option define -resultset resultSet ResultSet ""
-    itk_option define -activecontrolbackground activeControlBackground Background ""
-    itk_option define -activecontrolforeground activeControlForeground Foreground ""
-    itk_option define -controlactiveforeground controlActiveForeground Foreground ""
-    itk_option define -togglebackground toggleBackground Background ""
-    itk_option define -toggleforeground toggleForeground Foreground ""
-    itk_option define -textfont textFont Font ""
-    itk_option define -boldfont boldFont Font ""
-    itk_option define -foreground foreground Foreground ""
-    itk_option define -settingscommand settingsCommand SettingsCommand ""
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method activate {column}
-    public method size {{what -results}}
-
-    protected method _doClear {what}
-    protected method _doSettings {{cmd ""}}
-    protected method _control {option args}
-    protected method _fixControls {args}
-    protected method _fixLayout {args}
-    protected method _fixNumResults {}
-    protected method _fixSettings {args}
-    protected method _fixValue {column why}
-    protected method _drawValue {column widget wmax}
-    protected method _toggleAll {{column "current"}}
-    protected method _getValues {column {which "all"}}
-    protected method _getTooltip {role column}
-    protected method _getParamDesc {which {index "current"}}
-    protected method _log {col}
-
-    private variable _dispatcher ""  ;# dispatchers for !events
-    private variable _resultset ""   ;# object containing results
-    private variable _active ""      ;# name of active control
-    private variable _plotall 0      ;# non-zero => plot all active results
-    private variable _layout         ;# info used in _fixLayout
-    private variable _counter 0      ;# counter for unique control names
-    private variable _settings 0     ;# non-zero => _fixSettings in progress
-
-    private common _cntlInfo         ;# maps column name => control info
-}
-
-itk::usual ResultSelector {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::constructor {args} {
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    # create a dispatcher for events
-    Rappture::dispatcher _dispatcher
-
-    $_dispatcher register !layout
-    $_dispatcher dispatch $this !layout \
-        [itcl::code $this _fixLayout]
-
-    $_dispatcher register !settings
-    $_dispatcher dispatch $this !settings \
-        [itcl::code $this _fixSettings]
-
-    # initialize controls info
-    set _cntlInfo($this-all) ""
-
-    # initialize layout info
-    set _layout(mode) "usual"
-    set _layout(active) ""
-    set _layout(numcntls) 0
-
-    itk_component add cntls {
-        frame $itk_interior.cntls
-    } {
-        usual
-        rename -background -controlbarbackground controlbarBackground Background
-        rename -highlightbackground -controlbarbackground controlbarBackground Background
-    }
-    pack $itk_component(cntls) -fill x -pady {0 2}
-
-    itk_component add clearall {
-        button $itk_component(cntls).clearall -text "Clear" -state disabled \
-            -padx 1 -pady 1 \
-            -relief flat -overrelief raised \
-            -command [itcl::code $this _doClear all]
-    } {
-        usual
-        rename -background -controlbarbackground controlbarBackground Background
-        rename -foreground -controlbarforeground controlbarForeground Foreground
-        rename -highlightbackground -controlbarbackground controlbarBackground Background
-    }
-    pack $itk_component(clearall) -side right -padx 2 -pady 1
-    Rappture::Tooltip::for $itk_component(clearall) \
-        "Clears all results collected so far."
-
-    itk_component add clear {
-        button $itk_component(cntls).clear -text "Clear One" -state disabled \
-            -padx 1 -pady 1 \
-            -relief flat -overrelief raised \
-            -command [itcl::code $this _doClear current]
-    } {
-        usual
-        rename -background -controlbarbackground controlbarBackground Background
-        rename -foreground -controlbarforeground controlbarForeground Foreground
-        rename -highlightbackground -controlbarbackground controlbarBackground Background
-    }
-    pack $itk_component(clear) -side right -padx 2 -pady 1
-    Rappture::Tooltip::for $itk_component(clear) \
-        "Clears the result that is currently selected."
-
-    itk_component add status {
-        label $itk_component(cntls).status -anchor w \
-            -text "No results" -padx 0 -pady 0
-    } {
-        usual
-        rename -background -controlbarbackground controlbarBackground Background
-        rename -foreground -controlbarforeground controlbarForeground Foreground
-        rename -highlightbackground -controlbarbackground controlbarBackground Background
-    }
-    pack $itk_component(status) -side left -padx 2 -pady {2 0}
-
-    itk_component add dials {
-        frame $itk_interior.dials
-    }
-    pack $itk_component(dials) -expand yes -fill both
-    bind $itk_component(dials) <Configure> \
-        [list $_dispatcher event -after 10 !layout why resize]
-
-    # create the permanent controls in the "short list" area
-    set dials $itk_component(dials)
-    frame $dials.bg
-    Rappture::Radiodial $dials.dial -valuewidth 0
-    Rappture::Tooltip::for $dials.dial \
-        "@[itcl::code $this _getTooltip dial active]"
-
-    set fn [option get $itk_component(hull) textFont Font]
-    label $dials.all -text "All" -padx 8 \
-        -borderwidth 1 -relief raised -font $fn
-    Rappture::Tooltip::for $dials.all \
-        "@[itcl::code $this _getTooltip all active]"
-    bind $dials.all <ButtonRelease> [itcl::code $this _toggleAll]
-
-    frame $dials.labelmore
-    label $dials.labelmore.arrow -bitmap [Rappture::icon empty] -borderwidth 0
-    pack $dials.labelmore.arrow -side left -fill y
-    label $dials.labelmore.name -text "more parameters..." -font $fn \
-        -borderwidth 0 -padx 0 -pady 1
-    pack $dials.labelmore.name -side left
-    label $dials.labelmore.value
-    pack $dials.labelmore.value -side left
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::destructor {} {
-    # disconnect any existing resultset to stop notifications
-    configure -resultset ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: activate <column>
-#
-# Clients use this to activate a particular column in the set of
-# controls.  When a column is active, its label is bold and its
-# value has a radiodial in the "short list" area.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::activate {column} {
-    if {$_resultset ne ""} {
-        set allowed [$_resultset diff names]
-        if {[lsearch $allowed $column] < 0} {
-            error "bad value \"$column\": should be one of [join $allowed {, }]"
-        }
-
-        # column is now active
-        set _active $column
-
-        # keep track of usage, so we know which controls are popular
-        incr _cntlInfo($this-$column-usage)
-
-        # fix controls at next idle point
-        $_dispatcher event -idle !layout why data
-        $_dispatcher event -idle !settings column $_active
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: size ?-results|-controls|-controlarea?
-#
-# Returns various measures for the size of this area:
-#   -results ....... number of results loaded
-#   -controls ...... number of distinct control parameters
-#   -controlarea ... minimum size of usable control area, in pixels
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::size {{what -results}} {
-    switch -- $what {
-        -results {
-            if {$_resultset eq ""} {
-                return 0
-            }
-            return [$_resultset size]
-        }
-        -controls {
-            return [expr {[llength [$_resultset diff names]]-1}]
-        }
-        -controlarea {
-            set ht [winfo reqheight $itk_component(cntls)]
-            incr ht 2  ;# padding below controls
-
-            set normalLine [font metrics $itk_option(-textfont) -linespace]
-            incr normalLine 2  ;# padding
-            set boldLine [font metrics $itk_option(-boldfont) -linespace]
-            incr boldLine 2  ;# padding
-
-            set numcntls [expr {[llength [$_resultset diff names]]-1}]
-            switch -- $numcntls {
-                0 - 1 {
-                    # 0 = no controls (no data at all)
-                    # 1 = run control, but only 1 run so far
-                    # add nothing
-                }
-                default {
-                    # non-active controls
-                    incr ht [expr {($numcntls-1)*$normalLine}]
-                    # active control
-                    incr ht $boldLine
-                    # dial for active control
-                    incr ht [winfo reqheight $itk_component(dials).dial]
-                    # padding around active control
-                    incr ht 4
-                }
-            }
-            return $ht
-        }
-        default {
-            error "bad option \"$what\": should be -results, -controls, or -controlarea"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _doClear all|current
-#
-# Invoked automatically when the user presses the "Clear One" or
-# "Clear All" buttons.  Clears results from the ResultSet and then
-# waits for an event to react to the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_doClear {what} {
-    if {$_resultset ne ""} {
-        switch -- $what {
-            current {
-                set simnum $_cntlInfo($this-simnum-value)
-                foreach xmlobj [$_resultset find simnum $simnum] {
-                    $_resultset clear $xmlobj
-                }
-                Rappture::Logger::log result -clear one
-            }
-            all {
-                $_resultset clear
-                Rappture::Logger::log result -clear all
-            }
-            default { error "bad option \"$what\": should be current or all" }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _doSettings ?<command>?
-#
-# Used internally whenever the result selection changes to invoke
-# the -settingscommand.  This will notify some external widget, which
-# with perform the plotting action specified in the <command>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_doSettings {{cmd ""}} {
-    if {[string length $itk_option(-settingscommand)] > 0} {
-        uplevel #0 $itk_option(-settingscommand) $cmd
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _control bind <widget> <column>
-# USAGE: _control hilite <state> <column> <panel>
-# USAGE: _control load <widget> <column>
-#
-# Used internally to manage the interactivity of controls.  The "bind"
-# operation sets up bindings on the label/value for each control, so
-# you can mouse over and click on a control to activate it.  The
-# "hilite" operation controls highlighting of the control.  The "load"
-# operation loads data into the specified radiodial <widget>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_control {option args} {
-    switch -- $option {
-        bind {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be _control bind widget column"
-            }
-            set widget [lindex $args 0]
-            set col [lindex $args 1]
-
-            set panel [winfo parent $widget]
-            if {[string match label* [winfo name $panel]]} {
-                set panel [winfo parent $panel]
-            }
-
-            bind $widget <Enter> \
-                [itcl::code $this _control hilite on $col $panel]
-            bind $widget <Leave> \
-                [itcl::code $this _control hilite off $col $panel]
-            bind $widget <ButtonRelease> "
-                [itcl::code $this activate $col]
-                [list Rappture::Logger::log result -active $col]
-            "
-        }
-        hilite {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be _control hilite state column panel"
-            }
-            if {$_layout(mode) != "usual"} {
-                # abbreviated controls? then skip highlighting
-                return
-            }
-            set state [lindex $args 0]
-            set col [lindex $args 1]
-            set panel [lindex $args 2]
-
-            if {[string index $col 0] == "@"} {
-                # handle artificial names like "@more"
-                set id [string range $col 1 end]
-            } else {
-                # get id for ordinary columns
-                set id $_cntlInfo($this-$col-id)
-            }
-
-            # highlight any non-active entries
-            if {$col != $_active} {
-                if {$state} {
-                    set fg $itk_option(-controlactiveforeground)
-                    $panel.label$id.name configure -fg $fg
-                    $panel.label$id.value configure -fg $fg
-                    $panel.label$id.arrow configure -fg $fg \
-                        -bitmap [Rappture::icon rarrow2]
-                } else {
-                    set fg $itk_option(-foreground)
-                    $panel.label$id.name configure -fg $fg
-                    $panel.label$id.value configure -fg $fg
-                    $panel.label$id.arrow configure -fg $fg \
-                        -bitmap [Rappture::icon empty]
-                }
-            }
-        }
-        load {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be _control load widget column"
-            }
-            set dial [lindex $args 0]
-            set col [lindex $args 1]
-
-            set shortlist $itk_component(dials)
-            $shortlist.dial configure -variable ""
-            $dial clear
-            foreach {label val} [_getValues $col all] {
-                $dial add $label $val
-            }
-            $shortlist.dial configure -variable \
-                "::Rappture::ResultSelector::_cntlInfo($this-$col-value)" \
-                -interactcommand [itcl::code $this _log $col]
-        }
-        default {
-            error "bad option \"$option\": should be bind, hilite, or load"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixControls ?<eventArgs...>?
-#
-# Called automatically at the idle point after one or more results
-# have been added to this result set.  Scans through all existing
-# data and updates controls used to select the data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_fixControls {args} {
-    array set eventData $args
-    if {![info exists itk_component(dials)]} {
-        # no controls? then nothing to fix
-        # this happens when the widget is being destroyed
-        return
-    }
-    set shortlist $itk_component(dials)
-
-    # added or cleared something -- update number of results
-    _fixNumResults
-
-    if {$_resultset eq ""} {
-        return
-    }
-
-    # cleared something?
-    if {$eventData(op) eq "clear"} {
-        if {[$_resultset size] == 0} {
-            # cleared everything? then reset controls to initial state
-            array unset _cntlInfo $this-*
-            set _cntlInfo($this-all) ""
-            set _active ""
-            set _plotall 0
-            $itk_component(dials).all configure -relief raised \
-                -background $itk_option(-background) \
-                -foreground $itk_option(-foreground)
-
-            # clean up all of the label/value widgets
-            foreach w [winfo children $itk_component(dials)] {
-                if {[string match {label[0-9]*} [winfo name $w]]} {
-                    destroy $w
-                }
-            }
-            set _counter 0
-
-            $_dispatcher event -idle !layout why data
-
-            return
-        }
-
-        # cleared a single value? then move to another one
-        array set params $eventData(what)
-
-        # clear any currently highlighted result
-        _doSettings
-
-        # did the active control go away?  then switch to simnum
-        if {[lsearch -exact [$_resultset diff names] $_active] < 0} {
-            set _cntlInfo($this-$_active-value) ""
-            activate simnum
-        }
-
-        # figure out where we were in the active control, and
-        # what value we should display now that this was deleted
-        if {[info exists params($_active)]} {
-            set current $params($_active)
-            if {$current eq [$shortlist.dial get -format label current]} {
-                # result deleted is the current result
-                set vlist [$shortlist.dial get]
-                set i [lsearch -exact $vlist $current]
-                if {$i >= 0} {
-                    if {$i+1 < [llength $vlist]} {
-                        set newControlValue [lindex $vlist [expr {$i+1}]]
-                    } elseif {$i-1 >= 0} {
-                        set newControlValue [lindex $vlist [expr {$i-1}]]
-                    }
-                }
-            }
-        }
-
-        if {[info exists newControlValue]} {
-            # Set the control to a value we were able to find.
-            # Disconnect the current variable, then plug in the
-            # new (legal) value, then reload the controls.
-            # This will trigger !settings and other adjustments.
-            $shortlist.dial configure -variable ""
-            set _cntlInfo($this-$_active-value) $newControlValue
-            _control load $shortlist.dial $_active
-        } else {
-            # if all else fails, show solution #1
-            set xmlobj0 [lindex [$_resultset find * *] 0]
-            set simnum0 [$_resultset get simnum $xmlobj0]
-            set _cntlInfo($this-simnum-value) $simnum0
-            activate simnum
-        }
-
-        # if clearing this dataset changed the controls, then
-        # fix the layout
-        set numcntls [expr {[llength [$_resultset diff names]]-1}]
-        if {$numcntls != $_layout(numcntls)} {
-            $_dispatcher event -idle !layout why data
-        }
-        return
-    }
-
-    # must have added something...
-    set shortlist $itk_component(dials)
-    grid columnconfigure $shortlist 1 -weight 1
-
-    #
-    # Scan through all columns in the data and create any
-    # controls that just appeared.
-    #
-    set nadded 0
-    foreach col [$_resultset diff names] {
-        if {$col eq "xmlobj"} {
-            continue  ;# never create a control for this column
-        }
-
-        #
-        # If this column doesn't have a control yet, then
-        # create one.
-        #
-        if {![info exists _cntlInfo($this-$col-id)]} {
-            set tip ""
-            if {$col eq "simnum"} {
-                set quantity "Simulation"
-                set tip "List of all simulations that you have performed so far."
-            } else {
-                # search for the first XML object with this element defined
-                foreach xmlobj [$_resultset find * *] {
-                    set quantity [$xmlobj get $col.about.label]
-                    set tip [$xmlobj get $col.about.description]
-                    if {"" != $quantity} {
-                        break
-                    }
-                }
-                if {"" == $quantity && "" != $xmlobj} {
-                    set quantity [$xmlobj element -as id $col]
-                }
-            }
-
-            # Create the controls for the "short list" area.
-            set fn $itk_option(-textfont)
-            set w $shortlist.label$_counter
-            set row [lindex [grid size $shortlist] 1]
-            frame $w
-            grid $w -row $row -column 1 -sticky ew
-            label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0
-            pack $w.arrow -side left -fill y
-            _control bind $w.arrow $col
-
-            label $w.name -text $quantity -anchor w \
-                -borderwidth 0 -padx 0 -pady 1 -font $fn
-            pack $w.name -side left
-            bind $w.name <Configure> [itcl::code $this _fixValue $col resize]
-            _control bind $w.name $col
-
-            label $w.value -anchor w \
-                -borderwidth 0 -padx 0 -pady 1 -font $fn
-            pack $w.value -side left
-            bind $w.value <Configure> [itcl::code $this _fixValue $col resize]
-            _control bind $w.value $col
-
-            Rappture::Tooltip::for $w \
-                "@[itcl::code $this _getTooltip label $col]"
-
-            # create a record for this control
-            lappend _cntlInfo($this-all) $col
-            set _cntlInfo($this-$col-id) $_counter
-            set _cntlInfo($this-$col-label) $quantity
-            set _cntlInfo($this-$col-tip) $tip
-            set _cntlInfo($this-$col-value) ""
-            set _cntlInfo($this-$col-usage) 0
-            set _cntlInfo($this-$col) ""
-
-            trace add variable _cntlInfo($this-$col-value) write \
-                "[itcl::code $this _fixValue $col value]; list"
-
-            incr _counter
-
-            incr nadded
-        }
-
-        #
-        # Determine the unique values for this column and load
-        # them into the control.
-        #
-        set id $_cntlInfo($this-$col-id)
-
-        if {$col == $_layout(active)} {
-            _control load $shortlist.dial $col
-        }
-    }
-
-    #
-    # Activate the most recent control.  If a bunch of controls
-    # were just added, then activate the "Simulation" control,
-    # since that's the easiest way to page through results.
-    #
-    set numcntls [expr {[llength [$_resultset diff names]]-1}]
-    if {$nadded > 0 || $numcntls != $_layout(numcntls)} {
-        if {$numcntls == 2 || $nadded == 1} {
-            activate [lindex [$_resultset diff names] end]
-        } else {
-            activate simnum
-        }
-
-        # fix the shortlist layout to show as many controls as we can
-        $_dispatcher event -idle !layout why data
-    }
-
-    #
-    # Set all controls to the settings of the most recent addition.
-    # Setting the value slot will trigger the !settings event, which
-    # will then fix all other controls to match the one that changed.
-    #
-    if {[info exists eventData(what)]} {
-        set xmlobj $eventData(what)
-        set simnum [$_resultset get simnum $xmlobj]
-        set _cntlInfo($this-simnum-value) $simnum
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixLayout ?<eventArgs...>?
-#
-# Called automatically at the idle point after the controls have
-# changed, or the size of the window has changed.  Fixes the layout
-# so that the active control is displayed, and other recent controls
-# are shown above and/or below.  At the very least, we must show the
-# "more options..." control.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_fixLayout {args} {
-    array set eventdata $args
-
-    set shortlist $itk_component(dials)
-
-    # clear out the short list area
-    foreach w [grid slaves $shortlist] {
-        grid forget $w
-    }
-
-    # reset all labels back to an ordinary font/background
-    set fn $itk_option(-textfont)
-    set bg $itk_option(-background)
-    set fg $itk_option(-foreground)
-    foreach col $_cntlInfo($this-all) {
-        set id $_cntlInfo($this-$col-id)
-        $shortlist.label$id configure -background $bg
-        $shortlist.label$id.arrow configure -background $bg \
-            -bitmap [Rappture::icon empty]
-        $shortlist.label$id.name configure -font $fn -background $bg
-        $shortlist.label$id.value configure -background $bg
-    }
-
-    # only 1 result? then we don't need any controls
-    if {$_resultset eq "" || [$_resultset size] < 2} {
-        set _layout(active) $_active
-
-        # let clients know that the layout has changed
-        # so they can fix the overall size accordingly
-        if {![info exists eventdata(why)] || $eventdata(why) ne "resize"} {
-            event generate $itk_component(hull) <<Layout>>
-        }
-
-        return
-    }
-
-    # compute the number of controls that will fit in the shortlist area
-    set dials $itk_component(dials)
-    set h [winfo height $dials]
-    set normalLine [font metrics $itk_option(-textfont) -linespace]
-    set boldLine [font metrics $itk_option(-boldfont) -linespace]
-    set active [expr {$boldLine+[winfo reqheight $dials.dial]+4}]
-
-    if {$h < $active+$normalLine} {
-        # active control kinda big? then show parameter values only
-        set _layout(mode) abbreviated
-        set ncntls [expr {int(floor(double($h)/$normalLine))}]
-    } else {
-        set _layout(mode) usual
-        set ncntls [expr {int(floor(double($h-$active)/$normalLine))+1}]
-    }
-
-    # find the controls with the most usage
-    set order ""
-    foreach col [lrange [$_resultset diff names] 1 end] {
-        lappend order [list $col $_cntlInfo($this-$col-usage)]
-    }
-    set order [lsort -integer -decreasing -index 1 $order]
-
-    set mostUsed ""
-    if {[llength $order] <= $ncntls} {
-        # plenty of space? then show all controls
-        foreach item $order {
-            lappend mostUsed [lindex $item 0]
-        }
-    } else {
-        # otherwise, limit to the most-used controls
-        foreach item [lrange $order 0 [expr {$ncntls-1}]] {
-            lappend mostUsed [lindex $item 0]
-        }
-
-        # make sure the active control is included
-        if {"" != $_active && [lsearch -exact $mostUsed $_active] < 0} {
-            set mostUsed [lreplace [linsert $mostUsed 0 $_active] end end]
-        }
-
-        # if there are more controls, add the "more parameters..." entry
-        if {$ncntls >= 2} {
-            set mostUsed [lreplace $mostUsed end end @more]
-            set rest [expr {[llength $order]-($ncntls-1)}]
-            if {$rest == 1} {
-                $dials.labelmore.name configure -text "1 more parameter..."
-            } else {
-                $dials.labelmore.name configure -text "$rest more parameters..."
-            }
-        }
-    }
-
-    # show controls associated with diffs and put up the radiodial
-    # for the "active" column
-    set row 0
-    foreach col [concat [lrange [$_resultset diff names] 1 end] @more] {
-        # this control not on the short list? then ignore it
-        if {[lsearch $mostUsed $col] < 0} {
-            continue
-        }
-
-        if {[string index $col 0] == "@"} {
-            set id [string range $col 1 end]
-        } else {
-            set id $_cntlInfo($this-$col-id)
-        }
-        grid $shortlist.label$id -row $row -column 1 -sticky ew -padx 4
-
-        if {$col == $_active} {
-            if {$_layout(mode) == "usual"} {
-                # put the background behind the active control in the shortlist
-                grid $shortlist.bg -row $row -rowspan 2 \
-                    -column 0 -columnspan 2 -sticky nsew
-                lower $shortlist.bg
-
-                # place the All and dial in the shortlist area
-                grid $shortlist.all -row $row -rowspan 2 -column 0 \
-                    -sticky nsew -padx 2 -pady 2
-                grid $shortlist.dial -row [expr {$row+1}] -column 1 \
-                    -sticky ew -padx 4
-                incr row
-
-                if {$_layout(active) != $_active} {
-                    $shortlist.dial configure -variable ""
-                    _control load $shortlist.dial $col
-                    $shortlist.dial configure -variable \
-                      "::Rappture::ResultSelector::_cntlInfo($this-$col-value)"
-                    set _layout(active) $_active
-                }
-            }
-        }
-        incr row
-    }
-
-    # highlight the active control
-    if {[info exists _cntlInfo($this-$_active-id)]} {
-        set id $_cntlInfo($this-$_active-id)
-        set bf $itk_option(-boldfont)
-        set fg $itk_option(-activecontrolforeground)
-        set bg $itk_option(-activecontrolbackground)
-
-        if {$_layout(mode) == "usual"} {
-            $shortlist.label$id configure -background $bg
-            $shortlist.label$id.arrow configure -foreground $fg \
-                -background $bg -bitmap [Rappture::icon rarrow]
-            $shortlist.label$id.name configure -foreground $fg \
-                -background $bg -font $bf
-            $shortlist.label$id.value configure -foreground $fg \
-                -background $bg
-            $shortlist.dial configure -background $bg
-            $shortlist.bg configure -background $bg
-
-            if {[$shortlist.all cget -relief] == "raised"} {
-                $shortlist.all configure -foreground $fg -background $bg
-            }
-        }
-    }
-
-    # let clients know that the layout has changed
-    # so they can fix the overall size accordingly
-    if {![info exists eventdata(why)] || $eventdata(why) ne "resize"} {
-        event generate $itk_component(hull) <<Layout>>
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixNumResults
-#
-# Used internally to update the number of results displayed near the
-# top of this widget.  If there is only 1 result, then there is also
-# a single "Clear" button.  If there are no results, the clear button
-# is diabled.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_fixNumResults {} {
-    set size 0
-    if {$_resultset ne ""} {
-        set size [$_resultset size]
-    }
-
-    switch $size {
-        0 {
-            $itk_component(status) configure -text "No results"
-            $itk_component(clearall) configure -state disabled -text "Clear"
-            pack forget $itk_component(clear)
-        }
-        1 {
-            $itk_component(status) configure -text "1 result"
-            $itk_component(clearall) configure -state normal -text "Clear"
-            pack forget $itk_component(clear)
-        }
-        default {
-            $itk_component(status) configure -text "$size results"
-            $itk_component(clearall) configure -state normal -text "Clear All"
-            $itk_component(clear) configure -state normal
-            pack $itk_component(clear) -side right \
-                -after $itk_component(clearall) -padx {0 6}
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSettings ?<eventArgs...>?
-#
-# Called automatically at the idle point after a control has changed
-# to load new data into the plotting area at the top of this result
-# set.  Extracts the current tuple of control values from the control
-# area, then finds the corresponding data values.  Loads the data
-# by invoking a -settingscommand callback with parameters that
-# describe what data should be plotted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_fixSettings {args} {
-    array set eventdata $args
-    if {[info exists eventdata(column)]} {
-        set changed $eventdata(column)
-    } else {
-        set changed ""
-    }
-
-    if {[info exists _cntlInfo($this-$_active-label)]} {
-        lappend params $_cntlInfo($this-$_active-label)
-    } else {
-        lappend params "???"
-    }
-    if {$_active == ""} {
-        return   ;# nothing active -- don't do anything
-    }
-    eval lappend params [_getValues $_active all]
-
-    if {$_resultset eq "" || [$_resultset size] == 0} {
-        # no data? then do nothing
-        return
-    } elseif {[$_resultset size] == 1} {
-        # only one data set? then plot it
-        set xmlobj [$_resultset find * *]
-        set simnum [lindex [$_resultset get simnum $xmlobj] 0]
-
-        _doSettings [list \
-            $simnum [list -width 2 \
-                    -param [_getValues $_active current] \
-                    -description [_getParamDesc all] \
-              ] \
-            params $params \
-        ]
-        return
-    }
-
-    #
-    # Find the selected run.  If the run setting changed, then
-    # look at its current value.  Otherwise, search the results
-    # for a tuple that matches the current settings.
-    #
-    if {$changed == "xmlobj" || $changed == "simnum"} {
-        set xmlobj [$_resultset find simnum $_cntlInfo($this-simnum-value)]
-    } else {
-        set format ""
-        set tuple ""
-        foreach col [lrange [$_resultset diff names] 2 end] {
-            lappend format $col
-            lappend tuple $_cntlInfo($this-$col-value)
-        }
-        set xmlobj [lindex [$_resultset find $format $tuple] 0]
-
-        if {$xmlobj eq "" && $changed ne ""} {
-            #
-            # No data for these settings.  Try leaving the next
-            # column open, then the next, and so forth, until
-            # we find some data.
-            #
-            # allcols:  foo bar baz qux
-            #               ^^^changed
-            #
-            # search:   baz qux foo
-            #
-            set val $_cntlInfo($this-$changed-value)
-            set allcols [lrange [$_resultset diff names] 2 end]
-            set i [lsearch -exact $allcols $changed]
-            set search [concat \
-                [lrange $allcols [expr {$i+1}] end] \
-                [lrange $allcols 0 [expr {$i-1}]] \
-            ]
-            set nsearch [llength $search]
-
-            for {set i 0} {$i < $nsearch} {incr i} {
-                set format $changed
-                set tuple [list $val]
-                for {set j [expr {$i+1}]} {$j < $nsearch} {incr j} {
-                    set col [lindex $search $j]
-                    lappend format $col
-                    lappend tuple $_cntlInfo($this-$col-value)
-                }
-                set xmlobj [lindex [$_resultset find $format $tuple] 0]
-                if {$xmlobj ne ""} {
-                    break
-                }
-            }
-        }
-    }
-
-    #
-    # If we found a particular run, then load its values into all
-    # controls.
-    #
-    if {$xmlobj ne ""} {
-        # stop reacting to value changes
-        set _settings 1
-
-        set format [lrange [$_resultset diff names] 2 end]
-        if {[llength $format] == 1} {
-            set data [list [$_resultset get $format $xmlobj]]
-        } else {
-            set data [$_resultset get $format $xmlobj]
-        }
-
-        foreach col $format val $data {
-            set _cntlInfo($this-$col-value) $val
-        }
-
-        set simnum [$_resultset get simnum $xmlobj]
-        set _cntlInfo($this-simnum-value) $simnum
-
-        # okay, react to value changes again
-        set _settings 0
-    }
-
-    #
-    # Search for tuples matching the current setting and
-    # plot them.
-    #
-    if {$_plotall && $_active eq "simnum"} {
-        set format ""
-    } else {
-        set format ""
-        set tuple ""
-        foreach col [lrange [$_resultset diff names] 2 end] {
-            if {!$_plotall || $col ne $_active} {
-                lappend format $col
-                lappend tuple $_cntlInfo($this-$col-value)
-            }
-        }
-    }
-
-    if {$format ne ""} {
-        set xolist [$_resultset find $format $tuple]
-    } else {
-        set xolist [$_resultset find * *]
-    }
-
-    if {[llength $xolist] > 0} {
-        # search for the result for these settings
-        set format ""
-        set tuple ""
-        foreach col [lrange [$_resultset diff names] 2 end] {
-            lappend format $col
-            lappend tuple $_cntlInfo($this-$col-value)
-        }
-        set curr [$_resultset find $format $tuple]
-
-        if {[llength $xolist] == 1} {
-            # single result -- always use active color
-            set xmlobj [lindex $xolist 0]
-            set simnum [$_resultset get simnum $xmlobj]
-            set plist [list \
-                $simnum [list -width 2 \
-                         -param [_getValues $_active $xmlobj] \
-                         -description [_getParamDesc all $xmlobj] \
-                   ] \
-                params $params \
-            ]
-        } else {
-            #
-            # Get the color for all points according to
-            # the color spectrum.
-            #
-            set plist [list params $params]
-            foreach xmlobj $xolist {
-                set simnum [$_resultset get simnum $xmlobj]
-                if {$xmlobj eq $curr} {
-                    lappend plist $simnum [list -width 3 -raise 1 \
-                        -param [_getValues $_active $xmlobj] \
-                        -description [_getParamDesc all $xmlobj]]
-                } else {
-                    lappend plist $simnum [list -brightness 0.7 -width 1 \
-                        -param [_getValues $_active $xmlobj] \
-                        -description [_getParamDesc all $xmlobj]]
-                }
-            }
-        }
-
-        #
-        # Load up the matching plots
-        #
-        _doSettings $plist
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue <columnName> <why>
-#
-# Called automatically whenver a value for a parameter dial changes.
-# Updates the interface to display the new value.  The <why> is a
-# reason for the change, which may be "resize" (draw old value in
-# new size) or "value" (value changed).
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_fixValue {col why} {
-    if {[info exists _cntlInfo($this-$col-id)]} {
-        set id $_cntlInfo($this-$col-id)
-
-        set widget $itk_component(dials).label$id
-        set wmax [winfo width $itk_component(dials).dial]
-        if {$wmax <= 1} {
-            set wmax [expr {round(0.9*[winfo width $itk_component(cntls)])}]
-        }
-        _drawValue $col $widget $wmax
-
-        if {$why == "value" && !$_settings} {
-            # keep track of usage, so we know which controls are popular
-            incr _cntlInfo($this-$col-usage)
-
-            # adjust the settings according to the value in the column
-            $_dispatcher event -idle !settings column $col
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _drawValue <columnName> <widget> <widthMax>
-#
-# Used internally to fix the rendering of a "quantity = value" display.
-# If the name/value in <widget> are smaller than <widthMax>, then the
-# full "quantity = value" string is displayed.  Otherwise, an
-# abbreviated form is displayed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_drawValue {col widget wmax} {
-    set quantity $_cntlInfo($this-$col-label)
-    regsub -all {\n} $quantity " " quantity  ;# take out newlines
-
-    set newval $_cntlInfo($this-$col-value)
-    regsub -all {\n} $newval " " newval  ;# take out newlines
-
-    set lfont [$widget.name cget -font]
-    set vfont [$widget.value cget -font]
-
-    set wn [font measure $lfont $quantity]
-    set wv [font measure $lfont " = $newval"]
-    set w [expr {$wn + $wv}]
-
-    if {$w <= $wmax} {
-        # if the text fits, then shown "quantity = value"
-        $widget.name configure -text $quantity
-        $widget.value configure -text " = $newval"
-    } else {
-        # Otherwise, we'll have to appreviate.
-        # If the value is really long, then just show a little bit
-        # of it.  Otherwise, show as much of the value as we can.
-        if {[string length $newval] > 30} {
-            set frac 0.8
-        } else {
-            set frac 0.2
-        }
-        set wNameSpace [expr {round($frac*$wmax)}]
-        set wValueSpace [expr {$wmax-$wNameSpace}]
-
-        # fit as much of the "quantity" label in the space available
-        if {$wn < $wNameSpace} {
-            $widget.name configure -text $quantity
-            set wValueSpace [expr {$wmax-$wn}]
-        } else {
-            set wDots [font measure $lfont "..."]
-            set wchar [expr {double($wn)/[string length $quantity]}]
-            while {1} {
-                # figure out a good size for the abbreviated string
-                set cmax [expr {round(($wNameSpace-$wDots)/$wchar)}]
-                if {$cmax < 0} {set cmax 0}
-                set str "[string range $quantity 0 $cmax]..."
-                if {[font measure $lfont $str] <= $wNameSpace
-                      || $wDots >= $wNameSpace} {
-                    break
-                }
-                # we're measuring with average chars, so we may have
-                # to shave a little off and do this again
-                set wDots [expr {$wDots+2*$wchar}]
-            }
-            $widget.name configure -text $str
-            set wValueSpace [expr {$wmax-[font measure $lfont $str]}]
-        }
-
-        if {$wv < $wValueSpace} {
-            $widget.value configure -text " = $newval"
-        } else {
-            set wDots [font measure $vfont "..."]
-            set wEq [font measure $vfont " = "]
-            set wchar [expr {double($wv)/[string length " = $newval"]}]
-            while {1} {
-                # figure out a good size for the abbreviated string
-                set cmax [expr {round(($wValueSpace-$wDots-$wEq)/$wchar)}]
-                if {$cmax < 0} {set cmax 0}
-                set str " = [string range $newval 0 $cmax]..."
-                if {[font measure $vfont $str] <= $wValueSpace
-                      || $wDots >= $wValueSpace} {
-                    break
-                }
-                # we're measuring with average chars, so we may have
-                # to shave a little off and do this again
-                set wDots [expr {$wDots+2*$wchar}]
-            }
-            $widget.value configure -text $str
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _toggleAll ?<columnName>?
-#
-# Called automatically whenever the user clicks on an "All" button.
-# Toggles the button between its on/off states.  In the "on" state,
-# all results associated with the current control are sent to the
-# result viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_toggleAll {{col "current"}} {
-    if {$col == "current"} {
-        set col $_active
-    }
-    if {![info exists _cntlInfo($this-$col-id)]} {
-        return
-    }
-    set id $_cntlInfo($this-$col-id)
-    set sbutton $itk_component(dials).all
-    set current [$sbutton cget -relief]
-
-    if {$current == "sunken"} {
-        $sbutton configure -relief raised \
-            -background $itk_option(-activecontrolbackground) \
-            -foreground $itk_option(-activecontrolforeground)
-        set _plotall 0
-        Rappture::Logger::log result -all off
-    } else {
-        $sbutton configure -relief sunken \
-            -background $itk_option(-togglebackground) \
-            -foreground $itk_option(-toggleforeground)
-        set _plotall 1
-        Rappture::Logger::log result -all on
-
-        if {$col != $_active} {
-            # clicked on an inactive "All" button? then activate that column
-            activate $col
-        }
-    }
-    $_dispatcher event -idle !settings
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getValues <column> ?<which>?
-#
-# Returns one or more value names associated with the given <column>.
-# If the <which> parameter is "all", then it returns values for all
-# results in the ResultSet.  Each value appears as two values in the
-# flattened list: the normalized value and the value label.  If the
-# <which> parameter is "current"
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_getValues {col {which "all"}} {
-    switch -- $which {
-        current {
-            set simnum $_cntlInfo($this-simnum-value)
-            set xmlobj [$_resultset find simnum $simnum]
-            if {$xmlobj ne ""} {
-                return [$_resultset diff values $col $xmlobj]
-            }
-            return ""
-        }
-        all {
-            return [$_resultset diff values $col all]
-        }
-        default {
-            return [$_resultset diff values $col $which]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getTooltip <role> <column>
-#
-# Called automatically whenever the user hovers on a control within
-# this widget.  Returns the tooltip associated with the control.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_getTooltip {role column} {
-    set label ""
-    set tip ""
-    if {$column eq "active"} {
-        set column $_active
-    }
-    if {[info exists _cntlInfo($this-$column-label)]} {
-        set label $_cntlInfo($this-$column-label)
-    }
-    if {[info exists _cntlInfo($this-$column-tip)]} {
-        set tip $_cntlInfo($this-$column-tip)
-    }
-
-    switch -- $role {
-        label {
-            if {$column ne $_active} {
-                append tip "\n\nClick to activate this control."
-            }
-        }
-        dial {
-            append tip "\n\nClick to change the value of this parameter."
-        }
-        all {
-            if {$label eq ""} {
-                set tip "Plot all values for this quantity."
-            } else {
-                set tip "Plot all values for $label."
-            }
-            if {$_plotall} {
-                set what "all values"
-            } else {
-                set what "one value"
-            }
-            append tip "\n\nCurrently, plotting $what.  Click to toggle."
-        }
-    }
-    return [string trim $tip]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getParamDesc <which> ?<xmlobj>?
-#
-# Used internally to build a descripton of parameters for the data
-# tuple for the specified <xmlobj>.  This is passed on to the underlying
-# results viewer, so it will know what data is being viewed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_getParamDesc {which {xmlobj "current"}} {
-    if {$_resultset eq ""} {
-        return ""
-    }
-
-    if {$xmlobj eq "current"} {
-        # search for the result for these settings
-        set format ""
-        set tuple ""
-        foreach col [lrange [$_resultset diff names] 2 end] {
-            lappend format $col
-            lappend tuple $_cntlInfo($this-$col-value)
-        }
-        set xmlobj [$_resultset find $format $tuple]
-        if {$xmlobj eq ""} {
-            return ""  ;# somethings wrong -- bail out!
-        }
-    }
-
-    switch -- $which {
-        active {
-            if {$_active eq ""} {
-                return ""
-            }
-        }
-        all {
-            set desc ""
-            foreach col [lrange [$_resultset diff names] 1 end] {
-                set quantity $_cntlInfo($this-$col-label)
-                set val [$_resultset get $col $xmlobj]
-                append desc "$quantity = $val\n"
-            }
-            return [string trim $desc]
-        }
-        default {
-            error "bad value \"$which\": should be active or all"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _log <col>
-#
-# Used internally to log the event when a user switches to a different
-# result in the result selector.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSelector::_log {col} {
-    Rappture::Logger::log result -select $col $_cntlInfo($this-$col-value)
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -resultset
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::ResultSelector::resultset {
-    set obj $itk_option(-resultset)
-    if {$obj ne ""} {
-        if {[catch {$obj isa ::Rappture::ResultSet} valid] || !$valid} {
-            error "bad value \"$obj\": should be Rappture::ResultSet object"
-        }
-    }
-
-    # disconnect the existing ResultSet and install the new one
-    if {$_resultset ne ""} {
-        $_resultset notify remove $this
-        _fixControls op clear
-    }
-    set _resultset $obj
-
-    if {$_resultset ne ""} {
-        $_resultset notify add $this !change \
-            [itcl::code $this _fixControls]
-    }
-
-    _fixControls op add
-    activate simnum
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -activecontrolbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::ResultSelector::activecontrolbackground {
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -activecontrolforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::ResultSelector::activecontrolforeground {
-    $_dispatcher event -idle !layout
-}
-
Index: trunk/gui/scripts/resultset.tcl
===================================================================
--- trunk/gui/scripts/resultset.tcl	(revision 6716)
+++ 	(revision )
@@ -1,572 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: ResultSet - set of XML objects for simulated results
-#
-#  This data structure collects all of the simulated results
-#  produced by a series of tool runs.  It is used by the Analyzer,
-#  ResultSelector, and other widgets to keep track of all known runs
-#  and visualize the result that is currently selected.  Each run
-#  has an index number ("#1", "#2", "#3", etc.) that can be used to
-#  label the run and refer to it later.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-
-itcl::class Rappture::ResultSet {
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method add {xmlobj}
-    public method clear {{xmlobj ""}}
-    public method diff {option args}
-    public method find {collist vallist}
-    public method get {collist xmlobj}
-    public method contains {xmlobj}
-    public method size {}
-
-    public method notify {option args}
-    protected method _notifyHandler {args}
-
-    protected method _addOneResult {tuples xmlobj {simnum ""}}
-
-    private variable _dispatcher ""  ;# dispatchers for !events
-    private variable _results ""     ;# tuple of known results
-    private variable _resultnum 0    ;# counter for result #1, #2, etc.
-    private variable _notify         ;# info used for notify command
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::constructor {args} {
-    # create a dispatcher for events
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !change
-    $_dispatcher dispatch $this !change \
-        [itcl::code $this _notifyHandler]
-
-    # create a list of tuples for data
-    set _results [Rappture::Tuples ::#auto]
-    $_results column insert end -name xmlobj -label "top-level XML object"
-    $_results column insert end -name simnum -label "simulation number"
-
-    # clear notification info
-    set _notify(ALL) ""
-
-    eval configure $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::destructor {} {
-    clear
-    itcl::delete object $_results
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <xmlobj>
-#
-# Adds a new result to this result set.  Scans through all existing
-# results to look for a difference compared to previous results.
-# Returns the simulation number (#1, #2, #3, etc.) of this new result
-# to the caller.  The various data objects for this result set should
-# be added to their result viewers at the same index.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::add {xmlobj} {
-    set xmlobj0 [$_results get -format xmlobj end]
-    if {$xmlobj0 eq ""} {
-        #
-        # If this is the first result, then there are no diffs.
-        # Add it right in.
-        #
-        set simnum "#[incr _resultnum]"
-        $_results insert end [list $xmlobj $simnum]
-    } else {
-        #
-        # For all later results, find the diffs and add any new columns
-        # into the results tuple.  The latest result is the most recent.
-        #
-        set simnum [_addOneResult $_results $xmlobj]
-    }
-
-    # make sure we fix up associated controls
-    $_dispatcher event -now !change op add what $xmlobj
-
-    return $simnum
-}
-
-# ----------------------------------------------------------------------
-# USAGE: clear ?<xmlobj>?
-#
-# Clears one or all results in this result set.  If no specific
-# result object is specified, then all results are cleared.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::clear {{xmlobj ""}} {
-    if {$xmlobj ne ""} {
-        #
-        # Delete just one result.  Look for the result among the
-        # tuples and remove it.  Then, rebuild all of the tuples
-        # by scanning back through them and building them back up.
-        # This will rebuild the columns/controls as they should
-        # be now, removing anything that is no longer necessary.
-        #
-        set irun [$_results find -format xmlobj $xmlobj]
-        if {[llength $irun] == 1} {
-            # grab a description of what we're about to delete
-            set dlist [list simnum [$_results get -format simnum $irun]]
-            foreach col [lrange [$_results column names] 2 end] {
-                set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0]
-                lappend dlist $col $raw  ;# use "raw" (user-readable) label
-            }
-
-            # delete this from the tuples of all results
-            itcl::delete object $xmlobj
-            $_results delete $irun
-
-            set new [Rappture::Tuples ::#auto]
-            $new column insert end -name xmlobj -label "top-level XML object"
-            $new column insert end -name simnum -label "simulation number"
-
-            for {set n 0} {$n < [$_results size]} {incr n} {
-                set rec [lindex [$_results get -format {xmlobj simnum} $n] 0]
-                foreach {obj num} $rec break
-                if {$n == 0} {
-                    $new insert end [list $obj $num]
-                } else {
-                    _addOneResult $new $obj $num
-                }
-            }
-
-            # plug in the new set of rebuilt tuples
-            itcl::delete object $_results
-            set _results $new
-
-            # make sure we fix up associated controls at some point
-            $_dispatcher event -now !change op clear what $dlist
-        }
-    } else {
-        #
-        # Delete all results.
-        #
-        for {set irun 0} {$irun < [$_results size]} {incr irun} {
-            set xo [$_results get -format xmlobj $irun]
-            itcl::delete object $xo
-        }
-        $_results delete 0 end
-
-        # make sure we fix up associated controls at some point
-        $_dispatcher event -now !change op clear what all
-    }
-
-    if {[$_results size] == 0} {
-        # no results left?  then reset to a clean state
-        eval $_results column delete [lrange [$_results column names] 2 end]
-        set _resultnum 0
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: diff names
-# USAGE: diff values <column> ?<which>?
-#
-# Returns information about the diffs in the current set of known
-# results.  The "diff names" returns a list of column names for
-# parameters that have diffs.  (These are the columns in the tuples.)
-#
-# The "diff values" returns the various values associated with a
-# particular <column> name.  If the optional <which> is specified,
-# then it is treated as an index into the list of values--0 for the
-# first value, 1 for the second, etc.  Each value is returned as
-# a list with two words.  The first is the the label associated with
-# the value.  The second is the normalized (numeric) value, which can
-# be sorted to get a particular ordering.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::diff {option args} {
-    switch -- $option {
-        names {
-            return [$_results column names]
-        }
-        values {
-            if {[llength $args] < 1} {
-                error "wrong # args: should be \"diff values col ?which?\""
-            }
-            set col [lindex $args 0]
-
-            set which "all"
-            if {[llength $args] > 1} {
-                set which [lindex $args 1]
-            }
-
-            set rlist ""
-            # build an array of normalized values and their labels
-            if {$col == "simnum"} {
-                set nruns [$_results size]
-                for {set n 0} {$n < $nruns} {incr n} {
-                    set simnum [$_results get -format simnum $n]
-                    lappend rlist $simnum $n
-                }
-            } else {
-                set havenums 1
-                foreach rec [$_results get -format [list xmlobj $col]] {
-                    set xo [lindex $rec 0]
-                    set v [lindex $rec 1]
-                    foreach {raw norm} \
-                        [Rappture::LibraryObj::value $xo $col] break
-                    if {![info exists unique($v)]} {
-                        # keep only unique label strings
-                        set unique($v) $norm
-                    }
-                    if {$havenums && ![string is double $norm]} {
-                        set havenums 0
-                    }
-                }
-
-                if {!$havenums} {
-                    # don't have normalized nums? then sort and create nums
-                    set rlist ""
-                    set n 0
-                    foreach val [lsort -dictionary [array names unique]] {
-                        lappend rlist $val [incr n]
-                    }
-                } else {
-                    set rlist [array get unique]
-                }
-            }
-
-            if {$which eq "all"} {
-                return $rlist
-            }
-
-            # treat the "which" parameter as an XML object
-            set irun [lindex [$_results find -format xmlobj $which] 0]
-            if {$irun ne ""} {
-                set val [lindex [$_results get -format $col $irun] 0]
-                array set val2norm $rlist
-                if {[info exists val2norm($val)]} {
-                    return [list $val $val2norm($val)]
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be names or values"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: find <columnList> <valueList>
-#
-# Searches through the results for a set of tuple values that match
-# the <valueList> for the given <columnList>.  Returns a list of
-# matching xml objects or "" if there is no match.  If the <valueList>
-# is *, then it returns a list of all xml objects.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::find {collist vallist} {
-    if {$vallist eq "*"} {
-        return [$_results get -format xmlobj]
-    }
-
-    set rlist ""
-    foreach irun [$_results find -format $collist -- $vallist] {
-        lappend rlist [$_results get -format xmlobj $irun]
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get <columnList> <xmlobj>
-#
-# Returns values for the specified <columnList> for the given <xmlobj>.
-# This is a way of querying associated data for the given object.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::get {collist xmlobj} {
-    set irun [lindex [$_results find -format xmlobj $xmlobj] 0]
-    if {$irun ne ""} {
-        return [lindex [$_results get -format $collist $irun] 0]
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: contains <xmlobj>
-#
-# Checks to see if the given <xmlobj> is already represented by
-# some result in this result set.  This comes in handy when checking
-# to see if an input case is already covered.
-#
-# Returns 1 if the result set already contains this result, and
-# 0 otherwise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::contains {xmlobj} {
-    # no results? then this must be new
-    if {[$_results size] == 0} {
-        return 0
-    }
-
-    #
-    # Compare this new object against the last XML object in the
-    # results set.  If it has a difference, make sure that there
-    # is a column to represent the quantity with the difference.
-    #
-    set xmlobj0 [$_results get -format xmlobj end]
-    foreach {op vpath oldval newval} [$xmlobj0 diff $xmlobj] {
-        if {[$xmlobj get $vpath.about.diffs] == "ignore"} {
-            continue
-        }
-        if {$op == "+" || $op == "-"} {
-            # ignore differences where parameters come and go
-            # such differences make it hard to work controls
-            continue
-        }
-        if {[$_results column names $vpath] == ""} {
-            # no column for this quantity yet
-            return 0
-        }
-    }
-
-    #
-    # If we got this far, then look through existing results for
-    # matching tuples, then check each one for diffs.
-    #
-    set format ""
-    set tuple ""
-    foreach col [lrange [$_results column names] 2 end] {
-        lappend format $col
-        set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0]
-        lappend tuple $raw  ;# use the "raw" (user-readable) label
-    }
-    if {[llength $format] > 0} {
-        set ilist [$_results find -format $format -- $tuple]
-    } else {
-        set ilist 0  ;# no diffs -- must match first entry
-    }
-
-    foreach i $ilist {
-        set xmlobj0 [$_results get -format xmlobj $i]
-        set diffs [$xmlobj0 diff $xmlobj]
-        if {[llength $diffs] == 0} {
-            # no diffs -- already contained here
-            return 1
-        }
-    }
-
-    # must be some differences
-    return 0
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: size
-#
-# Returns the number of results currently stored in the set.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::size {} {
-    return [$_results size]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: notify add <client> ?!event !event ...? <command>
-# USAGE: notify get ?<client>? ?!event?
-# USAGE: notify remove <client> ?!event !event ...?
-#
-# Clients use this to add/remove requests for notifications about
-# various events that signal changes to the data in each ResultSet.
-#
-# The "notify add" operation takes a <client> name (any unique string
-# identifying the client), an optional list of events, and the <command>
-# that should be called for the callback.
-#
-# The "notify get" command returns information about clients and their
-# registered callbacks.  With no args, it returns a list of <client>
-# names.  If the <client> is specified, it returns a list of !events.
-# If the <client> and !event is specified, it returns the <command>.
-#
-# The "notify remove" command removes any callback associated with
-# a given <client>.  If no particular !events are specified, then it
-# removes callbacks for all events.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::notify {option args} {
-    set allEvents {!change}
-    switch -- $option {
-        add {
-            if {[llength $args] < 2} {
-                error "wrong # args: should be \"notify add caller ?!event !event ...? command"
-            }
-            set caller [lindex $args 0]
-            set command [lindex $args end]
-            if {[llength $args] > 2} {
-                set events [lrange $args 1 end-1]
-            } else {
-                set events $allEvents
-            }
-
-            foreach name $events {
-                if {[lsearch -exact $allEvents $name] < 0} {
-                    error "bad event \"$name\": should be [join $allEvents ,]"
-                }
-                if {[lsearch $_notify(ALL) $caller] < 0} {
-                    lappend _notify(ALL) $caller
-                }
-                set _notify($caller-$name) $command
-            }
-        }
-        get {
-            switch -- [llength $args] {
-                0 {
-                    return $_notify(ALL)
-                }
-                1 {
-                    set caller [lindex $args 0]
-                    set rlist ""
-                    foreach key [array names _notify $caller-*] {
-                        lappend rlist [lindex [split $key -] end]
-                    }
-                    return $rlist
-                }
-                2 {
-                    set caller [lindex $args 0]
-                    set name [lindex $args 1]
-                    if {[info exists _notify($caller-$name)]} {
-                        return $_notify($caller-$name)
-                    }
-                    return ""
-                }
-                default {
-                    error "wrong # args: should be \"notify get ?caller? ?!event?\""
-                }
-            }
-        }
-        remove {
-            if {[llength $args] < 1} {
-                error "wrong # args: should be \"notify remove caller ?!event !event ...?"
-            }
-            set caller [lindex $args 0]
-            if {[llength $args] > 1} {
-                set events [lrange $args 1 end]
-            } else {
-                set events $allEvents
-            }
-
-            foreach name $events {
-                catch {unset _notify($caller-$name)}
-            }
-            if {[llength [array names _notify $caller-*]] == 0} {
-                set i [lsearch $_notify(ALL) $caller]
-                if {$i >= 0} {
-                    set _notify(ALL) [lreplace $_notify(ALL) $i $i]
-                }
-            }
-        }
-        default {
-            error "wrong # args: should be add, get, remove"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _notifyHandler ?<eventArgs>...?
-#
-# Called automatically whenever a !change event is triggered in this
-# object.  Scans through the list of clients that want to receive this
-# event and executes each of their callbacks.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::_notifyHandler {args} {
-    array set data $args
-    set event $data(event)
-
-    foreach caller $_notify(ALL) {
-        if {[info exists _notify($caller-$event)]} {
-            if {[catch {uplevel #0 $_notify($caller-$event) $args} result]} {
-                # anything go wrong? then throw a background error
-                bgerror "$result\n(while dispatching $event to $caller)"
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _addOneResult <tuples> <xmlobj> ?<simNum>?
-#
-# Used internally to add one new <xmlobj> to the given <tuples>
-# object.  If the new xmlobj contains different input parameters
-# that are not already columns in the tuple, then this routine
-# creates the new columns.  If the optional <simNum> is specified,
-# then it is added as the simulation number #1, #2, #3, etc.  If
-# not, then the new object is automatically numbered.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultSet::_addOneResult {tuples xmlobj {simnum ""}} {
-    #
-    # Compare this new object against the last XML object in the
-    # results set.  If it has a difference, make sure that there
-    # is a column to represent the quantity with the difference.
-    #
-    set xmlobj0 [$tuples get -format xmlobj end]
-    foreach {op vpath oldval newval} [$xmlobj0 diff $xmlobj] {
-        if {[$xmlobj get $vpath.about.diffs] == "ignore"} {
-            continue
-        }
-        if {$op == "+" || $op == "-"} {
-            # ignore differences where parameters come and go
-            # such differences make it hard to work controls
-            continue
-        }
-
-        # make sure that these values really are different
-        set oldval [lindex [Rappture::LibraryObj::value $xmlobj0 $vpath] 0]
-        set newval [lindex [Rappture::LibraryObj::value $xmlobj $vpath] 0]
-
-        if {$oldval != $newval && [$tuples column names $vpath] == ""} {
-            # no column for this quantity yet
-            $tuples column insert end -name $vpath -default $oldval
-        }
-    }
-
-    # build a tuple for this new object
-    set cols ""
-    set tuple ""
-    foreach col [lrange [$tuples column names] 2 end] {
-        lappend cols $col
-        set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0]
-        lappend tuple $raw  ;# use the "raw" (user-readable) label
-    }
-
-    # find a matching tuple? then replace it -- only need one
-    if {[llength $cols] > 0} {
-        set ilist [$tuples find -format $cols -- $tuple]
-    } else {
-        set ilist 0  ;# no diffs -- must match first entry
-    }
-
-    # add all remaining columns for this new entry
-    set tuple [linsert $tuple 0 $xmlobj]
-    set cols [linsert $cols 0 "xmlobj"]
-
-    if {[llength $ilist] > 0} {
-        if {[llength $ilist] > 1} {
-            error "why so many matching results?"
-        }
-
-        # overwrite the first matching entry
-        # start by freeing the old result
-        set index [lindex $ilist 0]
-        set xo [$tuples get -format xmlobj $index]
-        itcl::delete object $xo
-
-        # put this new result in its place
-        $tuples put -format $cols $index $tuple
-        set simnum [$tuples get -format simnum $index]
-    } else {
-        if {$simnum eq ""} {
-            set simnum "#[incr _resultnum]"
-        }
-        set tuple [linsert $tuple 1 $simnum]
-        $tuples insert end $tuple
-    }
-    return $simnum
-}
Index: trunk/gui/scripts/resultviewer.tcl
===================================================================
--- trunk/gui/scripts/resultviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,614 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: ResultViewer - plots a collection of related results
-#
-#  This widget plots a collection of results that all represent
-#  the same quantity, but for various ranges of input values.  It
-#  is normally used as part of an Analyzer, to plot the various
-#  results selected by a ResultSet.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::ResultViewer {
-    inherit itk::Widget
-
-    itk_option define -width width Width 4i
-    itk_option define -height height Height 4i
-    itk_option define -colors colors Colors ""
-    itk_option define -clearcommand clearCommand ClearCommand ""
-    itk_option define -simulatecommand simulateCommand SimulateCommand ""
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method add {index xmlobj path label {uq_part ""}}
-    public method clear {{index ""}}
-    public method value {xmlobj}
-
-    public method plot {option args}
-    public method download {option args}
-
-    protected method _plotAdd {xmlobj {settings ""}}
-    protected method _fixScale {args}
-    protected method _xml2data {xmlobj path label {uq_part ""}}
-    protected method _cleanIndex {index}
-
-    private variable _dispatcher ""  ;# dispatchers for !events
-    private variable _mode ""        ;# current plotting mode (xy, etc.)
-    private variable _mode2widget    ;# maps plotting mode => widget
-    private variable _dataslots ""   ;# list of all data objects in this widget
-    private variable _xml2data       ;# maps xmlobj => data obj in _dataslots
-}
-
-itk::usual ResultViewer {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::constructor {args} {
-    #puts "Creating RV $args"
-    # create a dispatcher for events
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !scale
-    $_dispatcher dispatch $this !scale \
-        [itcl::code $this _fixScale]
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::destructor {} {
-    foreach slot $_dataslots {
-        foreach obj $slot {
-            itcl::delete object $obj
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <index> <xmlobj> <path>
-#
-# Adds a new result to this result viewer at the specified <index>.
-# Data is taken from the <xmlobj> object at the <path>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::add {index xmlobj path label {uq_part ""}} {
-    #puts "RV add index=$index path=$path label=$label uq_part=$uq_part"
-    set index [_cleanIndex $index]
-    set dobj [_xml2data $xmlobj $path $label $uq_part]
-
-    #
-    # If the index doesn't exist, then fill in empty slots and
-    # make it exist.
-    #
-    for {set i [llength $_dataslots]} {$i <= $index} {incr i} {
-        lappend _dataslots ""
-    }
-
-    set slot [lindex $_dataslots $index]
-
-    # only add dobj if it isn't already there.
-    if {[lsearch -exact $slot $dobj] < 0} {
-        lappend slot $dobj
-        #puts "slot=$slot"
-        set _dataslots [lreplace $_dataslots $index $index $slot]
-        $_dispatcher event -idle !scale
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: clear ?<index>|<xmlobj>?
-#
-# Clears one or all results in this result viewer.  If a particular
-# <index> is specified, then all data objects at that index are
-# deleted.  If a particular <xmlobj> is specified, then all data
-# objects related to that <xmlobj> are removed--regardless of whether
-# they reside at one or more indices.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::clear {{index ""}} {
-    #puts "RV::clear $index"
-    if {$index ne ""} {
-        # clear one result
-        if {[catch {_cleanIndex $index} i] == 0} {
-            if {$i >= 0 && $i < [llength $_dataslots]} {
-                set slot [lindex $_dataslots $i]
-                foreach dobj $slot {
-                    if {"" != $_mode} {
-                        $_mode2widget($_mode) delete $dobj
-                    }
-                    itcl::delete object $dobj
-                }
-                set _dataslots [lreplace $_dataslots $i $i ""]
-                $_dispatcher event -idle !scale
-            }
-        } else {
-            foreach key [array names _xml2data $index-*] {
-                set dobj $_xml2data($key)
-
-                # search for and remove all references to this data object
-                for {set n 0} {$n < [llength $_dataslots]} {incr n} {
-                    set slot [lindex $_dataslots $n]
-                    set pos [lsearch -exact $slot $dobj]
-                    if {$pos >= 0} {
-                        set slot [lreplace $slot $pos $pos]
-                        set _dataslots [lreplace $_dataslots $n $n $slot]
-                        $_dispatcher event -idle !scale
-                    }
-                }
-
-                if {"" != $_mode} {
-                    $_mode2widget($_mode) delete $dobj
-                }
-                # destroy the object and forget it
-                itcl::delete object $dobj
-                unset _xml2data($key)
-            }
-        }
-    } else {
-        # clear all results
-        plot clear
-        foreach slot $_dataslots {
-            foreach dobj $slot {
-                itcl::delete object $dobj
-            }
-        }
-        set _dataslots ""
-        catch {unset _xml2data}
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value <xmlobj>
-#
-# Convenience method for showing a single value.  Loads the value
-# into the widget via add/clear, then immediately plots the value.
-# This makes the widget consistent with other widgets, such as
-# the DeviceEditor, etc.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::value {xmlobj} {
-    clear
-    if {"" != $xmlobj} {
-        add 0 $xmlobj ""
-        plot add 0 ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: plot add ?<simnum> <settings> <simnum> <settings> ...?
-# USAGE: plot clear
-#
-# Used to manipulate the contents of this viewer.  The "plot clear"
-# command clears the current viewer.  Data is still stored in the
-# widget, but the results are not shown on screen.  The "plot add"
-# command adds the data at the specified <simnum> to the plot.  Each
-# <simnum> is the simulation number, like "#1", "#2", "#3", etc.  If
-# the optional <settings> are specified, then they are applied
-# to the plot; otherwise, default settings are used.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::plot {option args} {
-    #puts "RV plot option=$option args=$args"
-    switch -- $option {
-        add {
-            set params ""
-            foreach {index opts} $args {
-                if {$index == "params"} {
-                    set params $opts
-                    continue
-                }
-
-                set index [_cleanIndex $index]
-                lappend opts "-simulation" [expr $index + 1]
-                set reset "-color autoreset"
-                set slot [lindex $_dataslots $index]
-                foreach dobj $slot {
-                    set settings ""
-                    # start with color reset, only for first object in series
-                    if {"" != $reset} {
-                        set settings $reset
-                        set reset ""
-                    }
-                    # add default settings from data object
-                    if {[catch {$dobj hints style} style] == 0} {
-                        eval lappend settings $style
-                    }
-                    if {[catch {$dobj hints type} type] == 0} {
-                        if {"" != $type} {
-                            eval lappend settings "-type $type"
-                        }
-                    }
-                    # add override settings passed in here
-                    eval lappend settings $opts
-                    _plotAdd $dobj $settings
-                }
-            }
-            if {"" != $params && "" != $_mode} {
-                eval $_mode2widget($_mode) parameters $params
-            }
-        }
-        clear {
-            # clear the contents of the current mode
-            if {"" != $_mode} {
-                $_mode2widget($_mode) delete
-            }
-        }
-        default {
-            error "bad option \"$option\": should be add or clear"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _plotAdd <dataobj> <settings>
-#
-# Used internally to add a <dataobj> representing some data to
-# the plot at the top of this widget.  The data is added to the
-# current plot.  Use the "clear" function to clear before adding
-# new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::_plotAdd {dataobj {settings ""}} {
-    #puts "RV _plotAdd $dataobj : [$dataobj info class] : $settings"
-    switch -- [$dataobj info class] {
-        ::Rappture::UqInfo {
-            set mode "uq"
-            if {![info exists _mode2widget($mode)]} {
-                set w $itk_interior.uq
-                Rappture::UqNotebook $w
-                set _mode2widget($mode) $w
-            }
-        }
-        ::Rappture::DataTable {
-            set mode "datatable"
-            if {![info exists _mode2widget($mode)]} {
-                set w $itk_interior.datatable
-                Rappture::DataTableResult $w
-                set _mode2widget($mode) $w
-            }
-        }
-        ::Rappture::Drawing {
-            set mode "vtkviewer"
-            if {![info exists _mode2widget($mode)]} {
-                set w $itk_interior.vtkviewer
-                Rappture::VtkViewer $w
-                set _mode2widget($mode) $w
-            }
-        }
-        ::Rappture::Histogram {
-            set mode "histogram"
-            if {![info exists _mode2widget($mode)]} {
-                set w $itk_interior.histogram
-                Rappture::HistogramResult $w
-                set _mode2widget($mode) $w
-            }
-        }
-        ::Rappture::Curve {
-            set type [$dataobj hints type]
-            set mode "xy"
-            if { $type == "bars" } {
-                if {![info exists _mode2widget($mode)]} {
-                    set w $itk_interior.xy
-                    Rappture::BarchartResult $w
-                    set _mode2widget($mode) $w
-                }
-            } else {
-                if {![info exists _mode2widget($mode)]} {
-                    set w $itk_interior.xy
-                    Rappture::XyResult $w
-                    set _mode2widget($mode) $w
-                }
-            }
-        }
-        ::Rappture::Map {
-            if { ![$dataobj isvalid] } {
-                return;                 # Ignore invalid map objects.
-            }
-            set mode "map"
-            if {![info exists _mode2widget($mode)]} {
-                set w $itk_interior.$mode
-                Rappture::MapViewer $w
-                set _mode2widget($mode) $w
-            }
-        }
-        ::Rappture::Field {
-            if { ![$dataobj isvalid] } {
-                return;                 # Ignore invalid field objects.
-            }
-            set dims [lindex [lsort [$dataobj components -dimensions]] end]
-            switch -- $dims {
-                1D {
-                    set mode "xy"
-                    if {![info exists _mode2widget($mode)]} {
-                        set w $itk_interior.xy
-                        Rappture::XyResult $w
-                        set _mode2widget($mode) $w
-                    }
-                }
-                default {
-                    set mode [$dataobj viewer]
-                    if {![info exists _mode2widget($mode)]} {
-                        set w $itk_interior.$mode
-                        if { ![winfo exists $w] } {
-                            Rappture::FieldResult $w -mode $mode
-                        }
-                        set _mode2widget($mode) $w
-                    }
-                }
-            }
-        }
-        ::Rappture::Mesh {
-            if { ![$dataobj isvalid] } {
-                return;                 # Ignore invalid mesh objects.
-            }
-            set mode "vtkmeshviewer"
-            if {![info exists _mode2widget($mode)]} {
-                set w $itk_interior.$mode
-                Rappture::VtkMeshViewer $w
-                set _mode2widget($mode) $w
-            }
-        }
-        ::Rappture::Table {
-            set cols [Rappture::EnergyLevels::columns $dataobj]
-            if {"" != $cols} {
-                set mode "energies"
-                if {![info exists _mode2widget($mode)]} {
-                    set w $itk_interior.energies
-                    Rappture::EnergyLevels $w
-                    set _mode2widget($mode) $w
-                }
-            }
-        }
-        ::Rappture::LibraryObj {
-            switch -- [$dataobj element -as type] {
-                string - log {
-                    set mode "log"
-                    if {![info exists _mode2widget($mode)]} {
-                        set w $itk_interior.log
-                        Rappture::TextResult $w
-                        set _mode2widget($mode) $w
-                    }
-                }
-                structure {
-                    set mode "structure"
-                    if {![info exists _mode2widget($mode)]} {
-                        set w $itk_interior.struct
-                        Rappture::DeviceResult $w
-                        set _mode2widget($mode) $w
-                    }
-                }
-                number - integer {
-                    set mode "number"
-                    if {![info exists _mode2widget($mode)]} {
-                        set w $itk_interior.number
-                        Rappture::NumberResult $w
-                        set _mode2widget($mode) $w
-                    }
-                }
-                boolean - choice - multichoice {
-                    set mode "value"
-                    if {![info exists _mode2widget($mode)]} {
-                        set w $itk_interior.value
-                        Rappture::ValueResult $w
-                        set _mode2widget($mode) $w
-                    }
-                }
-            }
-        }
-        ::Rappture::Image {
-            set mode "image"
-            if {![info exists _mode2widget($mode)]} {
-                set w $itk_interior.image
-                Rappture::ImageResult $w
-                set _mode2widget($mode) $w
-            }
-        }
-        ::Rappture::Sequence {
-            set mode "sequence"
-            if {![info exists _mode2widget($mode)]} {
-                set w $itk_interior.image
-                Rappture::SequenceResult $w
-                set _mode2widget($mode) $w
-            }
-        }
-        default {
-            error "don't know how to plot <$type> data [$dataobj info class]"
-        }
-    }
-
-    # Are we plotting in a new mode? then change widgets
-    if {$_mode2widget($mode) != [pack slaves $itk_interior]} {
-        # remove any current window
-        foreach w [pack slaves $itk_interior] {
-            pack forget $w
-        }
-        pack $_mode2widget($mode) -expand yes -fill both
-
-        set _mode $mode
-        $_dispatcher event -idle !scale
-    }
-    $_mode2widget($mode) add $dataobj $settings
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixScale ?<eventArgs>...?
-#
-# Invoked automatically whenever a new dataset is added to fix the
-# overall scales of the viewer.  This makes the visualizer consistent
-# across all <dataobj> in this widget, so that it can plot all
-# available data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::_fixScale {args} {
-    if {"" != $_mode} {
-        set dlist ""
-        set objclass ""
-        foreach slot $_dataslots {
-            foreach dobj $slot {
-                if {$objclass == ""} {
-                    set objclass [$dobj info class]
-                } else {
-                    if {$objclass != [$dobj info class]} {
-                        # If some of the objects are different classes
-                        # then we cannot use the same scale, so give up.
-                        return
-                    }
-                }
-                lappend dlist $dobj
-            }
-        }
-        eval $_mode2widget($_mode) scale $dlist
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::download {option args} {
-    if {"" == $_mode} {
-        return ""
-    }
-    return [eval $_mode2widget($_mode) download $option $args]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _xml2data <xmlobj> <path>
-#
-# Used internally to create a data object for the data at the
-# specified <path> in the <xmlobj>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::_xml2data {xmlobj path label {uq_part ""}} {
-    #puts "RV:_xml2data $path ([$xmlobj element -as type $path]) label=$label uq_part=$uq_part"
-
-    if {$uq_part != ""} {
-        if {[info exists _xml2data($xmlobj-$label)]} {
-            $_xml2data($xmlobj-$label) add $xmlobj $path $uq_part
-            return $_xml2data($xmlobj-$label)
-        }
-    } elseif {[info exists _xml2data($xmlobj-$path]} {
-        return $_xml2data($xmlobj-$path)
-    }
-
-    if {$uq_part != ""} {
-        set type "UQ"
-    } else {
-        set type [$xmlobj element -as type $path]
-    }
-
-    switch -- $type {
-        UQ {
-            set dobj [Rappture::UqInfo ::#auto $xmlobj $path $uq_part]
-            set path $label
-        }
-        curve {
-            set dobj [Rappture::Curve ::#auto $xmlobj $path]
-        }
-        datatable {
-            set dobj [Rappture::DataTable ::#auto $xmlobj $path]
-        }
-        histogram {
-            set dobj [Rappture::Histogram ::#auto $xmlobj $path]
-        }
-        field {
-            set dobj [Rappture::Field ::#auto $xmlobj $path]
-        }
-        map {
-            set dobj [Rappture::Map ::#auto $xmlobj $path]
-        }
-        mesh {
-            set dobj [Rappture::Mesh ::#auto $xmlobj $path]
-        }
-        table {
-            set dobj [Rappture::Table ::#auto $xmlobj $path]
-        }
-        image {
-            set dobj [Rappture::Image ::#auto $xmlobj $path]
-        }
-        sequence {
-            set dobj [Rappture::Sequence ::#auto $xmlobj $path]
-        }
-        string - log {
-            set dobj [$xmlobj element -as object $path]
-        }
-        structure {
-            set dobj [$xmlobj element -as object $path]
-        }
-        number - integer - boolean - choice - multichoice {
-            set dobj [$xmlobj element -as object $path]
-        }
-        drawing3d - drawing {
-            set dobj [Rappture::Drawing ::#auto $xmlobj $path]
-        }
-        time - status {
-            set dobj ""
-        }
-        default {
-            error "don't know how to plot <$type> data path=$path"
-        }
-    }
-
-    # store the mapping xmlobj=>dobj so we can find this result later
-    if {$dobj ne ""} {
-        set _xml2data($xmlobj-$path) $dobj
-    }
-    return $dobj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _cleanIndex <index>
-#
-# Used internally to create a data object for the data at the
-# specified <path> in the <xmlobj>.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ResultViewer::_cleanIndex {index} {
-    set index [lindex $index 0]
-    if {[regexp {^#([0-9]+)} $index match num]} {
-        return [expr {$num-1}]  ;# start from 0 instead of 1
-    } elseif {[string is integer -strict $index]} {
-        return $index
-    }
-    error "bad plot index \"$index\": should be 0,1,2,... or #1,#2,#3,..."
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -width
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::ResultViewer::width {
-    set w [winfo pixels $itk_component(hull) $itk_option(-width)]
-    set h [winfo pixels $itk_component(hull) $itk_option(-height)]
-    if {$w == 0 || $h == 0} {
-        pack propagate $itk_component(hull) yes
-    } else {
-        component hull configure -width $w -height $h
-        pack propagate $itk_component(hull) no
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -height
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::ResultViewer::height {
-    set h [winfo pixels $itk_component(hull) $itk_option(-height)]
-    set w [winfo pixels $itk_component(hull) $itk_option(-width)]
-    if {$w == 0 || $h == 0} {
-        pack propagate $itk_component(hull) yes
-    } else {
-        component hull configure -width $w -height $h
-        pack propagate $itk_component(hull) no
-    }
-}
Index: trunk/gui/scripts/scroller.tcl
===================================================================
--- trunk/gui/scripts/scroller.tcl	(revision 6716)
+++ trunk/gui/scripts/scroller.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: scroller - adds scrollbars to any standard Tk widget
@@ -10,8 +9,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -19,6 +15,4 @@
 option add *Scroller.xScrollMode off widgetDefault
 option add *Scroller.yScrollMode auto widgetDefault
-option add *Scroller.xScrollSide bottom widgetDefault
-option add *Scroller.yScrollSide right widgetDefault
 option add *Scroller.width 0 widgetDefault
 option add *Scroller.height 0 widgetDefault
@@ -29,11 +23,8 @@
     itk_option define -xscrollmode xScrollMode XScrollMode ""
     itk_option define -yscrollmode yScrollMode YScrollMode ""
-    itk_option define -xscrollside xScrollSide XScrollSide ""
-    itk_option define -yscrollside yScrollSide YScrollSide ""
     itk_option define -width width Width 0
     itk_option define -height height Height 0
 
     constructor {args} { # defined below }
-    destructor { # defined below }
 
     public method contents {{frame "!@#query"}}
@@ -41,14 +32,12 @@
     protected method _widget2sbar {which args}
     protected method _fixsbar {which {state ""}}
-    protected method _fixframe {which}
-    protected method _fixsize {}
-    protected method _lock {option which}
-
-    private variable _dispatcher "" ;# dispatcher for !events
+    protected method _fixframe {}
+    protected method _lock {option}
+
     private variable _contents ""   ;# widget being controlled
     private variable _frame ""      ;# for "contents frame" calls
-    private variable _lock          ;# for _lock on x/y scrollbar
-}
-
+    private variable _lock 0        ;# for _lock on x-scrollbar
+}
+                                                                                
 itk::usual Scroller {
     keep -background -activebackground -activerelief
@@ -62,20 +51,4 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Scroller::constructor {args} {
-    array set _lock { x 0 y 0 }
-
-    Rappture::dispatcher _dispatcher
-
-    $_dispatcher register !fixframe-inner
-    $_dispatcher dispatch $this !fixframe-inner \
-        "[itcl::code $this _fixframe inner]; list"
-
-    $_dispatcher register !fixframe-outer
-    $_dispatcher dispatch $this !fixframe-outer \
-        "[itcl::code $this _fixframe outer]; list"
-
-    $_dispatcher register !fixsize
-    $_dispatcher dispatch $this !fixsize \
-        "[itcl::code $this _fixsize]; list"
-
     itk_component add xsbar {
         scrollbar $itk_interior.xsbar -orient horizontal
@@ -85,23 +58,8 @@
     }
 
-    # we don't fix scrollbars when window is withdrawn, so
-    # fix them whenever a window pops up
-    bind $itk_component(hull) <Map> "
-        [itcl::code $this _fixsbar x]
-        [itcl::code $this _fixsbar y]
-    "
-
-    grid rowconfigure $itk_component(hull) 1 -weight 1
-    grid columnconfigure $itk_component(hull) 1 -weight 1
+    grid rowconfigure $itk_component(hull) 0 -weight 1
+    grid columnconfigure $itk_component(hull) 0 -weight 1
 
     eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Scroller::destructor {} {
-    after cancel [itcl::code $this _lock reset x]
-    after cancel [itcl::code $this _lock reset y]
 }
 
@@ -118,7 +76,4 @@
 itcl::body Rappture::Scroller::contents {{widget "!@#query"}} {
     if {$widget == "!@#query"} {
-        if {$_contents == $_frame} {
-            return $_frame.f
-        }
         return $_contents
     }
@@ -145,13 +100,6 @@
     if {$widget == "frame"} {
         if {$_frame == ""} {
-            set _frame [canvas $itk_component(hull).ifr -highlightthickness 0]
-            frame $_frame.f
-            $_frame create window 0 0 -anchor nw -window $_frame.f -tags frame
-            bind $_frame.f <Map> \
-                [itcl::code $_dispatcher event -idle !fixframe-inner]
-            bind $_frame.f <Configure> \
-                [itcl::code $_dispatcher event -idle !fixframe-inner]
-            bind $_frame <Configure> \
-                [itcl::code $_dispatcher event -idle !fixframe-outer]
+            set _frame [canvas $itk_component(hull).ifr]
+            bind $_frame <Configure> [itcl::code $this _resizeframe]
         }
         set widget $_frame
@@ -162,5 +110,5 @@
     #
     contents ""
-    grid $widget -row 1 -column 1 -sticky nsew
+    grid $widget -row 0 -column 0 -sticky nsew
     $widget configure \
         -xscrollcommand [itcl::code $this _widget2sbar x] \
@@ -171,15 +119,4 @@
     set _contents $widget
 
-    if {[string equal "x11" [tk windowingsystem]]} {
-        bind ${widget} <4> { %W yview scroll -5 units }
-        bind ${widget} <5> { %W yview scroll 5 units }
-    } else {
-        bind ${widget} <MouseWheel> {
-            %W yview scroll [expr {- (%D / 120) * 4}] units
-        }
-    }
-    if {$widget == $_frame} {
-        return $_frame.f
-    }
     return $widget
 }
@@ -211,15 +148,6 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Scroller::_fixsbar {which {state ""}} {
-    if {![winfo ismapped $itk_component(hull)]} {
-        #
-        # If we're not on yet screen, bail out!  This keeps bad
-        # numbers (from an empty or partially constructed widget)
-        # from prematurely influencing the scrollbar.
-        #
-        return
-    }
-
     if {$state == ""} {
-        switch -- [string tolower $itk_option(-${which}scrollmode)] {
+        switch -- $itk_option(-${which}scrollmode) {
             on - 1 - true - yes  { set state 1 }
             off - 0 - false - no { set state 0 }
@@ -233,32 +161,4 @@
                 }
             }
-            default {
-                set state 0
-            }
-        }
-    }
-
-    set row 0
-    set col 0
-    switch -- [string tolower $itk_option(-${which}scrollside)] {
-        top {
-            set row 0
-            set col 1
-        }
-        bottom {
-            set row 2
-            set col 1
-        }
-        left {
-            set row 1
-            set col 0
-        }
-        right {
-            set row 1
-            set col 2
-        }
-        default {
-            set row 0
-            set col 0
         }
     }
@@ -268,13 +168,9 @@
         x {
             if {$state} {
-                if {$col == 1} {
-                    grid $itk_component(xsbar) -row $row -column $col -sticky ew
-                }
+                grid $itk_component(xsbar) -row 1 -column 0 -sticky ew
+                _lock set
             } else {
-                # handle the lock on the "forget" side, so scrollbar
-                # tends to appear, rather than disappear
-                if {![_lock active x]} {
+                if {![_lock active]} {
                     grid forget $itk_component(xsbar)
-                    _lock set x
                 }
             }
@@ -282,14 +178,7 @@
         y {
             if {$state} {
-                if {$row == 1} {
-                    grid $itk_component(ysbar) -row $row -column $col -sticky ns
-                }
+                grid $itk_component(ysbar) -row 0 -column 1 -sticky ns
             } else {
-                # handle the lock on the "forget" side, so scrollbar
-                # tends to appear, rather than disappear
-                if {![_lock active y]} {
-                    grid forget $itk_component(ysbar)
-                    _lock set y
-                }
+                grid forget $itk_component(ysbar)
             }
         }
@@ -298,5 +187,5 @@
 
 # ----------------------------------------------------------------------
-# USAGE: _fixframe <which>
+# USAGE: _fixframe
 #
 # Invoked automatically whenever the canvas representing the "frame"
@@ -304,58 +193,12 @@
 # to the new size.
 # ----------------------------------------------------------------------
-itcl::body Rappture::Scroller::_fixframe {which} {
-    switch -- $which {
-        inner {
-            set w [winfo reqwidth $_frame.f]
-            set h [winfo reqheight $_frame.f]
-            $_frame configure -scrollregion [list 0 0 $w $h]
-            _fixframe outer
-            _lock reset x
-            _lock reset y
-            $_dispatcher event -idle !fixsize
-        }
-        outer {
-            if {[winfo width $_frame] > [winfo reqwidth $_frame.f]} {
-                $_frame itemconfigure frame -width [winfo width $_frame]
-            } else {
-                $_frame itemconfigure frame -width 0
-            }
-            if {[winfo height $_frame] > [winfo reqheight $_frame.f]} {
-                $_frame itemconfigure frame -height [winfo height $_frame]
-            } else {
-                $_frame itemconfigure frame -height 0
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixsize
-#
-# Used internally to update the size options for the widget
-# whenever the -width/-height options change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Scroller::_fixsize {} {
-    if {$itk_option(-width) == "0" && $itk_option(-height) == "0"} {
-        # for default size, let the frame being controlled set the size
-        grid propagate $itk_component(hull) yes
-        if {$_frame == "$itk_component(hull).ifr"} {
-            set w [expr {[winfo reqwidth $_frame.f]+2}]
-            set h [winfo reqheight $_frame.f]
-            $_frame configure -width $w -height $h
-        }
-    } else {
-        # for specific size, set the overall size of the widget
-        grid propagate $itk_component(hull) no
-        set w $itk_option(-width); if {$w == "0"} { set w 1i }
-        set h $itk_option(-height); if {$h == "0"} { set h 1i }
-        component hull configure -width $w -height $h
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _lock set <which>
-# USAGE: _lock reset <which>
-# USAGE: _lock active <which>
+itcl::body Rappture::Scroller::_fixframe {} {
+    $_frame configure -scrollregion [$_frame bbox all]
+}
+
+# ----------------------------------------------------------------------
+# USAGE: _lock set
+# USAGE: _lock reset
+# USAGE: _lock active
 #
 # Used internally to lock out vibrations when the x-scrollbar pops
@@ -367,16 +210,16 @@
 # up.
 # ----------------------------------------------------------------------
-itcl::body Rappture::Scroller::_lock {option which} {
+itcl::body Rappture::Scroller::_lock {option} {
     switch -- $option {
         set {
-            set _lock($which) 1
-            after cancel [itcl::code $this _lock reset $which]
-            after 50 [itcl::code $this _lock reset $which]
+            set _lock 1
+            after cancel [itcl::code $this _lock reset]
+            after 50 [itcl::code $this _lock reset]
         }
         reset {
-            set _lock($which) 0
+            set _lock 0
         }
         active {
-            return $_lock($which)
+            return $_lock
         }
         default {
@@ -401,25 +244,17 @@
 
 # ----------------------------------------------------------------------
-# OPTION: -xscrollside
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Scroller::xscrollside {
-    _fixsbar x
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -yscrollside
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Scroller::yscrollside {
-    _fixsbar y
-}
-
-# ----------------------------------------------------------------------
 # OPTION: -width
 # ----------------------------------------------------------------------
 itcl::configbody Rappture::Scroller::width {
-    # check for proper value
-    winfo pixels $itk_component(hull) $itk_option(-width)
-
-    $_dispatcher event -idle !fixsize
+    if {$itk_option(-width) == "0"} {
+        if {$itk_option(-width) == "0"} {
+            grid propagate $itk_component(hull) yes
+        } else {
+            component hull configure -width 1i
+        }
+    } else {
+        grid propagate $itk_component(hull) no
+        component hull configure -width $itk_option(-width)
+    }
 }
 
@@ -428,7 +263,13 @@
 # ----------------------------------------------------------------------
 itcl::configbody Rappture::Scroller::height {
-    # check for proper value
-    winfo pixels $itk_component(hull) $itk_option(-height)
-
-    $_dispatcher event -idle !fixsize
-}
+    if {$itk_option(-height) == "0"} {
+        if {$itk_option(-height) == "0"} {
+            grid propagate $itk_component(hull) yes
+        } else {
+            component hull configure -height 1i
+        }
+    } else {
+        grid propagate $itk_component(hull) no
+        component hull configure -height $itk_option(-height)
+    }
+}
Index: trunk/gui/scripts/sequence.tcl
===================================================================
--- trunk/gui/scripts/sequence.tcl	(revision 6716)
+++ 	(revision )
@@ -1,271 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: sequence - represents a sequence of output results
-#
-#  This object represents a sequence of other output results.  Each
-#  element in the sequence has an index and a value.  All values in
-#  the sequence must have the same type, but they can all be curves,
-#  images, or other results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture { # forward declaration }
-
-itcl::class Rappture::Sequence {
-    constructor {xmlobj path} { # defined below }
-    destructor { # defined below }
-
-    public method value {pos}
-    public method label {pos}
-    public method index {pos}
-    public method size {}
-    public method hints {{keyword ""}}
-
-    private variable _xmlobj ""  ;# ref to lib obj with sequence data
-    private variable _dataobjs   ;# maps index => data object
-    private variable _labels     ;# maps index => labels
-    private variable _indices    ;# list of sorted index values
-    private variable _hints      ;# cache of hints stored in XML
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Sequence::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be LibraryObj"
-    }
-    set _xmlobj [$xmlobj element -as object $path]
-
-    #
-    # Extract data values from the element definitions.
-    #
-    foreach name [$_xmlobj children -type element] {
-        set index [$xmlobj get $path.$name.index]
-        if {"" == $index} {
-            continue
-        }
-
-        # check for an element about.label stanza
-        set elelabel [$xmlobj get $path.$name.about.label]
-
-        set ctype ""
-        set _dataobjs($index) ""
-        set _labels($index) ""
-        foreach cname [$_xmlobj children $name] {
-            set type [$xmlobj element -as type $path.$name.$cname]
-            switch -- $type {
-                index {
-                    # ignore this
-                    continue
-                }
-                about {
-                    # ignore this
-                    continue
-                }
-                curve {
-                    set obj [Rappture::Curve ::\#auto $xmlobj $path.$name.$cname]
-                }
-                drawing {
-                    set obj [Rappture::Drawing ::\#auto $xmlobj $path.$name.$cname]
-                }
-                datatable {
-                    set obj [Rappture::DataTable ::\#auto $xmlobj $path.$name.$cname]
-                }
-                histogram {
-                    set obj [Rappture::Histogram ::\#auto $xmlobj $path.$name.$cname]
-                }
-                field {
-                    set obj [Rappture::Field ::\#auto $xmlobj $path.$name.$cname]
-                }
-                image {
-                    set obj [Rappture::Image ::\#auto $xmlobj $path.$name.$cname]
-                }
-                map {
-                    set obj [Rappture::Map ::\#auto $xmlobj $path.$name.$cname]
-                }
-                mesh {
-                    set obj [Rappture::Mesh ::\#auto $xmlobj $path.$name.$cname]
-                }
-                structure {
-                    # extract unique result set prefix
-                    scan $xmlobj "::libraryObj%d" rset
-
-                    # object rooted at x.sequence(y).element(z).structure
-                    set obj [$xmlobj element -as object $path.$name.$cname]
-
-                    # scene id (sequence id)
-                    set sceneid [$xmlobj element -as id $path]-$rset
-
-                    # sequence/element/frame number starting at 1
-                    set frameid [expr [$xmlobj element -as id $path.$name] + 1]
-
-                    # only supporting one molecule per structure at the moment
-                    # otherwise should go through all children that are molecules
-                    # and insert scene/frame data.
-                    $obj put "components.molecule.state" $frameid
-                    $obj put "components.molecule.model" $sceneid
-                }
-                default {
-                    error "don't know how to handle sequences of $type"
-                }
-            }
-            if {"" == $ctype} {
-                set ctype $type
-            }
-            if {$type == $ctype} {
-                lappend _dataobjs($index) $obj
-                set _labels($index) $elelabel
-            } else {
-                itcl::delete object $obj
-            }
-        }
-    }
-    #
-    # Generate a list of sorted index values.
-    #
-    set units [$xmlobj get $path.index.units]
-    if {"" != $units} {
-        # build up a list:  {10m 10} {10cm 0.1} ...
-        set vals ""
-        foreach key [array names _dataobjs] {
-            lappend vals [list $key [Rappture::Units::convert $key \
-                -context $units -to $units -units off]]
-        }
-
-        # sort according to raw values; store both values
-        set _indices [lsort -real -index 1 $vals]
-    } else {
-        # are the indices integers, reals, or strings?
-        set how -integer
-        foreach key [array names _dataobjs] {
-            if {[regexp {^[0-9]+[eE][-+]?[0-9]+|([0-9]+)?\.[0-9]+([eE][-+]?[0-9]+)?$} $key]} {
-                set how -real
-                break
-            } elseif {![regexp {^[0-9]+$} $key]} {
-                set how -dictionary
-                break
-            }
-        }
-
-        # keep a list of indices sorted in order
-        set _indices ""
-        if {[string equal $how -dictionary]} {
-            set n 0
-            foreach val [lsort $how [array names _dataobjs]] {
-                lappend _indices [list $val $n]
-                incr n
-            }
-        } else {
-            foreach val [lsort $how [array names _dataobjs]] {
-                lappend _indices [list $val $val]
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Sequence::destructor {} {
-    foreach key [array names _dataobjs] {
-        eval itcl::delete object $_dataobjs($key)
-    }
-    itcl::delete object $_xmlobj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value <pos>
-#
-# Returns the value for the element as position <pos> in the
-# list of all elements.  Here, <pos> runs from 0 to size-1.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Sequence::value {pos} {
-    set i [lindex [lindex $_indices $pos] 0]
-
-    # FIXME:  This is a bandaid on what appears to be a timing problem.
-    # This "dataobjs" method is now called before any sequence frames
-    # have been added.
-    if { ![info exists _dataobjs($i)] } {
-        return ""
-    }
-
-    return $_dataobjs($i)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label <pos>
-#
-# Returns the label for the element as position <pos> in the
-# list of all elements.  Here, <pos> runs from 0 to size-1.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Sequence::label {pos} {
-    set i [lindex [lindex $_indices $pos] 0]
-
-    # FIXME:  This is a bandaid on what appears to be a timing problem.
-    # This "label" method is now called before any sequence frames
-    # have been added.
-    if { ![info exists _labels($i)] } {
-        return ""
-    }
-
-    return $_labels($i)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: index <pos>
-#
-# Returns information about the index value for the element at
-# position <pos> in the list of all elements.  The return value is
-# a list of two elements:  {string rawNumberValue}.  Here, <pos>
-# runs from 0 to size-1.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Sequence::index {pos} {
-    return [lindex $_indices $pos]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: size
-#
-# Returns the number of elements in this sequence.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Sequence::size {} {
-    return [llength $_indices]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about showing
-# this image.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Sequence::hints {{keyword ""}} {
-    if {![info exists _hints]} {
-        foreach {key path} {
-            label        about.label
-            indexlabel   index.label
-            indexdesc    index.description
-        } {
-            set str [$_xmlobj get $path]
-            if {"" != $str} {
-                set _hints($key) $str
-            }
-        }
-    }
-
-    if {$keyword != ""} {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
-        }
-        return ""
-    }
-    return [array get _hints]
-}
Index: trunk/gui/scripts/sequencedial.tcl
===================================================================
--- trunk/gui/scripts/sequencedial.tcl	(revision 6716)
+++ 	(revision )
@@ -1,843 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Sequencedial - selector, like the dial on a car radio
-#
-#  This widget looks like the dial on an old-fashioned car radio.
-#  It draws a series of values along an axis, and allows a selector
-#  to move back and forth to select the values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *SequenceDial.thickness 10 widgetDefault
-option add *SequenceDial.length 2i widgetDefault
-option add *SequenceDial.knobImage knob widgetDefault
-option add *SequenceDial.knobPosition n@middle widgetDefault
-option add *SequenceDial.dialOutlineColor black widgetDefault
-option add *SequenceDial.dialFillColor white widgetDefault
-option add *SequenceDial.lineColor gray widgetDefault
-option add *SequenceDial.activeLineColor black widgetDefault
-option add *SequenceDial.padding 0 widgetDefault
-option add *SequenceDial.valueWidth 10 widgetDefault
-option add *SequenceDial.valuePadding 0.1 widgetDefault
-option add *SequenceDial.foreground black widgetDefault
-option add *SequenceDial.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::SequenceDial {
-    inherit itk::Widget
-
-    itk_option define -min min Min ""
-    itk_option define -max max Max ""
-    itk_option define -variable variable Variable ""
-
-    itk_option define -thickness thickness Thickness 0
-    itk_option define -length length Length 0
-    itk_option define -padding padding Padding 0
-
-    itk_option define -foreground foreground Foreground "black"
-    itk_option define -dialoutlinecolor dialOutlineColor Color "black"
-    itk_option define -dialfillcolor dialFillColor Color "white"
-    itk_option define -dialprogresscolor dialProgressColor Color ""
-    itk_option define -linecolor lineColor Color "black"
-    itk_option define -activelinecolor activeLineColor Color "black"
-    itk_option define -knobimage knobImage KnobImage ""
-    itk_option define -knobposition knobPosition KnobPosition ""
-
-    itk_option define -font font Font ""
-    itk_option define -valuewidth valueWidth ValueWidth 0
-    itk_option define -valuepadding valuePadding ValuePadding 0
-
-    itk_option define -interactcommand interactCommand InteractCommand ""
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method add {label {value ""}}
-    public method clear {}
-    public method get {args}
-    public method current {args}
-    public method color {value}
-
-    protected method _setCurrent {val}
-    protected method _redraw {}
-    protected method _click {x y}
-    protected method _navigate {offset}
-    protected method _limits {}
-    protected method _findLabel {str}
-    protected method _fixSize {}
-    protected method _fixValue {args}
-    protected method _doInteract {}
-
-    private method EventuallyRedraw {}
-    private variable _redrawPending 0
-    private variable _afterId -1
-    private variable _values ""       ;# list of all values on the dial
-    private variable _val2label       ;# maps value => string label(s)
-    private variable _current ""      ;# current value (where pointer is)
-    private variable _variable ""     ;# variable associated with -variable
-
-    private variable _knob ""         ;# image for knob
-    private variable _spectrum ""     ;# width allocated for values
-    private variable _activecolor ""  ;# width allocated for values
-    private variable _vwidth 0        ;# width allocated for values
-}
-
-itk::usual SequenceDial {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::constructor {args} {
-    itk_component add dial {
-        canvas $itk_interior.dial
-    }
-    pack $itk_component(dial) -expand yes -fill both
-    bind $itk_component(dial) <Configure> [itcl::code $this EventuallyRedraw]
-
-#    bind $itk_component(dial) <ButtonPress-1> [itcl::code $this _click %x %y]
-    bind $itk_component(dial) <B1-Motion> [itcl::code $this _click %x %y]
-#    bind $itk_component(dial) <ButtonRelease-1> [itcl::code $this _click %x %y]
-
-    bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate -1]
-    bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate 1]
-
-    eval itk_initialize $args
-
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::destructor {} {
-    configure -variable ""  ;# remove variable trace
-    after cancel $_afterId
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <label> ?<value>?
-#
-# Clients use this to add new values to the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::add {label {value ""}} {
-    if {"" == $value} {
-        set value [llength $_values]
-    }
-
-    # Add this value if we've never see it before
-    if {[lsearch -real $_values $value] < 0} {
-        lappend _values $value
-        set _values [lsort -real $_values]
-    }
-
-    # Keep all equivalent strings for this value.
-    # That way, we can later select either "1e18" or "1.0e+18"
-    lappend _val2label($value) $label
-
-    if {"" == $_current} {
-        _setCurrent $value
-    }
-    EventuallyRedraw
-}
-
-itcl::body Rappture::SequenceDial::EventuallyRedraw {} {
-    if { !$_redrawPending } {
-        set _afterId [after 150 [itcl::code $this _redraw]]
-        event generate $itk_component(hull) <<Value>>
-        set _resizePending 1
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: clear
-#
-# Clients use this to remove all existing values from the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::clear {} {
-    set _values ""
-    _setCurrent ""
-    catch {unset _val2label}
-
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-format what? ?current|@index?
-#
-# Clients use this to query values within this radiodial.  With no
-# args, it returns a list of all values stored in the widget.  The
-# "current" arg requests only the current value on the radiodial.
-# The @index syntax can be used to request a particular value at
-# an index within the list of values.
-#
-# By default, this method returns the label for each value.  The
-# format option can be used to request the label, the value, or
-# both.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::get {args} {
-    Rappture::getopts args params {
-        value -format "label"
-    }
-    if {[llength $args] > 1} {
-        error "wrong # args: should be \"get ?-format f? ?current|@index\""
-    }
-    set index [lindex $args 0]
-    if {"" == $index} {
-        set ilist ""
-        for {set i 0} {$i < [llength $_values]} {incr i} {
-            lappend ilist $i
-        }
-    } elseif {"current" == $index} {
-        set ilist [lsearch -exact $_values $_current]
-        if {$ilist < 0} {
-            set ilist ""
-        }
-    } elseif {[regexp {^@([0-9]+|end)$} $index match i]} {
-        set ilist $i
-    }
-    if {[llength $ilist] == 1} {
-        set op set
-    } else {
-        set op lappend
-    }
-
-    set rlist ""
-    foreach i $ilist {
-        switch -- $params(-format) {
-            label {
-                set v [lindex $_values $i]
-                $op rlist [lindex $_val2label($v) 0]
-            }
-            value {
-                $op rlist [lindex $_values $i]
-            }
-            position {
-                foreach {min max} [_limits] break
-                set v [lindex $_values $i]
-                set frac [expr {double($v-$min)/($max-$min)}]
-                $op rlist $frac
-            }
-            all {
-                set v [lindex $_values $i]
-                foreach {min max} [_limits] break
-                set frac [expr {double($v-$min)/($max-$min)}]
-                set l [lindex $_val2label($v) 0]
-                $op rlist [list $l $v $frac]
-            }
-            default {
-                error "bad value \"$v\": should be label, value, position, all"
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current ?<newval>?
-#
-# Clients use this to get/set the current value for this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::current {args} {
-    if {[llength $args] == 0} {
-        return $_current
-    } elseif {[llength $args] == 1} {
-        set newval [lindex $args 0]
-        set n [_findLabel $newval]
-
-        # Don't use expr (?:) because it evaluates the resulting string.
-        # For example, it changes -0.020 to -0.02.
-        if { $n >= 0 } {
-            set rawval [lindex $_values $n]
-        } else {
-            set rawval ""
-        }
-        _setCurrent $rawval
-
-        EventuallyRedraw
-        event generate $itk_component(hull) <<Value>>
-
-        return $_current
-    }
-    error "wrong # args: should be \"current ?newval?\""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: color <value>
-#
-# Clients use this to query the color associated with a <value>
-# along the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::color {value} {
-    _findLabel $value  ;# make sure this label is recognized
-
-    if {"" != $_spectrum} {
-        foreach {min max} [_limits] break
-        set frac [expr {double($value-$min)/($max-$min)}]
-        set color [$_spectrum get $frac]
-    } else {
-        if {$value == $_current} {
-            set color $_activecolor
-        } else {
-            set color $itk_option(-linecolor)
-        }
-    }
-    return $color
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _setCurrent <value>
-#
-# Called automatically whenever the widget changes size to redraw
-# all elements within it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_setCurrent {value} {
-    set _current $value
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        if {[info exists _val2label($value)]} {
-            set var [lindex $_val2label($value) 0]
-        } else {
-            set var $value
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Called automatically whenever the widget changes size to redraw
-# all elements within it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_redraw {} {
-
-    set _redrawPending 0
-
-    set c $itk_component(dial)
-    $c delete all
-
-    set fg $itk_option(-foreground)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set p [winfo pixels $c $itk_option(-padding)]
-    set t [expr {$itk_option(-thickness)+1}]
-    set y1 [expr {$h-1}]
-
-    if {"" != $_knob} {
-        set kw [image width $_knob]
-        set kh [image height $_knob]
-
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top {
-                set extra [expr {$t-$kh}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-            n@middle - nw@middle - ne@middle {
-                set extra [expr {int(ceil($kh-0.5*$t))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-            n@bottom - nw@bottom - ne@bottom {
-                set y1 [expr {$h-$kh-1}]
-            }
-
-            e@top - w@top - center@top -
-            e@bottom - w@bottom - center@bottom {
-                set extra [expr {int(ceil(0.5*$kh))}]
-                set y1 [expr {$h-$extra-1}]
-            }
-            e@middle - w@middle - center@middle {
-                set extra [expr {int(ceil(0.5*($kh-$t)))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$h-$extra-1}]
-            }
-
-            s@top - sw@top - se@top -
-            s@middle - sw@middle - se@middle -
-            s@bottom - sw@bottom - se@bottom {
-                set y1 [expr {$h-2}]
-            }
-        }
-    }
-    set y0 [expr {$y1-$t}]
-    set x0 [expr {$p+1}]
-    set x1 [expr {$w-$_vwidth-$p-4}]
-    foreach {min max} [_limits] break
-
-    # draw the background rectangle
-    $c create rectangle $x0 $y0 $x1 $y1 \
-        -outline $itk_option(-dialoutlinecolor) \
-        -fill $itk_option(-dialfillcolor) -tags "range"
-
-    # draw the optional progress bar, from start to current
-    if {"" != $itk_option(-dialprogresscolor)
-          && [llength $_values] > 0 && "" != $_current} {
-        if {$max != $min} {
-            set frac [expr {double($_current-$min)/($max-$min)}]
-        } else {
-            set frac 0.
-        }
-        set xx1 [expr {$frac*($x1-$x0) + $x0}]
-        $c create rectangle [expr {$x0+1}] [expr {$y0+3}] $xx1 [expr {$y1-2}] \
-            -outline "" -fill $itk_option(-dialprogresscolor)
-    }
-
-    $c create rectangle $x0 $y0 $x1 $y1 -outline "" -fill "" -tags "range"
-
-    # draw lines for all values
-    if {$max > $min} {
-        foreach v $_values {
-            set frac [expr {double($v-$min)/($max-$min)}]
-            if {"" != $_spectrum} {
-                set color [$_spectrum get $frac]
-            } else {
-                if {$v == $_current} {
-                    set color $_activecolor
-                } else {
-                    set color $itk_option(-linecolor)
-                }
-            }
-            set thick [expr {($v == $_current) ? 3 : 1}]
-
-            if {"" != $color} {
-                set x [expr {$frac*($x1-$x0) + $x0}]
-                $c create line $x [expr {$y0+1}] $x $y1 \
-                    -fill $color -width $thick
-            }
-        }
-
-        if {"" != $_current} {
-            set x [expr {double($_current-$min)/($max-$min)*($x1-$x0) + $x0}]
-            regexp {([nsew]+|center)@} $itk_option(-knobposition) match anchor
-            switch -glob -- $itk_option(-knobposition) {
-                *@top    { set kpos $y0 }
-                *@middle { set kpos [expr {int(ceil(0.5*($y1+$y0)))}] }
-                *@bottom { set kpos $y1 }
-            }
-            $c create image $x $kpos -anchor $anchor -image $_knob -tags "knob"
-        }
-    }
-
-    $c bind range <ButtonPress-1> [itcl::code $this _click %x %y]
-    $c bind range <ButtonRelease-1> [itcl::code $this _click %x %y]
-
-    # Only need release event for knob.
-    $c bind knob <ButtonRelease-1> [itcl::code $this _click %x %y]
-
-    # if the -valuewidth is > 0, then make room for the value
-    set vw $itk_option(-valuewidth)
-    if {$vw > 0 && "" != $_current} {
-        set str [lindex $_val2label($_current) 0]
-        if {[string length $str] >= $vw} {
-            set str "[string range $str 0 [expr {$vw-3}]]..."
-        }
-
-        set dy [expr {([font metrics $itk_option(-font) -linespace]
-                        - [font metrics $itk_option(-font) -ascent])/2}]
-
-        set id [$c create text [expr {$x1+4}] [expr {($y1+$y0)/2+$dy}] \
-            -anchor w -text $str -font $itk_option(-font) -foreground $fg]
-        foreach {x0 y0 x1 y1} [$c bbox $id] break
-        set x0 [expr {$x0 + 10}]
-
-        # set up a tooltip so you can mouse over truncated values
-        Rappture::Tooltip::text $c [lindex $_val2label($_current) 0]
-        $c bind $id <Enter> \
-            [list ::Rappture::Tooltip::tooltip pending %W +$x0,$y1]
-        $c bind $id <Leave> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-        $c bind $id <ButtonPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-        $c bind $id <KeyPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _click <x> <y>
-#
-# Called automatically whenever the user clicks or drags on the widget
-# to select a value.  Moves the current value to the one nearest the
-# click point.  If the value actually changes, it generates a <<Value>>
-# event to notify clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_click {x y} {
-    set c $itk_component(dial)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set x0 1
-    set x1 [expr {$w-$_vwidth-4}]
-
-    focus $itk_component(hull)
-
-    # draw lines for all values
-    foreach {min max} [_limits] break
-    if {$max > $min && $x >= $x0 && $x <= $x1} {
-        set dmin $w
-        set xnearest 0
-        set vnearest ""
-        foreach v $_values {
-            set xv [expr {double($v-$min)/($max-$min)*($x1-$x0) + $x0}]
-            if {abs($xv-$x) < $dmin} {
-                set dmin [expr {abs($xv-$x)}]
-                set xnearest $xv
-                set vnearest $v
-            }
-        }
-
-        if {$vnearest != $_current} {
-            _setCurrent $vnearest
-            EventuallyRedraw
-
-            #event generate $itk_component(hull) <<Value>>
-            _doInteract
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_navigate {offset} {
-    set index [lsearch -exact $_values $_current]
-    if {$index >= 0} {
-        incr index $offset
-        if {$index >= [llength $_values]} {
-            set index [expr {[llength $_values]-1}]
-        } elseif {$index < 0} {
-            set index 0
-        }
-
-        set newval [lindex $_values $index]
-        if {$newval != $_current} {
-            _setCurrent $newval
-            EventuallyRedraw
-
-            event generate $itk_component(hull) <<Value>>
-            _doInteract
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _limits
-#
-# Used internally to compute the overall min/max limits for the
-# radio dial.  Returns {min max}, representing the end values for
-# the scale.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_limits {} {
-    if {[llength $_values] == 0} {
-        set min 0
-        set max 0
-    } else {
-        set min [lindex $_values 0]
-        set max $min
-        foreach v [lrange $_values 1 end] {
-            if {$v < $min} { set min $v }
-            if {$v > $max} { set max $v }
-        }
-        set del [expr {$max-$min}]
-        set min [expr {$min-$itk_option(-valuepadding)*$del}]
-        set max [expr {$max+$itk_option(-valuepadding)*$del}]
-    }
-
-    if {"" != $itk_option(-min)} {
-        set min $itk_option(-min)
-    }
-    if {"" != $itk_option(-max)} {
-        set max $itk_option(-max)
-    }
-    return [list $min $max]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _findLabel <string>
-#
-# Used internally to search for the given <string> label among the
-# known values.  Returns an index into the _values list, or throws
-# an error if the string is not recognized.  Given the null string,
-# it returns -1, indicating that the value is not in _values, but
-# it is valid.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_findLabel {str} {
-    if {"" == $str} {
-        return -1
-    }
-    for {set nv 0} {$nv < [llength $_values]} {incr nv} {
-        set v [lindex $_values $nv]
-        if {[lsearch -exact $_val2label($v) $str] >= 0} {
-            return $nv
-        }
-    }
-
-    # didn't match -- build a return string of possible values
-    set labels ""
-    foreach vlist $_values {
-        foreach v $vlist {
-            lappend labels "\"$_val2label($v)\""
-        }
-    }
-    error "bad value \"$str\": should be one of [join $labels ,]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Used internally to compute the overall size of the widget based
-# on the -thickness and -length options.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_fixSize {} {
-    set h [winfo pixels $itk_component(hull) $itk_option(-thickness)]
-
-    if {"" != $_knob} {
-        set kh [image height $_knob]
-
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top -
-            s@bottom - sw@bottom - se@bottom {
-                if {$kh > $h} { set h $kh }
-            }
-            n@middle - nw@middle - ne@middle -
-            s@middle - sw@middle - se@middle {
-                set h [expr {int(ceil(0.5*$h + $kh))}]
-            }
-            n@bottom - nw@bottom - ne@bottom -
-            s@top - sw@top - se@top {
-                set h [expr {$h + $kh}]
-            }
-            e@middle - w@middle - center@middle {
-                set h [expr {(($h > $kh) ? $h : $kh) + 1}]
-            }
-            n@middle - ne@middle - nw@middle -
-            s@middle - se@middle - sw@middle {
-                set extra [expr {int(ceil($kh-0.5*$h))}]
-                if {$extra < 0} { set extra 0 }
-                set h [expr {$h+$extra}]
-            }
-        }
-    }
-    incr h 1
-
-    set w [winfo pixels $itk_component(hull) $itk_option(-length)]
-
-    # if the -valuewidth is > 0, then make room for the value
-    if {$itk_option(-valuewidth) > 0} {
-        set charw [font measure $itk_option(-font) "n"]
-        set _vwidth [expr {$itk_option(-valuewidth)*$charw}]
-        set w [expr {$w+$_vwidth+4}]
-    } else {
-        set _vwidth 0
-    }
-
-    $itk_component(dial) configure -width $w -height $h
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-
-    set newval $var
-    set n [_findLabel $newval]
-    set rawval [expr {($n >= 0) ? [lindex $_values $n] : ""}]
-    set _current $rawval  ;# set current directly, so we don't trigger again
-
-    EventuallyRedraw
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _doInteract
-#
-# Used internally to call the -interactcommand code whenever the user
-# changes the value of the widget.  This is different from the <<Value>>
-# event, which gets invoked whenever the value changes for any reason,
-# including programmatic changes.  If there is no command code, then
-# this does nothing.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceDial::_doInteract {} {
-    if {[string length $itk_option(-interactcommand)] > 0} {
-        uplevel #0 $itk_option(-interactcommand)
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -thickness
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::thickness {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -length
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::length {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -font
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::font {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuewidth
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::valuewidth {
-    if {![string is integer $itk_option(-valuewidth)]} {
-        error "bad value \"$itk_option(-valuewidth)\": should be integer"
-    }
-    _fixSize
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -foreground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::foreground {
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialoutlinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::dialoutlinecolor {
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialfillcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::dialfillcolor {
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialprogresscolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::dialprogresscolor {
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -linecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::linecolor {
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -activelinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::activelinecolor {
-    set val $itk_option(-activelinecolor)
-    if {[catch {$val isa ::Rappture::Spectrum} valid] == 0 && $valid} {
-        set _spectrum $val
-        set _activecolor ""
-    } elseif {[catch {winfo rgb $itk_component(hull) $val}] == 0} {
-        set _spectrum ""
-        set _activecolor $val
-    } elseif {"" != $val} {
-        error "bad value \"$val\": should be Spectrum object or color"
-    }
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobimage
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::knobimage {
-    if {[regexp {^image[0-9]+$} $itk_option(-knobimage)]} {
-        set _knob $itk_option(-knobimage)
-    } elseif {"" != $itk_option(-knobimage)} {
-        set _knob [Rappture::icon $itk_option(-knobimage)]
-    } else {
-        set _knob ""
-    }
-    _fixSize
-
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobposition
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::knobposition {
-    if {![regexp {^([nsew]+|center)@(top|middle|bottom)$} $itk_option(-knobposition)]} {
-        error "bad value \"$itk_option(-knobposition)\": should be anchor@top|middle|bottom"
-    }
-    _fixSize
-
-    EventuallyRedraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -padding
-# This adds padding on left/right side of dial background.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::padding {
-    if {[catch {winfo pixels $itk_component(hull) $itk_option(-padding)}]} {
-        error "bad value \"$itk_option(-padding)\": should be size in pixels"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuepadding
-# This shifts min/max limits in by a fraction of the overall size.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::valuepadding {
-    if {![string is double $itk_option(-valuepadding)]
-          || $itk_option(-valuepadding) < 0} {
-        error "bad value \"$itk_option(-valuepadding)\": should be >= 0.0"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SequenceDial::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
Index: trunk/gui/scripts/sequenceresult.tcl
===================================================================
--- trunk/gui/scripts/sequenceresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,611 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: sequenceresult - series of results forming an animation
-#
-#  This widget displays a series of results of the same type that are
-#  grouped together and displayed as an animation.  The user can play
-#  through the results, or single step through individual values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *SequenceResult.width 3i widgetDefault
-option add *SequenceResult.height 3i widgetDefault
-option add *SequenceResult.controlBackground gray widgetDefault
-option add *SequenceResult.dialProgressColor #ccccff widgetDefault
-option add *SequenceResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-option add *SequenceResult.boldFont \
-    -*-helvetica-bold-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::SequenceResult {
-    inherit itk::Widget
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method download {option args}
-
-    public method play {{why -program}}
-    public method pause {{why -program}}
-    public method goto {{newval ""}}
-
-    protected method _rebuild {args}
-    protected method _playFrame {}
-    protected method _fixValue {}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-    private variable _dlist ""      ;# list of data objects
-    private variable _topmost ""    ;# topmost data object in _dlist
-    private variable _indices ""    ;# list of active indices
-    private variable _pos 0         ;# current position in the animation
-    private variable _afterId ""    ;# current "after" event for play op
-
-    private common _play            ;# options for "play" operation
-    set _play(speed) 60
-    set _play(loop) 0
-}
-
-itk::usual SequenceResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild [itcl::code $this _rebuild]
-
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add player {
-        frame $itk_interior.player
-    }
-    pack $itk_component(player) -side bottom -fill x
-    grid columnconfigure $itk_component(player) 1 -weight 1
-
-    itk_component add play {
-        button $itk_component(player).play \
-            -bitmap [Rappture::icon play] \
-            -command [itcl::code $this play -user]
-    }
-    grid $itk_component(play) -row 0 -rowspan 2 -column 0 \
-        -ipadx 2 -padx {0 4} -pady 4 -sticky nsew
-
-    itk_component add dial {
-        Rappture::SequenceDial $itk_component(player).dial \
-            -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \
-            -linecolor "" -activelinecolor "" \
-            -knobimage [Rappture::icon knob2] -knobposition center@middle
-    } {
-        usual
-        keep -dialprogresscolor
-    }
-    grid $itk_component(dial) -row 1 -column 1 -sticky ew
-    bind $itk_component(dial) <<Value>> [itcl::code $this _fixValue]
-
-    # use this command for logging "goto" interactions
-    $itk_component(dial) configure -interactcommand \
-        [format {Rappture::Logger::log sequence goto [%s get -format label current]} $itk_component(dial)]
-
-    itk_component add info {
-        frame $itk_component(player).info
-    }
-    grid $itk_component(info) -row 0 -column 1 -columnspan 2 -sticky ew
-
-    itk_component add indexLabel {
-        label $itk_component(info).ilabel
-    } {
-        usual
-        rename -font -boldfont boldFont Font
-    }
-    pack $itk_component(indexLabel) -side left
-
-    itk_component add indexValue {
-        label $itk_component(info).ivalue -padx 0
-    }
-    pack $itk_component(indexValue) -side left
-
-    # add an element.about.label stanza
-    itk_component add eleLabel {
-        label $itk_component(info).elabel -padx 10
-    }
-    pack $itk_component(eleLabel) -side left
-
-    itk_component add options {
-        button $itk_component(player).options -text "Options..." \
-            -padx 1 -pady 0 -relief flat -overrelief raised
-    }
-    grid $itk_component(options) -row 1 -column 2 -sticky sw
-
-    #
-    # Popup option panel
-    #
-    set fn [option get $itk_component(hull) font Font]
-    set bfn [option get $itk_component(hull) boldFont Font]
-
-    Rappture::Balloon $itk_component(hull).popup \
-        -title "Player Settings" -padx 4 -pady 4
-    set inner [$itk_component(hull).popup component inner]
-
-    label $inner.loopl -text "Loop:" -font $bfn
-    grid $inner.loopl -row 0 -column 0 -sticky e
-    radiobutton $inner.loopOn -text "Play once and stop" -font $fn \
-        -variable ::Rappture::SequenceResult::_play(loop) -value 0
-    grid $inner.loopOn -row 0 -column 1 -sticky w
-    radiobutton $inner.loopOff -text "Play continuously" -font $fn \
-        -variable ::Rappture::SequenceResult::_play(loop) -value 1
-    grid $inner.loopOff -row 1 -column 1 -sticky w
-    grid rowconfigure $inner 2 -minsize 8
-
-    label $inner.speedl -text "Speed:" -font $bfn
-    grid $inner.speedl -row 3 -column 0 -sticky e
-    frame $inner.speed
-    grid $inner.speed -row 3 -column 1 -sticky ew
-    label $inner.speed.slowl -text "Slower" -font $fn
-    pack $inner.speed.slowl -side left
-    ::scale $inner.speed.value -from 100 -to 1 \
-        -showvalue 0 -orient horizontal \
-        -variable ::Rappture::SequenceResult::_play(speed)
-    pack $inner.speed.value -side left
-    label $inner.speed.fastl -text "Faster" -font $fn
-    pack $inner.speed.fastl -side left
-
-    $itk_component(options) configure -command \
-        [list $itk_component(hull).popup activate $itk_component(options) above]
-
-    #
-    # Main viewer
-    #
-    itk_component add area {
-        frame $itk_interior.area
-    }
-    pack $itk_component(area) -expand yes -fill both
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::destructor {} {
-    pause  ;# stop any animation that might be playing
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <sequence> ?<settings>?
-#
-# Clients use this to add a data sequence to the viewer.  The optional
-# <settings> are used to configure the display of the data.  Allowed
-# settings are -color, -brightness, -width, -linestyle and -raise.
-# The only setting used here is -raise, which indicates the current
-# object.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -raise 0
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    if {$params(-raise) && "" == $_topmost} {
-        set _topmost $dataobj
-    }
-    lappend _dlist $dataobj
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of data objects being displayed,
-# in order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-
-    set i [lsearch $_dlist $_topmost]
-    if {$i >= 0} {
-        set dlist [lreplace $dlist $i $i]
-        set dlist [linsert $dlist 0 $_topmost]
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a data object from the viewer.  If no
-# data objects are specified, then all data objects are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-    pause
-
-    # delete all specified curves
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            set changed 1
-
-            if {$dataobj == $_topmost} {
-                set _topmost ""
-            }
-        }
-    }
-
-    # if anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all data objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all data objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::scale {args} {
-    # do nothing
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::download {option args} {
-    if { ![winfo exists $itk_component(area).viewer] } {
-        return "";      # No data, no viewer, no download.
-    }
-    switch $option {
-        coming {
-            return [$itk_component(area).viewer download coming]
-        }
-        controls {
-            return [eval $itk_component(area).viewer download controls $args]
-        }
-        now {
-            if {0} {
-                # produce a movie of results
-                set rval ""
-                if {"" != $_topmost} {
-                    set max [$_topmost size]
-                    set all ""
-                    for {set i 0} {$i < $max} {incr i} {
-                        set dataobj [lindex [$_topmost value $i] 0]
-                        if {[catch {$dataobj tkimage} imh] == 0} {
-                            lappend all $imh
-                        }
-                    }
-                    if {[llength $all] > 0} {
-                        set delay [expr {int(ceil(pow($_play(speed)/10.0+2,2.0)*15))}]
-                        set rval [eval Rappture::icon::gif_animate $delay $all]
-                    }
-                }
-                if {[string length $rval] > 0} {
-                    return [list .gif $rval]
-                }
-                return ""
-            }
-            # otherwise, return download of single frame
-            return [eval $itk_component(area).viewer download now $args]
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: play ?-user|-program?
-#
-# Invoked when the user hits the "play" button to play the current
-# sequence of frames as a movie.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::play {{why -program}} {
-    if { [llength $_indices] == 0 } {
-        return;                         # No frames (i.e. no data).
-    }
-
-    if {$why eq "-user"} {
-        Rappture::Logger::log sequence play -loop $_play(loop) -speed $_play(speed)
-    }
-
-    # Stop any existing animation.
-    pause
-
-    # At the end? then restart fresh
-    if {$_pos >= [llength $_indices]-1} {
-        goto 0
-    }
-
-    # Toggle the button to "pause" mode
-    $itk_component(play) configure \
-        -bitmap [Rappture::icon pause] \
-        -command [itcl::code $this pause -user]
-
-    global readyForNextFrame
-    set readyForNextFrame 1;            # By default, always ready
-    # Schedule the first frame
-    set delay [expr {int(ceil(pow($_play(speed)/10.0+2,2.0)*15))}]
-    set _afterId [after $delay [itcl::code $this _playFrame]]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: pause ?-user|-program?
-#
-# Invoked when the user hits the "pause" button to stop playing the
-# current sequence of frames as a movie.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::pause {{why -program}} {
-    if {$why eq "-user"} {
-        Rappture::Logger::log sequence pause
-    }
-
-    if {"" != $_afterId} {
-        catch {after cancel $_afterId}
-        set _afterId ""
-    }
-    global readyForNextFrame
-    set readyForNextFrame 1;            # By default, always ready
-
-    # Check if the play button still exists. We may be in the process
-    # of destroying the widget.
-    if { [info exists itk_component(play)] } {
-        # toggle the button to "play" mode
-        $itk_component(play) configure \
-            -bitmap [Rappture::icon play] \
-            -command [itcl::code $this play -user]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: goto ?<index>?
-#
-# Used internally to move the current position of the animation to
-# the frame at a particular <index>.  If the <index> is not specified,
-# then it returns the current position.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::goto {{newval ""}} {
-    if {"" == $newval} {
-        return $_pos
-    }
-    set _pos $newval
-    set val [$itk_component(dial) get -format label @$_pos]
-    $itk_component(dial) current $val
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _rebuild
-#
-# Invoked automatically whenever the data displayed in this viewer
-# changes.  Loads the data from the topmost (current) value into
-# the viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::_rebuild {args} {
-    if {"" == $_topmost && [llength $_dlist] > 0} {
-        set _topmost [lindex $_dlist 0]
-    }
-
-    #
-    # If we have any data, then show the viewer.
-    # Otherwise, hide it.
-    #
-    set w $itk_component(area).viewer
-    if {[winfo exists $w]} {
-        if {"" == $_topmost} {
-            pack forget $w
-            pack forget $itk_component(player)
-            return
-        } else {
-            pack $w -expand yes -fill both
-            pack $itk_component(player) -side bottom -fill x
-        }
-    } else {
-        if {"" == $_topmost} {
-            return
-        }
-
-        set type ""
-        if {[$_topmost size] > 0} {
-            set dataobj [lindex [$_topmost value 0] 0]
-            set type [$dataobj info class]
-        }
-        switch -- $type {
-            ::Rappture::Drawing {
-                Rappture::VtkViewer $w
-                pack $w -expand yes -fill both
-            }
-            ::Rappture::Curve {
-                Rappture::XyResult $w
-                pack $w -expand yes -fill both
-            }
-            ::Rappture::Histogram {
-                Rappture::HistogramResult $w
-                pack $w -expand yes -fill both
-            }
-            ::Rappture::DataTable {
-                Rappture::DataTable $w
-                pack $w -expand yes -fill both
-            }
-            ::Rappture::Image {
-                Rappture::ImageResult $w
-                pack $w -expand yes -fill both
-            }
-            ::Rappture::Field {
-                set dimensions ""
-                set dim ""
-                foreach dim [$dataobj components -dimensions] {
-                    # check to see if the dimensions are the same
-                    # for all elements of the field. i dont think
-                    # we can display fields of differing dimensions
-                    # within the same field object.
-                    if {"" != $dimensions} {
-                        if {$dimensions != $dim} {
-                            error "don't know how to view sequences of $type\
-                                with dimensions as follows:\
-                                [$dataobj components -dimensions]"
-                        }
-                    } else {
-                        set dimensions $dim
-                    }
-                }
-                set mode [$dataobj viewer]
-                Rappture::FieldResult $w -mode $mode
-                pack $w -expand yes -fill both
-            }
-            ::Rappture::Map {
-                Rappture::MapViewer $w
-                pack $w -expand yes -fill both
-            }
-            ::Rappture::Mesh {
-                Rappture::VtkMeshViewer $w
-                pack $w -expand yes -fill both
-            }
-            ::Rappture::LibraryObj {
-                switch -- [$dataobj element -as type] {
-                    structure {
-                        Rappture::DeviceResult $w
-                        pack $w -expand yes -fill both
-                    }
-                    default {
-                        error "don't know how to view sequences of [$dataobj element -as type]"
-                    }
-                }
-            }
-            default {
-                puts stderr "don't know how to view sequences of type \"$type\""
-                puts stderr "Is the sequence empty?"
-                return
-            }
-        }
-    }
-    #
-    # Load the current sequence info the viewer.
-    #
-    $itk_component(indexLabel) configure -text [$_topmost hints indexlabel]
-
-    $w delete
-    $itk_component(dial) clear
-
-    set max [$_topmost size]
-    set all ""
-    for {set i 0} {$i < $max} {incr i} {
-        eval lappend all [$_topmost value $i]
-    }
-    eval $w scale $all
-
-    set _indices ""
-    for {set i 0} {$i < $max} {incr i} {
-        set index [$_topmost index $i]
-        eval $itk_component(dial) add $index
-        lappend _indices [lindex $index 0]
-    }
-    _fixValue
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _playFrame
-#
-# Used internally to advance each frame in the animation.  Advances
-# the frame and displays it.  When we reach the end of the animation,
-# we either loop back or stop.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::_playFrame {} {
-    global readyForNextFrame
-    if { $readyForNextFrame } {
-        set _pos [expr {$_pos+1}]
-        set last [expr {[llength $_indices]-1}]
-
-        if {$_pos > $last} {
-            if {$_play(loop)} {
-                set _pos 0
-            } else {
-                set _pos $last
-                pause
-                return
-            }
-        }
-        goto $_pos
-        set delay [expr {int(ceil(pow($_play(speed)/10.0+2,2.0)*15))}]
-    } else {
-        set delay 50;                   # Poll for completion
-    }
-    set _afterId [after $delay [itcl::code $this _playFrame]]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue
-#
-# Invoked automatically whenever the value on the dial changes.
-# Updates the viewer to display the value for the selected result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SequenceResult::_fixValue {} {
-    set w $itk_component(area).viewer
-    if {![winfo exists $w]} {
-        return
-    }
-    $w delete
-    if { $_topmost == "" } {
-        return
-    }
-    set val [$itk_component(dial) get -format label current]
-    set _pos [lsearch -glob $_indices $val*]
-
-    # populate the label for this element
-    if { "" != [$_topmost hints indexlabel] } {
-        $itk_component(indexValue) configure -text "= $val"
-    }
-    $itk_component(eleLabel) configure -text "[$_topmost label $_pos]"
-    foreach dataobj [$_topmost value $_pos] {
-        set settings "-color autoreset -width 2"
-        if {[catch {$dataobj hints style} style] == 0} {
-            eval lappend settings $style
-        }
-        if { [catch {$dataobj hints type} type] == 0} {
-            if {"" != $type} {
-                lappend settings -type $type
-            }
-        }
-        $w add $dataobj $settings
-    }
-}
Index: trunk/gui/scripts/service.tcl
===================================================================
--- trunk/gui/scripts/service.tcl	(revision 6716)
+++ 	(revision )
@@ -1,316 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: service - represents a tool embedded within another tool
-#
-#  The tool.xml description for a Rappture tool can contain one or
-#  more embedded <tool> references.  Each Rappture::Service object
-#  represents an embedded <tool> and manages its operation,
-#  contributing some service to the overall tool.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require BLT
-
-itcl::class Rappture::Service {
-    constructor {owner path args} { # defined below }
-    destructor { # defined below }
-
-    public method control {}
-    public method input {}
-    public method output {args}
-
-    public method run {}
-    public method abort {}
-    public method clear {}
-
-    protected method _link {from to}
-
-    private variable _owner ""    ;# thing managing this service
-    private variable _path ""     ;# path to the <tool> description in _owner
-    private variable _tool ""     ;# underlying tool for this service
-    private variable _control ""  ;# control: auto/manual
-    private variable _show        ;# <show> info for input/output methods
-    private variable _obj2path    ;# maps object in _show => service path
-    private variable _path2widget ;# maps path for object in _show => widget
-    private variable _path2path   ;# maps path for object in _show => link path
-    private variable _result ""   ;# result from last run
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    #
-    # Load up the tool description from the <interface> file.
-    #
-    set intf [string trim [$_owner xml get $path.interface]]
-    if {"" == $intf} {
-        puts "can't find <interface> description for tool at $path"
-    } else {
-        set installdir [[$_owner tool] installdir]
-        regsub -all @tool $intf $installdir intf
-
-        set xmlobj [Rappture::library $intf]
-        set installdir [file dirname $intf]
-        set _tool [Rappture::Tool ::\#auto $xmlobj $installdir]
-        set _control [string trim [$_tool xml get tool.control]]
-
-        #
-        # Scan through the <tool> and establish all of the
-        # relationships:
-        #
-        #   <show> ... Add to list of "input" for this service.
-        #              Caller will add controls to the interface.
-        #
-        #   <link> ... Link this value to another input/output
-        #              that exists in the containing tool.
-        #
-        #   <set> .... Hard-code the value for this input/output.
-        #
-        foreach dir {input output} {
-            set _show($dir) ""
-            foreach cname [$_owner xml children $path.$dir] {
-                set ppath $path.$dir.$cname
-
-                set spath [string trim [$_owner xml get $ppath.path]]
-                if {"" == $spath} {
-                    error "missing <path> at $ppath"
-                }
-
-                set type [$_owner xml element -as type $ppath]
-                switch -- $type {
-                  show {
-puts "show: $spath"
-                      set tpath [string trim [$_owner xml get $ppath.to]]
-                      if {"" == $tpath && $dir == "input"} {
-                          error "missing <to> at $ppath"
-                      }
-                      set obj [$_tool xml element -as object $spath]
-                      puts " => $obj"
-                      lappend _show($dir) $obj
-                      set _obj2path($obj) $spath
-
-                      if {$dir == "input"} {
-                          puts "link: $tpath => $spath"
-                          $_owner notify add $this $tpath \
-                              [itcl::code $this _link $tpath $spath]
-                      }
-                  }
-                  link {
-                      set tpath [string trim [$_owner xml get $ppath.to]]
-                      if {"" == $tpath} {
-                          error "missing <to> at $ppath"
-                      }
-                      if {"" == [$_owner xml element $tpath]} {
-                          error "bad <to> path \"$tpath\" at $ppath"
-                      }
-                      if {$dir == "input"} {
-                          puts "link: $tpath => $spath"
-                          $_owner notify add $this $tpath \
-                              [itcl::code $this _link $tpath $spath]
-                      } else {
-                          puts "path2path: $spath => $tpath"
-                          set _path2path($spath) $tpath
-                      }
-                  }
-                    set {
-                        if {"" == [$_owner xml element $ppath.value]} {
-                        error "missing <value> at $ppath"
-                    }
-puts "set: $spath from $ppath.value"
-                    $_tool xml copy $spath from \
-                        [$_owner xml object] $ppath.value
-                  }
-                }
-            }
-        }
-
-        if {$_control != "auto"} {
-            set _show(control) [$_tool xml element -as object tool.control]
-        } else {
-            set _show(control) ""
-        }
-    }
-
-    eval configure $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::destructor {} {
-    foreach dir [array names _show] {
-        foreach obj $_show($dir) {
-            itcl::delete object $obj
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: control
-#
-# Used by the container that displays this service to determine what
-# the control for this service should look like.  Returns "" if
-# there is no control--the service is invoked automatically whenever
-# the inputs change.  Otherwise, it returns a list of the form
-# {key value key value ...} with attributes that configure the button
-# controlling this service.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::control {} {
-    return $_show(control)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: input
-#
-# Used by the container that displays this service to describe any
-# inputs for this service that should be added to the main service.
-# Returns a list of XML objects representing various input controls.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::input {} {
-    return $_show(input)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: output
-# USAGE: output for <object> <widget>
-#
-# Used by the container that displays this service to describe any
-# outputs for this service that should be added to the main service.
-#
-# With no args, it returns a list of XML objects representing various
-# outputs.  The caller uses this information to create various output
-# widgets.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::output {args} {
-    if {[llength $args] == 0} {
-        return $_show(output)
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        for {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"output for object widget\""
-            }
-            set obj [lindex $args 1]
-            set win [lindex $args 2]
-            if {[info exists _obj2path($obj)]} {
-                set path $_obj2path($obj)
-puts "OUTPUT $path => $win"
-                set _path2widget($path) $win
-            } else {
-                puts "error: don't recognize output object $obj"
-            }
-        }
-        default {
-            error "bad option \"$option\": should be for"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: run
-#
-# This method causes the service to run.  All widgets are synchronized
-# to the current XML representation, and a "driver.xml" file is
-# created as the input for the run.  That file is fed to the tool
-# according to the <tool><command> string, and the job is executed.
-#
-# All outputs are pushed out to the tool containing this service
-# according to the <outputs> directive for the service.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::run {} {
-puts "running..."
-    clear
-    foreach {status result} [$_tool run] break
-
-    if {$status == 0 && $result != "ABORT"} {
-        if {[regexp {=RAPPTURE-RUN=>([^\n]+)} $result match file]} {
-            set xmlobj [Rappture::library $file]
-            #
-            # Scan through all outputs and copy them to the final output
-            # for the tool.  If they have widgets associated with them,
-            # set the value for the widget.
-            #
-puts "showing output..."
-            foreach cname [$xmlobj children output] {
-                set path output.$cname
-puts " for $path"
-                $_owner xml copy $path from $xmlobj $path
-
-                if {[info exists _path2widget($path)]} {
-                    set obj [$xmlobj element -as object $path]
-puts " sending $obj to $_path2widget($path)"
-                    $_path2widget($path) value $obj
-                }
-                if {[info exists _path2path($path)]} {
-puts " sending $path to $_path2path($path)"
-                    $_owner xml copy $_path2path($path) from $xmlobj $path
-                    set w [$_owner widgetfor $_path2path($path)]
-                    if {$w != ""} {
-                        set obj [$_owner xml element -as object $_path2path($path)]
-                        $w value $obj
-                    }
-                }
-            }
-            set _result $xmlobj
-        } else {
-            set status 1
-            set result "Can't find result file in output:\n\n$result"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: abort
-#
-# Clients use this during a "run" to abort the current job.
-# Kills the job and forces the "run" method to return.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::abort {} {
-    $_tool abort
-}
-
-# ----------------------------------------------------------------------
-# USAGE: clear
-#
-# Clears any result hanging around from the last run.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::clear {} {
-    if {"" != $_result} {
-        foreach cname [$_result children output] {
-            set path output.$cname
-
-            if {[info exists _path2widget($path)]} {
-                $_path2widget($path) value ""
-            }
-        }
-        itcl::delete object $_result
-        set _result ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _link <fromPath> <toPath>
-#
-# Used internally to link the value at <fromPath> in the outer tool
-# to the value at <toPath> for this service.  If this service is
-# automatic and <toPath> is an input, this also invokes the service.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Service::_link {from to} {
-    $_tool xml copy $to from [$_owner xml object] $from
-    if {$_control == "auto" && [regexp -nocase {^input\.} $to]} {
-        after cancel [itcl::code $this run]
-        after idle [itcl::code $this run]
-    }
-}
Index: trunk/gui/scripts/sidebarframe.tcl
===================================================================
--- trunk/gui/scripts/sidebarframe.tcl	(revision 6716)
+++ 	(revision )
@@ -1,622 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: SidebarFrame - pop-out controls for visualization widgets
-#
-#  The sidebar provides a way to put a thin strip of controls along the
-#  side of a visualization widget, with tabs that cause control panels
-#  to pop out.  The SidebarFrame has an empty frame (component "frame")
-#  on the left and a sidebar that pops out on the right.
-# ======================================================================
-#  AUTHOR:  George Howlett, Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *SidebarFrame.width 3i widgetDefault
-option add *SidebarFrame.height 3i widgetDefault
-option add *SidebarFrame.titlebarBackground #6666cc widgetDefault
-option add *SidebarFrame.titlebarForeground white widgetDefault
-option add *SidebarFrame.controlBackground gray widgetDefault
-option add *SidebarFrame*cntls*highlightBackground gray widgetDefault
-option add *SidebarFrame.sashRelief flat widgetDefault
-option add *SidebarFrame.sashActiveRelief solid widgetDefault
-option add *SidebarFrame.sashColor gray widgetDefault
-option add *SidebarFrame.sashWidth 2 widgetDefault
-option add *SidebarFrame.sashPadding 2 widgetDefault
-option add *SidebarFrame.sashCursor sb_h_double_arrow
-
-itcl::class Rappture::SidebarFrame {
-    inherit itk::Widget
-
-    itk_option define -sashrelief sashRelief Relief ""
-    itk_option define -sashactiverelief sashActiveRelief SashActiveRelief ""
-    itk_option define -sashcolor sashColor SashColor ""
-    itk_option define -sashwidth sashWidth SashWidth 0
-    itk_option define -sashpadding sashPadding SashPadding 0
-    itk_option define -sashcursor sashCursor Cursor ""
-
-    public variable resizeframe 1
-    constructor {args} { # defined below }
-
-    public method insert {pos args}
-    public method exists {which}
-    public method panel {which}
-    public method select {which}
-    public method pop {what}
-    public method width { size } {
-        set _width $size
-    }
-    public method enable { which }
-    public method disable { which }
-
-    protected method _toggleTab {which}
-    protected method _sash {op x}
-    protected method _fixLayout {args}
-    protected method TabIndex { which }
-
-    private variable _dispatcher ""  ;# dispatcher for !events
-    private variable _state "closed" ;# sidebar open/closed
-    private variable _panels         ;# maps panel => title, etc.
-    private variable _selected ""    ;# selected panel
-    private variable _width "auto"   ;# width adjusted by sash or "auto"
-    private variable _counter 0      ;# counter for auto-generated names
-    private variable _title2panel
-}
-
-itk::usual SidebarFrame {
-    keep -background -cursor
-    keep -titlebarbackground -titlebarforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::constructor {args} {
-    itk_option add hull.width hull.height
-
-    # create a dispatcher for events
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !layout
-    $_dispatcher dispatch $this !layout [itcl::code $this _fixLayout]
-
-    # fix the layout whenever the window size changes
-    bind SidebarFrame <Configure> [itcl::code %W _fixLayout]
-
-    #
-    # Empty frame for main widget
-    #
-    itk_component add frame {
-        frame $itk_interior.f
-    }
-
-    #
-    # Sash along the left side of sidebar
-    #
-    itk_component add sashbg {
-        frame $itk_interior.sashbg
-    } {
-        usual
-        rename -cursor -sashcursor sashCursor Cursor
-    }
-
-    itk_component add sash {
-        frame $itk_component(sashbg).sash -borderwidth 1
-    } {
-        usual
-        ignore -background -borderwidth
-        rename -relief -sashrelief sashRelief Relief
-        rename -width -sashwidth sashWidth SashWidth
-        rename -cursor -sashcursor sashCursor Cursor
-    }
-    pack $itk_component(sash) -side left -fill y
-
-    foreach c {sash sashbg} {
-        bind $itk_component($c) <Enter> \
-            [itcl::code $this _sash enter %X]
-        bind $itk_component($c) <Leave> \
-            [itcl::code $this _sash leave %X]
-        bind $itk_component($c) <ButtonPress-1> \
-            [itcl::code $this _sash grab %X]
-        bind $itk_component($c) <B1-Motion> \
-            [itcl::code $this _sash drag %X]
-        bind $itk_component($c) <ButtonRelease-1> \
-            [itcl::code $this _sash release %X]
-    }
-
-    itk_component add sidebar {
-        frame $itk_interior.sbar
-    }
-
-    #
-    # Title bar along top of sidebar
-    #
-    itk_component add titlebar {
-        frame $itk_component(sidebar).tbar -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -titlebarbackground titlebarBackground Background
-    }
-    pack $itk_component(titlebar) -side top -fill x
-
-    itk_component add popbutton {
-        button $itk_component(titlebar).popb \
-            -borderwidth 1 -relief flat -overrelief raised \
-            -highlightthickness 0 \
-            -image [Rappture::icon sbar-open] \
-            -command [itcl::code $this pop toggle]
-    } {
-        usual
-        ignore -borderwidth -relief -overrelief -highlightthickness
-        rename -background -titlebarbackground titlebarBackground Background
-        rename -activebackground -titlebarbackground titlebarBackground Background
-    }
-    pack $itk_component(popbutton) -side left -padx 6 -pady 2
-    Rappture::Tooltip::for $itk_component(popbutton) \
-        "Open/close the sidebar"
-
-    itk_component add title {
-        label $itk_component(titlebar).title -anchor w -font "Arial 10"
-    } {
-        usual
-        ignore -font
-        rename -foreground -titlebarforeground titlebarForeground Foreground
-        rename -background -titlebarbackground titlebarBackground Background
-    }
-    pack $itk_component(title) -side left -expand yes -fill both -padx 1 -pady 1
-
-    #
-    # Area for active panel
-    #
-    itk_component add area {
-        Rappture::Scroller $itk_component(sidebar).area \
-            -xscrollmode auto -yscrollmode auto \
-            -highlightthickness 0
-    }
-    $itk_component(area) contents frame
-
-    itk_component add controlbar {
-        frame $itk_component(sidebar).cbar
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    pack $itk_component(controlbar) -side left -fill y
-
-    #
-    # Control area above the tabs
-    #
-    itk_component add controls {
-        frame $itk_component(controlbar).cntls -height 20
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    pack $itk_component(controls) -side top -pady {8 20}
-
-    #
-    # Tabs used to select sidebar panels.
-    #
-    # Note:  Bugs in BLT 2.4 tabset/VNC server crashes the server
-    #        when -outerpad is set to 0.
-    #
-    itk_component add tabs {
-        blt::tabset $itk_component(controlbar).tabs \
-            -highlightthickness 0 -tearoff 0 -side left \
-            -bd 0 -gap 0 -tabborderwidth 1 \
-            -outerpad 1
-    } {
-        keep -background -cursor
-        ignore -highlightthickness -borderwidth
-        rename -highlightbackground -controlbackground controlBackground \
-            Background
-        rename -background -controlbackground controlBackground \
-            Background
-    }
-    pack $itk_component(tabs) -side top -expand yes -anchor e -padx {4 0} -fill y
-
-    eval itk_initialize $args
-
-    # make sure we fix up the layout at some point
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# USAGE: insert <pos> ?-title t? ?-icon i?
-#
-# Adds a new panel into this widget at the given position <pos>.  The
-# panel has a tab with the specified -icon, and is labeled by the
-# -title string in the titlebar area when it is selected.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::insert {pos args} {
-    Rappture::getopts args panel "
-        value -title Options
-        value -icon [Rappture::icon cboff]
-    "
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"insert pos ?-title t? ?-icon i?\""
-    }
-
-    set f [$itk_component(area) contents]
-    set pname "panel[incr _counter]"
-    itk_component add $pname {
-        frame $f.$pname
-    }
-
-    $itk_component(tabs) insert $pos $pname \
-        -image $panel(-icon) -text "" -padx 0 -pady 0 \
-        -command [itcl::code $this _toggleTab $pname]
-
-    set _title2panel($panel(-title)) $pname
-    Rappture::Tooltip::text $itk_component(tabs)-$pname \
-        "Open/close sidebar for $panel(-title)"
-    $itk_component(tabs) bind $pname <Enter> \
-        [list ::Rappture::Tooltip::tooltip pending %W-$pname @%X,%Y]
-    $itk_component(tabs) bind $pname <Leave> \
-        [list ::Rappture::Tooltip::tooltip cancel]
-    $itk_component(tabs) bind $pname <ButtonPress> \
-        [list ::Rappture::Tooltip::tooltip cancel]
-    $itk_component(tabs) bind $pname <KeyPress> \
-        [list ::Rappture::Tooltip::tooltip cancel]
-
-    set _panels($pname-title) $panel(-title)
-    if { ![info exists _panels(all)] || $pos == "end" } {
-        lappend _panels(all) $pname
-    } else {
-        set _panels(all) [linsert $_panels(all) $pos $pname]
-    }
-    if {$_selected == ""} {
-        set _selected $pname
-        if {$_state == "open"} {
-            $itk_component(title) configure -text $panel(-title)
-        }
-    }
-
-    return $itk_component($pname)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: panel <which>
-#
-# Returns the frame representing the requested panel.  The <which>
-# argument can be a panel index, name, or title, or the keyword
-# "current" for the selected panel.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::panel {which} {
-    switch -glob -- $which {
-        current {
-            return $itk_component($_selected)
-        }
-        [0-9]* {
-            set pname [lindex $_panels(all) $which]
-            return $itk_component($pname)
-        }
-        panel[0-9]* {
-            if {[info exists itk_component($which)]} {
-                return $itk_component($which)
-            }
-            error "bad panel name \"$which\""
-        }
-        default {
-            foreach pname $_panels(all) {
-                if {[string equal $_panels($pname-title) $which]} {
-                    return $itk_component($pname)
-                }
-            }
-            error "bad panel title \"$which\""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: exists <which>
-#
-# Returns the frame representing the requested panel.  The <which>
-# argument can be a panel index, name, or title, or the keyword
-# "current" for the selected panel.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::exists { title } {
-    if { [info exists _title2panel($title)] } {
-        return 1
-    }
-    return 0
-}
-
-# ----------------------------------------------------------------------
-# USAGE: select <which>
-#
-# Pops open the sidebar and selects the specified panel.  The <which>
-# argument can be a panel index, name, or title.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::select {which} {
-    set pname ""
-    switch -glob -- $which {
-        [0-9]* {
-            set pname [lindex $_panels(all) $which]
-        }
-        panel[0-9]* {
-            if {[info exists itk_component($which)]} {
-                set pname $which
-            }
-        }
-        default {
-            foreach p $_panels(all) {
-                if {[string equal $_panels($p-title) $which]} {
-                    set pname $p
-                    break
-                }
-            }
-        }
-    }
-    if {$pname == ""} {
-        error "bad panel name \"$which\": should be panel id, title, or index"
-    }
-
-    if {$_state == "closed"} {
-        pop open
-    }
-
-    set minw [winfo reqwidth $itk_component(controlbar)]
-    if {$_width != "auto" && $_width < $minw+50} {
-        set _width [expr {$minw+50}]
-        $_dispatcher event -idle !layout
-    }
-    set n [$itk_component(tabs) index -name $pname]
-    $itk_component(tabs) select $n
-
-    $itk_component(title) configure -text $_panels($pname-title)
-
-    set f [$itk_component(area) contents]
-    foreach w [pack slaves $f] {
-        pack forget $w
-    }
-    pack $itk_component($pname) -expand yes -fill both
-
-    #
-    # HACK ALERT!  Force the scroller to check the size of the
-    # panel that we just slid in under the covers.  Make it
-    # think the panel and the scroller itself have changed size.
-    #
-    event generate [winfo parent $f] <Configure>
-    event generate $f <Configure>
-
-    set _selected $pname
-    return $pname
-}
-
-# ----------------------------------------------------------------------
-# USAGE: pop open|close|toggle
-#
-# Used to open/close the sidebar area.  When open, the selected panel
-# appears and the titlebar shows its name.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::pop {how} {
-    if {$how == "toggle"} {
-        if {$_state == "closed"} {
-            set how "open"
-        } else {
-            set how "close"
-        }
-    }
-
-    switch -- $how {
-        open {
-            $itk_component(popbutton) configure \
-                -image [Rappture::icon sbar-closed]
-            pack $itk_component(area) -side right -expand yes -fill both
-
-            set _state "open"
-            select $_selected
-            $_dispatcher event -idle !layout
-        }
-        close {
-            $itk_component(popbutton) configure \
-                -image [Rappture::icon sbar-open]
-            $itk_component(title) configure -text ""
-            pack forget $itk_component(area)
-
-            set _state "closed"
-            $_dispatcher event -idle !layout
-        }
-        default {
-            error "bad option \"$how\": should be open, close, toggle"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: disable <which>
-#
-# Pops open the sidebar and selects the specified panel.  The <which>
-# argument can be a panel index, name, or title.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::disable {which} {
-    set index [TabIndex $which]
-    set tab [$itk_component(tabs) get $index]
-    $itk_component(tabs) tab configure $tab -state disabled
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: enable <which>
-#
-# Pops open the sidebar and selects the specified panel.  The <which>
-# argument can be a panel index, name, or title.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::enable {which} {
-    set index [TabIndex $which]
-    set tab [$itk_component(tabs) get $index]
-    $itk_component(tabs) tab configure $tab -state normal
-}
-
-# ----------------------------------------------------------------------
-# USAGE: TabIndex <which>
-#
-# Pops open the sidebar and selects the specified panel.  The <which>
-# argument can be a panel index, name, or title.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::TabIndex {which} {
-    set pname ""
-    switch -glob -- $which {
-        [0-9]* {
-            set pname [lindex $_panels(all) $which]
-        }
-        panel[0-9]* {
-            if {[info exists itk_component($which)]} {
-                set pname $which
-            }
-        }
-        default {
-            foreach p $_panels(all) {
-                if {[string equal $_panels($p-title) $which]} {
-                    set pname $p
-                    break
-                }
-            }
-        }
-    }
-    if {$pname == ""} {
-        error "bad panel name \"$which\": should be panel id, title, or index"
-    }
-    set n [$itk_component(tabs) index -name $pname]
-    return $n
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _toggleTab <which>
-#
-# Invoked automatically when the user clicks on a tab for the sidebar.
-# If the sidebar is closed, it is automatically opened and the tab is
-# selected.  If the sidebar is opened, then it's closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::_toggleTab {which} {
-    if {$_state == "closed"} {
-        pop open
-        select $which
-    } elseif {[$itk_component(tabs) index -name $_selected]
-          == [$itk_component(tabs) index -name $which]} {
-        pop close
-    } else {
-        select $which
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _sash <op> <X>
-#
-# Invoked automatically when the user clicks/drags on a sash, to resize
-# the sidebar.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::_sash {op X} {
-    switch -- $op {
-        enter {
-            # mouse over sash -- make it active
-            if {$itk_option(-sashactiverelief) != ""} {
-                $itk_component(sash) configure -relief $itk_option(-sashactiverelief)
-            }
-        }
-        leave {
-            # mouse left sash -- back to normal
-            $itk_component(sash) configure -relief $itk_option(-sashrelief)
-        }
-        grab {
-            if {$_state == "closed"} { pop open }
-            _sash drag $X
-        }
-        drag {
-            set w [winfo width $itk_component(hull)]
-            set minw [winfo reqwidth $itk_component(controlbar)]
-            set dx [expr {$X - [winfo rootx $itk_component(hull)]}]
-            set sashw [winfo reqwidth $itk_component(sashbg)]
-            set _width [expr {$w - $dx - $sashw/2}]
-
-            if {$_width < $minw} { set _width $minw }
-            if {$_width > $w-50} { set _width [expr {$w-50}] }
-            _fixLayout
-        }
-        release {
-            set minw [winfo reqwidth $itk_component(controlbar)]
-            if {$_width-$minw < 40} {
-                set _width "auto"
-                pop close
-            }
-        }
-        default {
-            error "bad option \"$op\": should be enter, leave, grab, drag, release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixLayout ?<eventArgs>...?
-#
-# Used internally to update the layout of panes whenever a new pane
-# is added or a sash is moved.
-# ----------------------------------------------------------------------
-itcl::body Rappture::SidebarFrame::_fixLayout {args} {
-    set w [winfo width $itk_component(hull)]
-    set h [winfo height $itk_component(hull)]
-
-    set sashw [winfo reqwidth $itk_component(sashbg)]
-
-    set tabw [winfo reqwidth $itk_component(tabs)]
-    set btnw [winfo reqwidth $itk_component(controls)]
-    set ctrlw [expr {($tabw > $btnw) ? $tabw : $btnw}]
-
-    if {$_state == "closed"} {
-        set sbarw $ctrlw
-    } else {
-        if {$_width == "auto"} {
-            # pop open to the size of the widest pane
-            set sbarw 0
-            foreach pname $_panels(all) {
-                set pw [winfo reqwidth $itk_component($pname)]
-                if {$pw > $sbarw} {
-                    set sbarw $pw
-                }
-            }
-            set sbarw [expr {$sbarw + $ctrlw + $sashw}]
-        } else {
-            set sbarw $_width
-        }
-    }
-
-    # don't let the sidebar take up too much of the window area
-    if {$sbarw > 0.75*$w} {
-        set sbarw [expr {int(0.75*$w)}]
-    }
-
-    set x1 [expr {$w - $sbarw - $sashw}]
-    set x2 [expr {$w - $sbarw}]
-    if { $resizeframe } {
-        set framew $x1
-    } else {
-        set framew [expr $w - $ctrlw - $sashw]
-    }
-    place $itk_component(frame) -x 0 -y 0 -anchor nw -width $framew -height $h
-    place $itk_component(sashbg) -x $x1 -y 0 -anchor nw -width $sashw -height $h
-    place $itk_component(sidebar) -x $x2 -y 0 -anchor nw \
-        -width $sbarw -height $h
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -sashpadding
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SidebarFrame::sashpadding {
-    pack $itk_component(sash) -padx $itk_option(-sashpadding)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -sashcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::SidebarFrame::sashcolor {
-    if {$itk_option(-sashcolor) != ""} {
-        $itk_component(sash) configure -background $itk_option(-sashcolor)
-    } else {
-        $itk_component(sash) configure -background $itk_option(-background)
-    }
-}
-
Index: trunk/gui/scripts/spectrum.tcl
===================================================================
--- trunk/gui/scripts/spectrum.tcl	(revision 6716)
+++ trunk/gui/scripts/spectrum.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: spectrum - maps a range of real values onto a color
@@ -15,8 +14,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -37,9 +33,6 @@
     private variable _gvals ""      ;# list of green components along axis
     private variable _bvals ""      ;# list of blue components along axis
-    private variable _spectrum 0    ;# use continuous visible spectrum
-    private variable _specv0 0      ;# minimum value
-    private variable _specw0 0      ;# wavelength for minimum
-}
-
+}
+                                                                                
 # ----------------------------------------------------------------------
 # CONSTRUCTOR
@@ -65,35 +58,4 @@
 itcl::body Rappture::Spectrum::insert {args} {
     set changed 0
-
-    # special case. Two values in nm, then use
-    # spectrum instead of gradient.
-    if {[llength $args] == 4} {
-        set cnt 0
-        foreach {value color} $args {
-            if {[string match "*nm" $color]} {
-                incr cnt
-            }
-        }
-        if {$cnt == 2} {
-            set val0 [lindex $args 0]
-            set color0 [string trimright [lindex $args 1] "nm"]
-            set val1 [lindex $args 2]
-            set color1 [string trimright [lindex $args 3] "nm"]
-
-            if {"" != $units} {
-                set val0 [Rappture::Units::convert $val0 \
-                              -context $units -to $units -units off]
-                set val1 [Rappture::Units::convert $val1 \
-                              -context $units -to $units -units off]
-            }
-
-            set _spectrum [expr (double($color1) - double($color0)) \
-                           / (double($val1) - double($val0))]
-            set _specv0 $val0
-            set _specw0 $color0
-            return
-        }
-    }
-
     foreach {value color} $args {
         if {"" != $units} {
@@ -101,5 +63,6 @@
                 -context $units -to $units -units off]
         }
-        foreach {r g b} [Rappture::color::RGB $color] { break }
+        foreach {r g b} [winfo rgb . $color] { break }
+
         set i 0
         foreach v $_axis {
@@ -187,5 +150,5 @@
     while {[llength $args] > 0} {
         set first [lindex $args 0]
-        if {[regexp {^-[a-zA-Z]} $first]} {
+        if {[string index $first 0] == "-"} {
             set what $first
             set args [lrange $args 1 end]
@@ -197,41 +160,11 @@
         error "wrong # args: should be \"get ?-color|-fraction? ?value?\""
     }
-
     set value [lindex $args 0]
 
-    switch -- [lindex $value 0] {
-        gaussian {
-            set value [lindex $value 1]
-            if {$units != ""} {
-                set value [Rappture::Units::convert $value \
-                -context $units -to $units -units off]
-            }
-        }
-        uniform {
-            set min [lindex $value 1]
-            set max [lindex $value 2]
-            if {$units != ""} {
-                set min [Rappture::Units::convert $min \
-                -context $units -to $units -units off]
-                set max [Rappture::Units::convert $max \
-                -context $units -to $units -units off]
-            }
-            set value [expr {0.5 * ($min + $max)}]
-        }
-        default {
-            if {$units != ""} {
-                set value [Rappture::Units::convert $value \
-                -context $units -to $units -units off]
-            }
-        }
-    }
+    set value [Rappture::Units::convert $value \
+        -context $units -to $units -units off]
 
     switch -- $what {
         -color {
-            if {$_spectrum != 0} {
-                # continuous spectrum. just compute wavelength
-                set waveln [expr ($value - $_specv0) * $_spectrum + $_specw0]
-                return [Rappture::color::wave2RGB $waveln]
-            }
             set i 0
             set ilast ""
Index: trunk/gui/scripts/spinint.tcl
===================================================================
--- trunk/gui/scripts/spinint.tcl	(revision 6716)
+++ 	(revision )
@@ -1,162 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: spinint - spinner for integer values
-#
-#  This widget is a spinner with up/down arrows for managing integer
-#  values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Spinint.width 5 widgetDefault
-option add *Spinint.textBackground white widgetDefault
-
-itcl::class Rappture::Spinint {
-    inherit itk::Widget
-
-    itk_option define -min min Min ""
-    itk_option define -max max Max ""
-    itk_option define -delta delta Delta 1
-
-    constructor {args} { # defined below }
-
-    public method value {args}
-    public method bump {{delta up}}
-    protected method _validate {char}
-}
-
-itk::usual Spinint {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Spinint::constructor {args} {
-    itk_component add entry {
-        entry $itk_interior.entry
-    } {
-        usual
-        keep -width
-        rename -background -textbackground textBackground Background
-        rename -foreground -textforeground textForeground Foreground
-        rename -highlightbackground -background background Background
-    }
-    pack $itk_component(entry) -side left -expand yes -fill x
-
-    bind $itk_component(entry) <KeyPress> \
-        [itcl::code $this _validate %A]
-    bind $itk_component(entry) <Return> \
-        "$this value \[$itk_component(entry) get\]"
-    bind $itk_component(entry) <KP_Enter> \
-        "$this value \[$itk_component(entry) get\]"
-
-    itk_component add controls {
-        frame $itk_interior.cntls
-    }
-    pack $itk_component(controls) -side right
-
-    itk_component add up {
-        button $itk_component(controls).spinup \
-            -image [Rappture::icon intplus] \
-            -borderwidth 1 -relief raised -highlightthickness 0 \
-            -command [itcl::code $this bump up]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-        rename -background -buttonbackground buttonBackground Background
-    }
-    pack $itk_component(up) -side left -expand yes -fill both
-
-    itk_component add down {
-        button $itk_component(controls).spindn \
-            -image [Rappture::icon intminus] \
-            -borderwidth 1 -relief raised -highlightthickness 0 \
-            -command [itcl::code $this bump down]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-        rename -background -buttonbackground buttonBackground Background
-    }
-    pack $itk_component(down) -side right -expand yes -fill both
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Spinint::value {args} {
-    if {[llength $args] == 1} {
-        set newval [lindex $args 0]
-
-        if {"" != $newval} {
-            if {"" != $itk_option(-min) && $newval < $itk_option(-min)} {
-                set newval $itk_option(-min)
-            }
-            if {"" != $itk_option(-max) && $newval > $itk_option(-max)} {
-                set newval $itk_option(-max)
-            }
-        }
-
-        $itk_component(entry) delete 0 end
-        $itk_component(entry) insert 0 $newval
-        after 10 [list catch [list event generate $itk_component(hull) <<Value>>]]
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?newval?\""
-    }
-    return [$itk_component(entry) get]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: bump ?<delta>?
-#
-# Used internally when you click on the up/down arrows.  Clients
-# can also use it directly to bump values up/down.  The optional
-# <delta> can be an integer value or the keyword "up" or "down".
-# ----------------------------------------------------------------------
-itcl::body Rappture::Spinint::bump {{delta up}} {
-    if {"up" == $delta} {
-        set delta $itk_option(-delta)
-    } elseif {"down" == $delta} {
-        set delta [expr {-$itk_option(-delta)}]
-    } elseif {![string is integer $delta]} {
-        error "bad delta \"$delta\": should be up, down, or integer"
-    }
-
-    set val [$itk_component(entry) get]
-    if {$val == ""} {
-        set val 0
-    }
-    value [expr {$val+$delta}]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _validate <char>
-#
-# Validates each character as it is typed into the spinner.
-# If the <char> is not a digit, then this procedure beeps and
-# prevents the character from being inserted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Spinint::_validate {char} {
-    if {[string match "\[ -~\]" $char]} {
-        if {![string match "\[0-9\]" $char]} {
-            bell
-            return -code break
-        }
-    }
-}
Index: trunk/gui/scripts/switch.tcl
===================================================================
--- trunk/gui/scripts/switch.tcl	(revision 6716)
+++ 	(revision )
@@ -1,168 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: switch - on/off switch
-#
-#  This widget is used to control a (boolean) on/off value.
-# It is just a wrapper around a button.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-itcl::class Rappture::Switch {
-    inherit itk::Widget
-
-    itk_option define -oncolor onColor Color "#00cc00"
-    itk_option define -state state State "normal"
-    itk_option define -showimage showimage Showimage "true"
-    itk_option define -showtext showtext Showtext "true"
-    itk_option define -interactcommand interactCommand InteractCommand ""
-
-    constructor {args} { # defined below }
-    public method value {args}
-
-    private method _updateText {}
-    private method _toggle {args}
-    private variable _value 0  ;# value for this widget
-}
-
-itk::usual Switch {
-    keep -cursor -background
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Switch::constructor {args} {
-
-    itk_component add button {
-        button $itk_interior.value -compound left \
-            -overrelief flat -relief flat -padx 3 -pady 0 -bd 0 \
-            -command [itcl::code $this _toggle]
-    } {
-        #rename -background -textbackground textBackground Background
-    }
-    pack $itk_component(button) -side left -expand yes -fill both
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Switch::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-    if {[llength $args] == 1} {
-        set newval [lindex $args 0]
-        # I don't like the "string is" commands. They have too many quirks.
-        # If we're calling "expr" anyways, just put a catch on it.
-        if { [catch {expr {($newval) ? 1 : 0}} newval] != 0 } {
-            error "$newval: should be a yes, no, on, off, true, false, 0, or 1."
-        }
-        if {$onlycheck} {
-            return
-        }
-        set _value $newval
-        event generate $itk_component(hull) <<Value>>
-        _updateText
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-    return [expr {($_value) ? "yes" : "no"}]
-}
-
-# ----------------------------------------------------------------------
-# _toggle
-#
-#        Use internally to convert the toggled button into the
-#        proper boolean format.  Yes, right now it's hardcoded to
-#        yes/no.  But in the future it could be some other text.
-#
-#        Can't use old "value" method because _value is already set
-#        be the widget and doesn't pass the value on the command line.
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Switch::_toggle {} {
-    if {$_value} {
-        value off
-    } else {
-        value on
-    }
-    if {[string length $itk_option(-interactcommand)] > 0} {
-        uplevel #0 $itk_option(-interactcommand)
-    }
-}
-
-itcl::body Rappture::Switch::_updateText {} {
-    set image ""
-    set text ""
-    if { $_value } {
-        if {$itk_option(-showimage)} {
-            set image [Rappture::icon switch1]
-        }
-        if {$itk_option(-showtext)} {
-            set text "yes"
-        }
-    } else {
-        if {$itk_option(-showimage)} {
-            set image [Rappture::icon switch0]
-        }
-        if {$itk_option(-showtext)} {
-            set text "no"
-        }
-    }
-    $itk_component(button) configure -text $text -image $image
-}
-
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -oncolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Switch::oncolor {
-    # does nothing now, but may come back soon
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Switch::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    $itk_component(button) configure -state $itk_option(-state)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -showimage
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Switch::showimage {
-    if {[string is boolean $itk_option(-showimage)] != 1} {
-        error "bad value \"$itk_option(-showimage)\": should be a boolean"
-    }
-    _updateText
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -showtext
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Switch::showtext {
-    if {[string is boolean $itk_option(-showtext)] != 1} {
-        error "bad value \"$itk_option(-showtext)\": should be a boolean"
-    }
-    _updateText
-}
Index: trunk/gui/scripts/table.tcl
===================================================================
--- trunk/gui/scripts/table.tcl	(revision 6716)
+++ 	(revision )
@@ -1,232 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: table - extracts data from an XML description of a table
-#
-#  This object represents one table in an XML description of a table.
-#  It simplifies the process of extracting data representing columns
-#  in the table.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-
-namespace eval Rappture { # forward declaration }
-
-itcl::class Rappture::Table {
-    constructor {xmlobj path} { # defined below }
-    destructor { # defined below }
-
-    public method rows {}
-    public method columns {args}
-    public method values {args}
-    public method limits {col}
-    public method hints {{key ""}}
-
-    private variable _xmlobj ""  ;# ref to lib obj with curve data
-    private variable _table ""   ;# lib obj representing this table
-    private variable _tuples ""  ;# list of tuples with table data
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Table::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be Rappture::library"
-    }
-    set _table [$xmlobj element -as object $path]
-
-    #
-    # Load data from the table and store in the tuples.
-    #
-    set _tuples [Rappture::Tuples ::#auto]
-    foreach cname [$_table children -type column] {
-        set label [$_table get $cname.label]
-        $_tuples column insert end -name $cname -label $label
-    }
-
-    set cols [llength [$_tuples column names]]
-    set nline 1
-    foreach line [split [$_table get data] \n] {
-        if {[llength $line] == 0} {
-            continue
-        }
-        if {[llength $line] != $cols} {
-            error "bad data at line $nline: expected $cols columns but got \"[string trim $line]\""
-        }
-        $_tuples insert end $line
-        incr nline
-    }
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Table::destructor {} {
-    itcl::delete object $_tuples
-    itcl::delete object $_table
-    # don't destroy the _xmlobj! we don't own it!
-}
-
-# ----------------------------------------------------------------------
-# USAGE: rows
-#
-# Returns the number of rows of information in this table.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Table::rows {} {
-    return [$_tuples size]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: columns ?-component|-label|-units? ?<pos>?
-#
-# Returns information about the columns associated with this table.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Table::columns {args} {
-    Rappture::getopts args params {
-        flag switch -component
-        flag switch -label default
-        flag switch -units
-    }
-    if {[llength $args] == 0} {
-        set cols [llength [$_tuples column names]]
-        set plist ""
-        for {set i 0} {$i < $cols} {incr i} {
-            lappend plist $i
-        }
-    } elseif {[llength $args] == 1} {
-        set p [lindex $args 0]
-        if {[string is integer $p]} {
-            lappend plist $p
-        } else {
-            set pos [lsearch -exact [$_tuples column names] $p]
-            if {$pos < 0} {
-                error "bad column \"$p\": should be column name or integer index"
-            }
-            lappend plist $pos
-        }
-    } else {
-        error "wrong # args: should be \"columns ?-component|-label|-units? ?pos?\""
-    }
-
-    set rlist ""
-    switch -- $params(switch) {
-        -component {
-            set names [$_tuples column names]
-            foreach p $plist {
-                lappend rlist [lindex $names $p]
-            }
-        }
-        -label {
-            set names [$_tuples column names]
-            foreach p $plist {
-                set name [lindex $names $p]
-                catch {unset opts}
-                array set opts [$_tuples column info $name]
-                lappend rlist $opts(-label)
-            }
-        }
-        -units {
-            set names [$_tuples column names]
-            foreach p $plist {
-                set comp [lindex $names $p]
-                lappend rlist [$_table get $comp.units]
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: values ?-row <index>? ?-column <index>?
-#
-# Returns a single value or a list of values for data in this table.
-# If a particular -row and -column is specified, then it returns
-# a single value for that row/column.  If either the -row or the
-# -column is specified, then it returns a list of values in that
-# row or column.  With no args, it returns all values in the table.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Table::values {args} {
-    Rappture::getopts args params {
-        value -row ""
-        value -column ""
-    }
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"values ?-row r? ?-column c?\""
-    }
-    if {"" == $params(-row) && "" == $params(-column)} {
-        return [$_tuples get]
-    } elseif {"" == $params(-column)} {
-        return [lindex [$_tuples get $params(-row)] 0]
-    }
-
-    if {[string is integer $params(-column)]} {
-        set col [lindex [$_tuples column names] $params(-column)]
-    } else {
-        set col $params(-column)
-        if {"" == [$_tuples column names $col]} {
-            error "bad column name \"$col\": should be [join [$_tuples column names] {, }]"
-        }
-    }
-
-    if {"" == $params(-row)} {
-        # return entire column
-        return [$_tuples get -format $col]
-    }
-    # return a particular cell
-    return [$_tuples get -format $col $params(-row)]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: limits <column>
-#
-# Returns the {min max} limits of the numerical values in the
-# specified <column>, which can be either an integer index to
-# a column or a column name.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Table::limits {column} {
-    set min ""
-    set max ""
-    foreach v [values -column $column] {
-        if {"" == $min} {
-            set min $v
-            set max $v
-        } else {
-            if {$v < $min} { set min $v }
-            if {$v > $max} { set max $v }
-        }
-    }
-    return [list $min $max]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this table.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Table::hints {{keyword ""}} {
-    foreach {key path} {
-        label   about.label
-        color   about.color
-        style   about.style
-    } {
-        set str [$_table get $path]
-        if {"" != $str} {
-            set hints($key) $str
-        }
-    }
-
-    if {$keyword != ""} {
-        if {[info exists hints($keyword)]} {
-            return $hints($keyword)
-        }
-        return ""
-    }
-    return [array get hints]
-}
Index: trunk/gui/scripts/tempgauge.tcl
===================================================================
--- trunk/gui/scripts/tempgauge.tcl	(revision 6716)
+++ trunk/gui/scripts/tempgauge.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: tempgauge - gauge for temperature values
@@ -7,29 +6,19 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
 
-option add *TemperatureGauge.sampleWidth 30 widgetDefault
-option add *TemperatureGauge.sampleHeight 20 widgetDefault
-option add *TemperatureGauge.borderWidth 2 widgetDefault
-option add *TemperatureGauge.relief sunken widgetDefault
+option add *TemperatureGauge.width 30 widgetDefault
+option add *TemperatureGauge.height 0 widgetDefault
 option add *TemperatureGauge.textBackground #cccccc widgetDefault
 option add *TemperatureGauge.valuePosition "right" widgetDefault
 option add *TemperatureGauge.editable yes widgetDefault
-option add *TemperatureGauge.state normal widgetDefault
 
 itcl::class Rappture::TemperatureGauge {
     inherit Rappture::Gauge
 
-    constructor {args} {
-        array set attrs $args
-        Rappture::Gauge::constructor -uq $attrs(-uq)
-    } {
-        eval itk_initialize -spectrum $_spectrum -units K $args
-    }
+    constructor {args} { # defined below }
+
     protected method _redraw {}
     protected method _resize {}
@@ -44,4 +33,11 @@
 
 itk::usual TemperatureGauge {
+}
+
+# ----------------------------------------------------------------------
+# CONSTRUCTOR
+# ----------------------------------------------------------------------
+itcl::body Rappture::TemperatureGauge::constructor {args} {
+    eval itk_initialize -spectrum $_spectrum -units K $args
 }
 
@@ -62,8 +58,6 @@
         $c create oval 0 0 1 1 -outline "" -tags bulbfill
         $c create oval 0 0 1 1 -outline black -tags bulboutline
-        $c create oval 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags {bulbscreen screen}
         $c create rect 0 0 1 1 -outline black -fill white -tags stickoutline
         $c create rect 0 0 1 1 -outline "" -tags stickfill
-        $c create rect 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags {stickscreen screen}
         $c create image 0 0 -anchor w -image "" -tags bimage
     }
@@ -97,6 +91,4 @@
         $c coords bulboutline $x [expr {$y-$bsize}] \
             [expr {$x+2*$bsize}] [expr {$y+$bsize}]
-        $c coords bulbscreen [expr {$x-1}] [expr {$y-$bsize-1}] \
-            [expr {$x+2*$bsize+1}] [expr {$y+$bsize+1}]
         $c coords bulbfill $x [expr {$y-$bsize}] \
             [expr {$x+2*$bsize}] [expr {$y+$bsize}]
@@ -107,6 +99,4 @@
         $c coords stickoutline [expr {$x0-2}] [expr {$y-$ssize}] \
             $x1 [expr {$y+$ssize}]
-        $c coords stickscreen [expr {$x0-2}] [expr {$y-$ssize}] \
-            [expr {$x1+1}] [expr {$y+$ssize+1}]
         $c coords stickfill [expr {$x0-2}] [expr {$y-$ssize+1}] \
             $xr [expr {$y+$ssize}]
@@ -114,10 +104,4 @@
         $c itemconfigure bulbfill -fill $color
         $c itemconfigure stickfill -fill $color
-    }
-
-    if {$itk_option(-state) == "disabled"} {
-        $c itemconfigure screen -fill white
-    } else {
-        $c itemconfigure screen -fill ""
     }
 }
@@ -130,6 +114,6 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::TemperatureGauge::_resize {} {
-    if {$itk_option(-samplewidth) > 0} {
-        set w $itk_option(-samplewidth)
+    if {$itk_option(-width) > 0} {
+        set w $itk_option(-width)
     } else {
         set w [winfo reqheight $itk_component(value)]
@@ -139,6 +123,6 @@
     }
 
-    if {$itk_option(-sampleheight) > 0} {
-        set h $itk_option(-sampleheight)
+    if {$itk_option(-height) > 0} {
+        set h $itk_option(-height)
     } else {
         if {$itk_option(-image) != ""} {
Index: trunk/gui/scripts/textentry.tcl
===================================================================
--- trunk/gui/scripts/textentry.tcl	(revision 6716)
+++ 	(revision )
@@ -1,674 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: textentry - general-purpose text entry widget
-#
-#  This widget is a cross between the Tk entry and text widgets.  For
-#  one-line messages, it acts like an entry widget.  For larger
-#  messages, it morphs into a text widget.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-
-option add *TextEntry.size auto widgetDefault
-option add *TextEntry.width 0 widgetDefault
-option add *TextEntry.height 0 widgetDefault
-option add *TextEntry.textBackground white widgetDefault
-option add *TextEntry*disabledForeground #a3a3a3 widgetDefault
-option add *TextEntry*disabledBackground white widgetDefault
-
-option add *TextEntry.hintForeground gray50 widgetDefault
-option add *TextEntry.hintFont \
-    -*-helvetica-medium-r-normal-*-10-* widgetDefault
-option add *TextEntry.codeFont \
-    -*-courier-medium-r-normal-*-12-* widgetDefault
-
-
-itcl::class Rappture::TextEntry {
-    inherit itk::Widget
-
-    itk_option define -state state State "normal"
-    itk_option define -disabledforeground disabledForeground DisabledForeground ""
-    itk_option define -disabledbackground disabledBackground DisabledBackground ""
-    itk_option define -width width Width 0
-    itk_option define -height height Height 0
-
-    constructor {owner path args} {
-        # defined below
-    }
-
-    public method value {args}
-
-    public method label {}
-    public method tooltip {}
-    public method size {} { return $_size }
-
-    protected method _layout {}
-    protected method _setValue {value}
-    protected method _newValue {}
-    protected method _edit {option args}
-    protected method _uploadValue {args}
-    protected method _downloadValue {}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-    private variable _owner ""      ;# thing managing this control
-    private variable _path ""       ;# path in XML to this number
-
-    private variable _layout ""     ;# entry or full text size
-    private variable _value ""      ;# value inside the widget
-    private variable _size ""       ;# size hint from XML
-    private variable _icon ""       ;# size hint from XML
-}
-
-itk::usual TextEntry {
-    keep -foreground -background -textbackground -font -cursor
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::constructor {owner path args} {
-    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
-        error "bad object \"$owner\": should be Rappture::ControlOwner"
-    }
-    set _owner $owner
-    set _path $path
-
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !layout
-    $_dispatcher dispatch $this !layout "[itcl::code $this _layout]; list"
-
-    set _size [string trim [$_owner xml get $path.size]]
-
-    set hints [string trim [$_owner xml get $path.about.hints]]
-    set icon  [string trim [$_owner xml get $path.about.icon]]
-    if {[string length $icon] > 0} {
-        set _icon [image create photo -data $icon]
-    }
-    if {[string length $hints] > 0} {
-        itk_component add hints {
-            ::label $itk_interior.hints -anchor w -text $hints
-        } {
-            usual
-            rename -foreground -hintforeground hintForeground Foreground
-            rename -font -hintfont hintFont Font
-        }
-        pack $itk_component(hints) -side bottom -fill x
-    }
-
-    eval itk_initialize $args
-
-    # Trimming for now.  May need a <verbatim> flag to indicate to leave
-    # the string alone.
-    set str [string trim [$_owner xml get $path.default]]
-    if {"" != $str} {
-        value $str
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?-check? ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.  If the -check flag is included, the
-# new value is not actually applied, but just checked for correctness.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::value {args} {
-    set onlycheck 0
-    set i [lsearch -exact $args -check]
-    if {$i >= 0} {
-        set onlycheck 1
-        set args [lreplace $args $i $i]
-    }
-
-    if {[llength $args] == 1} {
-        if {$onlycheck} {
-            # someday we may add validation...
-            return
-        }
-        set newval [string trim [lindex $args 0]]
-        _setValue $newval
-        _newValue
-
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?-check? ?newval?\""
-    }
-
-    #
-    # Query the value and return.
-    #
-    switch -- $_layout {
-        entry {
-            return [$itk_component(entry) get]
-        }
-        text {
-            return [$itk_component(text) get 1.0 end-1char]
-        }
-        binary {
-            return $_value
-        }
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: label
-#
-# Clients use this to query the label associated with this widget.
-# Reaches into the XML and pulls out the appropriate label string.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::label {} {
-    set label [string trim [$_owner xml get $_path.about.label]]
-    if {"" == $label} {
-        set label "String"
-    }
-    return $label
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip
-#
-# Clients use this to query the tooltip associated with this widget.
-# Reaches into the XML and pulls out the appropriate description
-# string.  Returns the string that should be used with the
-# Rappture::Tooltip facility.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::tooltip {} {
-    set str [string trim [$_owner xml get $_path.about.description]]
-    return $str
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _layout
-#
-# Used internally to change the layout of this widget depending
-# on the .size hint and its contents.  Switches between an entry
-# and a text widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::_layout {} {
-    set size $_size
-    if {$size == "" || $size == "auto"} {
-        #
-        # If the size is "auto", then look at the current value
-        # and count its lines/characters.
-        #
-        if {[string length $_value] > 1920} {
-            # if size is really big, don't bother counting lines
-            set size "80x24"
-        } else {
-            set chars 0
-            set lines 0
-            foreach line [split $_value \n] {
-                incr lines
-                if {[string length $line] > $chars} {
-                    set chars [string length $line]
-                }
-            }
-            incr chars
-
-            if {$lines > 1} {
-                set size "${chars}x${lines}"
-            } else {
-                set size $chars
-            }
-        }
-    }
-
-    if {$size == "binary" || [Rappture::encoding::is binary $_value]} {
-        set newlayout "binary"
-    } elseif {[regexp {^[0-9]+$} $size]} {
-        set newlayout "entry"
-    } elseif {[regexp {^([0-9]+)x([0-9]+)$} $size match w h]} {
-        set newlayout "text"
-    }
-
-    if {$newlayout != $_layout} {
-        set oldval ""
-        if {$_layout == "entry"} {
-            set oldval [$itk_component(entry) get]
-        } elseif {$_layout == "text"} {
-            set oldval [$itk_component(text) get 1.0 end-1char]
-        }
-
-        # Set the _layout here because unpacking the widgets triggers
-        # the "_edit finalize" method (focus change).
-
-        set _layout $newlayout
-
-        # take down any existing widget
-        foreach win [pack slaves $itk_interior] {
-            if { [winfo name $win] != "hints" } {
-                pack forget $win
-            }
-        }
-
-        switch -- $newlayout {
-            entry {
-                # don't have the entry widget yet? then create it
-                if {![winfo exists $itk_interior.entry]} {
-                    itk_component add entry {
-                        entry $itk_interior.entry
-                    } {
-                        usual
-                        rename -background -textbackground textBackground Background
-                        rename -foreground -textforeground textForeground Foreground
-                    }
-                    $itk_component(entry) configure \
-                        -background $itk_option(-textbackground) \
-                        -foreground $itk_option(-textforeground)
-
-                    # Make sure these event bindings occur after the class bindings.
-                    # Otherwise you'll always get the entry value before the edit.
-                    bind textentry-$this <KeyPress> \
-                        [itcl::code $this _newValue]
-                    bind textentry-$this <KeyPress-Return> \
-                        [itcl::code $this _edit finalize]
-                    bind textentry-$this <Control-KeyPress-a> \
-                        "[list $itk_component(entry) selection range 0 end]; break"
-                    bind textentry-$this <FocusOut> \
-                        [itcl::code $this _edit finalize]
-                    bind textentry-$this <Unmap> \
-                        [itcl::code $this _edit finalize]
-                    set bindtags [bindtags $itk_component(entry)]
-                    lappend bindtags textentry-$this
-                    bindtags $itk_component(entry) $bindtags
-
-                    itk_component add emenu {
-                        menu $itk_component(entry).menu -tearoff 0
-                    }
-                    $itk_component(emenu) add command \
-                        -label "Cut" -accelerator "^X" \
-                        -command [itcl::code $this _edit action entry cut]
-                    $itk_component(emenu) add command \
-                        -label "Copy" -accelerator "^C" \
-                        -command [itcl::code $this _edit action entry copy]
-                    $itk_component(emenu) add command \
-                        -label "Paste" -accelerator "^V" \
-                        -command [itcl::code $this _edit action entry paste]
-                    $itk_component(emenu) add command \
-                        -label "Select All" -accelerator "^A" \
-                        -command [itcl::code $this _edit action entry selectall]
-                    bind $itk_component(entry) <<PopupMenu>> \
-                        [itcl::code $this _edit menu emenu %X %Y]
-                }
-
-                # show the entry widget
-                pack $itk_component(entry) -expand yes -fill both
-
-                # load any previous value
-                regsub -all "\n" $oldval "" oldval
-                $itk_component(entry) delete 0 end
-                $itk_component(entry) insert end $oldval
-            }
-
-            text {
-                if {![winfo exists $itk_interior.scrl]} {
-                    itk_component add scrollbars {
-                        Rappture::Scroller $itk_interior.scrl \
-                            -xscrollmode auto -yscrollmode auto
-                    }
-
-                    itk_component add text {
-                        text $itk_component(scrollbars).text \
-                            -width 1 -height 1 -wrap char
-                    } {
-                        usual
-                        ignore -highlightthickness -highlightcolor
-                        rename -background -textbackground textBackground Background
-                        rename -foreground -textforeground textForeground Foreground
-                        rename -font -codefont codeFont CodeFont
-                    }
-                    $itk_component(text) configure \
-                        -background $itk_option(-textbackground) \
-                        -foreground $itk_option(-textforeground) \
-                        -font $itk_option(-codefont) \
-                        -highlightthickness 1
-                    $itk_component(scrollbars) contents $itk_component(text)
-
-                    # Make sure these event bindings occur after the class bindings.
-                    # Otherwise you'll always get the text value before the edit.
-                    bind textentry-$this <KeyPress> \
-                        [itcl::code $this _newValue]
-                    # leave [Return] key alone for multi-line text so the user
-                    # can enter newlines and keep editing
-                    bind textentry-$this <Control-KeyPress-a> \
-                        "[list $itk_component(text) tag add sel 1.0 end]; break"
-                    bind textentry-$this <FocusOut> \
-                        [itcl::code $this _edit finalize]
-                    bind textentry-$this <Unmap> \
-                        [itcl::code $this _edit finalize]
-                    set bindtags [bindtags $itk_component(text)]
-                    lappend bindtags textentry-$this
-                    bindtags $itk_component(text) $bindtags
-
-                    itk_component add tmenu {
-                        menu $itk_component(text).menu -tearoff 0
-                    }
-                    $itk_component(tmenu) add command \
-                        -label "Cut" -accelerator "^X" \
-                        -command [itcl::code $this _edit action text cut]
-                    $itk_component(tmenu) add command \
-                        -label "Copy" -accelerator "^C" \
-                        -command [itcl::code $this _edit action text copy]
-                    $itk_component(tmenu) add command \
-                        -label "Paste" -accelerator "^V" \
-                        -command [itcl::code $this _edit action text paste]
-                    $itk_component(tmenu) add command \
-                        -label "Select All" -accelerator "^A" \
-                        -command [itcl::code $this _edit action text selectall]
-                    $itk_component(tmenu) add separator
-
-                    $itk_component(tmenu) add command \
-                        -label [Rappture::filexfer::label upload] \
-                        -command [itcl::code $this _uploadValue -start]
-                    $itk_component(tmenu) add command \
-                        -label [Rappture::filexfer::label download] \
-                        -command [itcl::code $this _downloadValue]
-
-                    bind $itk_component(text) <<PopupMenu>> \
-                        [itcl::code $this _edit menu tmenu %X %Y]
-                }
-
-                # show the text editor widget
-                pack $itk_component(scrollbars) -expand yes -fill both
-                $itk_component(text) configure -width $w -height $h
-
-                # load any previous value
-                $itk_component(text) delete 1.0 end
-                $itk_component(text) insert end $oldval
-            }
-
-            binary {
-                if {![winfo exists $itk_interior.bin]} {
-                    itk_component add binary {
-                        frame $itk_interior.bin
-                    }
-                    set icon $_icon
-                    if { $icon == "" } {
-                        set icon [Rappture::icon binary]
-                    }
-                    itk_component add binicon {
-                        ::label $itk_component(binary).binicon \
-                            -image $icon -borderwidth 0
-                    }
-                    pack $itk_component(binicon) -side left
-
-                    itk_component add bininfo {
-                        ::label $itk_component(binary).bininfo \
-                            -text "Empty\n0 bytes" \
-                            -width 5 -justify left -anchor w -borderwidth 0
-                    }
-                    pack $itk_component(bininfo) -side left -expand yes -fill x -padx 4
-
-                    itk_component add bmenu {
-                        menu $itk_component(binary).menu -tearoff 0
-                    }
-                    $itk_component(bmenu) add command \
-                        -label [Rappture::filexfer::label upload] \
-                        -command [itcl::code $this _uploadValue -start]
-                    $itk_component(bmenu) add command \
-                        -label [Rappture::filexfer::label download] \
-                        -command [itcl::code $this _downloadValue]
-
-                    bind $itk_component(binicon) <<PopupMenu>> \
-                        [itcl::code $this _edit menu bmenu %X %Y]
-                    bind $itk_component(bininfo) <<PopupMenu>> \
-                        [itcl::code $this _edit menu bmenu %X %Y]
-                }
-
-                # show the binary mode rep
-                pack $itk_component(binary) -side top -fill x
-
-            }
-            default {
-                error "don't know how to handle mode \"$newlayout\" for string editor"
-            }
-        }
-    }
-
-    #
-    # Fix the overall widget size according to -width / -height
-    #
-    if {$itk_option(-width) == 0 && $itk_option(-height) == 0} {
-        pack propagate $itk_component(hull) yes
-    } else {
-        pack propagate $itk_component(hull) no
-        component hull configure \
-            -width $itk_option(-width) -height $itk_option(-width)
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _setValue <newValue>
-#
-# Used internally to set the value for this widget.  If the <newValue>
-# string is ASCII, then it is stored directly and the widget is enabled
-# for editing.  Otherwise, the value is cached and a representation of
-# the data is displayed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::_setValue {newval} {
-    if {[Rappture::encoding::is binary $newval]} {
-        # looks like a binary file
-        set _value $newval
-    } else {
-        # ascii file -- map carriage returns to line feeds
-        regsub -all "\r\n" $newval "\n" newval
-        regsub -all "\r" $newval "\n" newval
-        set _value $newval
-    }
-
-    # fix up the layout so the display widgets exist, then load the new value
-    _layout
-
-    switch -- $_layout {
-        entry {
-            $itk_component(entry) configure -state normal
-            $itk_component(entry) delete 0 end
-            $itk_component(entry) insert end $_value
-            $itk_component(entry) configure -state $itk_option(-state)
-        }
-        text {
-            $itk_component(text) configure -state normal
-            $itk_component(text) delete 1.0 end
-            $itk_component(text) insert end $_value
-            $itk_component(text) configure -state $itk_option(-state)
-        }
-        binary {
-            set desc [Rappture::utils::datatype $_value]
-            append desc "\n[Rappture::utils::binsize [string length $_value]]"
-            $itk_component(bininfo) configure -text $desc
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _newValue
-#
-# Invoked automatically whenever the value in the entry changes.
-# Sends a <<Value>> event to notify clients of the change.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::_newValue {} {
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _edit action <which> <action>
-# USAGE: _edit menu <which> <X> <Y>
-# USAGE: _edit finalize
-# USAGE: _edit log
-#
-# Used internally to manage edit operations.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::_edit {option args} {
-    if {$itk_option(-state) == "disabled"} {
-        return  ;# disabled? then bail out here!
-    }
-    switch -- $option {
-        action {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"_edit $option which action\""
-            }
-            set widget [lindex $args 0]
-            set action [lindex $args 1]
-            switch -- $action {
-                cut - copy - paste {
-                    set event "<<[string totitle $action]>>"
-                    event generate $itk_component($widget) $event
-                }
-                selectall {
-                    switch -- $widget {
-                        entry { $itk_component(entry) selection range 0 end }
-                        text  { $itk_component(text) tag add sel 1.0 end }
-                        default { error "don't know how to select for $widget" }
-                    }
-                }
-                default {
-                    error "don't know how to handle action $action"
-                }
-            }
-            Rappture::Logger::log input $_path -action $action
-        }
-        menu {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"_edit $option which x y\""
-            }
-            set mname [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            tk_popup $itk_component($mname) $x $y
-        }
-        finalize {
-            event generate $itk_component(hull) <<Final>>
-
-            # log each final value
-            set newval [value]
-            if {$newval ne $_value} {
-                Rappture::Logger::log input $_path $newval
-                set _value $newval
-            }
-        }
-        default {
-            error "bad option \"$option\": should be action, menu, log"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _uploadValue -start
-# USAGE: _uploadValue -assign <key> <value> <key> <value> ...
-#
-# Used internally to initiate an upload operation.  Prompts the
-# user to upload into the text area of this widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::_uploadValue {args} {
-    switch -- $_layout {
-        entry   { set widget $itk_component(entry) }
-        text    { set widget $itk_component(text) }
-        default { set widget $itk_component(hull) }
-    }
-
-    set opt [string trim [lindex $args 0]]
-    switch -- $opt {
-        -start {
-            set tool [Rappture::Tool::resources -appname]
-            set cntls [list $_path [label] [tooltip]]
-            Rappture::filexfer::upload \
-                $tool $cntls [itcl::code $this _uploadValue -assign]
-        }
-        -assign {
-            array set data [lrange $args 1 end] ;# skip option
-            if {[info exists data(error)]} {
-                Rappture::Tooltip::cue $widget $data(error)
-                Rappture::Logger::log warning $_path $data(error)
-            }
-            if {[info exists data(data)]} {
-                Rappture::Tooltip::cue hide  ;# take down note about the popup
-                _setValue $data(data)
-                _newValue
-                Rappture::Logger::log upload $_path $data(data)
-            }
-        }
-        default {
-            error "bad option \"$opt\": should be -start or -assign"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _downloadValue
-#
-# Used internally to initiate a download operation.  Takes the current
-# value and downloads it to the user in a new browser window.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextEntry::_downloadValue {} {
-    set mesg [Rappture::filexfer::download [value] input.txt]
-
-    if {$mesg ne ""} {
-        switch -- $_layout {
-            entry   { set widget $itk_component(entry) }
-            text    { set widget $itk_component(text) }
-            default { set widget $itk_component(hull) }
-        }
-        Rappture::Tooltip::cue $widget $mesg
-        Rappture::Logger::log warning $_path $mesg
-    } else {
-        Rappture::Logger::log download $_path
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -state
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::TextEntry::state {
-    set valid {normal disabled}
-    if {[lsearch -exact $valid $itk_option(-state)] < 0} {
-        error "bad value \"$itk_option(-state)\": should be [join $valid {, }]"
-    }
-    if {[info exists itk_component(text)]} {
-        $itk_component(text) configure -state $itk_option(-state)
-        $itk_component(tmenu) entryconfigure "Cut" -state $itk_option(-state)
-        $itk_component(tmenu) entryconfigure "Copy" -state $itk_option(-state)
-        $itk_component(tmenu) entryconfigure "Paste" -state $itk_option(-state)
-        if {$itk_option(-state) == "disabled"} {
-            $itk_component(text) configure \
-                -foreground $itk_option(-disabledforeground) \
-                -background $itk_option(-disabledbackground)
-        } else {
-            $itk_component(text) configure \
-                -foreground $itk_option(-foreground) \
-                -background $itk_option(-textbackground)
-        }
-    }
-    if {[info exists itk_component(entry)]} {
-        $itk_component(entry) configure -state $itk_option(-state)
-        $itk_component(emenu) entryconfigure "Cut" -state $itk_option(-state)
-        $itk_component(emenu) entryconfigure "Copy" -state $itk_option(-state)
-        $itk_component(emenu) entryconfigure "Paste" -state $itk_option(-state)
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -width
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::TextEntry::width {
-    # check size to see if it has the proper form
-    winfo pixels $itk_component(hull) $itk_option(-width)
-    $_dispatcher event -idle !layout
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -height
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::TextEntry::height {
-    # check size to see if it has the proper form
-    winfo pixels $itk_component(hull) $itk_option(-height)
-    $_dispatcher event -idle !layout
-}
-
-
Index: trunk/gui/scripts/textresult.tcl
===================================================================
--- trunk/gui/scripts/textresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,461 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: TextResult - Log output for ResultSet
-#
-#  This widget is used to show text output in a ResultSet.  The log
-#  output from a tool, for example, is rendered as a TextResult.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *TextResult.width 4i widgetDefault
-option add *TextResult.height 4i widgetDefault
-option add *TextResult.textBackground white widgetDefault
-option add *TextResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-option add *TextResult.textFont \
-    -*-courier-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::TextResult {
-    inherit itk::Widget
-
-    constructor {args} {
-        # defined below
-    }
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method download {option args}
-
-    public method select {option args}
-    public method find {option}
-    public method popup {option args}
-
-    private variable _dataobj ""  ;# data object currently being displayed
-    private variable _raised      ;# maps all data objects => -raise param
-}
-
-itk::usual TextResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::constructor {args} {
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    #
-    # CONTROL BAR with find/select functions
-    #
-    itk_component add controls {
-        frame $itk_interior.cntls
-    }
-    pack $itk_component(controls) -side bottom -fill x -pady {4 0}
-
-    itk_component add selectall {
-        button $itk_component(controls).selall -text "Select All" \
-            -command [itcl::code $this select all]
-    }
-    pack $itk_component(selectall) -side right -fill y
-
-    itk_component add findl {
-        label $itk_component(controls).findl -text "Find:"
-    }
-    pack $itk_component(findl) -side left
-
-    itk_component add find {
-        entry $itk_component(controls).find -width 20
-    }
-    pack $itk_component(find) -side left
-
-    itk_component add finddown {
-        button $itk_component(controls).finddown \
-            -image [Rappture::icon finddn] \
-            -relief flat -overrelief raised \
-            -command [itcl::code $this find down]
-    } {
-        usual
-        ignore -relief
-    }
-    pack $itk_component(finddown) -side left
-
-    itk_component add findup {
-        button $itk_component(controls).findup \
-            -image [Rappture::icon findup] \
-            -relief flat -overrelief raised \
-            -command [itcl::code $this find up]
-    } {
-        usual
-        ignore -relief
-    }
-    pack $itk_component(findup) -side left
-
-    itk_component add findstatus {
-        label $itk_component(controls).finds -width 10 -anchor w
-    }
-    pack $itk_component(findstatus) -side left -expand yes -fill x
-
-    # shortcut for Return in search field
-    bind $itk_component(find) <KeyPress-Return> "
-        $itk_component(finddown) configure -relief sunken
-        update idletasks
-        after 200
-        $itk_component(finddown) configure -relief flat
-        $itk_component(finddown) invoke
-    "
-    bind $itk_component(find) <KeyPress> \
-        [itcl::code $this find reset]
-
-    #
-    # TEXT AREA
-    #
-    itk_component add scroller {
-        Rappture::Scroller $itk_interior.scroller \
-            -xscrollmode auto -yscrollmode auto
-    }
-    pack $itk_component(scroller) -expand yes -fill both
-
-    itk_component add text {
-        text $itk_component(scroller).text -width 1 -height 1 -wrap none
-    } {
-        usual
-        rename -background -textbackground textBackground Background
-        rename -font -textfont textFont Font
-    }
-    $itk_component(scroller) contents $itk_component(text)
-    $itk_component(text) configure -state disabled
-
-    $itk_component(text) tag configure ERROR -foreground red
-
-    itk_component add emenu {
-        menu $itk_component(text).menu -tearoff 0
-    } {
-        ignore -tearoff
-    }
-    $itk_component(emenu) add command \
-        -label "Select All" -accelerator "Ctrl+A" \
-        -command [itcl::code $this select all]
-    $itk_component(emenu) add command \
-        -label "Select None" -accelerator "Esc" \
-        -command [itcl::code $this select none]
-    bind $itk_component(text) <<PopupMenu>> \
-        [itcl::code $this popup menu emenu %X %Y]
-    $itk_component(emenu) add command \
-        -label "Copy" -accelerator "Ctrl+C" \
-        -command [list event generate $itk_component(text) <<Copy>>]
-
-    bind $itk_component(text) <Control-KeyPress-a> \
-        [list $itk_component(emenu) invoke "Select All"]
-    bind $itk_component(text) <Control-KeyPress-c> \
-        [list $itk_component(emenu) invoke "Copy"]
-    bind $itk_component(text) <Escape> \
-        [list $itk_component(emenu) invoke "Select None" ]
-    bind $itk_component(text) <Enter> [list ::focus $itk_component(text)]
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  If the optional
-# <settings> are specified, then the are applied to the data.  Allowed
-# settings are -color and -brightness, -width, -linestyle and -raise.
-# (Many of these are ignored.)
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::add {dataobj {settings ""}} {
-    array set params {
-        -color ""
-        -brightness ""
-        -width ""
-        -linestyle ""
-        -raise 0
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    set replace 0
-    if {"" != $dataobj} {
-        set _raised($dataobj) $params(-raise)
-        if {"" == $_dataobj} {
-            set replace 1
-        } elseif {$_raised($_dataobj) == 0 && $params(-raise)} {
-            set replace 1
-        }
-    }
-
-    if {$replace} {
-        $itk_component(text) configure -state normal
-        $itk_component(text) delete 1.0 end
-
-        if {[$dataobj element -as type] == "log"} {
-            # log output -- remove special =RAPPTURE-???=> messages
-            set message [$dataobj get]
-            while {[regexp -indices \
-                       {=RAPPTURE-([a-zA-Z]+)=>([^\n]*)(\n|$)} $message \
-                        match type mesg]} {
-
-                foreach {i0 i1} $match break
-                set first [string range $message 0 [expr {$i0-1}]]
-                if {[string length $first] > 0} {
-                    $itk_component(text) insert end $first
-                }
-
-                foreach {t0 t1} $type break
-                set type [string range $message $t0 $t1]
-                foreach {m0 m1} $mesg break
-                set mesg [string range $message $m0 $m1]
-                if {[string length $mesg] > 0
-                       && $type != "RUN" && $type != "PROGRESS"} {
-                    $itk_component(text) insert end $mesg $type
-                    $itk_component(text) insert end \n $type
-                }
-                set message [string range $message [expr {$i1+1}] end]
-            }
-
-            if {[string length $message] > 0} {
-                $itk_component(text) insert end $message
-                if {[$itk_component(text) get end-2char] != "\n"} {
-                    $itk_component(text) insert end "\n"
-                }
-            }
-        } elseif {[$dataobj element -as type] == "string"} {
-            # add string values
-            set data [$dataobj get current]
-            if {[Rappture::encoding::is binary $data]} {
-                set data [Rappture::utils::hexdump -lines 1000 $data]
-            }
-            $itk_component(text) insert end $data
-        } else {
-            # any other string output -- add it directly
-            $itk_component(text) insert end [$dataobj get]
-        }
-        $itk_component(text) configure -state disabled
-
-        set _dataobj $dataobj
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::get {} {
-    return $_dataobj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<curve1> <curve2> ...?
-#
-# Clients use this to delete a curve from the plot.  If no curves
-# are specified, then all curves are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::delete {args} {
-    if {[llength $args] == 0} {
-        # delete everything
-        catch {unset _raised}
-        set _dataobj ""
-        $itk_component(text) configure -state normal
-        $itk_component(text) delete 1.0 end
-        $itk_component(text) configure -state disabled
-    } else {
-        # delete these specific objects
-        foreach obj $args {
-            catch {unset _raised($obj)}
-            if {$obj == $_dataobj} {
-                set _dataobj ""
-                $itk_component(text) configure -state normal
-                $itk_component(text) delete 1.0 end
-                $itk_component(text) configure -state disabled
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<curve1> <curve2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <curve> objects.  This
-# accounts for all curves--even those not showing on the screen.
-# Because of this, the limits are appropriate for all curves as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::scale {args} {
-    # nothing to do for text
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            # no controls for this download yet
-            return ""
-        }
-        now {
-            if {"" == $_dataobj} {
-                return ""
-            }
-            if {[$_dataobj element -as type] == "log"} {
-                set val [$itk_component(text) get 1.0 end]
-            } elseif {[$_dataobj element -as type] == "string"} {
-                set val [$_dataobj get current]
-            } else {
-                set val [$_dataobj get]
-            }
-
-            set ext [$_dataobj get filetype]
-            if {"" == $ext} {
-                if {[Rappture::encoding::is binary $val]} {
-                    set ext ".dat"
-                } else {
-                    set ext ".txt"
-                }
-            }
-            return [list $ext $val]
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: select all
-#
-# Handles various selection operations within the text.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::select {option args} {
-    switch -- $option {
-        all {
-            $itk_component(text) tag add sel 1.0 end
-        }
-        none {
-            if { [$itk_component(text) tag ranges "sel"] != "" } {
-                selection clear
-            }
-        }
-        default {
-            error "bad option \"$option\": should be all or none"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: find up
-# USAGE: find down
-# USAGE: find reset
-#
-# Handles various find operations within the text.  These find a
-# bit of text and highlight it within the widget.  The find operation
-# starts from the end of the currently highlighted text, or from the
-# beginning if there is no highlight.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::find {option} {
-    # handle the reset case...
-    $itk_component(find) configure \
-        -background $itk_option(-background) \
-        -foreground $itk_option(-foreground)
-    $itk_component(findstatus) configure -text ""
-
-    if {$option == "reset"} {
-        return
-    }
-
-    # handle the up/down cases...
-    set t $itk_component(text)
-    set pattern [string trim [$itk_component(find) get]]
-
-    if {"" == $pattern} {
-        $itk_component(find) configure -background red -foreground white
-        $itk_component(findstatus) configure -text "<< Enter a search string"
-        return
-    }
-
-    # find the starting point for the search
-    set seln [$t tag nextrange sel 1.0]
-    if {$seln == ""} {
-        set t0 1.0
-        set t1 end
-    } else {
-        foreach {t0 t1} $seln break
-    }
-    $t tag remove sel 1.0 end
-
-    # search up or down
-    switch -- $option {
-        up {
-            set start [$t index $t0-1char]
-            set next [$t search -backwards -nocase -- $pattern $start]
-            Rappture::Logger::log text find -up $pattern
-        }
-        down {
-            set start [$t index $t1+1char]
-            set next [$t search -forwards -nocase -- $pattern $start]
-            Rappture::Logger::log text find -down $pattern
-        }
-    }
-
-    if {"" != $next} {
-        set len [string length $pattern]
-        $t tag add sel $next $next+${len}chars
-        $t see $next
-        set lnum [lindex [split $next .] 0]
-        set lines [lindex [split [$t index end] .] 0]
-        set percent [expr {round(100.0*$lnum/$lines)}]
-        set status "line $lnum   --$percent%--"
-    } else {
-        set status "Not found"
-        $itk_component(find) configure -background red -foreground white
-    }
-    $itk_component(findstatus) configure -text $status
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _popup menu <which> <X> <Y>
-#
-# Used internally to manage edit operations.
-# ----------------------------------------------------------------------
-itcl::body Rappture::TextResult::popup {option args} {
-    switch -- $option {
-        menu {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"_popup $option which x y\""
-            }
-            set mname [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            tk_popup $itk_component($mname) $x $y
-        }
-        default {
-            error "bad option \"$option\": should be menu"
-        }
-    }
-}
Index: trunk/gui/scripts/tool.tcl
===================================================================
--- trunk/gui/scripts/tool.tcl	(revision 6716)
+++ 	(revision )
@@ -1,81 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: tool - represents an entire tool
-#
-#  This object represents an entire tool defined by Rappture.
-#  Each tool resides in an installation directory with other tool
-#  resources (libraries, examples, etc.).  Each tool is defined by
-#  its inputs and outputs, which are tied to various widgets in the
-#  GUI.  Each tool tracks the inputs, knows when they're changed,
-#  and knows how to run itself to produce new results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2014  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-itcl::class Rappture::Tool {
-    inherit Rappture::ControlOwner
-
-    constructor {xmlobj installdir} {
-        Rappture::ControlOwner::constructor ""
-    } { # defined below }
-
-    destructor { # defined below }
-
-    public method installdir {} {
-        return [$_task installdir]
-    }
-    public method get_uq {args} {
-        sync  ;# sync all widget values to XML
-        return [eval $_task get_uq $args]
-    }
-    public method run {args} {
-        sync  ;# sync all widget values to XML
-
-        foreach {status result} [eval $_task run $args] break
-        if {$status == 0} {
-            # move good results to the data/results directory
-            $_task save $result
-        }
-
-        return [list $status $result]
-    }
-    public method abort {} {
-        $_task abort
-    }
-    public method reset {} {
-        $_task reset
-    }
-
-    private variable _task ""  ;# underlying task for the tool
-
-    # global resources for this tool session (from task)
-    public proc resources {{option ""}} {
-        eval ::Rappture::Task::resources $option
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tool::constructor {xmlobj installdir} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be Rappture::Library"
-    }
-
-    set _task [Rappture::Task ::#auto $xmlobj $installdir \
-        -logger ::Rappture::Logger::log]
-
-    # save a reference to the tool XML in the ControlOwner
-    set _xmlobj $xmlobj
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tool::destructor {} {
-    itcl::delete object $_task
-}
Index: trunk/gui/scripts/tooltip.tcl
===================================================================
--- trunk/gui/scripts/tooltip.tcl	(revision 6716)
+++ trunk/gui/scripts/tooltip.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: tooltip - help information that pops up beneath a widget
@@ -18,8 +17,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itk
@@ -28,6 +24,6 @@
 option add *Tooltip.outline black widgetDefault
 option add *Tooltip.borderwidth 1 widgetDefault
-option add *Tooltip.font -*-helvetica-medium-r-normal-*-12-* widgetDefault
-option add *Tooltip.wrapLength 4i widgetDefault
+option add *Tooltip.font -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
+option add *Tooltip.wrapLength 3i widgetDefault
 
 itcl::class Rappture::Tooltip {
@@ -37,5 +33,4 @@
     itk_option define -icon icon Icon ""
     itk_option define -message message Message ""
-    itk_option define -log log Log ""
 
     constructor {args} { # defined below }
@@ -44,11 +39,8 @@
     public method hide {}
 
-    private variable _showing 0  ;# time when tooltip popped up on screen
-
-    public proc for {widget text args}
-    public proc text {widget args}
-    private common catalog    ;# maps widget => -message and -log
-
-    public proc tooltip {option args}
+    public proc for {widget args}
+    private common catalog    ;# maps widget => message
+
+    public proc tooltip {option {widget ""}}
     private common pending "" ;# after ID for pending "tooltip show"
 
@@ -63,4 +55,8 @@
     bind RapptureTooltip <KeyPress> \
         [list ::Rappture::Tooltip::tooltip cancel]
+
+    private common icons
+    set dir [file dirname [info script]]
+    set icons(cue) [image create photo -file [file join $dir images cue24.gif]]
 }
 
@@ -95,10 +91,9 @@
 
 # ----------------------------------------------------------------------
-# USAGE: show @<x>,<y>|<widget>+/-<x>,<y>
+# USAGE: show @<x>,<y>|<widget>
 #
 # Clients use this to pop up the tooltip on the screen.  The position
-# should be either a <widget> name with an optional offset +/-<x>,<y>
-# (tooltip pops up beneath widget by default), or a specific root
-# window coordinate of the form @x,y.
+# should be either a <widget> name (tooltip pops up beneath widget)
+# or a specific root window coordinate of the form @x,y.
 #
 # If the -message has the form "@command", then the command is executed
@@ -107,22 +102,12 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::Tooltip::show {where} {
-    set hull $itk_component(hull)
-    set _showing 0
-
-    set signx "+"
-    set signy "+"
-
     if {[regexp {^@([0-9]+),([0-9]+)$} $where match x y]} {
         set xpos $x
         set ypos $y
-    } elseif {[regexp {^(.*)([-+])([0-9]+),([-+]?)([0-9]+)$} $where match win signx x signy y]} {
-        if {$signy == ""} { set signy $signx }
-        set xpos [expr {[winfo rootx $win] + $x}]
-        set ypos [expr {[winfo rooty $win] + $y}]
     } elseif {[winfo exists $where]} {
         set xpos [expr {[winfo rootx $where]+10}]
         set ypos [expr {[winfo rooty $where]+[winfo height $where]}]
     } else {
-        error "bad position \"$where\": should be widget+x,y, or @x,y"
+        error "bad position \"$where\": should be widget name or @x,y"
     }
 
@@ -137,93 +122,11 @@
     }
 
-    # if there's no message to show, forget it
-    if {[string length $mesg] == 0} {
-        return
-    }
-
-    # strings can't be too big, or they'll go off screen!
-    set pos 0
-    ::for {set i 0} {$pos >= 0 && $i < 20} {incr i} {
-        incr pos
-        set pos [string first \n $mesg $pos]
-    }
-    if {$pos > 0} {
-        set mesg "[string range $mesg 0 $pos]..."
-    }
-    if {[string length $mesg] > 1000} {
-        set mesg "[string range $mesg 0 1500]..."
-    }
     $itk_component(text) configure -text $mesg
 
-    #
-    # Make sure the tooltip doesn't go off screen.
-    #
-    update idletasks
-    if {$signx == "+"} {
-        if {$xpos+[winfo reqwidth $hull] > [winfo screenwidth $hull]} {
-            set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}]
-        }
-        if {$xpos < 0} { set xpos 0 }
-    } else {
-        if {$xpos-[winfo reqwidth $hull] < 0} {
-            set xpos [expr {[winfo screenwidth $hull]-[winfo reqwidth $hull]}]
-        }
-        set xpos [expr {[winfo screenwidth $hull]-$xpos}]
-    }
-
-    if {$signy == "+"} {
-        if {$ypos+[winfo reqheight $hull] > [winfo screenheight $hull]} {
-            set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}]
-        }
-        if {$ypos < 0} { set ypos 0 }
-    } else {
-        if {$ypos-[winfo reqheight $hull] < 0} {
-            set ypos [expr {[winfo screenheight $hull]-[winfo reqheight $hull]}]
-        }
-        set ypos [expr {[winfo screenheight $hull]-$ypos}]
-    }
-
-    #
-    # Will the tooltip pop up under the mouse pointer?  If so, then
-    # it will just disappear.  Doh!  We should figure out a better
-    # place to pop it up.
-    #
-    set px [winfo pointerx $hull]
-    set py [winfo pointery $hull]
-    if {$px >= $xpos && $px <= $xpos+[winfo reqwidth $hull]
-          && $py >= $ypos && $py <= $ypos+[winfo reqheight $hull]} {
-
-        if {$px > [winfo screenwidth $hull]/2} {
-            set signx "-"
-            set xpos [expr {[winfo screenwidth $hull]-$px+4}]
-        } else {
-            set signx "+"
-            set xpos [expr {$px+4}]
-        }
-        if {$py > [winfo screenheight $hull]/2} {
-            set signy "-"
-            set ypos [expr {[winfo screenheight $hull]-$py+4}]
-        } else {
-            set signy "+"
-            set ypos [expr {$py+4}]
-        }
-    }
-
-    #
-    # Finally, put it up.
-    #
-    wm geometry $hull $signx$xpos$signy$ypos
+    wm geometry $itk_component(hull) +$xpos+$ypos
     update
 
-    wm deiconify $hull
-    raise $hull
-
-    #
-    # If logging is enabled, grab the start time.  We'll need this
-    # info later during the "hide" step to log activity.
-    #
-    if {$itk_option(-log) ne ""} {
-        set _showing [clock seconds]
-    }
+    wm deiconify $itk_component(hull)
+    raise $itk_component(hull)
 }
 
@@ -235,20 +138,8 @@
 itcl::body Rappture::Tooltip::hide {} {
     wm withdraw $itk_component(hull)
-
-    #
-    # If logging is enabled and the time is non-zero, then log
-    # the activity on this tooltip.
-    #
-    if {$itk_option(-log) ne "" && $_showing > 0} {
-        set dt [expr {[clock seconds] - $_showing}]
-        if {$dt > 0} {
-            Rappture::Logger::log tooltip -for $itk_option(-log) -time $dt
-        }
-    }
-    set _showing 0
-}
-
-# ----------------------------------------------------------------------
-# USAGE: for <widget> <text> ?-log <name>?
+}
+
+# ----------------------------------------------------------------------
+# USAGE: for <widget> <text>
 #
 # Used to register the tooltip <text> for a particular <widget>.
@@ -260,21 +151,7 @@
 # If the <text> has the form "@command", then the command is executed
 # just before the tip pops up to build the message on-the-fly.
-#
-# The -log option turns logging on/off for this tooltip.  Logging is
-# useful when you want to keep track of whether the user is looking at
-# tooltips and for how long.  If the <name> is specified, then any
-# activity on the tooltip is reported with that name on the log line.
-# If the name is not specified or "", then the activity is not logged.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tooltip::for {widget text args} {
-    Rappture::getopts args params {
-        value -log ""
-    }
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"for widget text ?-log name?\""
-    }
-
-    set catalog($widget-message) $text
-    set catalog($widget-log) $params(-log)
+# ----------------------------------------------------------------------
+itcl::body Rappture::Tooltip::for {widget text} {
+    set catalog($widget) $text
 
     set btags [bindtags $widget]
@@ -289,36 +166,6 @@
 
 # ----------------------------------------------------------------------
-# USAGE: text <widget> ?<text>? ?-log name?
-#
-# Used to query or set the text used for the tooltip for a widget.
-# This is done automatically when you call the "for" proc, but it
-# is sometimes handy to query or change the text later.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tooltip::text {widget args} {
-    if {[llength $args] == 0} {
-        if {[info exists catalog($widget-message)]} {
-            return $catalog($widget-message)
-        }
-        return ""
-    }
-
-    # set the text for the tooltip
-    set str [lindex $args 0]
-    set args [lrange $args 1 end]
-
-    Rappture::getopts args params {
-        value -log ""
-    }
-    if {[llength $args] > 0} {
-        error "wrong # args: should be \"text widget ?str? ?-log name?\""
-    }
-
-    set catalog($widget-message) $str
-    set catalog($widget-log) $params(-log)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: tooltip pending <widget> ?@<x>,<y>|+<x>,<y>?
-# USAGE: tooltip show <widget> ?@<x>,<y>|+<x>,<y>?
+# USAGE: tooltip pending <widget>
+# USAGE: tooltip show
 # USAGE: tooltip cancel
 #
@@ -329,46 +176,19 @@
 # bindings take over.
 # ----------------------------------------------------------------------
-itcl::body Rappture::Tooltip::tooltip {option args} {
+itcl::body Rappture::Tooltip::tooltip {option {widget ""}} {
     switch -- $option {
         pending {
-            if {[llength $args] < 1 || [llength $args] > 2} {
-                error "wrong # args: should be \"tooltip pending widget ?@x,y?\""
-            }
-            set widget [lindex $args 0]
-            set loc [lindex $args 1]
-
-            if {![info exists catalog($widget-message)]} {
-                return;                        # No tooltip for widget.
+            if {![info exists catalog($widget)]} {
+                error "can't find tooltip for $widget"
             }
             if {$pending != ""} {
                 after cancel $pending
             }
-            set pending [after 750 [itcl::code tooltip show $widget $loc]]
+            set pending [after 1500 [itcl::code tooltip show $widget]]
         }
         show {
-            if {[llength $args] < 1 || [llength $args] > 2} {
-                error "wrong # args: should be \"tooltip show tag loc\""
-            }
-            set tag [lindex $args 0]
-            set loc [lindex $args 1]
-
-            # tag name may be .g-axis -- get widget ".g" part
-            set widget $tag
-            if {[regexp {^(\.[^-]+)-[^\.]+$} $widget match wname]} {
-                set widget $wname
-            }
-
-            if {[winfo exists $widget] && [info exists catalog($tag-message)]} {
-                .rappturetooltip configure \
-                    -message $catalog($tag-message) \
-                    -log $catalog($tag-log)
-
-                if {[string index $loc 0] == "@"} {
-                    .rappturetooltip show $loc
-                } elseif {[regexp {^[-+]} $loc]} {
-                    .rappturetooltip show $widget$loc
-                } else {
-                    .rappturetooltip show $widget
-                }
+            if {[winfo exists $widget]} {
+                .rappturetooltip configure -message $catalog($widget)
+                .rappturetooltip show $widget
             }
         }
@@ -455,22 +275,10 @@
 }
 
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -log
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Tooltip::log {
-    # logging options changed -- reset showing time
-    set _showing 0
-}
-
 # create a tooltip widget to show tool tips
 Rappture::Tooltip .rappturetooltip
 
-# any click on any widget takes down the tooltip
-bind all <Leave> [list ::Rappture::Tooltip::tooltip cancel]
-bind all <ButtonPress> [list ::Rappture::Tooltip::tooltip cancel]
-
 # create a tooltip widget to show error cues
 Rappture::Tooltip .rappturetoolcue \
-    -icon [Rappture::icon cue24] \
+    -icon $Rappture::Tooltip::icons(cue) \
     -background black -outline #333333 -foreground white
 
Index: trunk/gui/scripts/transferfunctioneditor.tcl
===================================================================
--- trunk/gui/scripts/transferfunctioneditor.tcl	(revision 6716)
+++ 	(revision )
@@ -1,361 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: transferfunctioneditor - Rudimentary editor for 3D volume
-#                                      transfer functions
-#
-#  This class is used to modify transfer functions used in volume rendering
-#  on 3D scalar/vector datasets.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-package require Img
-
-itcl::class Rappture::TransferFunctionEditor {
-    constructor {c name args} {}
-    destructor {}
-    public method limits { min max }
-    public method names {}
-    public method name {}
-    public method values {}
-    public method absoluteValues {}
-    public method removeMarkers { list }
-    public method addMarkers { values }
-    public method newMarker { x y state }
-    public method deleteMarker { x y }
-    public method hideMarkers { {list {}} }
-    public method showMarkers { {limits {}} }
-
-    public variable command ""
-
-    private method SetAbsoluteValue { name x }
-    private method GetAbsoluteValue { name }
-    private method ContinueDrag { name x y }
-    private method EnterTick { name }
-    private method GetOverlappingMarkers { x y }
-    private method GetScreenPosition { name }
-    private method LeaveTick { name }
-    private method SetRelativeValue { name x }
-    private method GetRelativeValue { name }
-    private method RemoveDuplicateMarkers {name x y}
-    private method SetScreenPosition { name }
-    private method SetVisibility { name bool }
-    private method StartDrag { name x y }
-    private method StopDrag { name x y }
-    private method Activate { name }
-    private method Deactivate { name }
-    private method UpdateViewer {}
-
-    private variable _nextId 0;         # Used to create unique marker names
-    private variable _values;           # Relative values for each marker.
-    private variable _limits;           # Over limits of transfer function.
-    private variable _labels;           # Label id for each marker.
-    private variable _ticks;            # Tick id for each marker.
-    private variable _canvas ""
-    private variable _name "";                # Name of transfer function.
-    private variable _activeMotion 0
-    private variable _activePress 0
-    private variable _id2name
-
-    private common _normalIcon [Rappture::icon nvlegendmark]
-    private common _activeIcon [Rappture::icon nvlegendmark2]
-}
-
-itcl::body Rappture::TransferFunctionEditor::constructor {c name args} {
-    set _canvas $c
-    set _name $name
-    set _limits [list 0.0 1.0]
-    eval configure $args
-}
-
-itcl::body Rappture::TransferFunctionEditor::limits { min max } {
-    set _limits [list $min $max]
-}
-
-itcl::body Rappture::TransferFunctionEditor::names {} {
-    return [lsort [array names _values]]
-}
-
-itcl::body Rappture::TransferFunctionEditor::values {} {
-    set list {}
-    foreach name [array names _ticks] {
-        lappend list [GetRelativeValue $name]
-    }
-    return [lsort -real $list]
-}
-
-itcl::body Rappture::TransferFunctionEditor::absoluteValues {} {
-    set list {}
-    foreach name [array names _values] {
-        lappend list [GetAbsoluteValue $name]
-    }
-    return $list
-}
-
-itcl::body Rappture::TransferFunctionEditor::deleteMarker { x y } {
-    foreach marker [GetOverlappingMarkers $x $y] {
-        $_canvas delete $_ticks($marker)
-        $_canvas delete $_labels($marker)
-        array unset _ticks $marker
-        array unset _labels $marker
-        array unset _values $marker
-        bell
-        UpdateViewer
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::newMarker { x y state } {
-    foreach id [$_canvas find overlapping \
-                    [expr $x-5] [expr $y-5] [expr $x+5] [expr $y+5]] {
-        if { [info exists _id2name($id)] } {
-            puts stderr "Too close to existing marker"
-            return;                     # Too close to existing marker
-        }
-    }
-    set name "tick[incr _nextId]"
-    set w [winfo width $_canvas]
-    set h [winfo height $_canvas]
-
-    set _ticks($name) [$_canvas create image 0 $h \
-                           -image $_normalIcon -anchor s \
-                           -tags "tick $_name $this" -state $state]
-    set _labels($name) [$_canvas create text 0 $h \
-                            -anchor n -fill white -font "Helvetica 8" \
-                            -tags "labels text $this $_name" -state $state]
-    set _id2name($_ticks($name)) $name
-    $_canvas bind $_ticks($name) <Enter> [itcl::code $this EnterTick $name]
-    $_canvas bind $_ticks($name) <Leave> [itcl::code $this LeaveTick $name]
-    $_canvas bind $_ticks($name) <ButtonPress-1> \
-        [itcl::code $this StartDrag $name %x %y]
-    $_canvas bind $_ticks($name) <B1-Motion> \
-        [itcl::code $this ContinueDrag $name %x %y]
-    $_canvas bind $_ticks($name) <ButtonRelease-1> \
-        [itcl::code $this StopDrag $name %x %y]
-
-    SetRelativeValue $name [expr {double($x-10)/($w-20)}]
-    if { $state == "normal" } {
-        UpdateViewer
-    }
-    return $name
-}
-
-itcl::body Rappture::TransferFunctionEditor::destructor {} {
-    if { [winfo exists $_canvas] } {
-        $_canvas delete $_name
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::name {} {
-    return $_name
-}
-
-itcl::body Rappture::TransferFunctionEditor::Activate { name } {
-    if  { $_activePress || $_activeMotion } {
-        $_canvas itemconfigure $_labels($name) -state normal
-        $_canvas itemconfigure $_ticks($name) -image $_activeIcon
-        $_canvas itemconfigure title -state hidden
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::Deactivate { name } {
-    if  { $_activePress || $_activeMotion } {
-        #puts stderr "do nothing for Deactivate"
-    } else {
-        $_canvas itemconfigure $_labels($name) -state hidden
-        $_canvas itemconfigure $_ticks($name) -image $_normalIcon
-        $_canvas itemconfigure title -state normal
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::SetVisibility { name bool } {
-    if { $bool } {
-        $_canvas itemconfigure $_ticks($name) -state normal
-        $_canvas raise $_ticks($name)
-    } else {
-        $_canvas itemconfigure $_ticks($name) -state hidden
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::GetScreenPosition { name } {
-    set x [GetRelativeValue $name]
-    if { $x < 0.0 } {
-        set x 0.0
-    } elseif { $x > 1.0 } {
-        set x 1.0
-    }
-    set low 10
-    set w [winfo width $_canvas]
-    set high [expr {$w  - 10}]
-    set x [expr {round($x*($high - $low) + $low)}]
-    return $x
-}
-
-itcl::body Rappture::TransferFunctionEditor::SetScreenPosition { name } {
-    set value $_values($name)
-    set x [GetScreenPosition $name]
-    set absval [GetAbsoluteValue $name]
-    set y 31
-    $_canvas itemconfigure $_labels($name) -text [format %g $absval]
-    $_canvas coords $_ticks($name) $x [expr {$y+3}]
-    $_canvas coords $_labels($name) $x [expr {$y+5}]
-}
-
-itcl::body Rappture::TransferFunctionEditor::GetAbsoluteValue { name } {
-    foreach {min max} $_limits break
-    return [expr {($_values($name) * ($max - $min)) + $min}]
-}
-
-itcl::body Rappture::TransferFunctionEditor::SetAbsoluteValue { name value } {
-    foreach {min max} $_limits break
-    set absval $value
-    set relval [expr {($absval - $min) / ($max - $min)}]
-    set _values($name) $relval
-    set y 31
-    $_canvas itemconfigure $_label -text [format %g $absval]
-    set x [GetScreenPosition $name]
-    $_canvas coords $_ticks($name) $x [expr {$y+3}]
-    $_canvas coords $_labels($name) $x [expr {$y+5}]
-    return $absval
-}
-
-itcl::body Rappture::TransferFunctionEditor::GetRelativeValue { name } {
-    return $_values($name)
-}
-
-itcl::body Rappture::TransferFunctionEditor::SetRelativeValue { name value } {
-    if {$value < 0.0} {
-        set value 0.0
-    } elseif {$value > 1.0} {
-        set value 1.0
-    }
-    set _values($name) $value
-    set x [GetScreenPosition $name]
-    set y 31
-    set absval [GetAbsoluteValue $name]
-    $_canvas itemconfigure $_labels($name) -text [format %g $absval]
-    $_canvas coords $_ticks($name) $x [expr {$y+3}]
-    $_canvas coords $_labels($name) $x [expr {$y+5}]
-}
-
-itcl::body Rappture::TransferFunctionEditor::EnterTick { name } {
-    set _activeMotion 1
-    Activate $name
-    $_canvas raise $_ticks($name)
-}
-
-itcl::body Rappture::TransferFunctionEditor::LeaveTick { name } {
-    set _activeMotion 0
-    Deactivate $name
-}
-
-itcl::body Rappture::TransferFunctionEditor::StartDrag { name x y } {
-    $_canvas raise $_ticks($name)
-    set _activePress 1
-    Activate $name
-    $_canvas itemconfigure limits -state hidden
-    $_canvas itemconfigure title -state hidden
-}
-
-itcl::body Rappture::TransferFunctionEditor::StopDrag { name x y } {
-    ContinueDrag $name $x $y
-    RemoveDuplicateMarkers $name $x $y
-    set _activePress 0
-    Deactivate $name
-    $_canvas itemconfigure limits -state normal
-    $_canvas itemconfigure title -state normal
-}
-
-itcl::body Rappture::TransferFunctionEditor::ContinueDrag { name x y } {
-    set w [winfo width $_canvas]
-    SetRelativeValue $name [expr {double($x-10)/($w-20)}]
-    UpdateViewer
-    $_canvas raise $_ticks($name)
-    set _activePress 1
-    Activate $name
-    $_canvas itemconfigure limits -state hidden
-    $_canvas itemconfigure title -state hidden
-}
-
-itcl::body Rappture::TransferFunctionEditor::GetOverlappingMarkers { x y } {
-    set list {}
-    foreach id [$_canvas find overlapping $x $y $x $y] {
-        if { [info exists _id2name($id)] } {
-            lappend list $_id2name($id)
-        }
-    }
-    return $list
-}
-
-itcl::body Rappture::TransferFunctionEditor::hideMarkers { {list {}} } {
-    if { $list == "" } {
-        set list [array names _values]
-    }
-    foreach name $list {
-        SetVisibility $name 0
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::showMarkers { {limits {}} } {
-    if { $limits != "" } {
-        set _limits $limits
-        foreach name [array names _values] {
-            SetScreenPosition $name
-        }
-    }
-    foreach name [array names _values] {
-        SetVisibility $name 1
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::RemoveDuplicateMarkers {name x y} {
-    foreach marker [GetOverlappingMarkers $x $y] {
-        if { $marker != $name } {
-            Activate $marker
-            set markerx [GetScreenPosition $marker]
-            if { ($x < ($markerx-3)) || ($x > ($markerx+3)) } {
-                continue
-            }
-            $_canvas delete $_ticks($marker)
-            $_canvas delete $_labels($marker)
-            array unset _ticks $marker
-            array unset _labels $marker
-            array unset _values $marker
-            bell
-        }
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::addMarkers { values } {
-    foreach value $values {
-        set name [newMarker 0 0 hidden]
-        SetRelativeValue $name $value
-    }
-}
-
-itcl::body Rappture::TransferFunctionEditor::removeMarkers { names } {
-    if { $names == "" } {
-        set names [array names _values]
-    }
-    foreach name $names {
-        $_canvas delete $_ticks($name)
-        $_canvas delete $_labels($name)
-        array unset _ticks $name
-        array unset _labels $name
-        array unset _values $name
-    }
-    UpdateViewer
-}
-
-itcl::body Rappture::TransferFunctionEditor::UpdateViewer {} {
-    # Tell the nanovis/flowvis client to update its transfer functions
-    # now that a marker position has changed.
-    if { $command != "" } {
-        eval uplevel \#0 $command
-    }
-}
Index: trunk/gui/scripts/tuples.tcl
===================================================================
--- trunk/gui/scripts/tuples.tcl	(revision 6716)
+++ 	(revision )
@@ -1,453 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: tuples - represents a series of tuples for arbitrary data
-#
-#  This object represents a series of tuples.  Each tuple can contain
-#  one or more elements--for example, (a) or (a,b,c).  Each column
-#  in the tuple has a well-defined name and metadata.  Columns can
-#  be added even after data has been stored in the tuple list.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-
-itcl::class Rappture::Tuples {
-    constructor {args} { # defined below }
-
-    public method column {option args}
-    public method insert {pos args}
-    public method delete {{from ""} {to ""}}
-    public method put {args}
-    public method get {args}
-    public method find {args}
-    public method size {}
-
-    protected method _range {{from ""} {to ""}}
-
-    private variable _colnames ""  ;# list of column names
-    private variable _col2info     ;# maps column name => column options
-    private variable _tuples       ;# maps index => tuple data
-
-    private common _counter 0      ;# for auto-generated column names
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::constructor {args} {
-    eval configure $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: column insert <pos> ?-name n? ?-label l? ?-default v?
-# USAGE: column delete ?<name> <name>...?
-# USAGE: column names ?<pattern>?
-# USAGE: column info <name>
-#
-# Used by clients to manipulate the columns associated with this
-# list of tuples.  Each column is identified by a short name.  If
-# a name is not supplied when the column is created, then one is
-# generated automatically.  The column names can be queried back
-# in the order they appear in a tuple by using the "column names"
-# command.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::column {option args} {
-    switch -- $option {
-        insert {
-            # parse the incoming args
-            if {[llength $args] < 1} {
-                error "wrong # args: should be \"column insert pos ?-name n? ?-label l? ?-default v?\""
-            }
-            set pos [lindex $args 0]
-            set args [lrange $args 1 end]
-            Rappture::getopts args params {
-                value -name #auto
-                value -label ""
-                value -default ""
-            }
-
-            # FIXME: This is a band-aid.  The value can be an arbitrary
-            # string and therefore misinterpretered as an invalid list.
-            # Try to parse the value as a list and if that fails make a
-            # list out of it.  Hopefully this doesn't break run file
-            # comparisons.
-            if { [catch {llength $params(-default)}] != 0 } {
-                set params(-default) [list $params(-default)]
-            }
-
-            if {[llength $args] != 0} {
-                error "wrong # args: should be \"column insert pos ?-name n? ?-label l? ?-default v?\""
-            }
-
-            # insert the new column
-            set cname $params(-name)
-            if {$params(-name) == "#auto"} {
-                set cname "column[incr _counter]"
-            }
-            if {[lsearch -exact $_colnames $cname] >= 0} {
-                error "column name \"$cname\" already exists"
-            }
-            set _colnames [linsert $_colnames $pos $cname]
-            set _col2info($cname-label) $params(-label)
-            set _col2info($cname-default) $params(-default)
-
-            # run through all existing tuples and insert the default val
-            set max [array size _tuples]
-            for {set i 0} {$i < $max} {incr i} {
-                set oldval $_tuples($i)
-                set _tuples($i) [linsert $oldval $pos $params(-default)]
-            }
-        }
-        delete {
-            foreach cname $args {
-                set pos [lsearch -exact $_colnames $cname]
-                if {$pos < 0} {
-                    error "bad column name \"$cname\""
-                }
-                set _colnames [lreplace $_colnames $pos $pos]
-                unset _col2info($cname-label)
-                unset _col2info($cname-default)
-
-                # run through all existing tuples and delete the column
-                set max [array size _tuples]
-                for {set i 0} {$i < $max} {incr i} {
-                    set oldval $_tuples($i)
-                    set _tuples($i) [lreplace $oldval $pos $pos]
-                }
-            }
-        }
-        names {
-            if {[llength $args] == 0} {
-                return $_colnames
-            } elseif {[llength $args] == 1} {
-                set pattern [lindex $args 0]
-                set rlist ""
-                foreach cname $_colnames {
-                    if {[string match $pattern $cname]} {
-                        lappend rlist $cname
-                    }
-                }
-                return $rlist
-            } else {
-                error "wrong # args: should be \"column names ?pattern?\""
-            }
-        }
-        info {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"column info name\""
-            }
-            set cname [lindex $args 0]
-            set pos [lsearch -exact $_colnames $cname]
-            if {$pos < 0} {
-                error "bad column name \"$cname\""
-            }
-            return [list -label $_col2info($cname-label) -default $_col2info($cname-default)]
-        }
-        default {
-            error "bad option \"$option\": should be delete, info, insert, names"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: insert <pos> ?<tuple> <tuple> ...?
-#
-# Used by clients to insert one or more tuples into this list at
-# the given position <pos>.  Each <tuple> is a Tcl list of values
-# in order corresponding to the column names.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::insert {pos args} {
-    set cols [llength $_colnames]
-    set max [array size _tuples]
-
-    if {"end" == $pos} {
-        set pos $max
-    } elseif {![string is integer $pos]} {
-        error "bad position \"$pos\": should be integer or \"end\""
-    } elseif {$pos < 0} {
-        set pos 0
-    } elseif {$pos > $max} {
-        set pos $max
-    }
-
-    # make some room to insert these tuples
-    set need [llength $args]
-    for {set i [expr {$max-1}]} {$i >= $pos} {incr i -1} {
-        set _tuples([expr {$i+$need}]) $_tuples($i)
-    }
-
-    # add the tuples at the specified pos
-    foreach t $args {
-        # make sure each tuple has enough columns
-        while {[llength $t] < $cols} {
-            lappend t ""
-        }
-        set _tuples($pos) $t
-        incr pos
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<from>? ?<to>?
-#
-# Used by clients to delete one or more tuples in this list.  With
-# no args, it deletes all tuples.  With a single <from> arg, it deletes
-# the tuple at that number.  With both args, it deletes tuples in the
-# specified range.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::delete {{from ""} {to ""}} {
-    if {"" == $from && "" == $to} {
-        catch {unset _tuples}
-        return
-    }
-    if {[array size _tuples] == 0} {
-        return  ;# nothing to delete
-    }
-
-    set last [expr {[array size _tuples]-1}]
-    foreach {from to} [_range $from $to] break
-
-    # delete all tuples in the specified range
-    set gap [expr {$to-$from+1}]
-    for {set i $from} {$i <= $last-$gap} {incr i} {
-        set _tuples($i) $_tuples([expr {$i+$gap}])
-    }
-    for {} {$i <= $last} {incr i} {
-        unset _tuples($i)
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: put ?-format <columns>? <pos> <tuple>
-#
-# Used by clients to store a different tuple value at the specified
-# position <pos> in this list.  Normally, it stores the entire
-# <tuple> at the specified slot, which must already exist.  (Use
-# insert to create new slots.)  If the -format option is specified,
-# then it interprets <tuple> according to the names in the -format,
-# and updates only specific columns at that slot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::put {args} {
-    Rappture::getopts args params {
-        value -format ""
-    }
-    if {[llength $args] != 2} {
-        error "wrong # args: should be \"put ?-format cols? pos tuple\""
-    }
-    foreach {pos tuple} $args break
-    foreach {pos dummy} [_range $pos ""] break  ;# fix index
-
-    if {![info exists _tuples($pos)]} {
-        error "index $pos doesn't exist"
-    }
-
-    if {[string length $params(-format)] == 0} {
-        # no format -- add tuple as-is (with proper number of columns)
-        set cols [llength $_colnames]
-        while {[llength $tuple] < $cols} {
-            lappend tuple ""
-        }
-        set _tuples($pos) $tuple
-    } else {
-        # convert column names to indices
-        set nlist ""
-        foreach cname $params(-format) {
-            set n [lsearch -exact $_colnames $cname]
-            if {$n < 0} {
-                error "bad column name \"$cname\""
-            }
-            lappend nlist $n
-        }
-
-        # convert data only for those indices
-        set val $_tuples($pos)
-        foreach n $nlist t $tuple {
-            set val [lreplace $val $n $n $t]
-        }
-        set _tuples($pos) $val
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-format <columns>? ?<from>? ?<to>?
-#
-# Used by clients to query data from this list of tuples.  Returns
-# a list of tuples in the specified range, or a list of all tuples
-# if the range is not specified.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::get {args} {
-    Rappture::getopts args params {
-        value -format ""
-    }
-    if {[llength $args] > 2} {
-        error "wrong # args: should be \"get ?-format cols? ?from? ?to?\""
-    }
-    set from ""
-    set to ""
-    foreach {from to} $args break
-    foreach {from to} [_range $from $to] break
-
-    # empty? then return nothing
-    if {[array size _tuples] == 0} {
-        return ""
-    }
-
-    set rlist ""
-    if {[string length $params(-format)] == 0} {
-        # no format string -- return everything as-is
-        for {set i $from} {$i <= $to} {incr i} {
-            lappend rlist $_tuples($i)
-        }
-    } else {
-        # convert column names to indices
-        set nlist ""
-        foreach cname $params(-format) {
-            set n [lsearch -exact $_colnames $cname]
-            if {$n < 0} {
-                error "bad column name \"$cname\""
-            }
-            lappend nlist $n
-        }
-        set single [expr {[llength $nlist] == 1}]
-
-        # convert data only for those indices
-        for {set i $from} {$i <= $to} {incr i} {
-            set t ""
-            foreach n $nlist {
-                if {$single} {
-                    set t [lindex $_tuples($i) $n]
-                } else {
-                    lappend t [lindex $_tuples($i) $n]
-                }
-            }
-            lappend rlist $t
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: find ?-format <columns>? ?<tuple>?
-#
-# Used by clients to search for all or part of a <tuple> on the
-# list.  Without the extra -format option, this searches for an
-# exact match of the <tuple> and returns a list of indices that
-# match.  With the -format option, it checks the values for only
-# the specified <columns>, and again returns a list of indices
-# with matching values.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::find {args} {
-    Rappture::getopts args params {
-        value -format ""
-    }
-    if {[llength $args] > 1} {
-        error "wrong # args: should be \"find ?-format cols? ?tuple?\""
-    }
-
-    # convert column names to indices
-    set nlist ""
-    foreach cname $params(-format) {
-        set n [lsearch -exact $_colnames $cname]
-        if {$n < 0} {
-            error "bad column name \"$cname\""
-        }
-        lappend nlist $n
-    }
-
-    # scan through all entries and find matching values
-    set rlist ""
-    set last [expr {[array size _tuples]-1}]
-    if {[llength $args] == 0} {
-        # no tuple? then all match
-        for {set i 0} {$i <= $last} {incr i} {
-            lappend rlist $i
-        }
-    } else {
-        set tuple [lindex $args 0]
-        if {[llength $nlist] == 0} {
-            # no format? then look for an exact match
-            for {set i 0} {$i <= $last} {incr i} {
-                if {[string equal $tuple $_tuples($i)]} {
-                    lappend rlist $i
-                }
-            }
-        } else {
-            # match only the columns in the -format
-            for {set i 0} {$i <= $last} {incr i} {
-                set matching 1
-                foreach n $nlist t $tuple {
-                    set val [lindex $_tuples($i) $n]
-                    if {![string equal $t $val]} {
-                        set matching 0
-                        break
-                    }
-                }
-                if {$matching} {
-                    lappend rlist $i
-                }
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: size
-#
-# Used by clients to determine the number of tuples stored on this
-# list.  Returns the size of the list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::size {} {
-    return [array size _tuples]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _range ?<from>? ?<to>?
-#
-# Used internally to convert a <from>/<to> range to a range of real
-# number values.  If both are "", then the range is the entire range
-# of data.  The <from> and <to> values can be integers or the keyword
-# "end".
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tuples::_range {{from ""} {to ""}} {
-    set last [expr {[array size _tuples]-1}]
-    if {"" == $from && "" == $to} {
-        return [list 0 $last]
-    }
-
-    if {"end" == $from} {
-        set from $last
-    } elseif {![string is integer $from]} {
-        error "bad position \"$from\": should be integer or \"end\""
-    }
-    if {$from < 0} {
-        set from 0
-    } elseif {$from > $last} {
-        set from $last
-    }
-
-    if {"" == $to} {
-        set to $from
-    } elseif {"end" == $to} {
-        set to $last
-    } elseif {![string is integer $to]} {
-        error "bad position \"$to\": should be integer or \"end\""
-    }
-    if {$to < 0} {
-        set to 0
-    } elseif {$to > $last} {
-        set to $last
-    }
-
-    if {$from > $to} {
-        # make sure to/from are in proper order
-        set tmp $from
-        set from $to
-        set to $tmp
-    }
-    return [list $from $to]
-}
Index: trunk/gui/scripts/tweener.tcl
===================================================================
--- trunk/gui/scripts/tweener.tcl	(revision 6716)
+++ 	(revision )
@@ -1,114 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: tweener - used for animating smooth movements
-#
-#  Each Tweener executes a command repeatedly through a series of
-#  values from one extreme to another.  For example, the command may
-#  change the size of a rectangle, and the values may go from 10 to
-#  200.  The Tweener will make that happen over a specified interval
-#  of time.  The animation can be stopped or changed at any point,
-#  and if the Tweener is destroyed, the action is cancelled.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-
-itcl::class Rappture::Tweener {
-    public variable from 0        ;# value goes from this...
-    public variable to   1        ;# ...to this
-    public variable duration 500  ;# during this time interval
-    public variable steps 10      ;# with this many steps
-    public variable command ""    ;# gets executed with %v for value
-    public variable finalize ""   ;# gets executed at the end to finish up
-
-    constructor {args} { eval configure $args }
-    destructor { # defined below }
-
-    public method go {{how "-resume"}}
-    public method stop {}
-
-    private method _next {}
-
-    private variable _nstep 0      ;# current step number
-    private variable _afterid ""   ;# pending after event
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tweener::destructor {} {
-    stop
-}
-
-# ----------------------------------------------------------------------
-# USAGE: go ?-resume|-restart?
-#
-# Causes the current animation to start running, either where it
-# left off (-resume) or fromt the beginning (-restart).
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tweener::go {{how -resume}} {
-    switch -- $how {
-        -resume {
-            # leave _nstep alone
-        }
-        -restart {
-            set _nstep 0
-        }
-        default {
-            error "bad option \"$how\": should be -restart or -resume"
-        }
-    }
-    stop
-    set _afterid [after idle [itcl::code $this _next]]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: stop
-#
-# Causes the animation to stop by cancelling any pending after event.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tweener::stop {} {
-    if {"" != $_afterid} {
-        after cancel $_afterid
-        set _afterid ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _next
-#
-# Used internally to advance the animation.  Executes the -command
-# option with the current value substituted in place of any %v values.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Tweener::_next {} {
-    set value [expr {($to-$from)/double($steps)*$_nstep + $from}]
-    set cmd $command
-    regsub -all %v $cmd $value cmd
-    if {[catch {uplevel #0 $cmd} result]} {
-        bgerror "$result\n    (while managing tweener $this)"
-    }
-
-    if {[incr _nstep] <= $steps} {
-        set delay [expr {round($duration/double($steps))}]
-        set _afterid [after $delay [itcl::code $this _next]]
-    } elseif {[string length $finalize] > 0} {
-        set cmd $finalize
-        regsub -all %v $cmd $value cmd
-        if {[catch {uplevel #0 $cmd} result]} {
-            bgerror "$result\n    (while finalizing tweener $this)"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -command
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Tweener::command {
-    if {[string length $command] == 0} {
-        stop
-    }
-}
Index: trunk/gui/scripts/unirect2d.tcl
===================================================================
--- trunk/gui/scripts/unirect2d.tcl	(revision 6716)
+++ 	(revision )
@@ -1,300 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: unirect2d - represents a uniform rectangular 2-D mesh.
-#
-#  This object represents one field in an XML description of a device.
-#  It simplifies the process of extracting data vectors that represent
-#  the field.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture { # forward declaration }
-
-itcl::class Rappture::Unirect2d {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc fetch {xmlobj path}
-    public proc release {obj}
-
-    public method dimensions {} {
-        return 2
-    }
-    public method hints {{keyword ""}}
-    public method isvalid {} {
-        return $_isValid
-    }
-    public method label { axis }
-    public method limits {axis}
-    public method numpoints {} {
-        return $_numPoints
-    }
-    public method units { axis }
-    public method vtkdata {{what -partial}} {}
-
-    private method GetString { obj path varName }
-    private method GetValue { obj path varName }
-    private method GetSize { obj path varName }
-
-    private variable _xMax       0
-    private variable _xMin       0
-    private variable _xNum       0;     # Number of points along x-axis
-    private variable _yMax       0
-    private variable _yMin       0
-    private variable _yNum       0;     # Number of points along y-axis
-    private variable _hints
-    private variable _vtkdata    ""
-    private variable _numPoints  0
-    private variable _isValid    0;     # Indicates if the data is valid.
-
-    private common _xp2obj       ;      # used for fetch/release ref counting
-    private common _obj2ref      ;      # used for fetch/release ref counting
-}
-
-#
-# fetch <xmlobj> <path>
-#
-#    Clients use this instead of a constructor to fetch the Mesh for a
-#    particular <path> in the <xmlobj>.  When the client is done with the mesh,
-#    he calls "release" to decrement the reference count.  When the mesh is no
-#    longer needed, it is cleaned up automatically.
-#
-itcl::body Rappture::Unirect2d::fetch {xmlobj path} {
-    set handle "$xmlobj|$path"
-    if {[info exists _xp2obj($handle)]} {
-        set obj $_xp2obj($handle)
-        incr _obj2ref($obj)
-        return $obj
-    }
-    set obj [Rappture::Unirect2d ::#auto $xmlobj $path]
-    set _xp2obj($handle) $obj
-    set _obj2ref($obj) 1
-    return $obj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::Unirect2d::release <obj>
-#
-# Clients call this when they're no longer using a Mesh fetched
-# previously by the "fetch" proc.  This decrements the reference
-# count for the mesh and destroys the object when it is no longer
-# in use.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect2d::release { obj } {
-    if { ![info exists _obj2ref($obj)] } {
-        error "can't find reference count for $obj"
-    }
-    incr _obj2ref($obj) -1
-    if {$_obj2ref($obj) <= 0} {
-        unset _obj2ref($obj)
-        foreach handle [array names _xp2obj] {
-            if {$_xp2obj($handle) == $obj} {
-                unset _xp2obj($handle)
-            }
-        }
-        itcl::delete object $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# Constructor
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect2d::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be Rappture::library"
-    }
-    set m [$xmlobj element -as object $path]
-    GetValue $m "xaxis.min" _xMin
-    GetValue $m "xaxis.max" _xMax
-    GetValue $m "yaxis.min" _yMin
-    GetValue $m "yaxis.max" _yMax
-    GetSize $m "xaxis.numpoints" _xNum
-    GetSize $m "yaxis.numpoints" _yNum
-    foreach {key path} {
-        label   about.label
-        color   about.color
-        style   about.style
-        xlabel  xaxis.label
-        xdesc   xaxis.description
-        xunits  xaxis.units
-        xscale  xaxis.scale
-        xmin    xaxis.min
-        xmax    xaxis.max
-        ylabel  yaxis.label
-        ydesc   yaxis.description
-        yunits  yaxis.units
-        yscale  yaxis.scale
-        ymin    yaxis.min
-        ymax    yaxis.max
-        type    about.type
-    } {
-        set str [$m get $path]
-        if {"" != $str} {
-            set _hints($key) $str
-        }
-    }
-    itcl::delete object $m
-    set _numPoints [expr $_xNum * $_yNum]
-    if { $_numPoints == 0 } {
-        set _vtkdata ""
-        return
-    }
-    append out "DATASET STRUCTURED_POINTS\n"
-    append out "DIMENSIONS $_xNum $_yNum 1\n"
-    append out "ORIGIN $_xMin $_yMin 0\n"
-    if { $_xNum > 1 } {
-        set xSpace [expr (double($_xMax) - double($_xMin))/double($_xNum - 1)]
-    } else {
-        set xSpace 0.0
-    }
-    if { $_yNum > 1 } {
-        set ySpace [expr (double($_yMax) - double($_yMin))/double($_yNum - 1)]
-    } else {
-        set ySpace 0.0
-    }
-    append out "SPACING $xSpace $ySpace 0\n"
-    set _vtkdata $out
-    set _isValid 1
-    puts stderr "WARNING: The <unirect2d> element is deprecated.  Please use a <mesh> instead."
-}
-
-# ----------------------------------------------------------------------
-# Destructor
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect2d::destructor {} {
-    # empty
-}
-
-# ----------------------------------------------------------------------
-# method limits <axis>
-#       Returns a list {min max} representing the limits for the
-#       specified axis.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect2d::limits {which} {
-    set min ""
-    set max ""
-
-    switch -- $which {
-        x - xlin - xlog {
-            set min $_xMin
-            set max $_xMax
-        }
-        y - ylin - ylog {
-            set min $_yMin
-            set max $_yMax
-        }
-        z - zlin - zlog {
-            set min 0
-            set max 0
-        }
-        default {
-            error "unknown axis description \"$which\""
-        }
-    }
-    return [list $min $max]
-}
-
-#
-# units --
-#
-#       Returns the units of the given axis.
-#
-itcl::body Rappture::Unirect2d::units { axis } {
-    if { [info exists _hints(${axis}units)] } {
-        return $_hints(${axis}units)
-    }
-    return ""
-}
-
-#
-# label --
-#
-#       Returns the label of the given axis.
-#
-itcl::body Rappture::Unirect2d::label { axis } {
-    if { [info exists _hints(${axis}label)] } {
-        return $_hints(${axis}label)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this curve.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect2d::hints { {keyword ""} } {
-    if {[info exists _hints(xlabel)] && "" != $_hints(xlabel)
-        && [info exists _hints(xunits)] && "" != $_hints(xunits)} {
-        set _hints(xlabel) "$_hints(xlabel) ($_hints(xunits))"
-    }
-    if {[info exists _hints(ylabel)] && "" != $_hints(ylabel)
-        && [info exists _hints(yunits)] && "" != $_hints(yunits)} {
-        set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))"
-    }
-    if {[info exists _hints(group)] && [info exists _hints(label)]} {
-        # pop-up help for each curve
-        set _hints(tooltip) $_hints(label)
-    }
-    if {$keyword != ""} {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
-        }
-        return ""
-    }
-    return [array get _hints]
-}
-
-itcl::body Rappture::Unirect2d::vtkdata {{what -partial}} {
-    if {$what == "-full"} {
-        append out "# vtk DataFile Version 3.0\n"
-        append out "[hints label]\n"
-        append out "ASCII\n"
-        append out $_vtkdata
-        return $out
-    } else {
-        return $_vtkdata
-    }
-}
-
-itcl::body Rappture::Unirect2d::GetSize { obj path varName } {
-    set string [$obj get $path]
-    if { [scan $string "%d" value] != 1 || $value < 0 } {
-        puts stderr "can't get size \"$string\" of \"$path\""
-        return
-    }
-    upvar $varName size
-    set size $value
-}
-
-itcl::body Rappture::Unirect2d::GetValue { obj path varName } {
-    set string [$obj get $path]
-    if { [scan $string "%g" value] != 1 } {
-        puts stderr "can't get value \"$string\" of \"$path\""
-        return
-    }
-    upvar $varName number
-    set number $value
-}
-
-itcl::body Rappture::Unirect2d::GetString { obj path varName } {
-    set string [$obj get $path]
-    if { $string == "" } {
-        puts stderr "can't get string \"$string\" of \"$path\""
-        return
-    }
-    upvar $varName str
-    set str $string
-}
Index: trunk/gui/scripts/unirect3d.tcl
===================================================================
--- trunk/gui/scripts/unirect3d.tcl	(revision 6716)
+++ 	(revision )
@@ -1,320 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: unirect3d - represents a uniform rectangular 3-D mesh.
-#
-#  This object represents one field in an XML description of a device.
-#  It simplifies the process of extracting data vectors that represent
-#  the field.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itcl
-package require BLT
-
-namespace eval Rappture { # forward declaration }
-
-itcl::class Rappture::Unirect3d {
-    constructor {xmlobj path} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc fetch {xmlobj path}
-    public proc release {obj}
-
-    public method dimensions {} {
-        return 3
-    }
-    public method hints {{keyword ""}}
-    public method isvalid {} {
-        return $_isValid
-    }
-    public method label { axis }
-    public method limits {axis}
-    public method numpoints {} {
-        return $_numPoints
-    }
-    public method units { axis }
-    public method vtkdata {{what -partial}} {}
-
-    private method GetString { obj path varName }
-    private method GetValue { obj path varName }
-    private method GetSize { obj path varName }
-
-    private variable _xMax       0
-    private variable _xMin       0
-    private variable _xNum       0;     # Number of points along x-axis
-    private variable _yMax       0
-    private variable _yMin       0
-    private variable _yNum       0;     # Number of points along y-axis
-    private variable _zMax       0
-    private variable _zMin       0
-    private variable _zNum       0;     # Number of points along z-axis
-    private variable _hints
-    private variable _vtkdata    ""
-    private variable _numPoints  0
-    private variable _isValid    0;     # Indicates if the data is valid.
-
-    private common _xp2obj       ;      # used for fetch/release ref counting
-    private common _obj2ref      ;      # used for fetch/release ref counting
-}
-
-#
-# fetch <xmlobj> <path>
-#
-#    Clients use this instead of a constructor to fetch the Mesh for a
-#    particular <path> in the <xmlobj>.  When the client is done with the mesh,
-#    he calls "release" to decrement the reference count.  When the mesh is no
-#    longer needed, it is cleaned up automatically.
-#
-itcl::body Rappture::Unirect3d::fetch {xmlobj path} {
-    set handle "$xmlobj|$path"
-    if {[info exists _xp2obj($handle)]} {
-        set obj $_xp2obj($handle)
-        incr _obj2ref($obj)
-        return $obj
-    }
-    set obj [Rappture::Unirect3d ::#auto $xmlobj $path]
-    set _xp2obj($handle) $obj
-    set _obj2ref($obj) 1
-    return $obj
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rappture::Unirect3d::release <obj>
-#
-# Clients call this when they're no longer using a Mesh fetched
-# previously by the "fetch" proc.  This decrements the reference
-# count for the mesh and destroys the object when it is no longer
-# in use.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect3d::release { obj } {
-    if { ![info exists _obj2ref($obj)] } {
-        error "can't find reference count for $obj"
-    }
-    incr _obj2ref($obj) -1
-    if {$_obj2ref($obj) <= 0} {
-        unset _obj2ref($obj)
-        foreach handle [array names _xp2obj] {
-            if {$_xp2obj($handle) == $obj} {
-                unset _xp2obj($handle)
-            }
-        }
-        itcl::delete object $obj
-    }
-}
-
-# ----------------------------------------------------------------------
-# Constructor
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect3d::constructor {xmlobj path} {
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be Rappture::library"
-    }
-    set m [$xmlobj element -as object $path]
-    GetValue $m "xaxis.min" _xMin
-    GetValue $m "xaxis.max" _xMax
-    GetValue $m "yaxis.min" _yMin
-    GetValue $m "yaxis.max" _yMax
-    GetValue $m "zaxis.min" _zMin
-    GetValue $m "zaxis.max" _zMax
-    GetSize $m "xaxis.numpoints" _xNum
-    GetSize $m "yaxis.numpoints" _yNum
-    GetSize $m "zaxis.numpoints" _zNum
-    foreach {key path} {
-        label   about.label
-        color   about.color
-        style   about.style
-        xlabel  xaxis.label
-        xdesc   xaxis.description
-        xunits  xaxis.units
-        xscale  xaxis.scale
-        xmin    xaxis.min
-        xmax    xaxis.max
-        ylabel  yaxis.label
-        ydesc   yaxis.description
-        yunits  yaxis.units
-        yscale  yaxis.scale
-        ymin    yaxis.min
-        ymax    yaxis.max
-        zlabel  zaxis.label
-        zdesc   zaxis.description
-        zunits  zaxis.units
-        zscale  zaxis.scale
-        zmin    zaxis.min
-        zmax    zaxis.max
-    } {
-        set str [$m get $path]
-        if {"" != $str} {
-            set _hints($key) $str
-        }
-    }
-    itcl::delete object $m
-    set _numPoints [expr $_xNum * $_yNum * $_zNum]
-    if { $_numPoints == 0 } {
-        set _vtkdata ""
-        return
-    }
-    append out "DATASET STRUCTURED_POINTS\n"
-    append out "DIMENSIONS $_xNum $_yNum $_zNum\n"
-    append out "ORIGIN $_xMin $_yMin $_zMin\n"
-    if { $_xNum > 1 } {
-        set xSpace [expr (double($_xMax) - double($_xMin))/double($_xNum - 1)]
-    } else {
-        set xSpace 0.0
-    }
-    if { $_yNum > 1 } {
-        set ySpace [expr (double($_yMax) - double($_yMin))/double($_yNum - 1)]
-    } else {
-        set ySpace 0.0
-    }
-    if { $_zNum > 1 } {
-        set zSpace [expr (double($_zMax) - double($_zMin))/double($_zNum - 1)]
-    } else {
-        set zSpace 0.0
-    }
-    append out "SPACING $xSpace $ySpace $zSpace\n"
-    set _vtkdata $out
-    set _isValid 1
-    puts stderr "WARNING: The <unirect3d> element is deprecated.  Please use a <mesh> instead."
-}
-
-# ----------------------------------------------------------------------
-# Destructor
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect3d::destructor {} {
-    # empty
-}
-
-# ----------------------------------------------------------------------
-# method limits <axis>
-#       Returns a list {min max} representing the limits for the
-#       specified axis.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect3d::limits {which} {
-    set min ""
-    set max ""
-
-    switch -- $which {
-        x - xlin - xlog {
-            set min $_xMin
-            set max $_xMax
-        }
-        y - ylin - ylog {
-            set min $_yMin
-            set max $_yMax
-        }
-        z - zlin - zlog {
-            set min $_zMin
-            set max $_zMax
-        }
-        default {
-            error "unknown axis description \"$which\""
-        }
-    }
-    return [list $min $max]
-}
-
-#
-# units --
-#
-#       Returns the units of the given axis.
-#
-itcl::body Rappture::Unirect3d::units { axis } {
-    if { [info exists _hints(${axis}units)] } {
-        return $_hints(${axis}units)
-    }
-    return ""
-}
-
-#
-# label --
-#
-#       Returns the label of the given axis.
-#
-itcl::body Rappture::Unirect3d::label { axis } {
-    if { [info exists _hints(${axis}label)] } {
-        return $_hints(${axis}label)
-    }
-    return ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this curve.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Unirect3d::hints { {keyword ""} } {
-    if {[info exists _hints(xlabel)] && "" != $_hints(xlabel)
-        && [info exists _hints(xunits)] && "" != $_hints(xunits)} {
-        set _hints(xlabel) "$_hints(xlabel) ($_hints(xunits))"
-    }
-    if {[info exists _hints(ylabel)] && "" != $_hints(ylabel)
-        && [info exists _hints(yunits)] && "" != $_hints(yunits)} {
-        set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))"
-    }
-    if {[info exists _hints(zlabel)] && "" != $_hints(zlabel)
-        && [info exists _hints(zunits)] && "" != $_hints(zunits)} {
-        set _hints(ylabel) "$_hints(zlabel) ($_hints(zunits))"
-    }
-    if {[info exists _hints(group)] && [info exists _hints(label)]} {
-        # pop-up help for each curve
-        set _hints(tooltip) $_hints(label)
-    }
-    if {$keyword != ""} {
-        if {[info exists _hints($keyword)]} {
-            return $_hints($keyword)
-        }
-        return ""
-    }
-    return [array get _hints]
-}
-
-itcl::body Rappture::Unirect3d::vtkdata {{what -partial}} {
-    if {$what == "-full"} {
-        append out "# vtk DataFile Version 3.0\n"
-        append out "[hints label]\n"
-        append out "ASCII\n"
-        append out $_vtkdata
-        return $out
-    } else {
-        return $_vtkdata
-    }
-}
-
-itcl::body Rappture::Unirect3d::GetSize { obj path varName } {
-    set string [$obj get $path]
-    if { [scan $string "%d" value] != 1 || $value < 0 } {
-        puts stderr "can't get size \"$string\" of \"$path\""
-        return
-    }
-    upvar $varName size
-    set size $value
-}
-
-itcl::body Rappture::Unirect3d::GetValue { obj path varName } {
-    set string [$obj get $path]
-    if { [scan $string "%g" value] != 1 } {
-        puts stderr "can't get value \"$string\" of \"$path\""
-        return
-    }
-    upvar $varName number
-    set number $value
-}
-
-itcl::body Rappture::Unirect3d::GetString { obj path varName } {
-    set string [$obj get $path]
-    if { $string == "" } {
-        puts stderr "can't get string \"$string\" of \"$path\""
-        return
-    }
-    upvar $varName str
-    set str $string
-}
Index: trunk/gui/scripts/units.tcl
===================================================================
--- trunk/gui/scripts/units.tcl	(revision 6716)
+++ trunk/gui/scripts/units.tcl	(revision 1)
@@ -1,3 +1,2 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: units - mechanism for converting numbers with units
@@ -8,8 +7,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
 # ======================================================================
 package require Itcl
@@ -61,167 +57,4 @@
 }
 
-
-# ----------------------------------------------------------------------
-# USAGE: mcheck_range value {min ""} {max ""}
-#
-# Checks a value or PDF to determine if is is in a required range.
-# Automatically does unit conversion if necessary.
-# Returns value if OK.  Error if out-of-range
-# Examples:
-#    [mcheck_range "gaussian 0C 1C" 200K 500K] returns 1
-#    [mcheck_range "uniform 100 200" 150 250] returns 0
-#    [mcheck_range 100 0 200] returns 1
-# ----------------------------------------------------------------------
-
-proc Rappture::Units::_check_range {value min max units} {
-    # puts "_check_range $value min=$min max=$max units=$units"
-    # make sure the value has units
-    if {$units != ""} {
-        set value [Rappture::Units::convert $value -context $units]
-        # for comparisons, remove units
-        set nv [Rappture::Units::convert $value -context $units -units off]
-        # get the units for the value
-        set newunits [Rappture::Units::Search::for $value]
-    } else {
-        set nv $value
-    }
-
-    if {"" != $min} {
-        if {"" != $units} {
-            # compute the minimum in the new units
-            set minv [Rappture::Units::convert $min -to $newunits -context $units  -units off]
-            # same, but include units for printing
-            set convMinVal [Rappture::Units::convert $min -to $newunits -context $units]
-        } else {
-            set minv $min
-            set convMinVal $min
-        }
-        if {$nv < $minv} {
-            error "Minimum value allowed here is $convMinVal"
-        }
-    }
-    if {"" != $max} {
-        if {"" != $units} {
-            # compute the maximum in the new units
-            set maxv [Rappture::Units::convert $max -to $newunits -context $units -units off]
-            # same, but include units for printing
-            set convMaxVal [Rappture::Units::convert $max -to $newunits -context $units ]
-        } else {
-            set maxv $max
-            set convMaxVal $max
-        }
-        if {$nv > $maxv} {
-            error "Maximum value allowed here is $convMaxVal"
-        }
-    }
-    return $value
-}
-
-proc Rappture::Units::mcheck_range {value {min ""} {max ""} {units ""}} {
-    # puts "mcheck_range $value min=$min max=$max units=$units"
-
-    switch -- [lindex $value 0] {
-        normal -
-        gaussian {
-            # get the mean
-            set mean [_check_range [lindex $value 1] $min $max $units]
-            if {$units == ""} {
-                set dev [lindex $value 2]
-                set ndev $dev
-            } else {
-                set dev [Rappture::Units::convert [lindex $value 2] -context $units]
-                set ndev [Rappture::Units::convert $dev -units off]
-            }
-            if {$ndev <= 0} {
-                error "Deviation must be positive."
-            }
-            return [list gaussian $mean $dev]
-        }
-        uniform {
-            set min [_check_range [lindex $value 1] $min $max $units]
-            set max [_check_range [lindex $value 2] $min $max $units]
-            return [list uniform $min $max]
-        }
-        exact  {
-            return [_check_range [lindex $value 1] $min $max $units]
-        }
-        default {
-            return [_check_range [lindex $value 0] $min $max $units]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: mconvert value ?-context units? ?-to units? ?-units on/off?
-#
-# This version of convert() converts multiple values.  Used when the
-# value could be a range or probability density function (PDF).
-# Examples:
-#    gaussian 100k 1k
-#    uniform 0eV 10eV
-#    42
-#    exact 42
-# ----------------------------------------------------------------------
-
-proc Rappture::Units::mconvert {value args} {
-    # puts "mconvert $value : $args"
-    array set opts {
-        -context ""
-        -to ""
-        -units "on"
-    }
-
-    set value [split $value]
-
-    switch -- [lindex $value 0] {
-        normal - gaussian {
-            set valtype gaussian
-            set vals [lrange $value 1 2]
-            set convtype {0 1}
-        }
-        uniform {
-            set valtype uniform
-            set vals [lrange $value 1 2]
-            set convtype {0 0}
-        }
-        exact  {
-            set valtype ""
-            set vals [lindex $value 1]
-            set convtype {0}
-        }
-        default {
-            set valtype ""
-            set vals $value
-            set convtype {0}
-        }
-    }
-
-    foreach {key val} $args {
-        if {![info exists opts($key)]} {
-            error "bad option \"$key\": should be [join [lsort [array names opts]] {, }]"
-        }
-        set opts($key) $val
-    }
-
-    set newval $valtype
-    foreach val $vals ctype $convtype {
-        if {$ctype == 1} {
-            # This code handles unit conversion for deltas (changes).
-            # For example, if we want a standard deviation of 10C converted
-            # to Kelvin, that is 10K, NOT a standard deviation of 283.15K.
-            set units [Rappture::Units::Search::for $val]
-            set base [eval Rappture::Units::convert 0$units $args -units off]
-            set new [eval Rappture::Units::convert $val $args -units off]
-            set delta [expr $new - $base]
-            set val $delta$opts(-to)
-        }
-        # tcl 8.5 allows us to do this:
-        # lappend newval [Rappture::Units::convert $val {*}$args]
-        # but we are using tcl8.4 so we use eval :^(
-        lappend newval [eval Rappture::Units::convert $val $args]
-    }
-    return $newval
-}
-
 # ----------------------------------------------------------------------
 # USAGE: convert value ?-context units? ?-to units? ?-units on/off?
@@ -233,7 +66,54 @@
 # current system.
 # ----------------------------------------------------------------------
-# proc Rappture::Units::convert {value args} {}
-# Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc.
-
+proc Rappture::Units::convert {value args} {
+    array set opts {
+        -context ""
+        -to ""
+        -units "on"
+    }
+    foreach {key val} $args {
+        if {![info exists opts($key)]} {
+            error "bad option \"$key\": should be [join [lsort [array names opts]] {, }]"
+        }
+        set opts($key) $val
+    }
+
+    #
+    # Parse the value into the number part and the units part.
+    #
+    set value [string trim $value]
+    if {![regexp {^([-+]?[0-9]+\.?([0-9]+)?([eEdD][-+]?[0-9]+)?) *(/?[a-zA-Z]+[0-9]*)?$} $value match number dummy1 dummy2 units]} {
+        set mesg "bad value \"$value\": should be real number with units"
+        if {$opts(-context) != ""} {
+            append mesg " of [Rappture::Units::description $opts(-context)]"
+        }
+        error $mesg
+    }
+    if {$units == ""} {
+        set units $opts(-context)
+    }
+
+    #
+    # Try to find the object representing the current system of units.
+    #
+    set units [Rappture::Units::System::regularize $units]
+    set oldsys [Rappture::Units::System::for $units]
+    if {$oldsys == ""} {
+        set mesg "value \"$value\" has unrecognized units"
+        if {$opts(-context) != ""} {
+            append mesg ".\nShould be units of [Rappture::Units::description $opts(-context)]"
+        }
+        error $mesg
+    }
+
+    #
+    # Convert the number to the new system of units.
+    #
+    if {$opts(-to) == ""} {
+        # no units -- return the number as is
+        return "$number$units"
+    }
+    return [$oldsys convert "$number$units" $opts(-to) $opts(-units)]
+}
 
 # ----------------------------------------------------------------------
@@ -244,7 +124,16 @@
 # along with a list of all compatible systems.
 # ----------------------------------------------------------------------
-# proc Rappture::Units::description {units} {}
-# Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc.
-
+proc Rappture::Units::description {units} {
+    set sys [Rappture::Units::System::for $units]
+    if {$sys == ""} {
+        return ""
+    }
+    set mesg [$sys cget -type]
+    set ulist [Rappture::Units::System::all $units]
+    if {"" != $ulist} {
+        append mesg " ([join $ulist {, }])"
+    }
+    return $mesg
+}
 
 # ----------------------------------------------------------------------
@@ -261,8 +150,6 @@
     private variable _system ""  ;# this system of units
 
-    # These are in rappture/lang/tcl/src/RpUnitsTclInterface.cc.
-    # public proc for {units}
-    # public proc all {units}
-
+    public proc for {units}
+    public proc all {units}
     public proc regularize {units}
 
@@ -470,7 +357,49 @@
 # if there is no system that matches the units string.
 # ----------------------------------------------------------------------
-# itcl::body Rappture::Units::System::for {units} {}
-# Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc.
-
+itcl::body Rappture::Units::System::for {units} {
+    #
+    # See if the units are a recognized system.  If not, then try to
+    # extract any metric prefix and see if what's left is a recognized
+    # system.  If all else fails, see if we can find a system without
+    # the exact capitalization.  The user might say "25c" instead of
+    # "25C".  Try to allow that.
+    #
+    if {[info exists _base($units)]} {
+        return $_base($units)
+    } else {
+        set orig $units
+        if {[regexp {^(/?)[cCmMuUnNpPfFaAkKgGtT](.+)$} $units match slash tail]} {
+            set base "$slash$tail"
+            if {[info exists _base($base)]} {
+                set sys $_base($base)
+                if {[$sys cget -metric]} {
+                    return $sys
+                }
+            }
+
+            # check the base part for improper capitalization below...
+            set units $base
+        }
+
+        set matching ""
+        foreach u [array names _base] {
+            if {[string equal -nocase $u $units]} {
+                lappend matching $_base($u)
+            }
+        }
+        if {[llength $matching] == 1} {
+            set sys [lindex $matching 0]
+            #
+            # If we got rid of a metric prefix above, make sure
+            # that the system is metric.  If not, then we don't
+            # have a match.
+            #
+            if {[string equal $units $orig] || [$sys cget -metric]} {
+                return $sys
+            }
+        }
+    }
+    return ""
+}
 
 # ----------------------------------------------------------------------
@@ -481,7 +410,26 @@
 # relationships that lead to the same base system.
 # ----------------------------------------------------------------------
-# itcl::body Rappture::Units::System::all {units} {}
-# Actual implementation is in rappture/lang/tcl/src/RpUnitsTclInterface.cc.
-
+itcl::body Rappture::Units::System::all {units} {
+    set sys [Rappture::Units::System::for $units]
+    if {$sys == ""} {
+        return ""
+    }
+
+    if {"" != [$sys cget -basis]} {
+        set basis [lindex [$sys cget -basis] 0]
+    } else {
+        set basis $units
+    }
+
+    set ulist $basis
+    foreach u [array names _base] {
+        set obj $_base($u)
+        set b [lindex [$obj cget -basis] 0]
+        if {$b == $basis} {
+            lappend ulist $u
+        }
+    }
+    return $ulist
+}
 
 # ----------------------------------------------------------------------
@@ -499,5 +447,5 @@
     }
     # note: case-insensitive matching for metric prefix
-    if {[regexp {^(/?)([cCmMuUnNpPfFaAkKgGtT]?)([a-zA-Z]+[0-9]+|[a-zA-Z]+)$} $units match slash prefix tail]} {
+    if {[regexp {^(/?)([cCmMuUnNpPfFaAkKgGtT])(.+)$} $units match slash prefix tail]} {
         if {[regexp {^[CUNFAK]$} $prefix]} {
             # we know that these should be lower case
@@ -521,5 +469,4 @@
 
 Rappture::Units::define /m3 -type density -metric yes
-Rappture::Units::define /m2 -type misc -metric yes
 
 Rappture::Units::define C -type temperature -metric no
@@ -527,21 +474,3 @@
 Rappture::Units::define F->C {(F-32)/1.8} {(1.8*C)+32}
 
-Rappture::Units::define eV -type energy -metric yes
-Rappture::Units::define J->eV {J/1.602177e-19} {eV*1.602177e-19}
-
-Rappture::Units::define V -type voltage -metric yes
-
-Rappture::Units::define s -type seconds -metric yes
-# can't use min becase tcl thinks its milli-in's
-# Rappture::Units::define min->s {min*60.00} {s/60.00}
-Rappture::Units::define h->s {h*3600.00} {s/3600.00}
-Rappture::Units::define d->s {d*86400.00} {s/86400.00}
-
-# can't put mol's in because tcl thinks its milli-ol's
-# Rappture::Units::define mol -type misc -metric yes
-Rappture::Units::define Hz -type misc -metric yes
-Rappture::Units::define Bq -type misc -metric yes
-
-Rappture::Units::define deg -type angle -metric no
-Rappture::Units::define rad -type angle -metric no
-Rappture::Units::define deg->rad {deg*(3.1415926535897931/180.00)} {rad*(180.00/3.1415926535897931)}
+Rappture::Units::define eV -type potential -metric yes
Index: trunk/gui/scripts/uq.tcl
===================================================================
--- trunk/gui/scripts/uq.tcl	(revision 6716)
+++ 	(revision )
@@ -1,541 +1,0 @@
-package require Itk
-namespace eval Rappture {}
-
-itcl::class Rappture::UQ {
-
-    constructor {varlist num type uqargs} {
-        #puts "Rappture::UQ constructor $varlist:$type:$uqargs"
-        set _varlist $varlist
-        set _type $type
-        set _args $uqargs
-        set _num $num
-    }
-
-    destructor {
-        # defined below
-    }
-
-    public method run_dialog {win}
-    public method num_runs {}
-    public method type {} {return $_type}
-    public method args {} {return $_args}
-
-    protected method _setWaitVariable {state}
-    protected method _adjust_level {win}
-    protected method _set_text {win}
-    protected method _init_num_pts_array {}
-    public variable _type "smolyak"
-    private variable _args "2"
-    private variable _varlist {}
-    private variable _wait_uq 0
-    private variable _num_pts {}
-    private variable _go ""
-    private variable _num 0
-}
-
-# ----------------------------------------------------------------------
-# Display a dialog for setting UQ options.
-# Returns 0 to cancel, 1 to continue.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UQ::run_dialog {win} {
-
-    set popup .pop_simulate
-    if {[winfo exists $popup]} {destroy $popup}
-
-    if { ![winfo exists $popup] } {
-
-        Rappture::Balloon $popup -title "UQ Options"
-        set inner [$popup component inner]
-        labelframe  $inner.type -text "UQ Type"
-
-        set _val [Rappture::Combobox $inner.type.val -width 20 -editable no]
-        pack $_val -side top -expand yes -fill x -pady 5
-        $_val choices insert end smolyak "Smolyak"
-        $_val value [$_val label $_type]
-
-        label $inner.type.labeltext -text "Level" -font "Arial 9"
-        Rappture::Spinint $inner.type.level -min 1 -max 20
-        $inner.type.level value $_args
-        bind $inner.type.level <<Value>> [itcl::code $this _adjust_level $inner]
-        pack $inner.type.labeltext $inner.type.level -side left -expand yes -fill x -pady 5
-        pack $inner.type -side top -fill x
-
-        set fr [frame $inner.frame]
-
-        set nr [num_runs]
-        label $fr.text
-
-        #     bind $_val <<Value>> [itcl::code $this _change_param_type $inner]
-
-        button $fr.cancel -text Cancel -command  [itcl::code $this _setWaitVariable 0]
-        set _go $fr.go
-        button $_go -text "Launch Jobs" -command  [itcl::code $this _setWaitVariable 1]
-        _set_text $inner
-
-        pack $fr.text -side top -pady 10
-        pack $_go $fr.cancel -pady 4 -side right
-        pack $fr
-    }
-    update idletasks
-
-    _setWaitVariable -1
-    $popup activate $win below
-    tkwait variable [itcl::scope _wait_uq]
-    $popup deactivate
-
-    return $_wait_uq
-}
-
-itcl::body Rappture::UQ::_setWaitVariable {state} {
-    set _wait_uq $state
-}
-
-itcl::body Rappture::UQ::_set_text {win} {
-    set nr [num_runs]
-
-    switch $_type {
-        smolyak {
-            if {$nr == 0} {
-                set text "ERROR: The number of required jobs exceeds 100,000!\n\  Please\n\
-                adjust the polynomial level or reduce the number of UQ variables."
-                $_go configure -state disabled
-            } else {
-                set text "This method builds a polynomial response\
-                function of degree $_args.\n It will require $nr runs."
-                $_go configure -state normal
-            }
-        }
-        default {
-            set text "This will require $nr runs of the tool."
-            $_go configure -state normal
-        }
-    }
-    $win.frame.text configure -text $text
-}
-
-itcl::body Rappture::UQ::_adjust_level {win} {
-    set _args [$win.type.level value]
-    _set_text $win
-}
-
-itcl::body Rappture::UQ::num_runs {} {
-    #puts "varlist=$_varlist"
-    set numvars  $_num
-    #puts "UQ num_runs $numvars $_type $_args"
-    if {![array exists _num_pts]} { _init_num_pts_array }
-    switch $_type {
-        smolyak {
-            return $_num_pts($numvars,$_args)
-        }
-        default {
-            return $_args
-        }
-    }
-}
-
-itcl::body Rappture::UQ::_init_num_pts_array {} {
-    # array is indexed (dim,level)
-    unset _num_pts
-    array set _num_pts [list \
-        0,0 0 \
-        0,1 0 \
-        0,2 0 \
-        0,3 0 \
-        0,4 0 \
-        0,5 0 \
-        0,6 0 \
-        0,7 0 \
-        0,8 0 \
-        0,9 0 \
-        0,10 0 \
-        0,11 0 \
-        0,12 0 \
-        0,13 0 \
-        0,14 0 \
-        0,15 0 \
-        0,16 0 \
-        0,17 0 \
-        0,18 0 \
-        0,19 0 \
-        1,0 0 \
-        1,1 3 \
-        1,2 5 \
-        1,3 9 \
-        1,4 17 \
-        1,5 33 \
-        1,6 65 \
-        1,7 129 \
-        1,8 257 \
-        1,9 513 \
-        1,10 1025 \
-        1,11 2049 \
-        1,12 4097 \
-        1,13 8193 \
-        1,14 16385 \
-        1,15 32769 \
-        1,16 65537 \
-        1,17 131073 \
-        1,18 0 \
-        1,19 0 \
-        2,0 0 \
-        2,1 5 \
-        2,2 13 \
-        2,3 29 \
-        2,4 65 \
-        2,5 145 \
-        2,6 321 \
-        2,7 705 \
-        2,8 1537 \
-        2,9 3329 \
-        2,10 7169 \
-        2,11 15361 \
-        2,12 32769 \
-        2,13 69633 \
-        2,14 147457 \
-        2,15 0 \
-        2,16 0 \
-        2,17 0 \
-        2,18 0 \
-        2,19 0 \
-        3,0 0 \
-        3,1 7 \
-        3,2 25 \
-        3,3 69 \
-        3,4 177 \
-        3,5 441 \
-        3,6 1073 \
-        3,7 2561 \
-        3,8 6017 \
-        3,9 13953 \
-        3,10 32001 \
-        3,11 72705 \
-        3,12 163841 \
-        3,13 0 \
-        3,14 0 \
-        3,15 0 \
-        3,16 0 \
-        3,17 0 \
-        3,18 0 \
-        3,19 0 \
-        4,0 0 \
-        4,1 9 \
-        4,2 41 \
-        4,3 137 \
-        4,4 401 \
-        4,5 1105 \
-        4,6 2929 \
-        4,7 7537 \
-        4,8 18945 \
-        4,9 46721 \
-        4,10 113409 \
-        4,11 0 \
-        4,12 0 \
-        4,13 0 \
-        4,14 0 \
-        4,15 0 \
-        4,16 0 \
-        4,17 0 \
-        4,18 0 \
-        4,19 0 \
-        5,0 0 \
-        5,1 11 \
-        5,2 61 \
-        5,3 241 \
-        5,4 801 \
-        5,5 2433 \
-        5,6 6993 \
-        5,7 19313 \
-        5,8 51713 \
-        5,9 135073 \
-        5,10 0 \
-        5,11 0 \
-        5,12 0 \
-        5,13 0 \
-        5,14 0 \
-        5,15 0 \
-        5,16 0 \
-        5,17 0 \
-        5,18 0 \
-        5,19 0 \
-        6,0 0 \
-        6,1 13 \
-        6,2 85 \
-        6,3 389 \
-        6,4 1457 \
-        6,5 4865 \
-        6,6 15121 \
-        6,7 44689 \
-        6,8 127105 \
-        6,9 0 \
-        6,10 0 \
-        6,11 0 \
-        6,12 0 \
-        6,13 0 \
-        6,14 0 \
-        6,15 0 \
-        6,16 0 \
-        6,17 0 \
-        6,18 0 \
-        6,19 0 \
-        7,0 0 \
-        7,1 15 \
-        7,2 113 \
-        7,3 589 \
-        7,4 2465 \
-        7,5 9017 \
-        7,6 30241 \
-        7,7 95441 \
-        7,8 287745 \
-        7,9 0 \
-        7,10 0 \
-        7,11 0 \
-        7,12 0 \
-        7,13 0 \
-        7,14 0 \
-        7,15 0 \
-        7,16 0 \
-        7,17 0 \
-        7,18 0 \
-        7,19 0 \
-        8,0 0 \
-        8,1 17 \
-        8,2 145 \
-        8,3 849 \
-        8,4 3937 \
-        8,5 15713 \
-        8,6 56737 \
-        8,7 190881 \
-        8,8 0 \
-        8,9 0 \
-        8,10 0 \
-        8,11 0 \
-        8,12 0 \
-        8,13 0 \
-        8,14 0 \
-        8,15 0 \
-        8,16 0 \
-        8,17 0 \
-        8,18 0 \
-        8,19 0 \
-        9,0 0 \
-        9,1 19 \
-        9,2 181 \
-        9,3 1177 \
-        9,4 6001 \
-        9,5 26017 \
-        9,6 100897 \
-        9,7 0 \
-        9,8 0 \
-        9,9 0 \
-        9,10 0 \
-        9,11 0 \
-        9,12 0 \
-        9,13 0 \
-        9,14 0 \
-        9,15 0 \
-        9,16 0 \
-        9,17 0 \
-        9,18 0 \
-        9,19 0 \
-        10,0 0 \
-        10,1 21 \
-        10,2 221 \
-        10,3 1581 \
-        10,4 8801 \
-        10,5 41265 \
-        10,6 171425 \
-        10,7 0 \
-        10,8 0 \
-        10,9 0 \
-        10,10 0 \
-        10,11 0 \
-        10,12 0 \
-        10,13 0 \
-        10,14 0 \
-        10,15 0 \
-        10,16 0 \
-        10,17 0 \
-        10,18 0 \
-        10,19 0 \
-        11,0 0 \
-        11,1 23 \
-        11,2 265 \
-        11,3 2069 \
-        11,4 12497 \
-        11,5 63097 \
-        11,6 280017 \
-        11,7 0 \
-        11,8 0 \
-        11,9 0 \
-        11,10 0 \
-        11,11 0 \
-        11,12 0 \
-        11,13 0 \
-        11,14 0 \
-        11,15 0 \
-        11,16 0 \
-        11,17 0 \
-        11,18 0 \
-        11,19 0 \
-        12,0 0 \
-        12,1 25 \
-        12,2 313 \
-        12,3 2649 \
-        12,4 17265 \
-        12,5 93489 \
-        12,6 442001 \
-        12,7 0 \
-        12,8 0 \
-        12,9 0 \
-        12,10 0 \
-        12,11 0 \
-        12,12 0 \
-        12,13 0 \
-        12,14 0 \
-        12,15 0 \
-        12,16 0 \
-        12,17 0 \
-        12,18 0 \
-        12,19 0 \
-        13,0 0 \
-        13,1 27 \
-        13,2 365 \
-        13,3 3329 \
-        13,4 23297 \
-        13,5 134785 \
-        13,6 0 \
-        13,7 0 \
-        13,8 0 \
-        13,9 0 \
-        13,10 0 \
-        13,11 0 \
-        13,12 0 \
-        13,13 0 \
-        13,14 0 \
-        13,15 0 \
-        13,16 0 \
-        13,17 0 \
-        13,18 0 \
-        13,19 0 \
-        14,0 0 \
-        14,1 29 \
-        14,2 421 \
-        14,3 4117 \
-        14,4 30801 \
-        14,5 189729 \
-        14,6 0 \
-        14,7 0 \
-        14,8 0 \
-        14,9 0 \
-        14,10 0 \
-        14,11 0 \
-        14,12 0 \
-        14,13 0 \
-        14,14 0 \
-        14,15 0 \
-        14,16 0 \
-        14,17 0 \
-        14,18 0 \
-        14,19 0 \
-        15,0 0 \
-        15,1 31 \
-        15,2 481 \
-        15,3 5021 \
-        15,4 40001 \
-        15,5 261497 \
-        15,6 0 \
-        15,7 0 \
-        15,8 0 \
-        15,9 0 \
-        15,10 0 \
-        15,11 0 \
-        15,12 0 \
-        15,13 0 \
-        15,14 0 \
-        15,15 0 \
-        15,16 0 \
-        15,17 0 \
-        15,18 0 \
-        15,19 0 \
-        16,0 0 \
-        16,1 33 \
-        16,2 545 \
-        16,3 6049 \
-        16,4 51137 \
-        16,5 353729 \
-        16,6 0 \
-        16,7 0 \
-        16,8 0 \
-        16,9 0 \
-        16,10 0 \
-        16,11 0 \
-        16,12 0 \
-        16,13 0 \
-        16,14 0 \
-        16,15 0 \
-        16,16 0 \
-        16,17 0 \
-        16,18 0 \
-        16,19 0 \
-        17,0 0 \
-        17,1 35 \
-        17,2 613 \
-        17,3 7209 \
-        17,4 64465 \
-        17,5 470561 \
-        17,6 0 \
-        17,7 0 \
-        17,8 0 \
-        17,9 0 \
-        17,10 0 \
-        17,11 0 \
-        17,12 0 \
-        17,13 0 \
-        17,14 0 \
-        17,15 0 \
-        17,16 0 \
-        17,17 0 \
-        17,18 0 \
-        17,19 0 \
-        18,0 0 \
-        18,1 37 \
-        18,2 685 \
-        18,3 8509 \
-        18,4 80257 \
-        18,5 616657 \
-        18,6 0 \
-        18,7 0 \
-        18,8 0 \
-        18,9 0 \
-        18,10 0 \
-        18,11 0 \
-        18,12 0 \
-        18,13 0 \
-        18,14 0 \
-        18,15 0 \
-        18,16 0 \
-        18,17 0 \
-        18,18 0 \
-        18,19 0 \
-        19,0 0 \
-        19,1 39 \
-        19,2 761 \
-        19,3 9957 \
-        19,4 98801 \
-        19,5 797241 \
-        19,6 0 \
-        19,7 0 \
-        19,8 0 \
-        19,9 0 \
-        19,10 0 \
-        19,11 0 \
-        19,12 0 \
-        19,13 0 \
-        19,14 0 \
-        19,15 0 \
-        19,16 0 \
-        19,17 0 \
-        19,18 0 \
-        19,19 0 \
-    ]
-}
Index: trunk/gui/scripts/uqcurve.tcl
===================================================================
--- trunk/gui/scripts/uqcurve.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1681 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: UqCurve - Probability Curves in a UQ Notebook
-#
-#  Derived from xyresult.tcl.
-# ======================================================================
-#  AUTHOR:  Martin Hunt, Purdue University
-#  Copyright (c) 2015  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *UqCurve.width 3i widgetDefault
-option add *UqCurve.height 3i widgetDefault
-option add *UqCurve.gridColor #d9d9d9 widgetDefault
-option add *UqCurve.activeColor blue widgetDefault
-option add *UqCurve.dimColor gray widgetDefault
-option add *UqCurve.controlBackground gray widgetDefault
-option add *UqCurve.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-set autocolors {
-    #0000cd
-    #cd0000
-    #00cd00
-    #3a5fcd
-    #cdcd00
-    #cd1076
-    #009acd
-    #00c5cd
-    #a2b5cd
-    #7ac5cd
-    #66cdaa
-    #a2cd5a
-    #cd9b9b
-    #cdba96
-    #cd3333
-    #cd6600
-    #cd8c95
-    #cd00cd
-    #9a32cd
-    #6ca6cd
-    #9ac0cd
-    #9bcd9b
-    #00cd66
-    #cdc673
-    #cdad00
-    #cd5555
-    #cd853f
-    #cd7054
-    #cd5b45
-    #cd6889
-    #cd69c9
-    #551a8b
-}
-
-option add *UqCurve.autoColors $autocolors widgetDefault
-option add *UqCurve*Balloon*Entry.background white widgetDefault
-
-itcl::class Rappture::UqCurve {
-    inherit itk::Widget
-
-    itk_option define -gridcolor gridColor GridColor ""
-    itk_option define -activecolor activeColor ActiveColor ""
-    itk_option define -dimcolor dimColor DimColor ""
-    itk_option define -autocolors autoColors AutoColors ""
-
-    private variable _viewable "";      # Display list for widget.
-    private variable _dispatcher "";    # Dispatcher for !events
-    private variable _dlist "";         # List of dataobj objects
-    private variable _dataobj2raise;    # Maps dataobj => raise flag 0/1
-    private variable _dataobj2desc;     # Maps dataobj => description of data
-    private variable _dataobj2sim;      # Maps dataobj => type of graph element
-    private variable _elem2comp;        # Maps graph element => dataobj
-    private variable _comp2elem;        # Maps graph element => dataobj
-    private variable _label2axis;       # Maps axis label => axis ID
-    private variable _limits;           # Axis limits:  x-min, x-max, etc.
-    private variable _nextColorIndex 0; # Index for next "-color auto"
-    private variable _hilite;           # Info for element currently highlighted
-    private variable _axis;             # Info for axis manipulations
-    private variable _axisPopup;        # Info for axis being edited in popup
-    common _downloadPopup;              # Download options from popup
-    private variable _markers
-    private variable _nextElement 0
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method download {option args}
-
-    protected method Rebuild {}
-    protected method ResetLimits {}
-    protected method ResetLegend {}
-    protected method Zoom {option args}
-    protected method Hilite {state x y}
-    protected method Axis {option args}
-    protected method GetAxes {dataobj}
-    protected method GetLineMarkerOptions { style }
-    protected method GetTextMarkerOptions { style }
-    protected method EnterMarker { g name x y text }
-    protected method LeaveMarker { g name }
-
-
-    private method BuildGraph { dlist }
-    private method BuildMarkers { dataobj elem }
-    private method FormatAxis { axis w value }
-    private method GetFormattedValue { axis g value }
-    private method BuildAxisPopup { popup }
-    private method ShowAxisPopup { axis }
-    private method SetAxis { setting }
-    private method SetElements { dataobj {settings ""} }
-    private method SetAxisRangeState { axis }
-}
-
-itk::usual UqCurve {
-    keep -background -foreground -cursor -font
-}
-
-itk::usual Panedwindow {
-    keep -background -cursor
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::constructor {args} {
-    #puts "UqCurve::Cons $args"
-
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    array set _downloadPopup {
-        format csv
-    }
-
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add main {
-        Rappture::SidebarFrame $itk_interior.main
-    }
-    pack $itk_component(main) -expand yes -fill both
-    set f [$itk_component(main) component controls]
-
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(reset) -padx 4 -pady 2 -anchor e
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    set f [$itk_component(main) component frame]
-    itk_component add plot {
-        blt::graph $f.plot \
-            -highlightthickness 0 -plotpadx 0 -plotpady 4
-    } {
-        keep -background -foreground -cursor -font
-    }
-    pack $itk_component(plot) -expand yes -fill both
-
-    $itk_component(plot) pen configure activeLine \
-        -symbol square -pixels 3 -linewidth 2 \
-        -outline black -fill red -color black
-
-    # Add bindings so you can mouse over points to see values:
-    #
-    $itk_component(plot) element bind all <Enter> \
-        [itcl::code $this Hilite at %x %y]
-    $itk_component(plot) element bind all <Motion> \
-        [itcl::code $this Hilite at %x %y]
-    $itk_component(plot) element bind all <Leave> \
-        [itcl::code $this Hilite off %x %y]
-
-    $itk_component(plot) legend configure -hide yes
-
-    #
-    # Add legend for editing hidden/elements:
-    #
-    set inner [$itk_component(main) insert end \
-        -title "Legend" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    itk_component add legend {
-        Rappture::XyLegend $inner.legend $itk_component(plot)
-    }
-    pack $itk_component(legend) -expand yes -fill both
-    after idle [itcl::code $this ResetLegend]
-
-    # quick-and-dirty zoom functionality, for now...
-    Blt_ZoomStack $itk_component(plot)
-    eval itk_initialize $args
-
-    set _hilite(elem) ""
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a dataobj to the plot.  The optional <settings>
-# are used to configure the plot.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::add {dataobj {settings ""}} {
-    #puts "UqCurve::add $dataobj settings=$settings"
-    set g $itk_component(plot)
-    SetElements $dataobj $settings
-
-    array set attrs $settings
-
-    # If Pobability region, nothing to do here.
-    if {[info exists attrs(-probability)]} {
-        return
-    }
-
-    # Colors have to be set/reset here because of "-brightness" and "auto".
-    # Colors can't be overriden by the user.
-
-    # If the color is "auto", then select a color from -autocolors
-    if { ![info exists attrs(-color)] } {
-        set color "auto"
-    } else {
-        set color $attrs(-color)
-    }
-    if { ![info exists attrs(-width)] } {
-        set linewidth 1
-    } else {
-        set linewidth $attrs(-width)
-    }
-    if { $color == "auto" || $color == "autoreset" } {
-        #        if { $color == "autoreset" } {
-        #            set _nextColorIndex 0
-        #        }
-        set color [lindex $itk_option(-autocolors) $_nextColorIndex]
-        if { "" == $color} {
-            set color black
-        }
-        # Set up for next auto color
-        incr _nextColorIndex
-        if { $_nextColorIndex >= [llength $itk_option(-autocolors)] } {
-            set _nextColorIndex 0
-        }
-    }
-    # If -brightness is set, then update the color.
-    if { [info exists attrs(-brightness)] } {
-        set brightness $attrs(-brightness)
-        set color [Rappture::color::brightness $color $brightness]
-        set bg [$itk_component(plot) cget -plotbackground]
-        foreach {h s v} [Rappture::color::RGBtoHSV $bg] break
-        if {$v > 0.5} {
-            set color [Rappture::color::brightness_max $color 0.8]
-        } else {
-            set color [Rappture::color::brightness_min $color 0.2]
-        }
-    }
-    set type [$dataobj hints type]
-
-    set elem ""
-    foreach cname [$dataobj components] {
-        set tag $dataobj-$cname
-        set elem $_comp2elem($tag)
-        switch -- $type {
-            "bar" {
-                $g bar configure $elem -foreground $color -background $color \
-                    -hide no
-            }
-            "scatter" {
-                $g line configure $elem -color $color -hide no
-            }
-            default {
-                $g line configure $elem -color $color -hide no \
-                    -linewidth $linewidth
-            }
-        }
-        if { [lsearch $_viewable $elem] < 0 } {
-            lappend _viewable $elem
-        }
-    }
-    if { [$dataobj info class] == "::Rappture::Curve" } {
-        BuildMarkers $dataobj $elem
-    }
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::get {} {
-    #puts "UqCurve::get"
-    # put the dataobj list in order according to -raise options
-    set bottom {}
-    set top {}
-    foreach obj $_dlist {
-        if {[info exists _dataobj2raise($obj)] && $_dataobj2raise($obj)} {
-            lappend top $obj
-        } else {
-            lappend bottom $obj
-        }
-    }
-    set _dlist [concat $bottom $top]
-    return $_dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::delete {args} {
-    #puts "UqCurve::delete $args"
-    set g $itk_component(plot)
-
-    # First try to create list of elements from the dataobjs specified
-    set elemlist {}
-    foreach dataobj $args {
-        foreach cname [$dataobj components] {
-            set tag $dataobj-$cname
-            if { [info exists _comp2elem($tag)] } {
-                lappend elemlist $_comp2elem($tag)
-            }
-        }
-    }
-    # If no dataobjs were specified then hide all elements.
-    if { [llength $elemlist] == 0 } {
-        set elemlist [$g element names]
-    }
-    # Hide all elements specified by their dataobjs
-    foreach elem $elemlist {
-        $g element configure $elem -hide yes
-        set i [lsearch $_viewable $elem]
-        if { $i >= 0 } {
-            set _viewable [lreplace $_viewable $i $i]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all dataobjs--even those not showing on the screen.
-# Because of this, the limits are appropriate for all dataobjs as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::scale {args} {
-    set _dlist $args
-    BuildGraph $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::download {option args} {
-    #puts "UqCurve::download $option : $args"
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            set popup .UqCurvedownload
-            if {![winfo exists .UqCurvedownload]} {
-                # if we haven't created the popup yet, do it now
-                Rappture::Balloon $popup \
-                    -title "[Rappture::filexfer::label downloadWord] as..."
-                set inner [$popup component inner]
-                label $inner.summary -text "" -anchor w
-                pack $inner.summary -side top
-                radiobutton $inner.csv -text "Data as Comma-Separated Values" \
-                    -variable Rappture::UqCurve::_downloadPopup(format) \
-                    -value csv
-                pack $inner.csv -anchor w
-                radiobutton $inner.image -text "Image (PS/PDF/PNG/JPEG)" \
-                    -variable Rappture::UqCurve::_downloadPopup(format) \
-                    -value image
-                pack $inner.image -anchor w
-                button $inner.go -text [Rappture::filexfer::label download] \
-                    -command [lindex $args 0]
-                pack $inner.go -side bottom -pady 4
-            } else {
-                set inner [$popup component inner]
-            }
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:"
-            update idletasks ;# fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .UqCurvedownload
-            if {[winfo exists .UqCurvedownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                csv {
-                    # reverse the objects so the selected data appears on top
-                    set dlist ""
-                    foreach dataobj [get] {
-                        set dlist [linsert $dlist 0 $dataobj]
-                    }
-
-                    # generate the comma-separated value data for these objects
-                    set csvdata ""
-                    foreach dataobj $dlist {
-                        append csvdata "[string repeat - 60]\n"
-                        append csvdata " [$dataobj hints label]\n"
-                        if {[info exists _dataobj2desc($dataobj)]
-                            && [llength [split $_dataobj2desc($dataobj) \n]] > 1} {
-                            set indent "for:"
-                            foreach line [split $_dataobj2desc($dataobj) \n] {
-                                append csvdata " $indent $line\n"
-                                set indent "    "
-                            }
-                        }
-                        append csvdata "[string repeat - 60]\n"
-
-                        append csvdata "[$dataobj hints xlabel], [$dataobj hints ylabel]\n"
-                        set first 1
-                        foreach comp [$dataobj components] {
-                            if {!$first} {
-                                # blank line between components
-                                append csvdata "\n"
-                            }
-                            set xv [$dataobj mesh $comp]
-                            set yv [$dataobj values $comp]
-                            foreach x [$xv range 0 end] y [$yv range 0 end] {
-                                append csvdata [format "%20.15g, %20.15g\n" $x $y]
-                            }
-                            set first 0
-                        }
-                        append csvdata "\n"
-                    }
-                    return [list .txt $csvdata]
-                }
-                image {
-                    set popup .xyprintdownload
-                    if { ![winfo exists $popup] } {
-                        # Create a popup for the print dialog
-                        Rappture::Balloon $popup -title "Save as image..."
-                        set inner [$popup component inner]
-                        # Create the print dialog widget and add it to the
-                        # balloon popup.
-                        Rappture::XyPrint $inner.print
-                        $popup configure \
-                            -deactivatecommand [list $inner.print reset]
-                        blt::table $inner 0,0 $inner.print -fill both
-                    }
-                    update
-                    # Activate the popup and call for the output.
-                    foreach { widget toolName plotName } $args break
-                    $popup activate $widget left
-                    set inner [$popup component inner]
-                    set output [$inner.print print $itk_component(plot) \
-                                    $toolName $plotName]
-                    $popup deactivate
-                    return $output
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-itcl::body Rappture::UqCurve::BuildMarkers { dataobj elem } {
-    #puts "UqCurve::BuildMarkers $dataobj : $elem"
-    return
-    set g $itk_component(plot)
-
-    set ymin -Inf
-    set ymax Inf
-    set xmax Inf
-    set xmin -Inf
-    foreach m [$dataobj xmarkers] {
-        foreach {at label style} $m break
-        set id [$g marker create line -coords [list $at $ymin $at $ymax]]
-        $g marker bind $id <Enter> \
-            [itcl::code $this EnterMarker $g x-$label $at $ymin $at]
-        $g marker bind $id <Leave> \
-            [itcl::code $this LeaveMarker $g x-$label]
-        set options [GetLineMarkerOptions $style]
-        $g marker configure $id -element $elem
-        if { $options != "" } {
-            eval $g marker configure $id $options
-        }
-        if { $label != "" } {
-            set id [$g marker create text -anchor nw \
-                        -text $label -coords [list $at $ymax]]
-            $g marker configure $id -element $elem
-            set options [GetTextMarkerOptions $style]
-            if { $options != "" } {
-                eval $g marker configure $id $options
-            }
-        }
-    }
-    foreach m [$dataobj ymarkers] {
-        foreach {at label style} $m break
-        set id [$g marker create line -coords [list $xmin $at $xmax $at]]
-        $g marker configure $id -element $elem
-        $g marker bind $id <Enter> \
-            [itcl::code $this EnterMarker $g $label $at $xmin $at]
-        $g marker bind $id <Leave> \
-            [itcl::code $this LeaveMarker $g $label]
-        set options [GetLineMarkerOptions $style]
-        if { $options != "" } {
-            eval $g marker configure $id $options
-        }
-        if { $label != "" } {
-            set id [$g marker create text -anchor se \
-                        -text $label -coords [list $xmax $at]]
-            $g marker configure $id -element $elem
-            set options [GetTextMarkerOptions $style]
-            if { $options != "" } {
-                eval $g marker configure $id $options
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-#       Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::Rebuild {} {
-    ResetLegend
-    # Fix raise/lower elements
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ResetLimits
-#
-# Used internally to apply automatic limits to the axes for the
-# current plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::ResetLimits {} {
-    set g $itk_component(plot)
-
-    foreach axis [$g axis names] {
-        $g axis configure $axis -min "" -max ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ResetLegend
-#
-# Used internally to apply automatic limits to the axes for the
-# current plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::ResetLegend {} {
-    update idletasks
-
-    set g $itk_component(plot)
-    # Fix duplicate labels by appending the simulation number
-    # Collect the labels from all the viewable elements.
-    set above {}
-    set below {}
-    foreach elem $_viewable {
-        foreach {dataobj cname} [split $_elem2comp($elem) -] break
-        set label [$dataobj hints label]
-        lappend label2elem($label) $elem
-        if { $_dataobj2raise($dataobj) } {
-            lappend $g element raise $elem
-        }
-    }
-    # Then relabel elements with the same label, using the simulation number.
-    foreach label [array names label2elem] {
-        foreach elem $label2elem($label) {
-            if { [llength $label2elem($label)] == 1 } {
-                $g element configure $elem -label $label
-                continue
-            }
-            foreach {dataobj cname} [split $_elem2comp($elem) -] break
-            set sim $_dataobj2sim($dataobj)
-            set elabel [format "%s \#%d" $label $sim]
-            $g element configure $elem -label $elabel
-        }
-    }
-    $itk_component(legend) reset $_viewable
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::Zoom {option args} {
-    switch -- $option {
-        reset {
-            ResetLimits
-            Rappture::Logger::log curve zoom -reset
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Hilite <state> <x> <y>
-#
-# Called automatically when the user brushes one of the elements
-# on the plot.  Causes the element to highlight and a tooltip to
-# pop up with element info.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::Hilite {state x y} {
-    set g $itk_component(plot)
-    set elem ""
-
-    # Peek inside of Blt_ZoomStack package to see if we're currently in the
-    # middle of a zoom selection.
-    if {[info exists ::zoomInfo($g,corner)] && $::zoomInfo($g,corner) == "B" } {
-        return;
-    }
-    set tip ""
-    if {$state == "at"} {
-        if {[$g element closest $x $y info -interpolate yes]} {
-            # for dealing with xy line plots
-            set elem $info(name)
-
-            set mapx [$g element cget $elem -mapx]
-            set mapy [$g element cget $elem -mapy]
-
-            # search again for an exact point -- this time don't interpolate
-            set tip ""
-            array unset info
-            if {[$g element closest $x $y info -interpolate no]
-                  && $info(name) == $elem} {
-
-                set x [$g axis transform $mapx $info(x)]
-                set y [$g axis transform $mapy $info(y)]
-                if {[info exists _elem2comp($elem)]} {
-                    foreach {dataobj cname} [split $_elem2comp($elem) -] break
-                    set yunits [$dataobj hints yunits]
-                    set xunits [$dataobj hints xunits]
-                } else {
-                    set xunits ""
-                    set yunits ""
-                }
-                set tip [$g element cget $elem -label]
-                set yval [GetFormattedValue y $g $info(y)]
-                append tip "\n$yval$yunits"
-                set xval [GetFormattedValue x $g $info(x)]
-                append tip " @ $xval$xunits"
-                set tip [string trim $tip]
-            }
-            set state 1
-        } elseif {[$g element closest $x $y info -interpolate no]} {
-            # for dealing with xy scatter plot
-            set elem $info(name)
-
-            set mapx [$g element cget $elem -mapx]
-            set mapy [$g element cget $elem -mapy]
-
-            set tip ""
-            set x [$g axis transform $mapx $info(x)]
-            set y [$g axis transform $mapy $info(y)]
-
-            if {[info exists _elem2comp($elem)]} {
-                foreach {dataobj cname} [split $_elem2comp($elem) -] break
-                set yunits [$dataobj hints yunits]
-                set xunits [$dataobj hints xunits]
-            } else {
-                set xunits ""
-                set yunits ""
-            }
-            set tip [$g element cget $elem -label]
-            set yval [GetFormattedValue y $g $info(y)]
-            append tip "\n$yval$yunits"
-            set xval [GetFormattedValue x $g $info(x)]
-            append tip " @ $xval$xunits"
-            set tip [string trim $tip]
-            set state 1
-        } else {
-            set state 0
-        }
-    }
-
-    if {$state} {
-        #
-        # Highlight ON:
-        # - activate trace
-        # - multiple axes? dim other axes
-        # - pop up tooltip about data
-        #
-        if { [$g element exists $_hilite(elem)] && $_hilite(elem) != $elem } {
-            $g element deactivate $_hilite(elem)
-            $g crosshairs configure -hide yes
-            Rappture::Tooltip::tooltip cancel
-        }
-        #$g element activate $elem
-        set _hilite(elem) $elem
-
-        set mapx [$g element cget $elem -mapx]
-        set mapy [$g element cget $elem -mapy]
-        if {[info exists _elem2comp($elem)]} {
-            foreach {dataobj cname} [split $_elem2comp($elem) -] break
-            foreach {mapx mapy} [GetAxes $dataobj] break
-        }
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;           # fix main x-axis too
-            foreach axis $allx {
-                if {$axis == $mapx} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;           # fix main y-axis too
-            foreach axis $ally {
-                if {$axis == $mapy} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-        if {"" != $tip} {
-            $g crosshairs configure -hide no -position @$x,$y
-
-            if {$x > 0.5*[winfo width $g]} {
-                if {$x < 4} {
-                    set tipx "-0"
-                } else {
-                    set tipx "-[expr {$x-20}]"  ;# move tooltip to the left
-                }
-            } else {
-                if {$x < -4} {
-                    set tipx "+0"
-                } else {
-                    set tipx "+[expr {$x+20}]"  ;# move tooltip to the right
-                }
-            }
-            if {$y > 0.5*[winfo height $g]} {
-                if {$y < 4} {
-                    set tipy "-0"
-                } else {
-                    set tipy "-[expr {$y-20}]"  ;# move tooltip to the top
-                }
-            } else {
-                if {$y < -4} {
-                    set tipy "+0"
-                } else {
-                    set tipy "+[expr {$y+20}]"  ;# move tooltip to the bottom
-                }
-            }
-            Rappture::Tooltip::text $g $tip
-            Rappture::Tooltip::tooltip show $g $tipx,$tipy
-            Rappture::Logger::log tooltip -for "curve probe -- [string map [list \n " // "] $tip]"
-        }
-    } else {
-        #
-        # Highlight OFF:
-        # - deactivate (color back to normal)
-        # - put all axes back to normal color
-        # - take down tooltip
-        #
-        if { [$g element exists $_hilite(elem)] } {
-            $g element deactivate $_hilite(elem)
-        }
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;# fix main x-axis too
-            foreach axis $allx {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;# fix main y-axis too
-            foreach axis $ally {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        $g crosshairs configure -hide yes
-
-        # only cancel in plotting area or we'll mess up axes
-        if {[$g inside $x $y]} {
-            Rappture::Tooltip::tooltip cancel
-        }
-
-        # There is no currently highlighted element
-        set _hilite(elem) ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Axis hilite <axis> <state>
-#
-# USAGE: Axis click <axis> <x> <y>
-# USAGE: Axis drag <axis> <x> <y>
-# USAGE: Axis release <axis> <x> <y>
-#
-# Used internally to handle editing of the x/y axes.  The hilite
-# operation causes the axis to light up.  The edit operation pops
-# up a panel with editing options.  The changed operation applies
-# changes from the panel.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::Axis {option args} {
-    switch -- $option {
-        hilite {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Axis hilite axis state\""
-            }
-            set g $itk_component(plot)
-            set axis [lindex $args 0]
-            set state [lindex $args 1]
-
-            if {$state} {
-                $g axis configure $axis \
-                    -color $itk_option(-activecolor) \
-                    -titlecolor $itk_option(-activecolor)
-
-                set x [expr {[winfo pointerx $g]+4}]
-                set y [expr {[winfo pointery $g]+4}]
-                Rappture::Tooltip::tooltip pending $g-$axis @$x,$y
-            } else {
-                $g axis configure $axis \
-                    -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-                Rappture::Tooltip::tooltip cancel
-            }
-        }
-        click {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis click axis x y\""
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            set g $itk_component(plot)
-
-            set _axis(moved) 0
-            set _axis(click-x) $x
-            set _axis(click-y) $y
-            foreach {min max} [$g axis limits $axis] break
-            set _axis(min0) $min
-            set _axis(max0) $max
-            Rappture::Tooltip::tooltip cancel
-        }
-        drag {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis drag axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            set g $itk_component(plot)
-
-            if {[info exists _axis(click-x)] && [info exists _axis(click-y)]} {
-                foreach {x0 y0 pw ph} [$g extents plotarea] break
-                switch -glob $axis {
-                  x* {
-                    set pix $x
-                    set pix0 $_axis(click-x)
-                    set pixmin $x0
-                    set pixmax [expr {$x0+$pw}]
-                  }
-                  y* {
-                    set pix $y
-                    set pix0 $_axis(click-y)
-                    set pixmin [expr {$y0+$ph}]
-                    set pixmax $y0
-                  }
-                }
-                set log [$g axis cget $axis -logscale]
-                set min $_axis(min0)
-                set max $_axis(max0)
-                set dpix [expr {abs($pix-$pix0)}]
-                set v0 [$g axis invtransform $axis $pixmin]
-                set v1 [$g axis invtransform $axis [expr {$pixmin+$dpix}]]
-                if {$log} {
-                    set v0 [expr {log10($v0)}]
-                    set v1 [expr {log10($v1)}]
-                    set min [expr {log10($min)}]
-                    set max [expr {log10($max)}]
-                }
-
-                if {$pix > $pix0} {
-                    set delta [expr {$v1-$v0}]
-                } else {
-                    set delta [expr {$v0-$v1}]
-                }
-                set min [expr {$min-$delta}]
-                set max [expr {$max-$delta}]
-                if {$log} {
-                    set min [expr {pow(10.0,$min)}]
-                    set max [expr {pow(10.0,$max)}]
-                }
-                $g axis configure $axis -min $min -max $max
-
-                # move axis, don't edit on release
-                set _axis(move) 1
-            }
-        }
-        release {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis release axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-
-            if {!$_axis(moved)} {
-                # small movement? then treat as click -- pop up axis editor
-                set dx [expr {abs($x-$_axis(click-x))}]
-                set dy [expr {abs($y-$_axis(click-y))}]
-                if {$dx < 2 && $dy < 2} {
-                    ShowAxisPopup $axis
-                    return
-                }
-            }
-            # one last movement
-            Axis drag $axis $x $y
-
-            # log this change
-            Rappture::Logger::log curve axis $axis \
-                -drag [$itk_component(plot) axis limits $axis]
-
-            catch {unset _axis}
-        }
-        default {
-            error "bad option \"$option\": should be hilite"
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: GetLineMarkerOptions <style>
-#
-# Used internally to create a list of configuration options specific to the
-# axis line marker.  The input is a list of name value pairs.  Options that
-# are not recognized are ignored.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::GetLineMarkerOptions {style} {
-    array set lineOptions {
-        "-color"  "-outline"
-        "-dashes" "-dashes"
-        "-linecolor" "-outline"
-        "-linewidth" "-linewidth"
-    }
-    set options {}
-    foreach {name value} $style {
-        if { [info exists lineOptions($name)] } {
-            lappend options $lineOptions($name) $value
-        }
-    }
-    return $options
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetTextMarkerOptions <style>
-#
-# Used internally to create a list of configuration options specific to the
-# axis text marker.  The input is a list of name value pairs.  Options that
-# are not recognized are ignored.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::GetTextMarkerOptions {style} {
-    array set textOptions {
-        "-color"        "-outline"
-        "-textcolor"    "-outline"
-        "-font"         "-font"
-        "-xoffset"      "-xoffset"
-        "-yoffset"      "-yoffset"
-        "-anchor"       "-anchor"
-        "-rotate"       "-rotate"
-    }
-    set options {}
-    foreach {name value} $style {
-        if { [info exists textOptions($name)] } {
-            lappend options $textOptions($name) $value
-        }
-    }
-    return $options
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetAxes <dataobj>
-#
-# Used internally to figure out the axes used to plot the given
-# <dataobj>.  Returns a list of the form {x y}, where x is the
-# x-axis name (x, x2, x3, etc.), and y is the y-axis name.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqCurve::GetAxes {dataobj} {
-    set xlabel [$dataobj hints xlabel]
-    if {[info exists _label2axis($xlabel)]} {
-        set mapx $_label2axis($xlabel)
-    } else {
-        set mapx "x"
-    }
-
-    set ylabel [$dataobj hints ylabel]
-    if {[info exists _label2axis($ylabel)]} {
-        set mapy $_label2axis($ylabel)
-    } else {
-        set mapy "y"
-    }
-    return [list $mapx $mapy]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -gridcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::UqCurve::gridcolor {
-    if {"" == $itk_option(-gridcolor)} {
-        $itk_component(plot) grid off
-    } else {
-        $itk_component(plot) grid configure -color $itk_option(-gridcolor)
-        $itk_component(plot) grid on
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -autocolors
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::UqCurve::autocolors {
-    foreach c $itk_option(-autocolors) {
-        if {[catch {winfo rgb $itk_component(hull) $c}]} {
-            error "bad color \"$c\""
-        }
-    }
-        incr _nextColorIndex
-    if {$_nextColorIndex >= [llength $itk_option(-autocolors)]} {
-        set _nextColorIndex 0
-    }
-}
-
-itcl::body Rappture::UqCurve::EnterMarker { g name x y text } {
-    LeaveMarker $g $name
-    set id [$g marker create text \
-                -coords [list $x $y] \
-                -yoffset -1 \
-                -anchor s \
-                -text $text]
-    set _markers($name) $id
-}
-
-itcl::body Rappture::UqCurve::LeaveMarker { g name } {
-    if { [info exists _markers($name)] } {
-        set id $_markers($name)
-        $g marker delete $id
-        unset _markers($name)
-    }
-}
-
-#
-# SetAxis --
-#
-#       Configures the graph axis with the designated setting using
-#       the currently stored value.  User-configurable axis settings
-#       are stored in the _axisPopup variable or in the widgets. This
-#       routine syncs the graph with that setting.
-#
-itcl::body Rappture::UqCurve::SetAxis { setting } {
-    set g $itk_component(plot)
-    set axis $_axisPopup(axis)
-    switch -- $setting {
-        "logscale" {
-            set bool $_axisPopup(logscale)
-            $g axis configure $axis -logscale $bool
-        }
-        "loose" {
-            set bool $_axisPopup(loose)
-            $g axis configure $axis -loose $bool
-        }
-        "range" {
-            set auto $_axisPopup(auto)
-            set _axisPopup($axis-auto) $auto
-            if { $auto } {
-                # Set the axis range automatically
-                $g axis configure $axis -min "" -max ""
-            } else {
-                # Set the axis range from the entry values.
-                set label $_axisPopup(label)
-                set min $_axisPopup(${label}-min)
-                set max $_axisPopup(${label}-max)
-                $g axis configure $axis -min $min -max $max
-            }
-            SetAxisRangeState $axis
-        }
-        "format" {
-            set inner [$itk_component(hull).axes component inner]
-            set format [$inner.format translate [$inner.format value]]
-            set _axisPopup($axis-format) $format
-
-            # Force the graph to reformat the ticks
-            set min [$itk_component(plot) axis cget $axis -min]
-            $g axis configure $axis -min $min
-        }
-        "label" {
-            set label $_axisPopup(label)
-            $g axis configure $axis -title $label
-        }
-        "min" {
-            set min $_axisPopup(min)
-            if { [catch { $g axis configure $axis -min $min } msg] != 0 } {
-                set inner [$itk_component(hull).axes component inner]
-                Rappture::Tooltip::cue $inner.max $msg
-                bell
-                return
-            }
-            set label $_axisPopup(label)
-            set _axisPopup(${label}-min) $min
-        }
-        "max" {
-            set max $_axisPopup(max)
-            if { [catch { $g axis configure $axis -max $max } msg] != 0 } {
-                set inner [$itk_component(hull).axes component inner]
-                Rappture::Tooltip::cue $inner.max $msg
-                bell
-                return
-            }
-            set label $_axisPopup(label)
-            set _axisPopup(${label}-max) $max
-        }
-    }
-}
-
-#
-# SetAxisRangeState --
-#
-#       Sets the state of widgets controlling the axis range based
-#       upon whether the automatic or manual setting.  If the
-#       axis is configure to be automatic, the manual setting widgets
-#       are disabled.  And vesa-versa the automatic setting widgets
-#       are dsiabled if the axis is manual.
-#
-itcl::body Rappture::UqCurve::SetAxisRangeState { axis } {
-    set inner [$itk_component(hull).axes component inner]
-    set g $itk_component(plot)
-
-    if { $_axisPopup(auto) } {
-        foreach {min max} [$g axis limits $axis] break
-        $inner.minl configure -state disabled
-        $inner.min configure -state disabled
-        $inner.maxl configure -state disabled
-        $inner.max configure -state disabled
-        $inner.loose configure -state normal
-        $inner.tight configure -state normal
-    } else {
-        foreach {min max} [$g axis limits $axis] break
-        $inner.minl configure -state normal
-        $inner.min configure -state normal
-        set _axisPopup(min) [$g axis cget $axis -min]
-        $inner.maxl configure -state normal
-        $inner.max configure -state normal
-        set _axisPopup(max) [$g axis cget $axis -max]
-        $inner.loose configure -state disabled
-        $inner.tight configure -state disabled
-    }
-}
-
-#
-# BuildAxisPopup --
-#
-#       Creates the popup balloon dialog for axes. This routine is
-#       called only once the first time the user clicks to bring up
-#       an axis dialog.  It is reused for all other axes.
-#
-itcl::body Rappture::UqCurve::BuildAxisPopup { popup } {
-    Rappture::Balloon $popup -title "Axis Options"
-    set inner [$itk_component(hull).axes component inner]
-
-    label $inner.labell -text "Label:"
-    entry $inner.label \
-        -width 15 -highlightbackground $itk_option(-background) \
-        -textvariable [itcl::scope _axisPopup(label)]
-
-    bind $inner.label <Return>   [itcl::code $this SetAxis label]
-    bind $inner.label <KP_Enter> [itcl::code $this SetAxis label]
-    bind $inner.label <FocusOut> [itcl::code $this SetAxis label]
-
-    label $inner.formatl -text "Format:"
-    Rappture::Combobox $inner.format -width 15 -editable no
-    $inner.format choices insert end \
-        "%.6g"  "Auto"         \
-        "%.0f"  "X"          \
-        "%.1f"  "X.X"          \
-        "%.2f"  "X.XX"         \
-        "%.3f"  "X.XXX"        \
-        "%.6f"  "X.XXXXXX"     \
-        "%.1e"  "X.Xe+XX"      \
-        "%.2e"  "X.XXe+XX"     \
-        "%.3e"  "X.XXXe+XX"    \
-        "%.6e"  "X.XXXXXXe+XX"
-
-    bind $inner.format <<Value>> [itcl::code $this SetAxis format]
-
-    label $inner.rangel -text "Axis Range:"
-    radiobutton $inner.auto -text "Automatic" \
-        -variable [itcl::scope _axisPopup(auto)] -value 1 \
-        -command [itcl::code $this SetAxis range]
-    radiobutton $inner.manual -text "Manual" \
-        -variable [itcl::scope _axisPopup(auto)] -value 0 \
-        -command [itcl::code $this SetAxis range]
-
-    radiobutton $inner.loose -text "loose" \
-        -variable [itcl::scope _axisPopup(loose)] -value 1 \
-        -command [itcl::code $this SetAxis loose]
-    radiobutton $inner.tight -text "tight" \
-        -variable [itcl::scope _axisPopup(loose)] -value 0 \
-        -command [itcl::code $this SetAxis loose]
-
-    label $inner.minl -text "min"
-    entry $inner.min \
-        -width 15 -highlightbackground $itk_option(-background) \
-        -textvariable [itcl::scope _axisPopup(min)]
-    bind $inner.min <Return> [itcl::code $this SetAxis min]
-    bind $inner.min <KP_Enter> [itcl::code $this SetAxis min]
-    bind $inner.min <FocusOut> [itcl::code $this SetAxis min]
-
-    label $inner.maxl -text "max"
-    entry $inner.max \
-        -width 15 -highlightbackground $itk_option(-background) \
-        -textvariable [itcl::scope _axisPopup(max)]
-    bind $inner.max <Return> [itcl::code $this SetAxis max]
-    bind $inner.max <KP_Enter> [itcl::code $this SetAxis max]
-    bind $inner.max <FocusOut> [itcl::code $this SetAxis max]
-
-
-    label $inner.scalel -text "Scale:"
-    radiobutton $inner.linear -text "linear" \
-        -variable [itcl::scope _axisPopup(logscale)] -value 0 \
-        -command [itcl::code $this SetAxis logscale]
-    radiobutton $inner.log -text "logarithmic" \
-        -variable [itcl::scope _axisPopup(logscale)] -value 1 \
-        -command [itcl::code $this SetAxis logscale]
-
-    blt::table $inner \
-        0,0 $inner.labell -anchor w \
-        0,1 $inner.label -anchor w -fill x  -cspan 3 \
-        1,0 $inner.formatl -anchor w \
-        1,1 $inner.format -anchor w -fill x  -cspan 3 \
-        2,0 $inner.scalel -anchor w \
-        2,2 $inner.linear -anchor w \
-        2,3 $inner.log -anchor w \
-        3,0 $inner.rangel -anchor w \
-        4,0 $inner.manual -anchor w -padx 4 \
-        4,2 $inner.minl -anchor e \
-        4,3 $inner.min -anchor w \
-        5,2 $inner.maxl -anchor e \
-        5,3 $inner.max -anchor w \
-        6,0 $inner.auto -anchor w -padx 4 \
-        6,2 $inner.tight -anchor w \
-        6,3 $inner.loose -anchor w \
-
-
-    blt::table configure $inner r2 -pady 4
-    blt::table configure $inner c1 -width 20
-    update
-}
-
-#
-# ShowAxisPopup --
-#
-#       Displays the axis dialog for an axis.  It initializes the
-#       _axisInfo variables for that axis if necessary.
-#
-itcl::body Rappture::UqCurve::ShowAxisPopup { axis } {
-    set g $itk_component(plot)
-    set popup $itk_component(hull).axes
-
-    if { ![winfo exists $popup] } {
-        BuildAxisPopup $popup
-    }
-    set _axisPopup(axis)     $axis
-    set _axisPopup(label)    [$g axis cget $axis -title]
-    set _axisPopup(logscale) [$g axis cget $axis -logscale]
-    set _axisPopup(loose)    [$g axis cget $axis -loose]
-    if { ![info exists _axisPopup($axis-format)] } {
-        set inner [$itk_component(hull).axes component inner]
-        set _axisPopup($axis-format) "%.6g"
-        set fmts [$inner.format choices get -value]
-        set i [lsearch -exact $fmts $_axisPopup($axis-format)]
-        if {$i < 0} { set i 0 }  ;# use Auto choice
-        $inner.format value [$inner.format choices get -label $i]
-    }
-    foreach {min max} [$g axis limits $axis] break
-    if { $_axisPopup(logscale) } {
-        set type "log"
-    } else {
-        set type "lin"
-    }
-    set amin ""
-    set label $_axisPopup(label)
-    if { [info exists _limits(${label}-min)] } {
-        set amin $_limits(${label}-min)
-    }
-    set amax ""
-    if { [info exists _limits(${label}-max)] } {
-        set amax $_limits(${label}-max)
-    }
-    set auto 1
-    if { $amin != "" || $amax != "" } {
-        set auto 0
-    }
-    if { ![info exists _axisPopup($axis-auto)] } {
-        set _axisPopup($axis-auto) $auto;# Defaults to automatic
-    }
-    set _axisPopup(auto)  $_axisPopup($axis-auto)
-    SetAxisRangeState $axis
-    if { ![info exists _axisPopup(${label}-min)] } {
-        if { $amin != "" } {
-            set _axisPopup(${label}-min) $amin
-            set _axisPopup(min)   $_axisPopup(${label}-min)
-            SetAxis min
-        } else {
-            set _axisPopup(${label}-min) $min
-        }
-    }
-    if { ![info exists _axisPopup(${label}-max)] } {
-        if { $amax != "" } {
-            set _axisPopup(${label}-max) $amax
-            set _axisPopup(max)   $_axisPopup(${label}-max)
-            SetAxis max
-        } else {
-            set _axisPopup(${label}-max) $max
-        }
-    }
-    set _axisPopup(min)  $_axisPopup(${label}-min)
-    set _axisPopup(max)  $_axisPopup(${label}-max)
-    set _axisPopup(axis) $axis
-
-    #
-    # Figure out where the window should pop up.
-    #
-    set x [winfo rootx $g]
-    set y [winfo rooty $g]
-    set w [winfo width $g]
-    set h [winfo height $g]
-    foreach {x0 y0 pw ph} [$g extents plotarea] break
-    switch -glob -- $axis {
-        x {
-            set x [expr {round($x + $x0+0.5*$pw)}]
-            set y [expr {round($y + $y0+$ph + 0.5*($h-$y0-$ph))}]
-            set dir "above"
-        }
-        x* {
-            set x [expr {round($x + $x0+0.5*$pw)}]
-            set dir "below"
-            set allx [$itk_component(plot) x2axis use]
-            set max [llength $allx]
-            set i [lsearch -exact $allx $axis]
-            set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-        }
-        y {
-            set x [expr {round($x + 0.5*$x0)}]
-            set y [expr {round($y + $y0+0.5*$ph)}]
-            set dir "right"
-        }
-        y* {
-            set y [expr {round($y + $y0+0.5*$ph)}]
-            set dir "left"
-            set ally [$g y2axis use]
-            set max [llength $ally]
-            set i [lsearch -exact $ally $axis]
-            set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-            set x [expr {round($x+$x0+$pw + ($i+0.5)*($w-$x0-$pw)/double($max))}]
-        }
-    }
-    $popup activate @$x,$y $dir
-}
-
-#
-# GetFormattedValue --
-#
-#       Callback routine for the axis format procedure.  It formats the
-#       axis tick label according to the selected format.  This routine
-#       is also used to format tooltip values.
-#
-itcl::body Rappture::UqCurve::GetFormattedValue { axis g value } {
-    if { [$g axis cget $axis -logscale] ||
-         ![info exists _axisPopup($axis-format)] } {
-        set fmt "%.6g"
-    } else {
-        set fmt $_axisPopup($axis-format)
-    }
-    return [format $fmt $value]
-}
-
-
-#
-# BuildGraph --
-#
-#       This procedure loads each data objects specified into the
-#       graph.  The data object may already be loaded (from the "add"
-#       method which gets called first).   The graph elements that
-#       are created, are hidden.  This allows the graph to account
-#       for all datasets, even those not currently being displayed.
-#
-itcl::body Rappture::UqCurve::BuildGraph { dlist } {
-    #puts "UqCurve::BuildGraph $dlist"
-
-    set g $itk_component(plot)
-
-    foreach label [array names _label2axis] {
-        set axis $_label2axis($label)
-        switch -- $axis {
-            "x" - "x2" - "y" - "y2" {
-                $g axis configure $axis -hide yes -checklimits no
-            }
-            default {
-                $g axis delete $axis
-            }
-        }
-    }
-    array unset _label2axis
-    array unset _limits
-
-    # Scan through all objects and create a list of all axes.
-    # The first x-axis gets mapped to "x".  The second, to "x2".
-    # Beyond that, we must create new axes "x3", "x4", etc.
-    # We do the same for y.
-
-    set anum(x) 0
-    set anum(y) 0
-    foreach dataobj $dlist {
-        foreach axis {x y} {
-            set label [$dataobj hints ${axis}label]
-            if { $label == "" } {
-                continue
-            }
-            # Collect the limits (if set for the axis)
-            set min [$dataobj hints ${axis}min]
-            set max [$dataobj hints ${axis}max]
-            set tag ${label}-min
-            if { $min != "" && ( ![info exists _limits($tag)] ||
-                                   $_limits($tag) > $min ) } {
-                set _limits($tag) $min
-            }
-            set tag ${label}-max
-            if { $max != "" && (![info exists _limits($tag)] ||
-                                  $_limits($tag) < $max) } {
-                set _limits($tag) $max
-            }
-            if  { [$dataobj hints ${axis}scale] == "log" } {
-                set tag ${label}-log
-                set _limits($tag) 1
-            }
-            if { ![info exists _label2axis($label)] } {
-                switch [incr anum($axis)] {
-                    1 { set axisName $axis }
-                    2 { set axisName ${axis}2 }
-                    default {
-                        set axis $axis$anum($axis)
-                        catch {$g axis create $axisName}
-                    }
-                }
-                $g axis configure $axisName -title $label -hide no \
-                    -checklimits no -showticks yes
-                set _label2axis($label) $axisName
-
-                # If this axis has a description, add it as a tooltip
-                set desc [string trim [$dataobj hints ${axis}desc]]
-                Rappture::Tooltip::text $g-$axisName $desc
-            }
-        }
-    }
-    # Next, set the axes based on what we've found.
-    foreach label [array names _label2axis] {
-        set logscale [info exists _limits(${label}-log)]
-        set amin ""
-        if { [info exists _limits(${label}-min)] } {
-            set amin $_limits(${label}-min)
-        }
-        set amax ""
-        if { [info exists _limits(${label}-max)] } {
-            set amax $_limits(${label}-max)
-        }
-        set axis $_label2axis($label)
-        $g axis configure $axis \
-            -hide no -checklimits no \
-            -command [itcl::code $this GetFormattedValue $axis] \
-            -min $amin -max $amax -logscale $logscale
-        $g axis bind $axis <Enter> \
-            [itcl::code $this Axis hilite $axis on]
-        $g axis bind $axis <Leave> \
-            [itcl::code $this Axis hilite $axis off]
-        $g axis bind $axis <ButtonPress-1> \
-            [itcl::code $this Axis click $axis %x %y]
-        $g axis bind $axis <B1-Motion> \
-            [itcl::code $this Axis drag $axis %x %y]
-        $g axis bind $axis <ButtonRelease-1> \
-            [itcl::code $this Axis release $axis %x %y]
-        $g axis bind $axis <KeyPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-    }
-
-    foreach dataobj $dlist {
-        SetElements $dataobj
-    }
-    ResetLegend
-}
-
-#
-# SetElements --
-#
-#       This procedure loads each data objects specified into the
-#       graph.  The data object may already be loaded (from the "add"
-#       method which gets called first).   The graph elements that
-#       are created, are hidden.  This allows the graph to account
-#       for all datasets, even those not currently being displayed.
-#
-itcl::body Rappture::UqCurve::SetElements { dataobj {settings ""} } {
-    #puts "UqCurve::SetElements $dataobj"
-    set g $itk_component(plot)
-
-    array set attrs [$dataobj hints style]
-    array set attrs $settings
-    set type [$dataobj hints type]
-    if { $type == "" } {
-        set type "line"
-    }
-
-    if { ![info exists attrs(-probability)] } {
-        set prob ""
-    } else {
-        set prob $attrs(-probability)
-    }
-
-    # Now fix attributes to a more usable form for the graph.
-
-    # Convert -linestyle to BLT -dashes
-    if { ![info exists attrs(-linestyle)] } {
-        set dashes {}
-    } else {
-        switch -- $attrs(-linestyle) {
-            dashed  { set dashes {4 4} }
-            dotted  { set dashes {2 4} }
-            default { set dashes {}    }
-        }
-    }
-    if { ![info exists attrs(-barwidth)] } {
-        set barwidth 1.0
-    } else {
-        set barwidth $attrs(-barwidth)
-    }
-    if { ![info exists attrs(-width)] } {
-        set linewidth 1
-    } else {
-        set linewidth $attrs(-width)
-    }
-    set _dataobj2raise($dataobj) [info exists attrs(-raise)]
-    if { ![info exists attrs(-simulation)] } {
-        set sim 0
-    } else {
-        set sim $attrs(-simulation)
-    }
-    set _dataobj2sim($dataobj) $sim
-
-    foreach {mapx mapy} [GetAxes $dataobj] break
-    set label [$dataobj hints label]
-
-    foreach cname [$dataobj components] {
-        set tag $dataobj-$cname
-        set xv [$dataobj mesh $cname]
-        set yv [$dataobj values $cname]
-        set xev [$dataobj xErrorValues $cname]
-        set yev [$dataobj yErrorValues $cname]
-        if {([$xv length] <= 1) || ($linewidth == 0)} {
-            set sym square
-            set pixels 2
-        } else {
-            set sym ""
-            set pixels 6
-        }
-        if { ![info exists _comp2elem($tag)] } {
-            set elem "$type[incr _nextElement]"
-            set _elem2comp($elem) $tag
-            set _comp2elem($tag) $elem
-            set found($_comp2elem($tag)) 1
-            lappend label2elem($label) $elem
-            switch -- $type {
-                "line" {
-                    if {$prob != ""} {
-                        set _pts [blt::vector create pts]
-                        $_pts merge $xv $yv
-                        if {$prob == "50"} {
-                            set color gray80
-                        } else {
-                            set color gray50
-                        }
-                        #puts "Probability $prob $color $label"
-                        $g marker create polygon -fill $color -under 1 -coords $pts(0:end)
-                    }
-                    $g line create $elem \
-                        -x $xv -y $yv \
-                        -mapx $mapx \
-                        -mapy $mapy \
-                        -label $label \
-                        -pixels 0
-                }
-                "scatter" {
-                    #puts "SCATTER $xv $yv"
-                    $g line create $elem \
-                        -x $xv -y $yv \
-                        -symbol square \
-                        -pixels 2 \
-                        -linewidth 0 \
-                        -label $label \
-                        -dashes $dashes \
-                        -mapx $mapx \
-                        -mapy $mapy \
-                        -hide yes \
-                        -xerror $xev -yerror $yev
-                }
-                "bar" {
-                    #puts "BAR $xv $yv"
-                    $g bar create $elem \
-                        -x $xv -y $yv \
-                        -barwidth $barwidth \
-                        -label $label \
-                        -mapx $mapx \
-                        -mapy $mapy \
-                        -hide yes \
-                        -xerror $xev -yerror $yev
-                }
-            }
-        } else {
-            $g element configure $_comp2elem($tag) -mapx $mapx -mapy $mapy
-        }
-    }
-}
Index: trunk/gui/scripts/uqinfo.tcl
===================================================================
--- trunk/gui/scripts/uqinfo.tcl	(revision 6716)
+++ 	(revision )
@@ -1,98 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-
-package require Itcl
-package require BLT
-
-namespace eval Rappture {
-    # forward declaration
-}
-
-itcl::class Rappture::UqInfo {
-    constructor {xmlobj path uq_part} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method add {xmlobj path uq_part}
-    public method get {}
-    public method desc {}
-    public method hints {{key ""}}
-    private method _renumber {}
-    private variable _objlist;      # UQ objects
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqInfo::constructor {xmlobj path uq_part} {
-    #puts "UQ INFO CONST $xmlobj $path $uq_part"
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be LibraryObj"
-    }
-    add $xmlobj $path $uq_part
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqInfo::destructor {} {
-}
-
-itcl::body Rappture::UqInfo::_renumber {} {
-    set numtabs [array size _objlist]
-    set index 0
-
-    foreach name [list PDF Probability Sensitivity Response "All Runs" Sequence ] {
-        if {[info exists _objlist($name)]} {
-            foreach {i items} $_objlist($name) break
-            set _objlist($name) [list $index $items]
-            incr index
-        }
-    }
-}
-
-#
-# _objlist is an array of lists.
-# lindex 0 is the index (tab number)
-# lindex 1 is a list of lists containing the xmlobj and path
-# of each element.
-itcl::body Rappture::UqInfo::add {xmlobj path uq_part} {
-    #puts "\nUQ INFO ADD $xmlobj $path $uq_part"
-
-    if {![Rappture::library isvalid $xmlobj]} {
-        error "bad value \"$xmlobj\": should be LibraryObj"
-    }
-
-    if {![info exists _objlist($uq_part)]} {
-        set _objlist($uq_part)  {0 {}}
-    }
-
-    foreach {index items} $_objlist($uq_part) break
-    lappend items [list $xmlobj $path]
-    set _objlist($uq_part) [list $index $items]
-    _renumber
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqInfo::get {} {
-    #uts "UqInfo::get"
-    return [array get _objlist]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: hints ?<keyword>?
-#
-# Returns a list of key/value pairs for various hints about plotting
-# this curve.  If a particular <keyword> is specified, then it returns
-# the hint for that <keyword>, if it exists.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqInfo::hints {{keyword ""}} {
-    #puts "UqInfo hints $keyword"
-}
Index: trunk/gui/scripts/uqnotebook.tcl
===================================================================
--- trunk/gui/scripts/uqnotebook.tcl	(revision 6716)
+++ 	(revision )
@@ -1,250 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-
-# ----------------------------------------------------------------------
-#  COMPONENT: UqNotebook - Tabbed Notebook for UQ results.
-#
-# ======================================================================
-#  AUTHOR:  Martin Hunt, Purdue University
-#  Copyright (c) 2015  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-
-itcl::class Rappture::UqNotebook {
-    inherit itk::Widget
-
-    itk_option define -gridcolor gridColor GridColor ""
-    itk_option define -activecolor activeColor ActiveColor ""
-    itk_option define -dimcolor dimColor DimColor ""
-    itk_option define -autocolors autoColors AutoColors ""
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method add {dataobj {settings ""}}
-    public method scale {args}
-    public method download {option args}
-    public method parameters {title args} {}
-    public method delete {args}
-    public method get {}
-    private method _plotit {xmlobj path index settings}
-    private variable _index2widget; #_index2widget($sim,$tab) -> $w
-    private variable _nblist; # _nblist($sim) returns notebook to pack
-    private variable _nbnum 0; # currently displayed notebook number (sim)
-}
-
-itk::usual UqNotebook {
-    keep -background -cursor -font
-}
-itk::usual Tabset {
-    keep -background -cursor -font
-}
-itk::usual Tabnotebook {
-    keep -background -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqNotebook::constructor {args} {
-    #Rappture::dispatcher _dispatcher
-    #$_dispatcher register !rebuild
-    #$_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) yes
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqNotebook::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a dataobj to the plot.  The optional <settings>
-# are used to configure the plot.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqNotebook::add {uqobj {settings ""}} {
-    #puts "UqNotebook ADD $uqobj ($settings)"
-    array set attrs $settings
-    array set d [$uqobj get]
-    #puts "SIMULATION $attrs(-simulation)"
-
-    # the notebook number is the same as the simulation number
-    set nbnum $attrs(-simulation)
-
-    # See if we are already displaying the requested notebook
-    if {$nbnum == $_nbnum} {
-        return
-    }
-
-    if {[info exists _nblist($_nbnum)]} {
-        set active [$itk_component(uq_nb_$_nbnum) index select]
-        pack forget $itk_component(uq_nb_$_nbnum)
-    } else  {
-        set active -1
-    }
-
-    set _nbnum $nbnum
-
-    if {![info exists _nblist($nbnum)]} {
-        #puts "Creating notebook #$nbnum"
-        itk_component add uq_nb_$nbnum {
-            blt::tabnotebook $itk_interior.uq_nb_$nbnum -tearoff no
-        }
-
-        set _nblist($nbnum) $itk_component(uq_nb_$nbnum)
-
-        foreach name [list PDF Probability Sensitivity Response "All Runs" Sequence] {
-            if {[info exists d($name)]} {
-                foreach {index items} $d($name) break
-                $itk_component(uq_nb_$nbnum) insert $index -text $name
-                foreach obj $items {
-                    foreach {xmlobj path} $obj break
-                    _plotit $xmlobj $path $index $settings
-                }
-            }
-        }
-    }
-    pack $itk_component(uq_nb_$nbnum) -expand yes -fill both
-    if {$active >= 0} {
-        after 100 $itk_component(uq_nb_$nbnum) select $active
-        after idle $itk_component(uq_nb_$nbnum) select $active
-    }
-}
-
-itcl::body Rappture::UqNotebook::_plotit {xmlobj path index settings} {
-    set type [$xmlobj element -as type $path]
-    #puts "uqNotebook::_plotit: xmlobj=$xmlobj path=$path type=$type"
-
-    if {[regexp {output.curve\(curve_pdf-[^-]*-([0-9]+)\)} $path match prob]} {
-        puts "Probability: $prob"
-    } else {
-        set prob ""
-    }
-
-    array set attrs $settings
-    set sim $attrs(-simulation)
-    # puts "sim=$sim index=$index"
-    set dobj ""
-
-    set w $itk_component(uq_nb_$sim).$index
-    switch -- $type {
-        response {
-            set dobj [Rappture::Response ::#auto $xmlobj $path]
-            if {![info exists _index2widget($sim,$index)]} {
-                Rappture::ResponseViewer $w
-            }
-        }
-        histogram {
-            set dobj [Rappture::Histogram ::#auto $xmlobj $path]
-            if {![info exists _index2widget($sim,$index)]} {
-                Rappture::HistogramResult $w
-            }
-        }
-        curve {
-            set dobj [Rappture::Curve ::#auto $xmlobj $path]
-            set type [$dobj hints type]
-            if {![info exists _index2widget($sim,$index)]} {
-                if {$type == "bars"} {
-                    Rappture::BarchartResult $w
-                } elseif {$prob != ""} {
-                    Rappture::UqCurve $w
-                } else {
-                    Rappture::XyResult $w
-                }
-            }
-        }
-        sequence {
-            set dobj [Rappture::Sequence ::#auto $xmlobj $path]
-            if {![info exists _index2widget($sim,$index)]} {
-                Rappture::SequenceResult $w
-            }
-        }
-        field {
-            set dobj [Rappture::Field ::#auto $xmlobj $path]
-        }
-        mesh {
-            set dobj [Rappture::Mesh ::#auto $xmlobj $path]
-        }
-        default {
-            error "Don't know how to plot $type"
-        }
-    }
-    set _index2widget($sim,$index) $w
-    if {$dobj != ""} {
-        if {$prob != ""} {
-            lappend settings -probability $prob
-        }
-        $w add $dobj $settings
-    }
-    $itk_component(uq_nb_$sim) tab configure $index -window $w -fill both
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqNotebook::delete {args} {
-    # puts "UqNotebook::delete $args"
-    # catch {$itk_component(uq_nb) delete 0 end}
-
-    # foreach index [array name _index2widget] {
-    #     puts "destroying index $index"
-    #     destroy $_index2widget($index)
-    # }
-    # foreach dobj $_objlist {
-    #     puts "destroying $dobj"
-    #     destroy $dobj
-    # }
-    # unset _index2widget
-    # set _objlist {}
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all dataobjs--even those not showing on the screen.
-# Because of this, the limits are appropriate for all dataobjs as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::UqNotebook::scale {args} {
-    #puts "UqNotebook::scale $args"
-
-    # get all the tabs and call scale
-    #set num_tabs [$itk_component(uq_nb_$_nbnum) tab names]
-    #for {set i 0} {$i < $num_tabs} {incr i} {
-    #    puts "calling scale for tab $i"
-    #    eval $_index2widget($_nbnum,$i) scale $args
-    #}
-}
-
-itcl::body Rappture::UqNotebook::get {} {
-    #puts "*************** UqNotebook gets"
-}
-
-
-itcl::body Rappture::UqNotebook::download {option args} {
-    #set tab [$itk_component(uq_nb_$_nbnum) index select]
-    #puts "UqNotebook::download $option  : $args -> $_index2widget($_nbnum,$tab)"
-    #eval $_index2widget($_nbnum,$tab) download $option $args
-}
Index: trunk/gui/scripts/utils.tcl
===================================================================
--- trunk/gui/scripts/utils.tcl	(revision 6716)
+++ 	(revision )
@@ -1,164 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: utils - miscellaneous utilities
-#
-#  Misc routines used throughout the GUI.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-namespace eval Rappture { # forward declaration }
-namespace eval Rappture::utils { # forward declaration }
-
-# ----------------------------------------------------------------------
-# USAGE: hexdump ?-lines num? <data>
-#
-# Returns a hex dump for a blob of binary <data>.  This is used to
-# represent the data in an input/output <string> object.  The -lines
-# flag can be used to limit the output to the specified number of
-# lines.
-# ----------------------------------------------------------------------
-proc Rappture::utils::hexdump {args} {
-    Rappture::getopts args params {
-        value -lines unlimited
-    }
-    if {[llength $args] != 1} {
-        error "wrong # args: should be \"hexdump ?-lines num? data\""
-    }
-    set newval [lindex $args 0]
-    set args ""
-
-    set rval "<binary> [Rappture::utils::binsize [string length $newval]]"
-
-    if {$params(-lines) != "unlimited" && $params(-lines) <= 0} {
-        return $rval
-    }
-
-    append rval "\n\n"
-    set len [string length $newval]
-    for {set i 0} {$i < $len} {incr i 8} {
-        append rval [format "%#06x: " $i]
-        set ascii ""
-        for {set j 0} {$j < 8} {incr j} {
-            if {$i+$j < $len} {
-                set char [string index $newval [expr {$i+$j}]]
-                binary scan $char c ichar
-                set hexchar [format "%02x" [expr {0xff & $ichar}]]
-            } else {
-                set char " "
-                set hexchar "  "
-            }
-            append rval "$hexchar "
-            if {[regexp {[\000-\037\177-\377]} $char]} {
-                append ascii "."
-            } else {
-                append ascii $char
-            }
-        }
-        append rval " | $ascii\n"
-
-        if {"unlimited" != $params(-lines) && $i/8+1 >= $params(-lines)} {
-            if {$i < $len-1} {
-                append rval "more..."
-            }
-            break
-        }
-    }
-    return $rval
-}
-
-# ----------------------------------------------------------------------
-# USAGE: binsize <length>
-#
-# Returns a user-friendly expression of data size, like "12 kB" or
-# "144 MB".
-# ----------------------------------------------------------------------
-proc Rappture::utils::binsize {size} {
-    foreach {factor units} {
-        1073741824 GB
-        1048576 MB
-        1024 kB
-        1 bytes
-    } {
-        if {$size/$factor > 0} {
-            if {$factor > 1} {
-                set size [format "%.1f" [expr {double($size)/$factor}]]
-            }
-            break
-        }
-    }
-    return "$size $units"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: datatype <binary>
-#
-# Examines the given <binary> string and returns a description of
-# the data format.
-# ----------------------------------------------------------------------
-proc Rappture::utils::datatype {binary} {
-    set fileprog [auto_execok file]
-    if {[string length $binary] == 0} {
-        set desc "Empty"
-    } elseif {"" != $fileprog} {
-        #
-        # Use Unix "file" program to get info about type
-        # HACK ALERT! must send binary data in by creating a tmp file
-        #   or else it gets corrupted and misunderstood
-        #
-        set id [pid]
-        while {[file exists /tmp/datatype$id]} {
-            incr id
-        }
-        set fname "/tmp/datatype$id"
-        set fid [open $fname w]
-        fconfigure $fid -translation binary -encoding binary
-        puts -nonewline $fid [string range $binary 0 1024]
-        close $fid
-        if {[catch {exec $fileprog -b $fname} desc]} {
-            set desc "Binary data"
-        }
-        catch {file delete $fname}
-    } else {
-        set desc "Binary data"
-    }
-    return $desc
-}
-
-# ----------------------------------------------------------------------
-# USAGE: expandPath <path>
-#
-# Returns the true location of the provided path,
-# automatically expanding links to form an absolute path.
-# ----------------------------------------------------------------------
-proc Rappture::utils::expandPath {args} {
-    set path ""
-    set dirs [file split [lindex $args 0]]
-
-    while {[llength $dirs] > 0} {
-        set d [lindex $dirs 0]
-        set dirs [lrange $dirs 1 end]
-        if {[catch {file link [file join $path $d]} out] == 0} {
-            # directory d is a link, follow it
-            set outdirs [file split $out]
-            if {[string compare "/" [lindex $outdirs 0]] == 0} {
-                # directory leads back to root
-                # clear path
-                # reset dirs list
-                set path ""
-                set dirs $outdirs
-            } else {
-                # relative path for the link
-                # prepend directory to dirs list
-                set dirs [concat $outdirs $dirs]
-            }
-        } else {
-            set path [file join $path $d]
-        }
-    }
-    return $path
-}
-
Index: trunk/gui/scripts/valueresult.tcl
===================================================================
--- trunk/gui/scripts/valueresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,267 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: ValueResult - Log output for ResultSet
-#
-#  This widget is used to show text output in a ResultSet.  The log
-#  output from a tool, for example, is rendered as a ValueResult.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *ValueResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::ValueResult {
-    inherit itk::Widget
-
-    constructor {args} { # defined below }
-
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} { # do nothing }
-    public method download {option args}
-
-    protected method _rebuild {}
-
-    private variable _dispatcher "" ;# dispatcher for !events
-
-    private variable _dlist ""    ;# list of data objects being displayed
-    private variable _dobj2color  ;# maps data object => color
-    private variable _dobj2raise  ;# maps data object => raise flag 0/1
-    private variable _dobj2desc   ;# maps data object => description
-}
-
-itk::usual ValueResult {
-    keep -background -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::ValueResult::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this _rebuild]; list"
-
-    itk_component add scroller {
-        Rappture::Scroller $itk_interior.scroller \
-            -xscrollmode auto -yscrollmode auto
-    }
-    pack $itk_component(scroller) -expand yes -fill both
-
-    itk_component add html {
-        Rappture::HTMLviewer $itk_component(scroller).html
-    }
-    $itk_component(scroller) contents $itk_component(html)
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  If the optional
-# <settings> are specified, then the are applied to the data.  Allowed
-# settings are -color and -brightness, -width, -linestyle and -raise.
-# (Many of these are ignored.)
-# ----------------------------------------------------------------------
-itcl::body Rappture::ValueResult::add {dataobj {settings ""}} {
-    array set params {
-        -color ""
-        -brightness 0
-        -width ""
-        -linestyle ""
-        -raise 0
-        -description ""
-        -param ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-
-    if {"" != $dataobj} {
-        # find the value and assign it with the proper coloring
-        if {"" != $params(-color) && "" != $params(-brightness)
-              && $params(-brightness) != 0} {
-            set params(-color) [Rappture::color::brightness \
-                $params(-color) $params(-brightness)]
-        }
-
-        set pos [lsearch -exact $_dlist $dataobj]
-        if {$pos < 0} {
-            lappend _dlist $dataobj
-            set _dobj2color($dataobj) $params(-color)
-            set _dobj2raise($dataobj) $params(-raise)
-            set _dobj2desc($dataobj) $params(-description)
-            $_dispatcher event -idle !rebuild
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ValueResult::get {} {
-    # put the dataobj list in order according to -raise options
-    set dlist $_dlist
-    foreach obj $dlist {
-        if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} {
-            set i [lsearch -exact $dlist $obj]
-            if {$i >= 0} {
-                set dlist [lreplace $dlist $i $i]
-                lappend dlist $obj
-            }
-        }
-    }
-    return $dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<curve1> <curve2> ...?
-#
-# Clients use this to delete a curve from the plot.  If no curves
-# are specified, then all curves are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ValueResult::delete {args} {
-    if {[llength $args] == 0} {
-        set args $_dlist
-    }
-
-    # delete all specified objects
-    set changed 0
-    foreach obj $args {
-        set pos [lsearch -exact $_dlist $obj]
-        if {$pos >= 0} {
-            set _dlist [lreplace $_dlist $pos $pos]
-            catch {unset _dobj2color($obj)}
-            catch {unset _dobj2raise($obj)}
-            catch {unset _dobj2desc($obj)}
-            set changed 1
-        }
-    }
-
-    # if anything changed, then rebuild the plot
-    if {$changed} {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<curve1> <curve2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <curve> objects.  This
-# accounts for all curves--even those not showing on the screen.
-# Because of this, the limits are appropriate for all curves as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ValueResult::scale {args} {
-    # nothing to do for values
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ValueResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            # no controls for this download yet
-            return ""
-        }
-        now {
-            if {[llength $_dlist] == 1} {
-                set lstr [$_dlist get about.label]
-                set mesg "$lstr [$_dlist get current]"
-            } else {
-                set mesg ""
-                foreach obj $_dlist {
-                    set lstr [$obj get about.label]
-                    append mesg "$lstr [$obj get current]\n"
-                    if {[string length $_dobj2desc($obj)] > 0} {
-                        foreach line [split $_dobj2desc($obj) \n] {
-                            append mesg " * $line\n"
-                        }
-                        append mesg "\n"
-                    }
-                }
-            }
-            return [list .txt $mesg]
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _rebuild
-#
-# Used internally to rebuild the contents of this widget
-# whenever the data within it changes.  Shows the value
-# for the topmost data object in its associated color.
-# ----------------------------------------------------------------------
-itcl::body Rappture::ValueResult::_rebuild {} {
-    set html "<html><body>"
-
-    set obj [lindex $_dlist 0]
-    if {"" != $obj} {
-        set label [$obj get about.label]
-        if {"" != $label && [string index $label end] != ":"} {
-            append label ":"
-        }
-        append html "<h3>$label</h3>\n"
-    }
-
-    foreach obj $_dlist {
-        if {$_dobj2raise($obj)} {
-            set bold0 "<b>"
-            set bold1 "</b>"
-            set bg "background:#ffffcc; border:1px solid #cccccc;"
-        } else {
-            set bold0 ""
-            set bold1 ""
-            set bg ""
-        }
-        if {$_dobj2color($obj) != ""} {
-            set color0 "<font style=\"color: $_dobj2color($obj)\">"
-            set color1 "</font>"
-        } else {
-            set color0 ""
-            set color1 ""
-        }
-
-        append html "<div style=\"margin:8px; padding:4px; $bg\">${bold0}${color0}[$obj get current]${color1}${bold1}"
-        if {$_dobj2raise($obj) && [string length $_dobj2desc($obj)] > 0} {
-            foreach line [split $_dobj2desc($obj) \n] {
-                append html "<li style=\"margin-left:12px;\">$line</li>\n"
-            }
-        }
-        append html "</div>"
-    }
-    append html "</body></html>"
-    $itk_component(html) load $html
-}
Index: trunk/gui/scripts/videochooser.tcl
===================================================================
--- trunk/gui/scripts/videochooser.tcl	(revision 6716)
+++ 	(revision )
@@ -1,173 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: videochooser - list videos
-#
-# ======================================================================
-#  AUTHOR:  Derrick Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-# See the file "license.terms" for information on usage and redistribution of
-# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-package require Itk
-package require BLT
-package require Img
-package require Rappture
-package require RapptureGUI
-
-itcl::class Rappture::VideoChooser {
-    inherit itk::Widget
-
-    itk_option define -width width Width 300
-    itk_option define -height height Height 300
-    itk_option define -variable variable Variable ""
-    itk_option define -thumbsdir thumbsdir Thumbsdir ""
-
-    constructor { args } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method load {paths}
-    public method select {id}
-    protected method _fixSize {}
-
-    private variable _vcnt 0            ;# counter of videos
-    private variable _variable ""       ;# variable to pass along to each choice
-    private variable _paths ""          ;# list of choice paths
-    private variable _objs ""           ;# list of choice objects
-}
-
-
-itk::usual VideoChooser {
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooser::constructor {args} {
-
-    itk_component add scroller {
-        Rappture::Scroller $itk_interior.scroller \
-            -xscrollmode auto \
-            -yscrollmode off \
-            -xscrollside bottom
-    }
-
-
-    $itk_component(scroller) contents frame
-
-
-    pack $itk_component(scroller) -fill both -expand yes
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooser::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooser::load {paths} {
-
-    set f [$itk_component(scroller) contents]
-
-    foreach path $paths {
-        incr _vcnt
-
-        set ci [Rappture::VideoChooserInfo $f.vi${_vcnt} \
-                    -variable ${_variable} \
-                    -thumbsdir $itk_option(-thumbsdir)]
-        $ci load $path ""
-        pack $ci -expand yes -fill both -side left
-
-        # add the object to the list of video info objs
-        lappend _paths $path
-        lappend _objs $ci
-    }
-
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# USAGE: select
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooser::select {id} {
-
-    set obj ""
-
-    if {[string is integer $id] == 1} {
-        # treat $id as the index
-        if {($id < 0) && ($id >= [llength ${_objs}])} {
-            error "invalid id \"$id\": must be in range 0 to [llength ${_objs}]"
-        }
-    } else {
-        # treat $id as a file path
-        set idx [lsearch -exact ${_paths} $id]
-        if {$idx == -1} {
-            error "invalid id \"$id\": not found in list of loaded objects"
-        }
-        set id $idx
-    }
-
-    # grab the object associated with the id
-    # and call it's select function.
-    set obj [lindex ${_objs} $id]
-    $obj select
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooser::_fixSize {} {
-
-    # fix the dimesions of the canvas
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoChooser::variable {
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-
-        foreach o ${_objs} {
-            # tell this object's children about the variable change
-            $o configure -variable $var
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -width
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoChooser::width {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-width)] == 0} {
-        error "bad value: \"$itk_option(-width)\": width should be an integer"
-    }
-    set _width $itk_option(-width)
-    after idle [itcl::code $this _fixSize]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -height
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoChooser::height {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-height)] == 0} {
-        error "bad value: \"$itk_option(-height)\": height should be an integer"
-    }
-    set _height $itk_option(-height)
-    after idle [itcl::code $this _fixSize]
-}
Index: trunk/gui/scripts/videochooserinfo.tcl
===================================================================
--- trunk/gui/scripts/videochooserinfo.tcl	(revision 6716)
+++ 	(revision )
@@ -1,318 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: videochooserinfo - video info
-#
-# ======================================================================
-#  AUTHOR:  Derrick Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-# See the file "license.terms" for information on usage and redistribution of
-# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-package require Itk
-package require BLT
-package require Img
-package require Rappture
-
-itcl::class Rappture::VideoChooserInfo {
-    inherit itk::Widget
-
-    itk_option define -width width Width 96
-    itk_option define -height height Height 54
-    itk_option define -selectedwidth selectedwidth Selectedwidth 112
-    itk_option define -selectedheight selectedheight Selectedheight 63
-    itk_option define -variable variable Variable ""
-    itk_option define -thumbsdir thumbsdir Thumbsdir ""
-
-    constructor { args } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method load {path about}
-    public method select {}
-    public method query {what}
-
-    protected method _fixSize {}
-    protected method _fixValue {args}
-
-    private method _bindings {sequence}
-
-    private variable _preview           ""
-    private variable _selected          ""
-    private variable _path              ""
-    private variable _width             0
-    private variable _height            0
-    private variable _selectedwidth     0
-    private variable _selectedheight    0
-    private variable _variable          "" ;# variable associated with -variable
-}
-
-
-itk::usual VideoChooserInfo {
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooserInfo::constructor {args} {
-
-    itk_component add main {
-        canvas $itk_interior.main
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    bind $itk_component(main) <Configure> [itcl::code $this _fixSize]
-
-    blt::table $itk_interior \
-        0,0 $itk_component(main) -fill both -pady 2
-
-    blt::table configure $itk_interior c* -resize both
-    blt::table configure $itk_interior r0 -resize both
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooserInfo::destructor {} {
-    image delete ${_preview}
-    image delete ${_selected}
-}
-
-# ----------------------------------------------------------------------
-# USAGE: load
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooserInfo::load {path about} {
-
-    if {![file readable $path]} {
-        error "bad path $path: file not readable"
-    }
-
-    set _path $path
-    set preview_fname ""
-    set selected_fname ""
-
-    set _preview [image create photo]
-    set _selected [image create photo]
-
-    if {[string compare "" $itk_option(-thumbsdir)] != 0} {
-        set root [file tail [file rootname ${_path}]]
-        set preview_fname [file join $itk_option(-thumbsdir) ${root}_${_width}x${_height}.png]
-        set selected_fname [file join $itk_option(-thumbsdir) ${root}_${_selectedwidth}x${_selectedheight}.png]
-
-        if {[file readable $preview_fname] && [file readable $selected_fname]} {
-            set fid [open $preview_fname r]
-            fconfigure $fid -translation binary
-            ${_preview} put [read $fid]
-            close $fid
-
-            set fid [open $selected_fname r]
-            fconfigure $fid -translation binary
-            ${_selected} put [read $fid]
-            close $fid
-        }
-    } else {
-        # there are some incomplete movies that don't open up
-        set err [catch {
-            set movie [Rappture::Video file ${_path}]
-            $movie seek 60
-
-            ${_preview} put [$movie get image ${_width} ${_height}]
-            ${_selected} put [$movie get image ${_selectedwidth} ${_selectedheight}]
-
-            $movie release
-        }]
-        if {$err} {
-            puts stderr "Error while opening movie: $movie"
-            return
-        }
-    }
-
-    set cw [expr round(${_selectedwidth}/2.0)]
-    set ch [expr round(${_selectedheight}/2.0)]
-    $itk_component(main) create image $cw $ch \
-        -anchor center \
-        -image ${_preview} \
-        -activeimage ${_selected} \
-        -tags preview
-
-    $itk_component(main) bind preview <ButtonPress-1> [itcl::code $this _bindings b1press]
-    $itk_component(main) bind preview <Enter> [itcl::code $this _bindings enter]
-    $itk_component(main) bind preview <Leave> [itcl::code $this _bindings leave]
-
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# USAGE: select
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooserInfo::select {} {
-    if {"" == $_variable} {
-        return
-    }
-    # send this object's movie to the preview window
-
-    upvar #0 $_variable var
-    set var ${_path}
-
-    foreach {x0 y0 x1 y1} [$itk_component(main) bbox preview] break
-    set x0 [expr 0]
-    set y0 [expr 2]
-    set x1 [expr [$itk_component(main) cget -width]-2]
-    set y1 [expr [$itk_component(main) cget -height]-2]
-
-    # there is something wrong with the way we place the
-    # images on the canvas, or how the canvas is shapeed.
-    # the placement of the small image seems to be off
-    # by a pixel or two. for now we fudge the numbers to
-    # make the red line accesnts look decent.
-
-    $itk_component(main) create line $x0 $y0 $x1 $y0 \
-        -fill red \
-        -width 3 \
-        -tags previewselected
-
-    $itk_component(main) create line $x0 $y1 $x1 $y1 \
-        -fill red \
-        -width 3 \
-        -tags previewselected
-
-#    $itk_component(main) create rectangle \
-        [$itk_component(main) bbox preview] \
-        -outline red \
-        -width 4 \
-        -tags previewselected
-#    $itk_component(main) configure -background red
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _bindings
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooserInfo::_bindings {sequence} {
-    switch -- $sequence {
-        "b1press" {
-            select
-        }
-        "enter" {
-            $itk_component(main) itemconfigure previewselected -state hidden
-        }
-        "leave" {
-            $itk_component(main) itemconfigure previewselected -state normal
-        }
-        default {}
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooserInfo::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-    if {[string compare $var ${_path}] != 0} {
-        # unselect this object
-        $itk_component(main) delete previewselected
-        #$itk_component(main) configure -background black
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooserInfo::_fixSize {} {
-    $itk_component(main) configure -width ${_selectedwidth} -height ${_selectedheight}
-}
-
-# ----------------------------------------------------------------------
-# USAGE: query
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoChooserInfo::query {what} {
-    switch -- $what {
-        "preview" {return ${_preview}}
-        "selected" {return ${_selected}}
-        "file" {return ${_path}}
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoChooserInfo::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -width
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoChooserInfo::width {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-width)] == 0} {
-        error "bad value: \"$itk_option(-width)\": width should be an integer"
-    }
-    set _width $itk_option(-width)
-    after idle [itcl::code $this _fixSize]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -height
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoChooserInfo::height {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-height)] == 0} {
-        error "bad value: \"$itk_option(-height)\": height should be an integer"
-    }
-    set _height $itk_option(-height)
-    after idle [itcl::code $this _fixSize]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -selectedwidth
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoChooserInfo::selectedwidth {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-selectedwidth)] == 0} {
-        error "bad value: \"$itk_option(-selectedwidth)\": selectedwidth should be an integer"
-    }
-    set _selectedwidth $itk_option(-selectedwidth)
-    after idle [itcl::code $this _fixSize]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -selectedheight
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoChooserInfo::selectedheight {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-selectedheight)] == 0} {
-        error "bad value: \"$itk_option(-selectedheight)\": selectedheight should be an integer"
-    }
-    set _selectedheight $itk_option(-selectedheight)
-    after idle [itcl::code $this _fixSize]
-}
Index: trunk/gui/scripts/videodial.tcl
===================================================================
--- trunk/gui/scripts/videodial.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1338 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Videodial - selector, like the dial on a flow
-#
-#  This widget looks like the dial on an old-fashioned car flow.
-#  It draws a series of values along an axis, and allows a selector
-#  to move back and forth to select the values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Videodial.dialProgressColor #6666cc widgetDefault
-option add *Videodial.thickness 10 widgetDefault
-option add *Videodial.length 2i widgetDefault
-option add *Videodial.knobImage knob widgetDefault
-option add *Videodial.knobPosition n@middle widgetDefault
-option add *Videodial.dialOutlineColor black widgetDefault
-option add *Videodial.dialFillColor white widgetDefault
-option add *Videodial.lineColor gray widgetDefault
-option add *Videodial.activeLineColor black widgetDefault
-option add *Videodial.padding 0 widgetDefault
-option add *Videodial.valueWidth 10 widgetDefault
-option add *Videodial.valuePadding 0.1 widgetDefault
-option add *Videodial.foreground black widgetDefault
-option add *Videodial.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Videodial {
-    inherit itk::Widget
-
-    itk_option define -min min Min 0
-    itk_option define -max max Max 1
-    itk_option define -minortick minortick Minortick 1
-    itk_option define -majortick majortick Majortick 5
-    itk_option define -variable variable Variable ""
-    itk_option define -offset offset Offset 1
-
-    itk_option define -thickness thickness Thickness 0
-    itk_option define -length length Length 0
-    itk_option define -padding padding Padding 0
-
-    itk_option define -foreground foreground Foreground "black"
-    itk_option define -dialoutlinecolor dialOutlineColor Color "black"
-    itk_option define -dialfillcolor dialFillColor Color "white"
-    itk_option define -dialprogresscolor dialProgressColor Color ""
-    itk_option define -linecolor lineColor Color "black"
-    itk_option define -activelinecolor activeLineColor Color "black"
-    itk_option define -knobimage knobImage KnobImage ""
-    itk_option define -knobposition knobPosition KnobPosition ""
-
-    itk_option define -font font Font ""
-    itk_option define -valuewidth valueWidth ValueWidth 0
-    itk_option define -valuepadding valuePadding ValuePadding 0
-
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method current {value}
-    public method clear {}
-    public method mark {args}
-    public method bball {}
-
-    protected method _bindings {type args}
-    protected method _redraw {}
-    protected method _marker {tag action x y}
-    protected method _setmark {type args}
-    protected method _move {action x y}
-    protected method _knob {x y}
-    protected method _navigate {offset}
-    protected method _fixSize {}
-    protected method _fixMinorSize {}
-    protected method _fixValue {args}
-    protected method _fixOffsets {}
-
-    private method _current {value}
-    private method _see {item}
-    private method _draw_major_timeline {}
-    private method _draw_minor_timeline {}
-    private method _offsetx {x}
-    private method ms2rel {value}
-    private method rel2ms {value}
-    private common _click             ;# x,y point where user clicked
-    private common _marks             ;# list of marks
-    private variable _values ""       ;# list of all values on the dial
-    private variable _val2label       ;# maps value => string label(s)
-    private variable _current 0       ;# current value (where pointer is)
-    private variable _variable ""     ;# variable associated with -variable
-    private variable _knob ""         ;# image for knob
-    private variable _spectrum ""     ;# width allocated for values
-    private variable _activecolor ""  ;# width allocated for values
-    private variable _vwidth 0        ;# width allocated for values
-    private variable _offset_pos 1    ;#
-    private variable _offset_neg -1   ;#
-    private variable _imspace 10      ;# pixels between intermediate marks
-    private variable _pmcnt 0         ;# particle marker count
-    private variable _min 0
-    private variable _max 1
-    private variable _minortick 1
-    private variable _majortick 5
-}
-
-itk::usual Videodial {
-    keep -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::constructor {args} {
-
-    # bind $itk_component(hull) <<Frame>> [itcl::code $this _updateCurrent]
-
-    # ----------------------------------------------------------------------
-    # controls for the major timeline.
-    # ----------------------------------------------------------------------
-    itk_component add majordial {
-        canvas $itk_interior.majordial
-    }
-
-    bind $itk_component(majordial) <Configure> [itcl::code $this _draw_major_timeline]
-
-    bind $itk_component(majordial) <ButtonPress-1> [itcl::code $this _knob %x %y]
-    bind $itk_component(majordial) <B1-Motion> [itcl::code $this _knob %x %y]
-    bind $itk_component(majordial) <ButtonRelease-1> [itcl::code $this _knob %x %y]
-
-    #bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate $_offset_neg]
-    #bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate $_offset_pos]
-
-    $itk_component(majordial) bind  "knob" <Enter> \
-        [list $itk_component(majordial) configure -cursor sb_h_double_arrow]
-    $itk_component(majordial) bind  "knob" <Leave> \
-        [list $itk_component(majordial) configure -cursor ""]
-
-    # ----------------------------------------------------------------------
-    # controls for the minor timeline.
-    # ----------------------------------------------------------------------
-    itk_component add minordial {
-        canvas $itk_interior.minordial -background blue
-    }
-
-
-    bind $itk_component(minordial) <Configure> [itcl::code $this _draw_minor_timeline]
-
-    bind $itk_component(minordial) <ButtonPress-1> [itcl::code $this _move click %x %y]
-    bind $itk_component(minordial) <B1-Motion> [itcl::code $this _move drag %x %y]
-    bind $itk_component(minordial) <ButtonRelease-1> [itcl::code $this _move release %x %y]
-
-    # ----------------------------------------------------------------------
-    # place controls in widget.
-    # ----------------------------------------------------------------------
-
-    blt::table $itk_interior \
-        0,0 $itk_component(majordial) -fill x \
-        1,0 $itk_component(minordial) -fill x
-
-    blt::table configure $itk_interior c* -resize both
-    blt::table configure $itk_interior r0 -resize none
-    blt::table configure $itk_interior r1 -resize none
-
-
-    eval itk_initialize $args
-
-    $itk_component(majordial) configure -background green
-    $itk_component(minordial) configure -background cyan
-
-    #$itk_component(majordial) configure -relief sunken -borderwidth 1
-    #$itk_component(minordial) configure -relief sunken -borderwidth 1
-
-    _fixSize
-    _fixOffsets
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::destructor {} {
-    configure -variable ""  ;# remove variable trace
-    after cancel [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current ?<value>?
-#
-# Clients use this to set a new value for the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::current {value} {
-    if {"" == $value} {
-        return
-    }
-    _current [ms2rel $value]
-    # event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _current ?<value>?
-#
-# Clients use this to set a new value for the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_current {relval} {
-    if { $relval < 0.0 } {
-        set relval 0.0
-    }
-    if { $relval > 1.0 } {
-        set relval 1.0
-    }
-    set _current $relval
-
-    after cancel [itcl::code $this _draw_major_timeline]
-    after idle [itcl::code $this _draw_major_timeline]
-
-    # update the current marker and move the canvas so current is centered
-    set framenum [expr round([rel2ms $_current])]
-    #_see "frame$framenum"
-    #mark current $framenum
-    after idle [itcl::code $this _see "frame$framenum"]
-    after idle [_setmark current $framenum]
-
-    # update the upvar variable
-    if { $_variable != "" } {
-        upvar #0 $_variable var
-        set var $framenum
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _bindings <type> ?args?
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_bindings {type args} {
-    switch -- $type {
-        "marker" {
-            set tag [lindex $args 0]
-            bind $itk_component(minordial) <ButtonPress-1> [itcl::code $this _marker $tag click %x %y]
-            bind $itk_component(minordial) <B1-Motion> [itcl::code $this _marker $tag drag %x %y]
-            bind $itk_component(minordial) <ButtonRelease-1> [itcl::code $this _marker $tag release %x %y]
-            $itk_component(minordial) configure -cursor hand2
-        }
-        "timeline" {
-            bind $itk_component(minordial) <ButtonPress-1> [itcl::code $this _move click %x %y]
-            bind $itk_component(minordial) <B1-Motion> [itcl::code $this _move drag %x %y]
-            bind $itk_component(minordial) <ButtonRelease-1> [itcl::code $this _move release %x %y]
-            $itk_component(minordial) configure -cursor ""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: mark <property> <args>
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::mark {property args} {
-    set retval 0
-
-    switch -- $property {
-        add {
-            set retval [eval _setmark $args]
-        }
-        remove {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"mark remove <type>\""
-            }
-            set type [lindex $args 0]
-            if {[info exists _marks($type)]} {
-                $itk_component(minordial) delete $type
-                array unset _marks $type
-            }
-        }
-        position {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"mark position <type>\""
-            }
-            set type [lindex $args 0]
-            if {[info exists _marks($type)]} {
-                return $_marks($type)
-            }
-            set retval [expr ${_min}-1]
-        }
-        default {
-            error "bad value \"$property\": should be one of add, remove, position"
-        }
-    }
-
-    return $retval
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _setmark <type> ?[-xcoord|-tag]? <where>
-#
-# Clients use this to add a mark to the timeline
-#   type can be any one of loopstart, loopend, particle, arrow
-#   where is interpreted based on the preceeding flag if available.
-#       in the default case, <where> is interpreted as a frame number
-#       or "current". if the -xcoord flag is provided, where is
-#       interpreted as the x coordinate of where to center the marker.
-#       -xcoord should only be used for temporary placement of a
-#       marker. when -xcoord is used, the marker is placed exactly at
-#       the provided x coordinate, and is not associated with any
-#       frame. It's purpose is mainly for <B1-Motion> events.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_setmark {type args} {
-
-    set c $itk_component(minordial)
-
-    set cx0 0
-    set cy0 0
-    set cx1 0
-    set cy1 0
-    foreach {cx0 cy0 cx1 cy1} [$c bbox "imbox"] break
-
-    # get coords of where to place the marker
-    set frx0 0
-    set fry0 0
-    set frx1 0
-    set fry1 0
-
-    set where ""
-    set largs [llength $args]
-    if {$largs == 1} {
-        set where [lindex $args 0]
-        if {[string compare "current" $where] == 0} {
-            set where [expr round([rel2ms ${_current}])]
-        } elseif {[string is integer $where] == 0} {
-            error "bad value \"$where\": while trying to place marker \"$type\": <where> should be an integer value"
-        }
-
-        # restrict <where> to valid frames between min and max
-        if {$where < ${_min}} {
-            set where ${_min}
-        }
-        if {$where > ${_max}} {
-            set where ${_max}
-        }
-
-        set coords [$c coords "frame$where"]
-        if {![llength $coords]} {
-            # frame marker does not exist
-            # estimate where to put the marker
-            # use frame0 marker as a x=0 point
-            foreach {frx0 fry0 frx1 fry1} [$c coords "frame0"] break
-            set frx0 [expr {$frx0 + ((1.0*$where/${_minortick})*${_imspace})}]
-        } else {
-            foreach {frx0 fry0 frx1 fry1} $coords break
-        }
-        # where already contains the frame number
-    } elseif {$largs == 2} {
-        set flag [lindex $args 0]
-        switch -- $flag {
-            "-xcoord" {
-                set frx0 [lindex $args 1]
-                # where is not set for the -xcoord flag
-            }
-            "-tag" {
-                set id [lindex $args 1]
-                # find the frame# tag to associate with the marker with
-                if {[regexp {frame([0-9]+)} $id] == 0} {
-                    foreach tags [$c gettags $id] {
-                        if {"" != [set tmp [lsearch -inline -regexp $tags {frame[0-9]+}]]} {
-                            set where $tmp
-                            break
-                        }
-                    }
-                } else {
-                    set where $id
-                }
-                # store the frame number in where
-                regexp {frame([0-9]+)} $where match where
-
-                # restrict <where> to valid frames between min and max
-                if {$where < ${_min}} {
-                    set where ${_min}
-                }
-                if {$where > ${_max}} {
-                    set where ${_max}
-                }
-
-                foreach {frx0 fry0 frx1 fry1} [$c coords frame$where] break
-            }
-            default {
-                error "bad value \"$flag\": should be -xcoord or -tag"
-            }
-        }
-        if {[string is double $frx0] == 0} {
-            error "bad value \"$frx0\": <where> should be a double value"
-        }
-    } else {
-        error "wrong # args: should be \"mark <type> ?-xcoord? <where>\""
-    }
-
-    # add/remove the marker
-
-    switch -glob -- $type {
-        "loopstart" {
-            # add start marker
-
-            set smx0 $frx0                              ;# loopstart marker x0
-            set smy0 $cy0                               ;# loopstart marker y0
-
-            # polygon's outline adds a border to only one
-            # side of the object? so we have weird +1 in
-            # the triangle base in loopstart marker
-
-            # marker stem is 3 pixels thick
-            set smx1 [expr {$smx0+1}]                   ;# triangle top x
-            set smy1 [expr {$smy0-10}]                  ;# triangle top y
-            set smx2 $smx1                              ;# stem bottom right x
-            set smy2 $cy1                               ;# stem bottom right y
-            set smx3 [expr {$smx0-1}]                   ;# stem bottom left x
-            set smy3 $smy2                              ;# stem bottom left y
-            set smx4 $smx3                              ;# stem middle left x
-            set smy4 $smy0                              ;# stem middle left y
-            set smx5 [expr {$smx0-10+1}]                ;# triangle bottom left x
-            set smy5 $smy0                              ;# triangle bottom left y
-
-            set tag $type
-            $c delete $tag
-            $c create polygon \
-                $smx1 $smy1 \
-                $smx2 $smy2 \
-                $smx3 $smy3 \
-                $smx4 $smy4 \
-                $smx5 $smy5 \
-                -outline black -fill black -tags $tag
-
-            $c bind $tag <Enter> [itcl::code $this _bindings marker $tag]
-            $c bind $tag <Leave> [itcl::code $this _bindings timeline]
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-
-                # make sure loopstart marker is before loopend marker
-                if {[info exists _marks(loopend)]} {
-                    set endFrNum $_marks(loopend)
-                    if {$endFrNum < $where} {
-                        _setmark loopend -tag frame[expr $where+1]
-                    }
-                }
-            }
-
-            _fixMinorSize
-        }
-        "loopend" {
-            # add loopend marker
-
-            set emx0 $frx0                              ;# loopend marker x0
-            set emy0 $cy0                               ;# loopend marker y0
-
-            set emx1 [expr {$emx0-1}]                   ;# triangle top x
-            set emy1 [expr {$emy0-10}]                  ;# triangle top y
-            set emx2 $emx1                              ;# stem bottom left x
-            set emy2 $cy1                               ;# stem bottom left y
-            set emx3 [expr {$emx0+1}]                   ;# stem bottom right x
-            set emy3 $emy2                              ;# stem bottom right y
-            set emx4 $emx3                              ;# stem middle right x
-            set emy4 $emy0                              ;# stem middle right  y
-            set emx5 [expr {$emx0+10-1}]                ;# triangle bottom right x
-            set emy5 $emy0                              ;# triangle bottom right y
-
-            set tag $type
-            $c delete $tag
-            $c create polygon \
-                $emx1 $emy1 \
-                $emx2 $emy2 \
-                $emx3 $emy3 \
-                $emx4 $emy4 \
-                $emx5 $emy5 \
-                -outline black -fill black -tags $tag
-
-            $c bind $tag <Enter> [itcl::code $this _bindings marker $tag]
-            $c bind $tag <Leave> [itcl::code $this _bindings timeline]
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-
-                # make sure loopend marker is after loopstart marker
-                if {[info exists _marks(loopstart)]} {
-                    set startFrNum $_marks(loopstart)
-                    if {$startFrNum > $where} {
-                        _setmark loopstart -tag frame[expr $where-1]
-                    }
-                }
-            }
-
-            _fixMinorSize
-        }
-        "particle*" {
-            set radius 3
-            set pmx0 $frx0
-            set pmy0 [expr {$cy1+5}]
-            set coords [list [expr $pmx0-$radius] [expr $pmy0-$radius] \
-                             [expr $pmx0+$radius] [expr $pmy0+$radius]]
-
-            set tag $type
-            $c create oval $coords \
-                -fill green \
-                -outline black \
-                -width 1 \
-                -tags $tag
-
-            #$c bind $tag <Enter> [itcl::code $this _bindings marker $tag]
-            #$c bind $tag <Leave> [itcl::code $this _bindings timeline]
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-            }
-
-            _fixMinorSize
-
-        }
-        "arrow" {
-            set radius 3
-            set amx0 $frx0
-            set amy0 [expr {$cy1+15}]
-            set coords [list [expr $amx0-$radius] [expr $amy0-$radius] \
-                             [expr $amx0+$radius] [expr $amy0+$radius]]
-
-            set tag $type
-            $c create line $coords \
-                -fill red \
-                -width 3  \
-                -tags $tag
-
-            #$c bind $tag <Enter> [itcl::code $this _bindings marker $tag]
-            #$c bind $tag <Leave> [itcl::code $this _bindings timeline]
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-            }
-
-            _fixMinorSize
-        }
-        "current" {
-
-            set cmx0 $frx0                              ;# current marker x0
-            set cmy0 $cy0                               ;# current marker y0
-
-            set cmx1 [expr {$cmx0+5}]                   ;# lower right diagonal edge x
-            set cmy1 [expr {$cmy0-5}]                   ;# lower right diagonal edge y
-            set cmx2 $cmx1                              ;# right top x
-            set cmy2 [expr {$cmy1-5}]                   ;# right top y
-            set cmx3 [expr {$cmx0-5}]                   ;# left top x
-            set cmy3 $cmy2                              ;# left top y
-            set cmx4 $cmx3                              ;# lower left diagonal edge x
-            set cmy4 $cmy1                              ;# lower left diagonal edge y
-
-            set tag $type
-            $c delete $tag
-            $c create polygon \
-                $cmx0 $cmy0 \
-                $cmx1 $cmy1 \
-                $cmx2 $cmy2 \
-                $cmx3 $cmy3 \
-                $cmx4 $cmy4 \
-                -outline black -fill red -tags $tag
-            $c create line $cmx0 $cmy0 $cmx0 $cy1 -fill red -tags $tag
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-            }
-
-        }
-        default {
-            error "bad value \"$type\": should be \"loopstart\" or \"loopend\""
-        }
-    }
-    return
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _draw_major_timeline
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_draw_major_timeline {} {
-    set c $itk_component(majordial)
-    $c delete all
-
-    set fg $itk_option(-foreground)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set p [winfo pixels $c $itk_option(-padding)]
-    set t [expr {$itk_option(-thickness)+1}]
-    # FIXME: hack to get the reduce spacing in widget
-    set y1 [expr {$h-2}]
-
-    if {"" != $_knob} {
-        set kw [image width $_knob]
-        set kh [image height $_knob]
-
-        # anchor refers to where on knob
-        # top/middle/bottom refers to where on the dial
-        # leave room for the bottom of the knob if needed
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top {
-                set extra [expr {$t-$kh}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$y1-$extra}]
-            }
-            n@middle - nw@middle - ne@middle {
-                set extra [expr {int(ceil($kh-0.5*$t))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$y1-$extra}]
-            }
-            n@bottom - nw@bottom - ne@bottom {
-               set y1 [expr {$y1-$kh}]
-            }
-
-            e@top - w@top - center@top -
-            e@bottom - w@bottom - center@bottom {
-                set extra [expr {int(ceil(0.5*$kh))}]
-                set y1 [expr {$y1-$extra}]
-            }
-            e@middle - w@middle - center@middle {
-                set extra [expr {int(ceil(0.5*($kh-$t)))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$y1-$extra}]
-            }
-
-            s@top - sw@top - se@top -
-            s@middle - sw@middle - se@middle -
-            s@bottom - sw@bottom - se@bottom {
-                set y1 [expr {$y1-1}]
-            }
-        }
-    }
-    set y0 [expr {$y1-$t}]
-    set x0 [expr {$p+1}]
-    set x1 [expr {$w-$_vwidth-$p-4}]
-
-    # draw the background rectangle for the major time line
-    $c create rectangle $x0 $y0 $x1 $y1 \
-        -outline $itk_option(-dialoutlinecolor) \
-        -fill $itk_option(-dialfillcolor) \
-        -tags "majorbg"
-
-    # draw the optional progress bar for the major time line,
-    # from start to current
-    if {"" != $itk_option(-dialprogresscolor) } {
-        set xx1 [expr {$_current*($x1-$x0) + $x0}]
-        $c create rectangle [expr {$x0+1}] [expr {$y0+3}] $xx1 [expr {$y1-2}] \
-            -outline "" -fill $itk_option(-dialprogresscolor)
-    }
-
-    regexp {([nsew]+|center)@} $itk_option(-knobposition) match anchor
-    switch -glob -- $itk_option(-knobposition) {
-        *@top    { set kpos $y0 }
-        *@middle { set kpos [expr {int(ceil(0.5*($y1+$y0)))}] }
-        *@bottom { set kpos $y1 }
-    }
-
-    set x [expr {$_current*($x1-$x0) + $x0}]
-
-    set color $_activecolor
-    set thick 3
-    if {"" != $color} {
-        $c create line $x [expr {$y0+1}] $x $y1 -fill $color -width $thick
-    }
-
-    $c create image $x $kpos -anchor $anchor -image $_knob -tags "knob"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: bball
-#   debug function to print out the bounding box information for
-#   minor dial
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::bball {} {
-    set c $itk_component(minordial)
-    foreach item [$c find all] {
-        foreach {x0 y0 x1 y1} [$c bbox $item] break
-        if {! [info exists y1]} continue
-        puts stderr "$item : [expr $y1-$y0]: $y0 $y1"
-        lappend q $y0 $y1
-    }
-    set q [lsort -real $q]
-    puts stderr "q [lindex $q 0] [lindex $q end]"
-    puts stderr "height [winfo height $c]"
-    puts stderr "bbox all [$c bbox all]"
-    puts stderr "parent height [winfo height [winfo parent $c]]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _draw_minor_timeline
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_draw_minor_timeline {} {
-    set c $itk_component(minordial)
-    $c delete all
-
-    set fg $itk_option(-foreground)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set p [winfo pixels $c $itk_option(-padding)]
-    set t [expr {$itk_option(-thickness)+1}]
-    set y1 [expr {$h-1}]
-    set y0 [expr {$y1-$t}]
-    set x0 [expr {$p+1}]
-    set x1 [expr {$w-$_vwidth-$p-4}]
-
-
-    # draw the background rectangle for the minor time line
-    $c create rectangle $x0 $y0 $x1 $y1 \
-        -outline $itk_option(-dialoutlinecolor) \
-        -fill $itk_option(-dialfillcolor) \
-        -tags "imbox"
-
-    # add intermediate marks between markers
-    set imw 1.0                                 ;# intermediate mark width
-
-    set imsh [expr {$t/3.0}]                    ;# intermediate mark short height
-    set imsy0 [expr {$y0+(($t-$imsh)/2.0)}]     ;# precalc'd imark short y0 coord
-    set imsy1 [expr {$imsy0+$imsh}]             ;# precalc'd imark short y1 coord
-
-    set imlh [expr {$t*2.0/3.0}]                ;# intermediate mark long height
-    set imly0 [expr {$y0+(($t-$imlh)/2.0)}]     ;# precalc'd imark long y0 coord
-    set imly1 [expr {$imly0+$imlh}]             ;# precalc'd imark long y1 coord
-
-    set imty [expr {$y0-5}]                     ;# height of marker value
-
-    set imx $x0
-    for {set i [expr {int(${_min})}]} {$i <= ${_max}} {incr i} {
-        if {($i%${_majortick}) == 0} {
-            # draw major tick
-            $c create line $imx $imly0 $imx $imly1 \
-                -fill red \
-                -width $imw \
-                -tags [list longmark-c imark-c "frame$i"]
-
-            $c create text $imx $imty -anchor center -text $i \
-                -font $itk_option(-font) -tags "frame$i"
-
-            set imx [expr $imx+${_imspace}]
-        } elseif {($i%${_minortick}) == 0 } {
-            # draw minor tick
-            $c create line $imx $imsy0 $imx $imsy1 \
-                -fill blue \
-                -width $imw \
-                -tags [list shortmark-c imark-c "frame$i"]
-
-            set imx [expr $imx+${_imspace}]
-        }
-    }
-
-
-    # calculate the height of the intermediate tick marks
-    # and frame numbers on our canvas, resize the imbox
-    # to include both of them.
-    set box [$c bbox "all"]
-    if {![llength $box]} {
-        set box [list 0 0 0 0]
-    }
-    foreach {x0 y0 x1 y1} $box break
-    $c coords "imbox" $box
-
-    # add any marks that the user previously specified
-    foreach n [array names _marks] {
-        # mark $n -tag $_marks($n)
-        _setmark $n $_marks($n)
-    }
-
-    _fixMinorSize
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _fixMinorSize
-#
-# Used internally to compute the height of the minor dial based
-# on the items placed on the canvas
-#
-# FIXME: instead of calling this in the mark command, figure out how to
-#   make the canvas the correct size to start with
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_fixMinorSize {} {
-    # resize the height of the minor timeline canvas
-    # to include everything we know about
-
-    set c $itk_component(minordial)
-
-    set box [$c bbox "all"]
-    if {![llength $box]} {
-        set box [list 0 0 0 0]
-    }
-
-    foreach {x0 y0 x1 y1} $box break
-    set h [expr $y1-$y0]
-
-    $c configure -height $h -scrollregion $box -xscrollincrement 1p
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Called automatically whenever the widget changes size to redraw
-# all elements within it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_redraw {} {
-#    _draw_major_timeline
-#    _draw_minor_timeline
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _knob <x> <y>
-#
-# Called automatically whenever the user clicks or drags on the widget
-# to select a value.  Moves the current value to the one nearest the
-# click point.  If the value actually changes, it generates a <<Value>>
-# event to notify clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_knob {x y} {
-    set c $itk_component(majordial)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set x0 1
-    set x1 [expr {$w-$_vwidth-4}]
-    focus $itk_component(hull)
-    if {$x >= $x0 && $x <= $x1} {
-        current [rel2ms [expr double($x - $x0) / double($x1 - $x0)]]
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _offsetx <x>
-#
-# Calculate an x coordinate that has been offsetted by a scrolled canvas
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_offsetx {x} {
-    set c $itk_component(minordial)
-    set w [lindex [$c cget -scrollregion] 2]
-    set x0 [lindex [$c xview] 0]
-    set offset [expr {$w*$x0}]
-    set x [expr {$x+$offset}]
-    return $x
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _marker <tag> click <x> <y>
-#        _marker <tag> drag <x> <y>
-#        _marker <tag> release <x> <y>
-#
-# Called automatically whenever the user clicks or drags on a marker
-# widget.  Moves the selected marker to the next nearest tick mark.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_marker {tag action x y} {
-    set c $itk_component(minordial)
-    set x [_offsetx $x]
-    switch $action {
-        "click" {
-        }
-        "drag" {
-            _setmark $tag -xcoord $x
-            # if we are too close to the edge, scroll the canvas.
-            # $c xview scroll $dist "unit"
-        }
-        "release" {
-            # on release, snap to the closest imark
-            foreach {junk y0 junk y1} [$c bbox "imark-c"] break
-            set id ""
-            foreach item [$c find enclosed [expr {$x-((${_imspace}+1)/2.0)}] $y0 \
-                                           [expr {$x+((${_imspace}+1)/2.0)}] $y1] {
-                set itemtags [$c gettags $item]
-                if {[lsearch -exact $itemtags "imark-c"] != -1} {
-                    set id [lsearch -inline -regexp $itemtags {frame[0-9]}]
-                    break
-                }
-            }
-            if {[string compare "" $id] == 0} {
-                # something went wrong
-                # we should have found an imark with
-                # an associated "frame#" tag to snap to
-                # bailout
-                error "could not find an intermediate mark to snap marker to"
-            }
-
-            _setmark $tag -tag $id
-
-            # take care of cases where the mouse leaves the marker's boundries
-            # before the button-1 has been released. we check if the last
-            # coord was within the bounds of the marker. if not, we manually
-            # generate the "Leave" event.
-            set leave 1
-            foreach item [$c find overlapping $x $y $x $y] {
-                if {[lsearch -exact [$c gettags $item] $tag] != -1} {
-                    set leave 0
-                }
-            }
-            if {$leave == 1} {
-                # FIXME:
-                # i want to generate the event rather than
-                # calling the function myself...
-                # event generate $c <Leave>
-                _bindings timeline
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _move click <x> <y>
-#        _move drag <x> <y>
-#        _move release <x> <y>
-#
-# Called automatically whenever the user clicks or drags on the widget
-# to select a value.  Moves the current value to the one nearest the
-# click point.  If the value actually changes, it generates a <<Value>>
-# event to notify clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_move {action x y} {
-    switch $action {
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            set c $itk_component(minordial)
-            set dist [expr $_click(x)-$x]
-            $c xview scroll $dist "units"
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "release" {
-            _move drag $x $y
-            catch {unset _click}
-        }
-    }
-}
-
-## from http://tcl.sourceforge.net/faqs/tk/#canvas/see
-## "see" method alternative for canvas
-## Aligns the named item as best it can in the middle of the screen
-##
-## item - a canvas tagOrId
-itcl::body Rappture::Videodial::_see {item} {
-    set c $itk_component(minordial)
-    set box [$c bbox $item]
-    if {![llength $box]} return
-    ## always properly set -scrollregion
-    foreach {x y x1 y1}     $box \
-            {top btm}       [$c yview] \
-            {left right}    [$c xview] \
-            {p q xmax ymax} [$c cget -scrollregion] {
-        set xpos [expr {(($x1+$x)/2.0)/$xmax - ($right-$left)/2.0}]
-        #set ypos [expr {(($y1+$y)/2.0)/$ymax - ($btm-$top)/2.0}]
-    }
-    $c xview moveto $xpos
-    #$c yview moveto $ypos
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-#itcl::body Rappture::Videodial::_navigate {offset} {
-#    set index [lsearch -exact $_values $_current]
-#    if {$index >= 0} {
-#        incr index $offset
-#        if {$index >= [llength $_values]} {
-#            set index [expr {[llength $_values]-1}]
-#        } elseif {$index < 0} {
-#            set index 0
-#        }
-#
-#        set newval [lindex $_values $index]
-#        if {$newval != $_current} {
-#            current $newval
-#            _redraw
-#
-#            event generate $itk_component(hull) <<Value>>
-#        }
-#    }
-#}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_navigate {offset} {
-    _current [ms2rel [expr $_current + $offset]]
-    event generate $itk_component(hull) <<Value>>
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Used internally to compute the overall size of the widget based
-# on the -thickness and -length options.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_fixSize {} {
-    set h [winfo pixels $itk_component(hull) $itk_option(-thickness)]
-
-    if {"" != $_knob} {
-        set kh [image height $_knob]
-
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top -
-            s@bottom - sw@bottom - se@bottom {
-                if {$kh > $h} { set h $kh }
-            }
-            n@middle - nw@middle - ne@middle -
-            s@middle - sw@middle - se@middle {
-                set h [expr {int(ceil(0.5*$h + $kh))}]
-            }
-            n@bottom - nw@bottom - ne@bottom -
-            s@top - sw@top - se@top {
-                set h [expr {$h + $kh}]
-            }
-            e@middle - w@middle - center@middle {
-                set h [expr {(($h > $kh) ? $h : ($kh+1))}]
-            }
-            n@middle - ne@middle - nw@middle -
-            s@middle - se@middle - sw@middle {
-                set extra [expr {int(ceil($kh-0.5*$h))}]
-                if {$extra < 0} { set extra 0 }
-                set h [expr {$h+$extra}]
-            }
-        }
-    }
-    # FIXME: hack to get the reduce spacing in widget
-    incr h -1
-
-    set w [winfo pixels $itk_component(hull) $itk_option(-length)]
-
-    # if the -valuewidth is > 0, then make room for the value
-    if {$itk_option(-valuewidth) > 0} {
-        set charw [font measure $itk_option(-font) "n"]
-        set _vwidth [expr {$itk_option(-valuewidth)*$charw}]
-        set w [expr {$w+$_vwidth+4}]
-    } else {
-        set _vwidth 0
-    }
-
-    $itk_component(majordial) configure -width $w -height $h
-
-#    # resize the height of the minor canvas to include everything we know about
-#    set box [$itk_component(minordial) bbox "all"]
-#    if {![llength $box]} {
-#        set box [list 0 0 0 0]
-#    }
-#    foreach {cx0 cy0 cx1 cy1} $box break
-#    set h [expr $cy1-$cy0+1]
-#    $itk_component(minordial) configure -height $h
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-    _current [ms2rel $var]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixOffsets
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial::_fixOffsets {} {
-    if {0 == $itk_option(-offset)} {
-        return
-    }
-    set _offset_pos $itk_option(-offset)
-    set _offset_neg [expr -1*$_offset_pos]
-    bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate $_offset_neg]
-    bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate $_offset_pos]
-}
-
-itcl::body Rappture::Videodial::ms2rel { value } {
-    if { ${_max} > ${_min} } {
-        return [expr {1.0 * ($value - ${_min}) / (${_max} - ${_min})}]
-    }
-    return 0
-}
-
-itcl::body Rappture::Videodial::rel2ms { value } {
-    return [expr $value * (${_max} - ${_min}) + ${_min}]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -thickness
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::thickness {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -length
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::length {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -font
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::font {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuewidth
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::valuewidth {
-    if {![string is integer $itk_option(-valuewidth)]} {
-        error "bad value \"$itk_option(-valuewidth)\": should be integer"
-    }
-    _fixSize
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -foreground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::foreground {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialoutlinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::dialoutlinecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialfillcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::dialfillcolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialprogresscolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::dialprogresscolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -linecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::linecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -activelinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::activelinecolor {
-    set val $itk_option(-activelinecolor)
-    if {[catch {$val isa ::Rappture::Spectrum} valid] == 0 && $valid} {
-        set _spectrum $val
-        set _activecolor ""
-    } elseif {[catch {winfo rgb $itk_component(hull) $val}] == 0} {
-        set _spectrum ""
-        set _activecolor $val
-    } elseif {"" != $val} {
-        error "bad value \"$val\": should be Spectrum object or color"
-    }
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobimage
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::knobimage {
-    if {[regexp {^image[0-9]+$} $itk_option(-knobimage)]} {
-        set _knob $itk_option(-knobimage)
-    } elseif {"" != $itk_option(-knobimage)} {
-        set _knob [Rappture::icon $itk_option(-knobimage)]
-    } else {
-        set _knob ""
-    }
-    _fixSize
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobposition
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::knobposition {
-    if {![regexp {^([nsew]+|center)@(top|middle|bottom)$} $itk_option(-knobposition)]} {
-        error "bad value \"$itk_option(-knobposition)\": should be anchor@top|middle|bottom"
-    }
-    _fixSize
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -padding
-# This adds padding on left/right side of dial background.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::padding {
-    if {[catch {winfo pixels $itk_component(hull) $itk_option(-padding)}]} {
-        error "bad value \"$itk_option(-padding)\": should be size in pixels"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuepadding
-# This shifts min/max limits in by a fraction of the overall size.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::valuepadding {
-    if {![string is double $itk_option(-valuepadding)]
-          || $itk_option(-valuepadding) < 0} {
-        error "bad value \"$itk_option(-valuepadding)\": should be >= 0.0"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -offset
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::offset {
-    if {![string is double $itk_option(-offset)]} {
-        error "bad value \"$itk_option(-offset)\": should be >= 0.0"
-    }
-    _fixOffsets
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -min
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::min {
-    if {![string is integer $itk_option(-min)]} {
-        error "bad value \"$itk_option(-min)\": should be an integer"
-    }
-    if {$itk_option(-min) < 0} {
-        error "bad value \"$itk_option(-min)\": should be >= 0"
-    }
-    set _min $itk_option(-min)
-    _draw_minor_timeline
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -max
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::max {
-    if {![string is integer $itk_option(-max)]} {
-        error "bad value \"$itk_option(-max)\": should be an integer"
-    }
-    if {$itk_option(-max) < 0} {
-        error "bad value \"$itk_option(-max)\": should be >= 0"
-    }
-    set _max $itk_option(-max)
-    _draw_minor_timeline
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -minortick
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::minortick {
-    if {![string is integer $itk_option(-minortick)]} {
-        error "bad value \"$itk_option(-minortick)\": should be an integer"
-    }
-    if {$itk_option(-minortick) <= 0} {
-        error "bad value \"$itk_option(-minortick)\": should be > 0"
-    }
-    set _minortick $itk_option(-minortick)
-    _draw_minor_timeline
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -majortick
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial::majortick {
-    if {![string is integer $itk_option(-majortick)]} {
-        error "bad value \"$itk_option(-majortick)\": should be an integer"
-    }
-    if {$itk_option(-majortick) <= 0} {
-        error "bad value \"$itk_option(-majortick)\": should be > 0"
-    }
-    set _majortick $itk_option(-majortick)
-    _draw_minor_timeline
-}
Index: trunk/gui/scripts/videodial1.tcl
===================================================================
--- trunk/gui/scripts/videodial1.tcl	(revision 6716)
+++ 	(revision )
@@ -1,663 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Videodial1 - selector, like the dial on a flow
-#
-#  This widget looks like the dial on an old-fashioned car flow.
-#  It draws a series of values along an axis, and allows a selector
-#  to move back and forth to select the values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Videodial1.dialProgressColor #6666cc widgetDefault
-option add *Videodial1.thickness 10 widgetDefault
-option add *Videodial1.length 2i widgetDefault
-option add *Videodial1.knobImage knob widgetDefault
-option add *Videodial1.knobPosition n@middle widgetDefault
-option add *Videodial1.dialOutlineColor black widgetDefault
-option add *Videodial1.dialFillColor white widgetDefault
-option add *Videodial1.lineColor gray widgetDefault
-option add *Videodial1.activeLineColor black widgetDefault
-option add *Videodial1.padding 0 widgetDefault
-option add *Videodial1.valueWidth 10 widgetDefault
-option add *Videodial1.valuePadding 0.1 widgetDefault
-option add *Videodial1.foreground black widgetDefault
-option add *Videodial1.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Videodial1 {
-    inherit itk::Widget
-
-    itk_option define -min min Min 0
-    itk_option define -max max Max 1
-    itk_option define -variable variable Variable ""
-    itk_option define -offset offset Offset 1
-
-    itk_option define -thickness thickness Thickness 0
-    itk_option define -length length Length 0
-    itk_option define -padding padding Padding 0
-
-    itk_option define -foreground foreground Foreground "black"
-    itk_option define -dialoutlinecolor dialOutlineColor Color "black"
-    itk_option define -dialfillcolor dialFillColor Color "white"
-    itk_option define -dialprogresscolor dialProgressColor Color ""
-    itk_option define -linecolor lineColor Color "black"
-    itk_option define -activelinecolor activeLineColor Color "black"
-    itk_option define -knobimage knobImage KnobImage ""
-    itk_option define -knobposition knobPosition KnobPosition ""
-
-    itk_option define -font font Font ""
-    itk_option define -valuewidth valueWidth ValueWidth 0
-    itk_option define -valuepadding valuePadding ValuePadding 0
-
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method current {value}
-    public method clear {}
-
-    protected method _redraw {}
-    protected method _knob {x y}
-    protected method _navigate {offset}
-    protected method _fixSize {}
-    protected method _fixValue {args}
-    protected method _fixOffsets {}
-
-    private method _current {value}
-    private method _draw_major_timeline {}
-    private method ms2rel {value}
-    private method rel2ms {value}
-    private common _click             ;# x,y point where user clicked
-    private variable _values ""       ;# list of all values on the dial
-    private variable _val2label       ;# maps value => string label(s)
-    private variable _current 0       ;# current value (where pointer is)
-    private variable _variable ""     ;# variable associated with -variable
-    private variable _knob ""         ;# image for knob
-    private variable _spectrum ""     ;# width allocated for values
-    private variable _activecolor ""  ;# width allocated for values
-    private variable _vwidth 0        ;# width allocated for values
-    private variable _offset_pos 1    ;#
-    private variable _offset_neg -1   ;#
-    private variable _imspace 10      ;# pixels between intermediate marks
-    private variable _pmcnt 0         ;# particle marker count
-    private variable _min 0
-    private variable _max 1
-}
-
-itk::usual Videodial1 {
-    keep -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::constructor {args} {
-
-    # bind $itk_component(hull) <<Frame>> [itcl::code $this _updateCurrent]
-
-    # ----------------------------------------------------------------------
-    # controls for the major timeline.
-    # ----------------------------------------------------------------------
-    itk_component add majordial {
-        canvas $itk_interior.majordial
-    }
-
-    bind $itk_component(majordial) <Configure> [itcl::code $this _draw_major_timeline]
-
-    bind $itk_component(majordial) <ButtonPress-1> [itcl::code $this _knob %x %y]
-    bind $itk_component(majordial) <B1-Motion> [itcl::code $this _knob %x %y]
-    bind $itk_component(majordial) <ButtonRelease-1> [itcl::code $this _knob %x %y]
-
-    #bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate $_offset_neg]
-    #bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate $_offset_pos]
-
-    $itk_component(majordial) bind  "knob" <Enter> \
-        [list $itk_component(majordial) configure -cursor sb_h_double_arrow]
-    $itk_component(majordial) bind  "knob" <Leave> \
-        [list $itk_component(majordial) configure -cursor ""]
-
-    # ----------------------------------------------------------------------
-    # place controls in widget.
-    # ----------------------------------------------------------------------
-
-    blt::table $itk_interior \
-        0,0 $itk_component(majordial) -fill x
-
-    blt::table configure $itk_interior c* -resize both
-    blt::table configure $itk_interior r0 -resize none
-
-
-    eval itk_initialize $args
-
-    $itk_component(majordial) configure -background green
-
-    _fixSize
-    _fixOffsets
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::destructor {} {
-    configure -variable ""  ;# remove variable trace
-    after cancel [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current ?<value>?
-#
-# Clients use this to set a new value for the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::current {value} {
-    if {"" == $value} {
-        return
-    }
-    _current [ms2rel $value]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _current ?<value>?
-#
-# Clients use this to set a new value for the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::_current {relval} {
-    if { $relval < 0.0 } {
-        set relval 0.0
-    }
-    if { $relval > 1.0 } {
-        set relval 1.0
-    }
-    set _current $relval
-
-    after cancel [itcl::code $this _draw_major_timeline]
-    after idle [itcl::code $this _draw_major_timeline]
-
-    set framenum [expr round([rel2ms $_current])]
-
-    # update the upvar variable
-    if { $_variable != "" } {
-        upvar #0 $_variable var
-        set var $framenum
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _draw_major_timeline
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::_draw_major_timeline {} {
-    set c $itk_component(majordial)
-    $c delete all
-
-    set fg $itk_option(-foreground)
-
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set p [winfo pixels $c $itk_option(-padding)]
-    set t [expr {$itk_option(-thickness)+1}]
-    # FIXME: hack to get the reduce spacing in widget
-    set y1 [expr {$h-2}]
-
-    if {"" != $_knob} {
-        set kw [image width $_knob]
-        set kh [image height $_knob]
-
-        # anchor refers to where on knob
-        # top/middle/bottom refers to where on the dial
-        # leave room for the bottom of the knob if needed
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top {
-                set extra [expr {$t-$kh}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$y1-$extra}]
-            }
-            n@middle - nw@middle - ne@middle {
-                set extra [expr {int(ceil($kh-0.5*$t))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$y1-$extra}]
-            }
-            n@bottom - nw@bottom - ne@bottom {
-               set y1 [expr {$y1-$kh}]
-            }
-
-            e@top - w@top - center@top -
-            e@bottom - w@bottom - center@bottom {
-                set extra [expr {int(ceil(0.5*$kh))}]
-                set y1 [expr {$y1-$extra}]
-            }
-            e@middle - w@middle - center@middle {
-                set extra [expr {int(ceil(0.5*($kh-$t)))}]
-                if {$extra < 0} {set extra 0}
-                set y1 [expr {$y1-$extra}]
-            }
-
-            s@top - sw@top - se@top -
-            s@middle - sw@middle - se@middle -
-            s@bottom - sw@bottom - se@bottom {
-                set y1 [expr {$y1-1}]
-            }
-        }
-    }
-    set y0 [expr {$y1-$t}]
-    set x0 [expr {$p+1}]
-    set x1 [expr {$w-$_vwidth-$p-4}]
-
-    # draw the background rectangle for the major time line
-    $c create rectangle $x0 $y0 $x1 $y1 \
-        -outline $itk_option(-dialoutlinecolor) \
-        -fill $itk_option(-dialfillcolor) \
-        -tags "majorbg"
-
-    # draw the optional progress bar for the major time line,
-    # from start to current
-    if {"" != $itk_option(-dialprogresscolor) } {
-        set xx1 [expr {$_current*($x1-$x0) + $x0}]
-        $c create rectangle [expr {$x0+1}] [expr {$y0+3}] $xx1 [expr {$y1-2}] \
-            -outline "" -fill $itk_option(-dialprogresscolor)
-    }
-
-    regexp {([nsew]+|center)@} $itk_option(-knobposition) match anchor
-    switch -glob -- $itk_option(-knobposition) {
-        *@top    { set kpos $y0 }
-        *@middle { set kpos [expr {int(ceil(0.5*($y1+$y0)))}] }
-        *@bottom { set kpos $y1 }
-    }
-
-    set x [expr {$_current*($x1-$x0) + $x0}]
-
-    set color $_activecolor
-    set thick 3
-    if {"" != $color} {
-        $c create line $x [expr {$y0+1}] $x $y1 -fill $color -width $thick
-    }
-
-    $c create image $x $kpos -anchor $anchor -image $_knob -tags "knob"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#
-# Called automatically whenever the widget changes size to redraw
-# all elements within it.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::_redraw {} {
-    _draw_major_timeline
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _knob <x> <y>
-#
-# Called automatically whenever the user clicks or drags on the widget
-# to select a value.  Moves the current value to the one nearest the
-# click point.  If the value actually changes, it generates a <<Value>>
-# event to notify clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::_knob {x y} {
-    set c $itk_component(majordial)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set x0 1
-    set x1 [expr {$w-$_vwidth-4}]
-    focus $itk_component(hull)
-    if {$x >= $x0 && $x <= $x1} {
-        current [rel2ms [expr double($x - $x0) / double($x1 - $x0)]]
-    }
-    event generate $itk_component(hull) <<Value>>
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-#itcl::body Rappture::Videodial1::_navigate {offset} {
-#    set index [lsearch -exact $_values $_current]
-#    if {$index >= 0} {
-#        incr index $offset
-#        if {$index >= [llength $_values]} {
-#            set index [expr {[llength $_values]-1}]
-#        } elseif {$index < 0} {
-#            set index 0
-#        }
-#
-#        set newval [lindex $_values $index]
-#        if {$newval != $_current} {
-#            current $newval
-#            _redraw
-#
-#            event generate $itk_component(hull) <<Value>>
-#        }
-#    }
-#}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::_navigate {offset} {
-    _current [ms2rel [expr [rel2ms ${_current}] + $offset]]
-    event generate $itk_component(hull) <<Value>>
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Used internally to compute the overall size of the widget based
-# on the -thickness and -length options.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::_fixSize {} {
-    set h [winfo pixels $itk_component(hull) $itk_option(-thickness)]
-
-    if {"" != $_knob} {
-        set kh [image height $_knob]
-
-        switch -- $itk_option(-knobposition) {
-            n@top - nw@top - ne@top -
-            s@bottom - sw@bottom - se@bottom {
-                if {$kh > $h} { set h $kh }
-            }
-            n@middle - nw@middle - ne@middle -
-            s@middle - sw@middle - se@middle {
-                set h [expr {int(ceil(0.5*$h + $kh))}]
-            }
-            n@bottom - nw@bottom - ne@bottom -
-            s@top - sw@top - se@top {
-                set h [expr {$h + $kh}]
-            }
-            e@middle - w@middle - center@middle {
-                set h [expr {(($h > $kh) ? $h : ($kh+1))}]
-            }
-            n@middle - ne@middle - nw@middle -
-            s@middle - se@middle - sw@middle {
-                set extra [expr {int(ceil($kh-0.5*$h))}]
-                if {$extra < 0} { set extra 0 }
-                set h [expr {$h+$extra}]
-            }
-        }
-    }
-    # FIXME: hack to get the reduce spacing in widget
-    incr h -1
-
-    set w [winfo pixels $itk_component(hull) $itk_option(-length)]
-
-    # if the -valuewidth is > 0, then make room for the value
-    if {$itk_option(-valuewidth) > 0} {
-        set charw [font measure $itk_option(-font) "n"]
-        set _vwidth [expr {$itk_option(-valuewidth)*$charw}]
-        set w [expr {$w+$_vwidth+4}]
-    } else {
-        set _vwidth 0
-    }
-
-    $itk_component(majordial) configure -width $w -height $h
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-    _current [ms2rel $var]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixOffsets
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::_fixOffsets {} {
-    if {0 == $itk_option(-offset)} {
-        return
-    }
-    set _offset_pos $itk_option(-offset)
-    set _offset_neg [expr -1*$_offset_pos]
-    bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate $_offset_neg]
-    bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate $_offset_pos]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ms2rel
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::ms2rel { value } {
-    if { ${_max} > ${_min} } {
-        return [expr {1.0 * ($value - ${_min}) / (${_max} - ${_min})}]
-    }
-    return 0
-}
-
-# ----------------------------------------------------------------------
-# USAGE: rel2ms
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial1::rel2ms { value } {
-    return [expr $value * (${_max} - ${_min}) + ${_min}]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -thickness
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::thickness {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -length
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::length {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -font
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::font {
-    _fixSize
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuewidth
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::valuewidth {
-    if {![string is integer $itk_option(-valuewidth)]} {
-        error "bad value \"$itk_option(-valuewidth)\": should be integer"
-    }
-    _fixSize
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -foreground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::foreground {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialoutlinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::dialoutlinecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialfillcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::dialfillcolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialprogresscolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::dialprogresscolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -linecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::linecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -activelinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::activelinecolor {
-    set val $itk_option(-activelinecolor)
-    if {[catch {$val isa ::Rappture::Spectrum} valid] == 0 && $valid} {
-        set _spectrum $val
-        set _activecolor ""
-    } elseif {[catch {winfo rgb $itk_component(hull) $val}] == 0} {
-        set _spectrum ""
-        set _activecolor $val
-    } elseif {"" != $val} {
-        error "bad value \"$val\": should be Spectrum object or color"
-    }
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobimage
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::knobimage {
-    if {[regexp {^image[0-9]+$} $itk_option(-knobimage)]} {
-        set _knob $itk_option(-knobimage)
-    } elseif {"" != $itk_option(-knobimage)} {
-        set _knob [Rappture::icon $itk_option(-knobimage)]
-    } else {
-        set _knob ""
-    }
-    _fixSize
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -knobposition
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::knobposition {
-    if {![regexp {^([nsew]+|center)@(top|middle|bottom)$} $itk_option(-knobposition)]} {
-        error "bad value \"$itk_option(-knobposition)\": should be anchor@top|middle|bottom"
-    }
-    _fixSize
-
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -padding
-# This adds padding on left/right side of dial background.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::padding {
-    if {[catch {winfo pixels $itk_component(hull) $itk_option(-padding)}]} {
-        error "bad value \"$itk_option(-padding)\": should be size in pixels"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -valuepadding
-# This shifts min/max limits in by a fraction of the overall size.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::valuepadding {
-    if {![string is double $itk_option(-valuepadding)]
-          || $itk_option(-valuepadding) < 0} {
-        error "bad value \"$itk_option(-valuepadding)\": should be >= 0.0"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -offset
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::offset {
-    if {![string is double $itk_option(-offset)]} {
-        error "bad value \"$itk_option(-offset)\": should be >= 0.0"
-    }
-    _fixOffsets
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -min
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::min {
-    if {![string is integer $itk_option(-min)]} {
-        error "bad value \"$itk_option(-min)\": should be an integer"
-    }
-    if {$itk_option(-min) < 0} {
-        error "bad value \"$itk_option(-min)\": should be >= 0"
-    }
-    set _min $itk_option(-min)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -max
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial1::max {
-    if {![string is integer $itk_option(-max)]} {
-        error "bad value \"$itk_option(-max)\": should be an integer"
-    }
-    if {$itk_option(-max) < 0} {
-        error "bad value \"$itk_option(-max)\": should be >= 0"
-    }
-    set _max $itk_option(-max)
-}
Index: trunk/gui/scripts/videodial2.tcl
===================================================================
--- trunk/gui/scripts/videodial2.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1343 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: Videodial2 - selector, like the dial on a flow
-#
-#  This widget looks like the dial on an old-fashioned car flow.
-#  It draws a series of values along an axis, and allows a selector
-#  to move back and forth to select the values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Videodial2.thickness 10 widgetDefault
-option add *Videodial2.padding 0 widgetDefault
-option add *Videodial2.foreground black widgetDefault
-option add *Videodial2.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::Videodial2 {
-    inherit itk::Widget
-
-    itk_option define -min min Min 0
-    itk_option define -max max Max 1
-    itk_option define -minortick minortick Minortick 1
-    itk_option define -majortick majortick Majortick 5
-    itk_option define -variable variable Variable ""
-    itk_option define -offset offset Offset 1
-
-    itk_option define -thickness thickness Thickness 0
-    itk_option define -padding padding Padding 0
-
-    itk_option define -dialoutlinecolor dialOutlineColor Color "black"
-    itk_option define -dialfillcolor dialFillColor Color "white"
-    itk_option define -foreground foreground Foreground "black"
-
-    itk_option define -font font Font ""
-
-
-    constructor {args} { # defined below }
-    destructor { # defined below }
-
-    public method current {value}
-    public method clear {}
-    public method mark {args}
-    public method bball {}
-    public method loop {action args}
-
-    protected method _bindings {type args}
-    protected method _redraw {args}
-    protected method _marker {tag action x y}
-    protected method _setmark {type args}
-    protected method _move {action x y}
-    protected method _navigate {offset}
-    protected method _fixSize {}
-    protected method _fixValue {args}
-    protected method _fixOffsets {}
-
-    private method _calculateDialDimensions {}
-    private method _calculateDisplayRange {args}
-    private method _drawDial {disp_min disp_max}
-    private method _getFramenumFromId {id}
-    private method _nearestFrameMarker {x y}
-    private method _current {value}
-    private method _see {item}
-    private method _offsetx {x}
-    private method ms2rel {value}
-    private method rel2ms {value}
-    private method _goToFrame {framenum}
-
-    private common _click             ;# x,y point where user clicked
-    private common _marks             ;# list of marks
-    private common _dd                ;# holds the dimensions of the dial
-    private variable _values ""       ;# list of all values on the dial
-    private variable _val2label       ;# maps value => string label(s)
-    private variable _current 0       ;# current value (where pointer is)
-    private variable _variable ""     ;# variable associated with -variable
-    private variable _offset_pos 1    ;#
-    private variable _offset_neg -1   ;#
-    private variable _imspace 10      ;# pixels between intermediate marks
-    private variable _min 0
-    private variable _max 1
-    private variable _minortick 1
-    private variable _majortick 5
-    private variable _lockdial ""
-    private variable _displayMin 0
-    private variable _displayMax 0
-}
-
-itk::usual Videodial2 {
-    keep -foreground -cursor -font
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::constructor {args} {
-
-    # bind $itk_component(hull) <<Frame>> [itcl::code $this _updateCurrent]
-
-    # ----------------------------------------------------------------------
-    # controls for the minor timeline.
-    # ----------------------------------------------------------------------
-    itk_component add minordial {
-        canvas $itk_interior.minordial -background blue
-    }
-
-
-    bind $itk_component(minordial) <Configure> [itcl::code $this _redraw]
-
-    _bindings timeline
-
-    # ----------------------------------------------------------------------
-    # place controls in widget.
-    # ----------------------------------------------------------------------
-
-    blt::table $itk_interior \
-        0,0 $itk_component(minordial) -fill x
-
-    blt::table configure $itk_interior c* -resize both
-    blt::table configure $itk_interior r0 -resize none
-
-
-    eval itk_initialize $args
-
-    $itk_component(minordial) configure -background cyan
-
-    _fixOffsets
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::destructor {} {
-    configure -variable ""  ;# remove variable trace
-    after cancel [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: current ?<value>?
-#
-# Clients use this to set a new value for the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::current {value} {
-    if {"" == $value} {
-        return
-    }
-
-    if {$value < ${_min}} {
-        set value ${_min}
-    }
-
-    if {$value > ${_max}} {
-        set value ${_max}
-    }
-
-    _current [ms2rel $value]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _current ?<value>?
-#
-# Clients use this to set a new value for the dial.  Values are always
-# sorted in order along the dial.  If the value is not specified,
-# then it is created automatically based on the number of elements
-# on the dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_current {relval} {
-
-    if {[string is double $relval] == 0} {
-        error "bad value \"$relval\": expected relval to be a double"
-    }
-    if {${_current} == $relval} {
-        # nothing to do
-        return
-    }
-
-    if { $relval < 0.0 } {
-        set relval 0.0
-    }
-    if { $relval > 1.0 } {
-        set relval 1.0
-    }
-
-    set _current $relval
-    set framenum [expr round([rel2ms $_current])]
-
-    set updated 0
-    if {[llength ${_lockdial}] != 0} {
-        # the dial is "locked" this means we don't center the dial
-        # on the current value. we only move the dial if the
-        # current value is less than or greater than the marks alredy
-        # shown on the dial.
-        if {[expr ${_displayMin}+${_majortick}] >= $framenum} {
-            set newdmin [expr $framenum-${_majortick}]
-            foreach {dmin dmax} [_calculateDisplayRange -min $newdmin] break
-            incr updated
-        } elseif {[expr ${_displayMax}-${_majortick}] <= $framenum} {
-            set newdmax [expr $framenum+${_majortick}]
-            foreach {dmin dmax} [_calculateDisplayRange -max $newdmax] break
-            incr updated
-        }
-    } else {
-        # center the current marker
-        foreach {dmin dmax} [_calculateDisplayRange] break
-        incr updated
-    }
-
-    if {$updated == 1} {
-        _drawDial $dmin $dmax
-    }
-
-    after idle [_setmark currentmark $framenum]
-
-    # update the upvar variable
-    if { $_variable != "" } {
-        upvar #0 $_variable var
-        set var $framenum
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _bindings <type> ?args?
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_bindings {type args} {
-    set c $itk_component(minordial)
-    switch -- $type {
-        "marker" {
-            set tag [lindex $args 0]
-            bind $c <ButtonPress-1> [itcl::code $this _marker $tag click %x %y]
-            bind $c <B1-Motion> [itcl::code $this _marker $tag drag %x %y]
-            bind $c <ButtonRelease-1> [itcl::code $this _marker $tag release %x %y]
-            $c configure -cursor sb_h_double_arrow
-        }
-        "timeline" {
-            # bind $c <ButtonPress-1> [itcl::code $this _move click %x %y]
-            # bind $c <B1-Motion> [itcl::code $this _move drag %x %y]
-            # bind $c <ButtonRelease-1> [itcl::code $this _move release %x %y]
-            bind $c <ButtonPress-1> { }
-            bind $c <B1-Motion> { }
-            bind $c <ButtonRelease-1> { }
-            $c configure -cursor ""
-        }
-        "toolmark" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be _bindings toolmark \[enter|leave\] <tag>"
-            }
-
-            foreach {mode tag} $args break
-
-            switch -- $mode {
-                "enter" {
-                    #$c create rectangle [$c bbox $tag] \
-                        -outline red \
-                        -tags "highlight"
-                    bind $c <ButtonPress-1> [itcl::code $this _goToFrame $_marks($tag)]
-                }
-                "leave" {
-                    #$c delete "highlight"
-                    _bindings timeline
-                }
-                default {
-                    error "bad argument \"$mode\": should be enter or leave"
-                }
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: mark <property> <args>
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::mark {property args} {
-    set retval 0
-
-    switch -- $property {
-        add {
-            set retval [eval _setmark $args]
-        }
-        remove {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"mark remove <type>\""
-            }
-            set type [lindex $args 0]
-            if {[info exists _marks($type)]} {
-                $itk_component(minordial) delete $type
-                array unset _marks $type
-            }
-        }
-        position {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"mark position <type>\""
-            }
-            set type [lindex $args 0]
-            if {[info exists _marks($type)]} {
-                return $_marks($type)
-            }
-            set retval [expr ${_min}-1]
-        }
-        default {
-            error "bad value \"$property\": should be one of add, remove, position"
-        }
-    }
-
-    return $retval
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _getFramenumFromId <id>
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_getFramenumFromId {id} {
-    set where 0
-
-    # find the frame# tag to associate with the marker with
-    if {[regexp {frame([0-9]+)} $id] == 0} {
-        foreach tags [$c gettags $id] {
-            if {"" != [set tmp [lsearch -inline -regexp $tags {frame[0-9]+}]]} {
-                set where $tmp
-                break
-            }
-        }
-    } else {
-        set where $id
-    }
-    # store the frame number in where
-    regexp {frame([0-9]+)} $where match where
-
-    # restrict <where> to valid frames between min and max
-    if {$where < ${_min}} {
-        set where ${_min}
-    }
-    if {$where > ${_max}} {
-        set where ${_max}
-    }
-
-    return $where
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _setmark <type> ?[-xcoord|-tag]? <where>
-#
-# Clients use this to add a mark to the timeline
-#   type can be any of loopstart, loopend, particle, measure, currentmark
-#   where is interpreted based on the preceeding flag if available.
-#       in the default case, <where> is interpreted as a frame number
-#       or "current". if the -xcoord flag is provided, where is
-#       interpreted as the x coordinate of where to center the marker.
-#       -xcoord should only be used for temporary placement of a
-#       marker. when -xcoord is used, the marker is placed exactly at
-#       the provided x coordinate, and is not associated with any
-#       frame. It's purpose is mainly for <B1-Motion> events.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_setmark {type args} {
-
-    set c $itk_component(minordial)
-
-    set cx0 0
-    set cy0 0
-    set cx1 0
-    set cy1 0
-    foreach {cx0 cy0 cx1 cy1} [$c bbox "imbox"] break
-
-    # get coords of where to place the marker
-    set frx0 0
-    set fry0 0
-    set frx1 0
-    set fry1 0
-
-    set where ""
-    set largs [llength $args]
-    if {$largs == 1} {
-        set where [lindex $args 0]
-        if {[string compare "current" $where] == 0} {
-            set where [expr round([rel2ms ${_current}])]
-        } elseif {[string is integer $where] == 0} {
-            error "bad value \"$where\": while trying to place marker \"$type\": <where> should be an integer value"
-        }
-
-        # restrict <where> to valid frames between min and max
-        if {$where < ${_min}} {
-            set where ${_min}
-        }
-        if {$where > ${_max}} {
-            set where ${_max}
-        }
-
-        set coords [$c coords "frame$where"]
-        if {![llength $coords]} {
-            # frame marker does not exist
-            # estimate where to put the marker
-            # use frame0 marker as a x=0 point
-            foreach {frx0 fry0 frx1 fry1} [$c coords "frame0"] break
-            set frx0 [expr {$frx0 + ((1.0*$where/${_minortick})*${_imspace})}]
-        } else {
-            foreach {frx0 fry0 frx1 fry1} $coords break
-        }
-        # where already contains the frame number
-    } elseif {$largs == 2} {
-        set flag [lindex $args 0]
-        switch -- $flag {
-            "-xcoord" {
-                set frx0 [lindex $args 1]
-                # where is not set for the -xcoord flag
-            }
-            "-tag" {
-                set id [lindex $args 1]
-                set where [_getFramenumFromId $id]
-                foreach {frx0 fry0 frx1 fry1} [$c coords frame$where] break
-            }
-            default {
-                error "bad value \"$flag\": should be -xcoord or -tag"
-            }
-        }
-        if {[string is double $frx0] == 0} {
-            error "bad value \"$frx0\": <where> should be a double value"
-        }
-    } else {
-        error "wrong # args: should be \"mark <type> ?-xcoord? <where>\""
-    }
-
-    # add/remove the marker
-
-    switch -glob -- $type {
-        "loopstart" {
-            # add start marker
-
-            if {($where >= ${_displayMin}) && ($where < ${_displayMax})} {
-                set smx0 $frx0                              ;# loopstart marker x0
-                set smy0 $cy0                               ;# loopstart marker y0
-
-                # polygon's outline adds a border to only one
-                # side of the object? so we have weird +1 in
-                # the triangle base in loopstart marker
-
-                # marker stem is 3 pixels thick
-                set smx1 [expr {$smx0+1}]                   ;# triangle top x
-                set smy1 [expr {$smy0-10}]                  ;# triangle top y
-                set smx2 $smx1                              ;# stem bottom right x
-                set smy2 $cy1                               ;# stem bottom right y
-                set smx3 [expr {$smx0-1}]                   ;# stem bottom left x
-                set smy3 $smy2                              ;# stem bottom left y
-                set smx4 $smx3                              ;# stem middle left x
-                set smy4 $smy0                              ;# stem middle left y
-                set smx5 [expr {$smx0-10+1}]                ;# triangle bottom left x
-                set smy5 $smy0                              ;# triangle bottom left y
-
-                set tag $type
-                $c delete $tag
-                $c create polygon \
-                    $smx1 $smy1 \
-                    $smx2 $smy2 \
-                    $smx3 $smy3 \
-                    $smx4 $smy4 \
-                    $smx5 $smy5 \
-                    -outline black -fill black -tags [list $tag dialval]
-
-                $c bind $tag <Enter> [itcl::code $this _bindings marker $tag]
-                $c bind $tag <Leave> [itcl::code $this _bindings timeline]
-            }
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-
-                # make sure loopstart marker is before loopend marker
-                if {[info exists _marks(loopend)]} {
-                    set endFrNum $_marks(loopend)
-                    if {$endFrNum < $where} {
-                        _setmark loopend -tag frame[expr $where+1]
-                    }
-                }
-            }
-
-        }
-        "loopend" {
-            # add loopend marker
-
-            if {($where >= ${_displayMin}) && ($where < ${_displayMax})} {
-                set emx0 $frx0                              ;# loopend marker x0
-                set emy0 $cy0                               ;# loopend marker y0
-
-                set emx1 [expr {$emx0-1}]                   ;# triangle top x
-                set emy1 [expr {$emy0-10}]                  ;# triangle top y
-                set emx2 $emx1                              ;# stem bottom left x
-                set emy2 $cy1                               ;# stem bottom left y
-                set emx3 [expr {$emx0+1}]                   ;# stem bottom right x
-                set emy3 $emy2                              ;# stem bottom right y
-                set emx4 $emx3                              ;# stem middle right x
-                set emy4 $emy0                              ;# stem middle right  y
-                set emx5 [expr {$emx0+10-1}]                ;# triangle bottom right x
-                set emy5 $emy0                              ;# triangle bottom right y
-
-                set tag $type
-                $c delete $tag
-                $c create polygon \
-                    $emx1 $emy1 \
-                    $emx2 $emy2 \
-                    $emx3 $emy3 \
-                    $emx4 $emy4 \
-                    $emx5 $emy5 \
-                    -outline black -fill black -tags [list $tag dialval]
-
-                $c bind $tag <Enter> [itcl::code $this _bindings marker $tag]
-                $c bind $tag <Leave> [itcl::code $this _bindings timeline]
-            }
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-
-                # make sure loopend marker is after loopstart marker
-                if {[info exists _marks(loopstart)]} {
-                    set startFrNum $_marks(loopstart)
-                    if {$startFrNum > $where} {
-                        _setmark loopstart -tag frame[expr $where-1]
-                    }
-                }
-            }
-        }
-        "particle*" {
-            if {($where >= ${_displayMin}) && ($where < ${_displayMax})} {
-                set radius 3
-                set pmx0 $frx0
-                set pmy0 [expr {$cy1+5}]
-                set coords [list [expr $pmx0-$radius] [expr $pmy0-$radius] \
-                                 [expr $pmx0+$radius] [expr $pmy0+$radius]]
-
-                set tag $type
-                $c delete $tag
-                $c create oval $coords \
-                    -fill green \
-                    -outline black \
-                    -width 1 \
-                    -tags [list $tag dialval]
-
-                $c bind $tag <Enter> [itcl::code $this _bindings toolmark enter $tag]
-                $c bind $tag <Leave> [itcl::code $this _bindings toolmark leave $tag]
-            }
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-            }
-        }
-        "measure*" {
-            if {($where >= ${_displayMin}) && ($where < ${_displayMax})} {
-                set radius 3
-                set amx0 $frx0
-                set amy0 [expr {$cy1+15}]
-                set coords [list [expr $amx0-$radius] [expr $amy0-$radius] \
-                                 [expr $amx0+$radius] [expr $amy0+$radius]]
-
-                set tag $type
-                $c delete $tag
-                $c create line $coords \
-                    -fill red \
-                    -width 3  \
-                    -tags [list $tag dialval]
-
-                $c bind $tag <Enter> [itcl::code $this _bindings toolmark enter $tag]
-                $c bind $tag <Leave> [itcl::code $this _bindings toolmark leave $tag]
-            }
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-            }
-        }
-        "currentmark" {
-
-            if {($where >= ${_displayMin}) && ($where < ${_displayMax})} {
-                set cmx0 $frx0                              ;# current marker x0
-                set cmy0 $cy0                               ;# current marker y0
-
-                set cmx1 [expr {$cmx0+5}]                   ;# lower right diagonal edge x
-                set cmy1 [expr {$cmy0-5}]                   ;# lower right diagonal edge y
-                set cmx2 $cmx1                              ;# right top x
-                set cmy2 [expr {$cmy1-5}]                   ;# right top y
-                set cmx3 [expr {$cmx0-5}]                   ;# left top x
-                set cmy3 $cmy2                              ;# left top y
-                set cmx4 $cmx3                              ;# lower left diagonal edge x
-                set cmy4 $cmy1                              ;# lower left diagonal edge y
-
-                set tag $type
-                $c delete $tag
-                $c create polygon \
-                    $cmx0 $cmy0 \
-                    $cmx1 $cmy1 \
-                    $cmx2 $cmy2 \
-                    $cmx3 $cmy3 \
-                    $cmx4 $cmy4 \
-                    -outline black \
-                    -fill red \
-                    -tags [list $tag dialval]
-                $c create line $cmx0 $cmy0 $cmx0 $cy1 \
-                    -fill red \
-                    -tags [list $tag dialval]
-
-                $c bind $tag <Enter> [itcl::code $this _bindings marker $tag]
-                $c bind $tag <Leave> [itcl::code $this _bindings timeline]
-            }
-
-            if {[string compare "" $where] != 0} {
-                set _marks($type) $where
-            }
-        }
-        default {
-            error "bad value \"$type\": should be \"loopstart\" or \"loopend\""
-        }
-    }
-    return
-}
-
-# ----------------------------------------------------------------------
-# USAGE: bball
-#   debug function to print out the bounding box information for
-#   minor dial
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::bball {} {
-    set c $itk_component(minordial)
-    foreach item [$c find all] {
-        foreach {x0 y0 x1 y1} [$c bbox $item] break
-        if {! [info exists y1]} continue
-        puts stderr "$item : [expr $y1-$y0]: $y0 $y1"
-        lappend q $y0 $y1
-    }
-    set q [lsort -real $q]
-    puts stderr "q [lindex $q 0] [lindex $q end]"
-    puts stderr "height [winfo height $c]"
-    puts stderr "bbox all [$c bbox all]"
-    puts stderr "parent height [winfo height [winfo parent $c]]"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: loop
-#   loop between <start> <end> - setup looping between frames <start> and <end>
-#   loop disable - disable looping
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::loop {action args} {
-    switch -- $action {
-        "between" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be loop between <start> <end>"
-            }
-            foreach {startframe endframe} $args break
-            mark add loopstart $startframe
-            mark add loopend $endframe
-            lappend _lockdial "loop"
-        }
-        "disable" {
-            if {[llength $args] != 0} {
-                error "wrong # args: should be loop disable"
-            }
-            mark remove loopstart
-            mark remove loopend
-            set idx [lsearch -exact ${_lockdial} "loop"]
-            set _lockdial [lreplace ${_lockdial} $idx $idx]
-        }
-        default {
-            error "bad value \"$action\": should be \"between\" or \"disable\""
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _calculateDisplayRange
-#   calculate the minimum and maximum values to display on the dial
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_calculateDisplayRange {args} {
-
-    Rappture::getopts args params {
-        value -min 0
-        value -max 0
-    }
-
-    set disp_min $params(-min)
-    set disp_max $params(-max)
-
-    if {($disp_min == 0) && ($disp_max == 0)} {
-        # calculate the display min and max by
-        # centering the current value on the dial
-        set framenum [expr round([rel2ms ${_current}])]
-        set disp_min [expr ($framenum-$_dd(ni))]
-        set disp_max [expr ($framenum+$_dd(ni))]
-    } elseif {($disp_min != 0) && ($disp_max == 0)} {
-        # user supplied disp_min value
-        # calculate disp_max
-        set disp_max [expr round($disp_min+($_dd(ni)*2.0))]
-    } elseif {($disp_min == 0) && ($disp_max != 0)} {
-        # user supplied disp_max value
-        # calculate disp_min
-        set disp_min [expr round($disp_max-($_dd(ni)*2.0))]
-    }
-
-    # deal with edge cases
-
-    if {($disp_min < ${_min})} {
-        # don't display marks less than ${_min}
-        set disp_min ${_min}
-        set disp_max [expr round(${_min}+($_dd(ni)*2.0))]
-        if {$disp_max > ${_max}} {
-            set disp_max ${_max}
-        }
-    }
-
-    if {($disp_max > ${_max})} {
-        # don't display marks greater than ${_max}
-        set disp_min [expr round(${_max}-($_dd(ni)*2.0))]
-        if {$disp_min < ${_min}} {
-            set disp_min ${_min}
-        }
-        set disp_max ${_max}
-    }
-
-    return [list $disp_min $disp_max]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _calculateDialDimensions
-#   calculate dimensions used to draw the dial
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_calculateDialDimensions {} {
-    set c $itk_component(minordial)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set p [winfo pixels $c $itk_option(-padding)]
-    set t [expr {$itk_option(-thickness)+1}]
-    set y1 [expr {$h-1}]
-    set y0 [expr {$y1-$t}]
-    set x0 [expr {$p+1}]
-    set x1 [expr {$w-$p-4}]
-
-
-    # add intermediate marks between markers
-    set imw 1.0                                 ;# intermediate mark width
-
-    set imsh [expr {$t/3.0}]                    ;# intermediate mark short height
-    set imsy0 [expr {$y0+(($t-$imsh)/2.0)}]     ;# precalc'd imark short y0 coord
-    set imsy1 [expr {$imsy0+$imsh}]             ;# precalc'd imark short y1 coord
-
-    set imlh [expr {$t*2.0/3.0}]                ;# intermediate mark long height
-    set imly0 [expr {$y0+(($t-$imlh)/2.0)}]     ;# precalc'd imark long y0 coord
-    set imly1 [expr {$imly0+$imlh}]             ;# precalc'd imark long y1 coord
-
-    set imty [expr {$y0-5}]                     ;# height of marker value
-
-    set x [expr ($x1-$x0)/2.0]
-    set ni [expr int(($x-$x0)/${_imspace})]
-
-    set _dd(x0) $x0
-    set _dd(y0) $y0
-    set _dd(x1) $x1
-    set _dd(y1) $y1
-    set _dd(ni) $ni
-    set _dd(imly0) $imly0
-    set _dd(imly1) $imly1
-    set _dd(imw) $imw
-    set _dd(imty) $imty
-    set _dd(imsy0) $imsy0
-    set _dd(imsy1) $imsy1
-
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _redraw
-#   calculate dimensions, display range, and draw the dial, again
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_redraw {args} {
-
-    _calculateDialDimensions
-
-    foreach {disp_min disp_max} [_calculateDisplayRange] break
-
-    set c $itk_component(minordial)
-    $c delete all
-
-    # draw the background rectangle for the minor time line
-    $c create rectangle $_dd(x0) $_dd(y0) $_dd(x1) $_dd(y1) \
-        -outline $itk_option(-dialoutlinecolor) \
-        -fill $itk_option(-dialfillcolor) \
-        -tags "imbox"
-
-    _drawDial $disp_min $disp_max
-
-    # calculate the height of the intermediate tick marks
-    # and frame numbers on our canvas, resize the imbox
-    # to include both of them.
-    set box [$c bbox "all"]
-    if {![llength $box]} {
-        set box [list 0 0 0 0]
-    }
-    $c coords "imbox" $box
-
-    # add an invisible box 20 pixels above and below imbox
-    # to keep the canvas from changing sizes when the we add
-    # particle, loopstart, loopend, and line markers
-    foreach {x0 y0 x1 y1} $box break
-    $c create rectangle $x0 [expr $y0-20] $x1 [expr $y1+20] \
-        -outline "" \
-        -fill "" \
-        -tags "markerbox"
-
-    # re-add any marks that the user previously specified
-    # do it again because we changed the size of imbox
-    foreach n [array names _marks] {
-        if {($_marks($n) > ${_displayMin}) && ($_marks($n) < ${_displayMax})} {
-            _setmark $n $_marks($n)
-        }
-    }
-
-    _fixSize
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _drawDial
-#   draw the dial
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_drawDial {dmin dmax} {
-    set c $itk_component(minordial)
-    $c delete dialval
-
-    set _displayMin [expr int($dmin)]
-    set _displayMax [expr int($dmax)]
-
-    set imx [expr $_dd(x0)+5]
-    for {set i ${_displayMin}} {$i <= ${_displayMax}} {incr i} {
-        if {($i%${_majortick}) == 0} {
-            # draw major tick
-            $c create line $imx $_dd(imly0) $imx $_dd(imly1) \
-                -fill red \
-                -width $_dd(imw) \
-                -tags [list dialval longmark imark "frame$i"]
-
-            $c create text $imx $_dd(imty) \
-                -anchor center \
-                -text $i \
-                -font $itk_option(-font) \
-                -tags [list dialval frame$i frame$i-text]
-
-            set imx [expr $imx+${_imspace}]
-        } elseif {($i%${_minortick}) == 0 } {
-            # draw minor tick
-            $c create line $imx $_dd(imsy0) $imx $_dd(imsy1) \
-                -fill blue \
-                -width $_dd(imw) \
-                -tags [list dialval shortmark imark "frame$i"]
-
-            set imx [expr $imx+${_imspace}]
-        }
-    }
-
-    if {(${_displayMin}%${_majortick}) == 0} {
-        # first tick is numbered, delete the text if
-        # it shows up outside of our desired imbox
-        foreach {dmx0 dmy0 dmx1 dmy1} [$c bbox frame${_displayMin}-text] break
-        # need to check for if dmx0 exists because there
-        # are some cases when the widget is first being
-        # created where _calculateDisplayRange gives
-        # back bad values, dmin > dmax.
-        if {[info exists dmx0] && ($dmx0 < $_dd(x0))} {
-            $c delete frame${_displayMin}-text
-        }
-    }
-    if {(${_displayMax}%${_majortick}) == 0} {
-        # last tick is numbered, delete the text if
-        # it shows up outside of our desired imbox
-        foreach {dmx0 dmy0 dmx1 dmy1} [$c bbox frame${_displayMax}-text] break
-        # need to check for if dmx1 exists because there
-        # are some cases when the widget is first being
-        # created where _calculateDisplayRange gives
-        # back bad values, dmin > dmax.
-        if {[info exists dmx1] && ($dmx1 > $_dd(x1))} {
-            $c delete frame${_displayMax}-text
-        }
-    }
-
-    # add any marks that the user previously specified
-    foreach n [array names _marks] {
-        if {($_marks($n) > ${_displayMin}) && ($_marks($n) < ${_displayMax})} {
-            _setmark $n $_marks($n)
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixSize
-#
-# Used internally to compute the height of the minor dial based
-# on the items placed on the canvas
-#
-# FIXME: instead of calling this in the mark command, figure out how to
-#   make the canvas the correct size to start with
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_fixSize {} {
-    # resize the height of the minor timeline canvas
-    # to include everything we know about
-
-    set c $itk_component(minordial)
-
-    set box [$c bbox "all"]
-    if {![llength $box]} {
-        set box [list 0 0 0 0]
-    }
-
-    foreach {x0 y0 x1 y1} $box break
-    set h [expr $y1-$y0]
-
-    $c configure -height $h -scrollregion $box -xscrollincrement 1p
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _goToFrame <framenum>
-#
-# lock the dial and go to frame <framenum>
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_goToFrame {framenum} {
-    lappend _lockdial "_goToFrame"
-    current $framenum
-    event generate $itk_component(hull) <<Value>>
-    set idx [lsearch -exact ${_lockdial} "_goToFrame"]
-    set _lockdial [lreplace ${_lockdial} $idx $idx]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _offsetx <x>
-#
-# Calculate an x coordinate that has been offsetted by a scrolled canvas
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_offsetx {x} {
-    set c $itk_component(minordial)
-    set w [lindex [$c cget -scrollregion] 2]
-    set x0 [lindex [$c xview] 0]
-    set offset [expr {$w*$x0}]
-    set x [expr {$x+$offset}]
-    return $x
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _nearestFrameMarker <x> <y>
-#
-# Called automatically whenever the user clicks or drags on a marker
-# widget.  Moves the selected marker to the next nearest tick mark.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_nearestFrameMarker {x y} {
-
-    set c $itk_component(minordial)
-
-    foreach {junk y0 junk y1} [$c bbox "imark"] break
-    set id ""
-    # FIXME:
-    # the amount added to _imspace should be 1
-    # but for some reason the dial is slightly shifted
-    # on the canvas by 2 or 3 pixels. so we have to
-    # add a larger value like 3 to _imspace to find
-    # the next frame marker
-    set x0 [expr {$x-round((${_imspace}+3)/2.0)}]
-    set x1 [expr {$x+round((${_imspace}+3)/2.0)}]
-
-    #$c delete scrap
-    #$c create rectangle $x0 $y0 $x1 $y1 \
-        -outline green -tags "scrap"
-
-    foreach item [$c find enclosed $x0 $y0 $x1 $y1] {
-        set itemtags [$c gettags $item]
-
-        foreach {x00 junk x11 junk} [$c bbox $item] break
-
-        if {[lsearch -exact $itemtags "imark"] != -1} {
-            set id [lsearch -inline -regexp $itemtags {frame[0-9]}]
-            break
-        }
-    }
-    if {[string compare "" $id] == 0} {
-        # something went wrong
-        # we should have found an imark with
-        # an associated "frame#" tag to snap to
-        # bailout
-        #error "could not find an intermediate mark to snap marker to"
-        puts stderr "could not find an intermediate mark to snap marker to"
-    }
-
-    return $id
-
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _marker <tag> click <x> <y>
-#        _marker <tag> drag <x> <y>
-#        _marker <tag> release <x> <y>
-#
-# Called automatically whenever the user clicks or drags on a marker
-# widget.  Moves the selected marker to the next nearest tick mark.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_marker {tag action x y} {
-    set c $itk_component(minordial)
-    switch $action {
-        "click" {
-            if {"currentmark" == $tag} {
-                focus $itk_component(hull)
-                lappend _lockdial "currentmark"
-            }
-        }
-        "drag" {
-            set x [_offsetx $x]
-
-            # as the marker passes over frame marks, snap to the closest frame mark
-            set id [_nearestFrameMarker $x $y]
-            if {"" == $id} {
-                return
-            }
-
-            if {"currentmark" == $tag} {
-                # update the current frame shown on the screen
-                # this doesn't quite work yet, i think because
-                # the seek requests are buffered until the gui
-                # is idle
-                set newfn [_getFramenumFromId $id]
-                set oldfn [expr round([rel2ms ${_current}])]
-                if {$newfn != $oldfn} {
-                    _goToFrame $newfn
-                }
-            } else {
-                _setmark $tag -tag $id
-            }
-        }
-        "release" {
-
-            _marker $tag drag $x $y
-
-            if {"currentmark" == $tag} {
-                set idx [lsearch -exact ${_lockdial} "currentmark"]
-                set _lockdial [lreplace ${_lockdial} $idx $idx]
-            }
-
-            # take care of cases where the mouse leaves the marker's boundries
-            # before the button-1 has been released. we check if the last
-            # coord was within the bounds of the marker. if not, we manually
-            # generate the "Leave" event.
-            set leave 1
-            set x [_offsetx $x]
-            foreach item [$c find overlapping $x $y $x $y] {
-                if {[lsearch -exact [$c gettags $item] $tag] != -1} {
-                    set leave 0
-                }
-            }
-            if {$leave == 1} {
-                # FIXME:
-                # i want to generate the event rather than
-                # calling the function myself...
-                # event generate $c <Leave>
-                _bindings timeline
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _move click <x> <y>
-#        _move drag <x> <y>
-#        _move release <x> <y>
-#
-# Scroll the timeline canvas based on user's b1 click, drag, and release
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_move {action x y} {
-    switch $action {
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            set c $itk_component(minordial)
-            set dist [expr $_click(x)-$x]
-            #$c xview scroll $dist "units"
-            set _click(x) $x
-            set _click(y) $y
-
-
-            #set disp_min
-            #set disp_max
-            #_redraw $disp_min $disp_max
-        }
-        "release" {
-            _move drag $x $y
-            catch {unset _click}
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _see <item>
-#
-# from http://tcl.sourceforge.net/faqs/tk/#canvas/see
-# "see" method alternative for canvas
-# Aligns the named item as best it can in the middle of the screen
-#
-# item - a canvas tagOrId
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_see {item} {
-    set c $itk_component(minordial)
-    set box [$c bbox $item]
-    if {![llength $box]} return
-    ## always properly set -scrollregion
-    foreach {x y x1 y1}     $box \
-            {top btm}       [$c yview] \
-            {left right}    [$c xview] \
-            {p q xmax ymax} [$c cget -scrollregion] {
-        set xpos [expr {(($x1+$x)/2.0)/$xmax - ($right-$left)/2.0}]
-        #set ypos [expr {(($y1+$y)/2.0)/$ymax - ($btm-$top)/2.0}]
-    }
-    $c xview moveto $xpos
-    #$c yview moveto $ypos
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-#itcl::body Rappture::Videodial2::_navigate {offset} {
-#    set index [lsearch -exact $_values $_current]
-#    if {$index >= 0} {
-#        incr index $offset
-#        if {$index >= [llength $_values]} {
-#            set index [expr {[llength $_values]-1}]
-#        } elseif {$index < 0} {
-#            set index 0
-#        }
-#
-#        set newval [lindex $_values $index]
-#        if {$newval != $_current} {
-#            current $newval
-#            _redraw
-#
-#            event generate $itk_component(hull) <<Value>>
-#        }
-#    }
-#}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _navigate <offset>
-#
-# Called automatically whenever the user presses left/right keys
-# to nudge the current value left or right by some <offset>.  If the
-# value actually changes, it generates a <<Value>> event to notify
-# clients.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_navigate {offset} {
-    _goToFrame [expr [rel2ms ${_current}] + $offset]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-    _current [ms2rel $var]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixOffsets
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::_fixOffsets {} {
-    if {0 == $itk_option(-offset)} {
-        return
-    }
-    set _offset_pos $itk_option(-offset)
-    set _offset_neg [expr -1*$_offset_pos]
-    bind $itk_component(hull) <KeyPress-Left> [itcl::code $this _navigate $_offset_neg]
-    bind $itk_component(hull) <KeyPress-Right> [itcl::code $this _navigate $_offset_pos]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ms2rel
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::ms2rel { value } {
-    if { ${_max} > ${_min} } {
-        return [expr {1.0 * ($value - ${_min}) / (${_max} - ${_min})}]
-    }
-    return 0
-}
-
-# ----------------------------------------------------------------------
-# USAGE: rel2ms
-#
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videodial2::rel2ms { value } {
-    return [expr $value * (${_max} - ${_min}) + ${_min}]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -thickness
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::thickness {
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -font
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::font {
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -foreground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::foreground {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialoutlinecolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::dialoutlinecolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -dialfillcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::dialfillcolor {
-    after cancel [itcl::code $this _redraw]
-    after idle [itcl::code $this _redraw]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -padding
-# This adds padding on left/right side of dial background.
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::padding {
-    if {[catch {winfo pixels $itk_component(hull) $itk_option(-padding)}]} {
-        error "bad value \"$itk_option(-padding)\": should be size in pixels"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -offset
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::offset {
-    if {![string is integer $itk_option(-offset)] &&
-        ($itk_option(-offset) < 0)} {
-        error "bad value \"$itk_option(-offset)\": should be >= 1"
-    }
-    _fixOffsets
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -min
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::min {
-    if {![string is integer $itk_option(-min)]} {
-        error "bad value \"$itk_option(-min)\": should be an integer"
-    }
-    if {$itk_option(-min) < 0} {
-        error "bad value \"$itk_option(-min)\": should be >= 0"
-    }
-    set _min $itk_option(-min)
-    _redraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -max
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::max {
-    if {![string is integer $itk_option(-max)]} {
-        error "bad value \"$itk_option(-max)\": should be an integer"
-    }
-    if {$itk_option(-max) < 0} {
-        error "bad value \"$itk_option(-max)\": should be >= 0"
-    }
-    set _max $itk_option(-max)
-    _redraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -minortick
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::minortick {
-    if {![string is integer $itk_option(-minortick)]} {
-        error "bad value \"$itk_option(-minortick)\": should be an integer"
-    }
-    if {$itk_option(-minortick) <= 0} {
-        error "bad value \"$itk_option(-minortick)\": should be > 0"
-    }
-    set _minortick $itk_option(-minortick)
-    _redraw
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -majortick
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::Videodial2::majortick {
-    if {![string is integer $itk_option(-majortick)]} {
-        error "bad value \"$itk_option(-majortick)\": should be an integer"
-    }
-    if {$itk_option(-majortick) <= 0} {
-        error "bad value \"$itk_option(-majortick)\": should be > 0"
-    }
-    set _majortick $itk_option(-majortick)
-    _redraw
-}
Index: trunk/gui/scripts/videodistance.tcl
===================================================================
--- trunk/gui/scripts/videodistance.tcl	(revision 6716)
+++ 	(revision )
@@ -1,609 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: videodistance - specify a distance in a video canvas
-#
-# ======================================================================
-#  AUTHOR:  Derrick Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-# See the file "license.terms" for information on usage and redistribution of
-# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-package require Itk
-package require BLT
-package require Img
-package require Rappture
-package require RapptureGUI
-
-itcl::class Rappture::VideoDistance {
-    inherit itk::Widget
-
-    itk_option define -color color Color "green"
-    itk_option define -fncallback fncallback Fncallback ""
-    itk_option define -bindentercb bindentercb Bindentercb ""
-    itk_option define -bindleavecb bindleavecb Bindleavecb ""
-    itk_option define -writetextcb writetextcb Writetextcb ""
-    itk_option define -px2dist px2dist Px2dist ""
-    itk_option define -units units Units "m"
-    itk_option define -bindings bindings Bindings "enable"
-    itk_option define -ondelete ondelete Ondelete ""
-    itk_option define -onframe onframe Onframe ""
-
-
-    constructor { name win args } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method Show {args}
-    public method Hide {args}
-    public method Coords {args}
-    public method Frame {args}
-    public method Move {status x y}
-    public method Menu {args}
-
-
-    public variable  fncallback ""      ;# framenumber callback - tells what frame we are on
-    public variable  bindentercb ""     ;# enter binding callback - call this when entering the object
-    public variable  bindleavecb ""     ;# leave binding callback - call this when leaving the object
-    public variable  writetextcb ""     ;# write text callback - call this to write text to the canvas
-
-    protected method Enter {}
-    protected method Leave {}
-    protected method CatchEvent {event}
-
-    protected method _fixValue {args}
-    protected method _fixPx2Dist {px2dist}
-    protected method _fixBindings {status}
-
-    private variable _canvas        ""  ;# canvas which owns the object
-    private variable _name          ""  ;# id of the object
-    private variable _color         ""  ;# color of the object
-    private variable _frame         0   ;# frame number where the object lives
-    private variable _coords        ""  ;# coords of the object, x0 y0 x1 y1
-    private variable _x             0   ;# x coord when "pressed" for motion
-    private variable _y             0   ;# y coord when "pressed" for motion
-    private variable _px2dist       ""  ;# variable associated with -px2dist
-    private variable _units         ""  ;#
-    private variable _dist          0   ;# distance of the measured space
-}
-
-itk::usual VideoDistance {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::constructor {name win args} {
-
-    set _name $name
-    set _canvas $win
-
-    # setup the control menu
-    set menu $itk_component(hull).distancecontrols
-    itk_component add menu {
-        Rappture::Balloon $itk_interior.menu -title "Controls"
-    }
-    set controls [$itk_component(menu) component inner]
-
-    set fg [option get $itk_component(hull) font Font]
-    label $controls.propertiesl -text "Properties" -font $fg \
-        -highlightthickness 0
-
-    # Measurement control
-    label $controls.measurementl -text "Value" -font $fg \
-        -highlightthickness 0
-    entry $controls.measuremente -width 5 -background white
-
-    # Frame number control
-    label $controls.framenuml -text "Frame" -font "Arial 9"\
-         -highlightthickness 0
-    Rappture::Spinint $controls.framenume \
-        -min 0 -width 5 -font "arial 9"
-
-    # x0
-    label $controls.x0l -text "x0" -font $fg -highlightthickness 0
-    #FIXME: if the canvas width increases after the distance widget is created,
-    #       this max is not updated.
-    Rappture::Spinint $controls.x0e \
-            -min 0 -max [winfo width ${_canvas}] -width 4 -font "arial 9"
-
-    # y0
-    label $controls.y0l -text "y0" -font $fg -highlightthickness 0
-    #FIXME: if the canvas height increases after the distance widget is created,
-    #       this max is not updated.
-    Rappture::Spinint $controls.y0e \
-            -min 0 -max [winfo height ${_canvas}] -width 4 -font "arial 9"
-
-    # x1
-    label $controls.x1l -text "x1" -font $fg -highlightthickness 0
-    #FIXME: if the canvas width increases after the distance widget is created,
-    #       this max is not updated.
-    Rappture::Spinint $controls.x1e \
-            -min 0 -max [winfo width ${_canvas}] -width 4 -font "arial 9"
-
-    # y1
-    label $controls.y1l -text "y1" -font $fg -highlightthickness 0
-    #FIXME: if the canvas height increases after the distance widget is created,
-    #       this max is not updated.
-    Rappture::Spinint $controls.y1e \
-            -min 0 -max [winfo height ${_canvas}] -width 4 -font "arial 9"
-
-    # Delete control
-    label $controls.deletel -text "Delete" -font $fg \
-        -highlightthickness 0
-    Rappture::Switch $controls.deleteb -showtext "false"
-    $controls.deleteb value false
-
-    button $controls.saveb -text Save \
-        -relief raised -pady 0 -padx 0  -font "Arial 9" \
-        -command [itcl::code $this Menu deactivate save] \
-        -activebackground grey90
-
-    button $controls.cancelb -text Cancel \
-        -relief raised -pady 0 -padx 0  -font "Arial 9" \
-        -command [itcl::code $this Menu deactivate cancel] \
-        -activebackground grey90
-
-    grid $controls.measurementl    -column 0 -row 0 -sticky e
-    grid $controls.measuremente    -column 1 -row 0 -sticky w
-    grid $controls.framenuml       -column 2 -row 0 -sticky e
-    grid $controls.framenume       -column 3 -row 0 -sticky w
-    grid $controls.x0l             -column 0 -row 1 -sticky e
-    grid $controls.x0e             -column 1 -row 1 -sticky w
-    grid $controls.y0l             -column 2 -row 1 -sticky e
-    grid $controls.y0e             -column 3 -row 1 -sticky w
-    grid $controls.x1l             -column 0 -row 2 -sticky e
-    grid $controls.x1e             -column 1 -row 2 -sticky w
-    grid $controls.y1l             -column 2 -row 2 -sticky e
-    grid $controls.y1e             -column 3 -row 2 -sticky w
-    grid $controls.deletel         -column 2 -row 3 -sticky e
-    grid $controls.deleteb         -column 3 -row 3 -sticky w
-    grid $controls.saveb           -column 0 -row 4 -sticky e -columnspan 2
-    grid $controls.cancelb         -column 2 -row 4 -sticky w -columnspan 2
-
-
-    # finish configuring the object
-    eval itk_initialize $args
-
-    # set the frame for the particle
-    Frame [uplevel \#0 $fncallback]
-    bind ${_name}-FrameEvent <<Frame>> [itcl::code $this CatchEvent Frame]
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::destructor {} {
-    configure -px2dist ""  ;# remove variable trace
-
-    Hide object
-    _fixBindings disable
-
-    if {"" != $itk_option(-ondelete)} {
-        uplevel \#0 $itk_option(-ondelete)
-    }
-
-}
-
-# ----------------------------------------------------------------------
-#   Frame ?<frameNum>? - update the frame this object is in
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::Frame {args} {
-    if {[llength $args] == 1} {
-        set val [lindex $args 0]
-        if {([string is integer $val] != 1)} {
-            error "bad value: \"$val\": frame number should be an integer"
-        }
-
-        set _frame $val
-
-        if {"" != $itk_option(-onframe)} {
-            uplevel \#0 $itk_option(-onframe) ${_frame}
-        }
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"Frame ?<frameNumber>?\""
-    }
-    return ${_frame}
-}
-
-# ----------------------------------------------------------------------
-#   Coords ?<x0> <y0> <x1> <y1>? - update the coordinates of this object
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::Coords {args} {
-    if {[llength $args] == 0} {
-        return ${_coords}
-    } elseif {[llength $args] == 1} {
-        foreach {x0 y0 x1 y1} [lindex $args 0] break
-    } elseif {[llength $args] == 4} {
-        foreach {x0 y0 x1 y1} $args break
-    } else {
-        error "wrong # args: should be \"Coords ?<x0> <y0> <x1> <y1>?\""
-    }
-
-    if {([string is double $x0] != 1)} {
-        error "bad value: \"$x0\": x coordinate should be a double"
-    }
-    if {([string is double $y0] != 1)} {
-        error "bad value: \"$y0\": y coordinate should be a double"
-    }
-    if {([string is double $x1] != 1)} {
-        error "bad value: \"$x1\": x coordinate should be a double"
-    }
-    if {([string is double $y1] != 1)} {
-        error "bad value: \"$y1\": y coordinate should be a double"
-    }
-
-    set _coords [list $x0 $y0 $x1 $y1]
-
-    if {[llength [${_canvas} find withtag ${_name}-line]] > 0} {
-        eval ${_canvas} coords ${_name}-line ${_coords}
-    }
-
-    _fixValue
-    return ${_coords}
-}
-
-# ----------------------------------------------------------------------
-#   Enter - bindings if the mouse enters the object's space
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::Enter {} {
-    uplevel \#0 $bindentercb
-}
-
-# ----------------------------------------------------------------------
-#   Leave - bindings if the mouse leaves the object's space
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::Leave {} {
-    uplevel \#0 $bindleavecb
-}
-
-
-# ----------------------------------------------------------------------
-#   CatchEvent - bindings for caught events
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::CatchEvent {event} {
-    switch -- $event {
-        "Frame" {
-            if {[uplevel \#0 $fncallback] == ${_frame}} {
-                ${_canvas} itemconfigure ${_name}-line -fill red
-            } else {
-                ${_canvas} itemconfigure ${_name}-line -fill ${_color}
-            }
-        }
-        default {
-            error "bad event \"$event\": should be one of Frame."
-        }
-
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# Show - put properties of the object on the canvas
-#   object - draw the object on the canvas
-#   name - popup a ballon with the name of this object
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::Show {args} {
-    set option [lindex $args 0]
-    switch -- $option {
-        "object" {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"object\""
-            }
-            ${_canvas} create line ${_coords} \
-                -fill ${_color}\
-                -width 2  \
-                -tags "measure ${_name} ${_name}-line" \
-                -dash {4 4} \
-                -arrow both
-        }
-        "name" {
-
-        }
-        default {
-            error "bad option \"$option\": should be one of object, name."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Hide
-#   object - remove the particle from where it is drawn
-#   name - remove the popup with the name
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::Hide {args} {
-    set option [lindex $args 0]
-    switch -- $option {
-        "object" {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"object\""
-            }
-            ${_canvas} delete "${_name}"
-        }
-        "name" {
-
-        }
-        default {
-            error "bad option \"$option\": should be one of object, name."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Move - move the object to a new location
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::Move {status x y} {
-    switch -- $status {
-        "press" {
-            set _x $x
-            set _y $y
-        }
-        "motion" {
-            ${_canvas} move ${_name} [expr $x-${_x}] [expr $y-${_y}]
-            set _coords [${_canvas} coords ${_name}-line]
-            set _x $x
-            set _y $y
-        }
-        "release" {
-        }
-        default {
-            error "bad option \"$option\": should be one of press, motion, release."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Menu - popup a menu with the particle controls
-#   create
-#   activate x y
-#   deactivate status
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::Menu {args} {
-    set option [lindex $args 0]
-    switch -- $option {
-        "activate" {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"activate <x> <y>\""
-            }
-            foreach {x y} [lrange $args 1 end] break
-            set dir "left"
-            set x0 [winfo rootx ${_canvas}]
-            set y0 [winfo rooty ${_canvas}]
-            set w0 [winfo width ${_canvas}]
-            set h0 [winfo height ${_canvas}]
-            set x [expr $x0+$x]
-            set y [expr $y0+$y]
-            $itk_component(menu) activate @$x,$y $dir
-
-            # update the values in the menu
-            set controls [$itk_component(menu) component inner]
-            foreach {x0 y0 x1 y1} ${_coords} break
-            $controls.measuremente delete 0 end
-            $controls.measuremente insert 0 "${_dist} ${_units}"
-            $controls.framenume value ${_frame}
-            $controls.x0e value $x0
-            $controls.y0e value $y0
-            $controls.x1e value $x1
-            $controls.y1e value $y1
-            $controls.deleteb value false
-        }
-        "deactivate" {
-            $itk_component(menu) deactivate
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"deactivate <status>\""
-            }
-            set status [lindex $args 1]
-            switch -- $status {
-                "save" {
-                    set controls [$itk_component(menu) component inner]
-
-                    set newframenum [$controls.framenume value]
-                    if {${_frame} != $newframenum} {
-                        Frame $newframenum
-                    }
-
-                    foreach {oldx0 oldy0 oldx1 oldy1} ${_coords} break
-                    set newx0 [$controls.x0e value]
-                    set newy0 [$controls.y0e value]
-                    set newx1 [$controls.x1e value]
-                    set newy1 [$controls.y1e value]
-
-                    if {$oldx0 != $newx0 ||
-                        $oldy0 != $newy0 ||
-                        $oldx1 != $newx1 ||
-                        $oldy1 != $newy1} {
-
-                        Coords $newx0 $newy0 $newx1 $newy1
-                    }
-
-                    set newdist [Rappture::Units::convert \
-                        [$controls.measuremente get] \
-                        -context ${_units} -units off]
-
-                    if {$newdist != ${_dist}} {
-                        # update the distance displayed
-
-                        set px [expr sqrt(pow(($newx1-$newx0),2)+pow(($newy1-$newy0),2))]
-                        set px2dist [expr $newdist/$px]
-
-                        _fixPx2Dist $px2dist
-                    }
-
-                    if {[$controls.deleteb value]} {
-                        itcl::delete object $this
-                    }
-                }
-                "cancel" {
-                }
-                "default" {
-                    error "bad value \"$status\": should be one of save, cancel"
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be one of activate, deactivate."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# _fixBindings - enable/disable bindings
-#   enable
-#   disable
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::_fixBindings {status} {
-    switch -- $status {
-        "enable" {
-            ${_canvas} bind ${_name} <ButtonPress-1>   [itcl::code $this Move press %x %y]
-            ${_canvas} bind ${_name} <B1-Motion>       [itcl::code $this Move motion %x %y]
-            ${_canvas} bind ${_name} <ButtonRelease-1> [itcl::code $this Move release %x %y]
-
-            ${_canvas} bind ${_name} <ButtonPress-3>   [itcl::code $this Menu activate %x %y]
-
-            ${_canvas} bind ${_name} <Enter>           [itcl::code $this Enter]
-            ${_canvas} bind ${_name} <Leave>           [itcl::code $this Leave]
-
-            ${_canvas} bind ${_name} <B1-Enter>        { }
-            ${_canvas} bind ${_name} <B1-Leave>        { }
-            bindtags ${_canvas} [concat "${_name}-FrameEvent" [bindtags ${_canvas}]]
-        }
-        "disable" {
-            ${_canvas} bind ${_name} <ButtonPress-1>   { }
-            ${_canvas} bind ${_name} <B1-Motion>       { }
-            ${_canvas} bind ${_name} <ButtonRelease-1> { }
-
-            ${_canvas} bind ${_name} <ButtonPress-3>   { }
-
-            ${_canvas} bind ${_name} <Enter>           { }
-            ${_canvas} bind ${_name} <Leave>           { }
-
-            ${_canvas} bind ${_name} <B1-Enter>        { }
-            ${_canvas} bind ${_name} <B1-Leave>        { }
-            set tagnum [lsearch [bindtags ${_canvas}] "${_name}-FrameEvent"]
-            if {$tagnum >= 0} {
-                bindtags ${_canvas} [lreplace [bindtags ${_canvas}] $tagnum $tagnum]
-            }
-        }
-        default {
-            error "bad option \"$status\": should be one of enable, disable."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixPx2Dist
-# Invoked whenever the value for this object is changed by the user
-# via the popup menu.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::_fixPx2Dist {px2dist} {
-    if {"" == $itk_option(-px2dist)} {
-        return
-    }
-    upvar #0 $itk_option(-px2dist) var
-    set var $px2dist
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue
-# Invoked automatically whenever the -px2dist associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoDistance::_fixValue {args} {
-    if {"" == $itk_option(-px2dist)} {
-        return
-    }
-    upvar #0 $itk_option(-px2dist) var
-
-    if {"" == ${_coords}} {
-        # no coords, skip calculation
-        return
-    }
-
-    # calculate the length
-    foreach {x0 y0 x1 y1} ${_coords} break
-    set px [expr sqrt(pow(($x1-$x0),2)+pow(($y1-$y0),2))]
-    set _dist [expr $px*$var]
-
-    # run the new value through units conversion to round
-    # it off so when we show it in the menu and compare it
-    # to the value that comes back from the menu, we don't
-    # get differences in value due to rounding.
-    set _dist [Rappture::Units::convert ${_dist} -context ${_units} -units off]
-
-    set x [expr "$x0 + (($x1-$x0)/2)"]
-    set y [expr "$y0 + (($y1-$y0)/2)"]
-
-    set tt "${_dist} ${_units}"
-    set tags "meastext ${_name} ${_name}-val"
-    set width [expr sqrt(pow(abs($x1-$x0),2)+pow(abs($y1-$y0),2))]
-    set args [list $x $y "$tt" "${_color}" "$tags" $width]
-
-    # remove old text
-    ${_canvas} delete ${_name}-val
-
-    set controls [$itk_component(menu) component inner]
-    if {![$controls.deleteb value]} {
-        # if the object is not hidden, write _dist to the canvas
-        uplevel \#0 $writetextcb $args
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -color
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoDistance::color {
-    if {[string compare "" $itk_option(-color)] != 0} {
-        # FIXME how to tell if the color is valid?
-        set _color $itk_option(-color)
-    } else {
-        error "bad value: \"$itk_option(-color)\": should be a valid color"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -px2dist
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoDistance::px2dist {
-    if {"" != $_px2dist} {
-        upvar #0 $_px2dist var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _px2dist $itk_option(-px2dist)
-
-    if {"" != $_px2dist} {
-        upvar #0 $_px2dist var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -units
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoDistance::units {
-    set _units $itk_option(-units)
-    # _fixValue
-}
-
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -bindings
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoDistance::bindings {
-    _fixBindings $itk_option(-bindings)
-}
-# ----------------------------------------------------------------------
Index: trunk/gui/scripts/videoparticle.tcl
===================================================================
--- trunk/gui/scripts/videoparticle.tcl	(revision 6716)
+++ 	(revision )
@@ -1,612 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: videoparticle - mark a particle on a video frame
-#
-# ======================================================================
-#  AUTHOR:  Derrick Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-# See the file "license.terms" for information on usage and redistribution of
-# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-package require Img
-package require Rappture
-package require RapptureGUI
-
-itcl::class Rappture::VideoParticle {
-    inherit itk::Widget
-
-    itk_option define -halo halo Halo "10"
-    itk_option define -color color Color "green"
-    itk_option define -fncallback fncallback Fncallback ""
-    itk_option define -bindentercb bindentercb Bindentercb ""
-    itk_option define -bindleavecb bindleavecb Bindleavecb ""
-    itk_option define -trajcallback trajcallback Trajcallback ""
-    itk_option define -px2dist px2dist Px2dist ""
-    itk_option define -units units Units "m/s"
-    itk_option define -bindings bindings Bindings "enable"
-    itk_option define -ondelete ondelete Ondelete ""
-    itk_option define -onframe onframe Onframe ""
-    itk_option define -framerange framerange Framerange ""
-
-    constructor { name win args } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method Show {args}
-    public method Hide {args}
-    public method Link {args}
-    public method Coords {args}
-    public method Frame {args}
-    public method drawVectors {}
-    public method next {args}
-    public method prev {args}
-    public method name {}
-
-    public variable  fncallback ""      ;# framenumber callback - tells what frame we are on
-    public variable  bindentercb ""     ;# enter binding callback - call this when entering the object
-    public variable  bindleavecb ""     ;# leave binding callback - call this when leaving the object
-    public variable  trajcallback ""    ;# trajectory callback - calculates and draws trajectory
-
-    public method Move {status x y}
-    public method Menu {args}
-
-    protected method Enter {}
-    protected method Leave {}
-    protected method CatchEvent {event}
-
-    protected method _fixValue {args}
-    protected method _fixPx2Dist {px2dist}
-    protected method _fixBindings {status}
-
-    private variable _canvas        ""  ;# canvas which owns the particle
-    private variable _name          ""  ;# id of the particle
-    private variable _color         ""  ;# color of the particle
-    private variable _frame          0  ;# frame number where this object lives
-    private variable _coords        ""  ;# list of coords where the object lives
-    private variable _halo           0  ;# about the diameter of the particle
-    private variable _x              0  ;# x coord when "pressed" for motion
-    private variable _y              0  ;# y coord when "pressed" for motion
-    private variable _nextnode      ""  ;# particle this particle points to
-    private variable _prevnode      ""  ;# particle this particle is pointed to by
-    private variable _link          ""  ;# tag of vector linking this and nextnode
-    private variable _units         ""  ;#
-    private variable _px2dist       ""  ;# variable associated with -px2dist
-}
-
-itk::usual VideoParticle {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::constructor {name win args} {
-
-    set _name $name
-    set _canvas $win
-
-    # setup the particle control menu
-    itk_component add menu {
-        Rappture::Balloon $itk_interior.particlecontrols -title "Particle Controls"
-    }
-
-    set controls [$itk_component(menu) component inner]
-
-    # Frame number control
-    label $controls.framenuml -text "Frame" -font "Arial 9"\
-         -highlightthickness 0
-    Rappture::Spinint $controls.framenume \
-        -min 0 -width 5 -font "arial 9"
-
-    # Delete control
-    label $controls.deletel -text "Delete" -font "Arial 9" \
-        -highlightthickness 0
-    Rappture::Switch $controls.deleteb -showtext "false"
-    $controls.deleteb value false
-
-    # Save button
-    button $controls.saveb -text Save \
-        -relief raised -pady 0 -padx 0  -font "Arial 9" \
-        -command [itcl::code $this Menu deactivate save] \
-        -activebackground grey90
-
-    # Cancel button
-    button $controls.cancelb -text Cancel \
-        -relief raised -pady 0 -padx 0  -font "Arial 9" \
-        -command [itcl::code $this Menu deactivate cancel] \
-        -activebackground grey90
-
-
-    grid $controls.framenuml -column 0 -row 0 -sticky e
-    grid $controls.framenume -column 1 -row 0 -sticky w
-    grid $controls.deletel   -column 0 -row 1 -sticky e
-    grid $controls.deleteb   -column 1 -row 1 -sticky w
-    grid $controls.saveb     -column 0 -row 2 -sticky e
-    grid $controls.cancelb   -column 1 -row 2 -sticky w
-
-
-    grid columnconfigure $controls 0 -weight 1
-
-    # finish configuring the particle
-    eval itk_initialize $args
-
-    # set the frame for the particle
-    Frame [uplevel \#0 $fncallback]
-    bind ${_name}-FrameEvent <<Frame>> [itcl::code $this CatchEvent Frame]
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::destructor {} {
-    configure -px2dist ""  ;# remove variable trace
-
-    Hide object
-
-    # delete the vectors originating from this particle
-    if {[string compare "" ${_nextnode}] != 0} {
-        ${_canvas} delete ${_link}
-        ${_nextnode} prev ${_prevnode}
-    }
-
-    # delete the vectors pointing to this particle
-    if {[string compare "" ${_prevnode}] != 0} {
-        ${_prevnode} next ${_nextnode}
-        ${_prevnode} drawVectors
-    }
-
-    _fixBindings disable
-
-    if {"" != $itk_option(-ondelete)} {
-        uplevel \#0 $itk_option(-ondelete)
-    }
-}
-
-# ----------------------------------------------------------------------
-#   Enter - bindings if the mouse enters the object's space
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Enter {} {
-    uplevel \#0 $bindentercb
-}
-
-
-# ----------------------------------------------------------------------
-#   Leave - bindings if the mouse leaves the object's space
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Leave {} {
-    uplevel \#0 $bindleavecb
-}
-
-
-# ----------------------------------------------------------------------
-#   CatchEvent - bindings for caught events
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::CatchEvent {event} {
-    switch -- $event {
-        "Frame" {
-            if {[uplevel \#0 $fncallback] == ${_frame}} {
-                ${_canvas} itemconfigure ${_name}-particle -fill red
-            } else {
-                ${_canvas} itemconfigure ${_name}-particle -fill ${_color}
-            }
-        }
-        default {
-            error "bad event \"$event\": should be one of Frame."
-        }
-
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# Show - draw the particle
-#   particle - draw the particle on the canvas
-#   name - popup a ballon with the name of this object
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Show {args} {
-    set option [lindex $args 0]
-    switch -- $option {
-        "object" {
-            foreach {x y} ${_coords} break
-            set coords [list [expr $x-${_halo}] [expr $y-${_halo}] \
-                             [expr $x+${_halo}] [expr $y+${_halo}]]
-            ${_canvas} create oval $coords \
-                -fill ${_color} \
-                -width 0 \
-                -tags "particle ${_name} ${_name}-particle"
-        }
-        "name" {
-
-        }
-        default {
-            error "bad option \"$option\": should be one of object, name."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Hide
-#   particle - remove the particle from where it is drawn
-#   name - remove the popup with the name
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Hide {args} {
-    set option [lindex $args 0]
-    switch -- $option {
-        "object" {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"particle\""
-            }
-            ${_canvas} delete "${_name}"
-        }
-        "name" {
-
-        }
-        default {
-            error "bad option \"$option\": should be one of object, name."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Move - move the object to a new location
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Move {status x y} {
-    switch -- $status {
-        "press" {
-            set _x $x
-            set _y $y
-        }
-        "motion" {
-            ${_canvas} move ${_name} [expr $x-${_x}] [expr $y-${_y}]
-            foreach {x0 y0 x1 y1} [${_canvas} coords ${_name}-particle] break
-            set _coords [list [expr $x0+${_halo}] [expr $y0+${_halo}]]
-            set _x $x
-            set _y $y
-            drawVectors
-            if {[string compare "" ${_prevnode}] != 0} {
-                ${_prevnode} drawVectors
-            }
-        }
-        "release" {
-        }
-        default {
-            error "bad option \"$option\": should be one of press, motion, release."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Menu - popup a menu with the particle controls
-#   create
-#   activate x y
-#   deactivate status
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Menu {args} {
-    set option [lindex $args 0]
-    switch -- $option {
-        "activate" {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"activate <x> <y>\""
-            }
-            foreach {x y} [lrange $args 1 end] break
-            set dir "left"
-            set x0 [winfo rootx ${_canvas}]
-            set y0 [winfo rooty ${_canvas}]
-            set w0 [winfo width ${_canvas}]
-            set h0 [winfo height ${_canvas}]
-            set x [expr $x0+$x]
-            set y [expr $y0+$y]
-            $itk_component(menu) activate @$x,$y $dir
-
-            # update the values in the menu
-            set controls [$itk_component(menu) component inner]
-            $controls.framenume value ${_frame}
-            $controls.deleteb value false
-        }
-        "deactivate" {
-            $itk_component(menu) deactivate
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"deactivate <status>\""
-            }
-            set status [lindex $args 1]
-            switch -- $status {
-                "save" {
-                    set controls [$itk_component(menu) component inner]
-
-                    set newframenum [$controls.framenume value]
-                    if {${_frame} != $newframenum} {
-                        Frame $newframenum
-                    }
-
-                    if {[$controls.deleteb value]} {
-                        itcl::delete object $this
-                    }
-                }
-                "cancel" {
-                }
-                "default" {
-                    error "bad value \"$status\": should be one of save, cancel"
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be one of activate, deactivate."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Link - move the particle to a new location
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Link {args} {
-    # add a new particle list of linked particles
-    foreach {p} $args break
-    $p prev $this
-    next $p
-    drawVectors
-}
-
-# ----------------------------------------------------------------------
-# drawVectors - draw vectors from this particle
-#               to all particles it is linked to.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::drawVectors {} {
-
-    if {[string compare "" $trajcallback] != 0} {
-        set _link [uplevel \#0 $trajcallback $this ${_nextnode}]
-    }
-}
-
-
-# ----------------------------------------------------------------------
-#   Coords ?<x0> <y0>? - update the coordinates of this object
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Coords {args} {
-    if {[llength $args] == 0} {
-        return ${_coords}
-    } elseif {[llength $args] == 1} {
-        foreach {x0 y0} [lindex $args 0] break
-    } elseif {[llength $args] == 2} {
-        foreach {x0 y0} $args break
-    } else {
-        error "wrong # args: should be \"Coords ?<x0> <y0>?\""
-    }
-
-    if {([string is double $x0] != 1)} {
-        error "bad value: \"$x0\": x coordinate should be a double"
-    }
-    if {([string is double $y0] != 1)} {
-        error "bad value: \"$y0\": y coordinate should be a double"
-    }
-
-    set _coords [list $x0 $y0]
-    set coords [list [expr $x0-${_halo}] [expr $y0-${_halo}] \
-                     [expr $x0+${_halo}] [expr $y0+${_halo}]]
-
-    if {[llength [${_canvas} find withtag ${_name}-particle]] > 0} {
-        eval ${_canvas} coords ${_name}-particle $coords
-    }
-
-    _fixValue
-    return ${_coords}
-}
-
-# ----------------------------------------------------------------------
-#   Frame ?<frameNum>? - update the frame this object is in
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::Frame {args} {
-    if {[llength $args] == 1} {
-        set val [lindex $args 0]
-        if {([string is integer $val] != 1)} {
-            error "bad value: \"$val\": frame number should be an integer"
-        }
-
-        set _frame $val
-
-        if {"" != $itk_option(-onframe)} {
-            uplevel \#0 $itk_option(-onframe) ${_frame}
-        }
-
-        drawVectors
-        if {[string compare "" ${_prevnode}] != 0} {
-            ${_prevnode} drawVectors
-        }
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"Frame ?<number>?\""
-    }
-    return ${_frame}
-}
-
-
-# ----------------------------------------------------------------------
-# next - get/set the next particle
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::next {args} {
-    if {[llength $args] == 1} {
-        # set the next node
-        set _nextnode [lindex $args 0]
-        # drawVectors
-    }
-    return ${_nextnode}
-}
-
-# ----------------------------------------------------------------------
-# prev - get/set the prev particle
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::prev {args} {
-    if {[llength $args] == 1} {
-        # set the prev node
-        set _prevnode [lindex $args 0]
-    }
-    return ${_prevnode}
-}
-
-# ----------------------------------------------------------------------
-# name - get the name of the particle
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::name {} {
-    return ${_name}
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue
-# Invoked automatically whenever the -px2dist associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::_fixValue {args} {
-    if {"" == $itk_option(-px2dist)} {
-        return
-    }
-    upvar #0 $itk_option(-px2dist) var
-
-    drawVectors
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixPx2Dist
-# Invoked whenever the length part of the trajectory for this object
-# is changed by the user via the popup menu.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::_fixPx2Dist {px2dist} {
-    if {"" == $itk_option(-px2dist)} {
-        return
-    }
-    upvar #0 $itk_option(-px2dist) var
-    set var $px2dist
-}
-
-# ----------------------------------------------------------------------
-# _fixBindings - enable/disable bindings
-#   enable
-#   disable
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoParticle::_fixBindings {status} {
-    switch -- $status {
-        "enable" {
-            ${_canvas} bind ${_name} <ButtonPress-1>   [itcl::code $this Move press %x %y]
-            ${_canvas} bind ${_name} <B1-Motion>       [itcl::code $this Move motion %x %y]
-            ${_canvas} bind ${_name} <ButtonRelease-1> [itcl::code $this Move release %x %y]
-
-            ${_canvas} bind ${_name} <ButtonPress-3>   [itcl::code $this Menu activate %x %y]
-
-            ${_canvas} bind ${_name} <Enter>           [itcl::code $this Enter]
-            ${_canvas} bind ${_name} <Leave>           [itcl::code $this Leave]
-
-            ${_canvas} bind ${_name} <B1-Enter>        { }
-            ${_canvas} bind ${_name} <B1-Leave>        { }
-            # bind ${_canvas} <<Frame>>                  +[itcl::code $this CatchEvent Frame]
-            bindtags ${_canvas} [concat ${_name}-FrameEvent [bindtags ${_canvas}]]
-        }
-        "disable" {
-            ${_canvas} bind ${_name} <ButtonPress-1>   { }
-            ${_canvas} bind ${_name} <B1-Motion>       { }
-            ${_canvas} bind ${_name} <ButtonRelease-1> { }
-
-            ${_canvas} bind ${_name} <ButtonPress-3>   { }
-
-            ${_canvas} bind ${_name} <Enter>           { }
-            ${_canvas} bind ${_name} <Leave>           { }
-
-            ${_canvas} bind ${_name} <B1-Enter>        { }
-            ${_canvas} bind ${_name} <B1-Leave>        { }
-            set tagnum [lsearch [bindtags ${_canvas}] "${_name}-FrameEvent"]
-            if {$tagnum >= 0} {
-                bindtags ${_canvas} [lreplace [bindtags ${_canvas}] $tagnum $tagnum]
-            }
-        }
-        default {
-            error "bad option \"$status\": should be one of enable, disable."
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -halo
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoParticle::halo {
-    if {[string is double $itk_option(-halo)] == 1} {
-        set _halo $itk_option(-halo)
-    } else {
-        error "bad value: \"$itk_option(-halo)\": halo should be a number"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -color
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoParticle::color {
-    if {[string compare "" $itk_option(-color)] != 0} {
-        # FIXME how to tell if the color is valid?
-        set _color $itk_option(-color)
-    } else {
-        error "bad value: \"$itk_option(-color)\": should be a valid color"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -px2dist
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoParticle::px2dist {
-    if {"" != $_px2dist} {
-        upvar #0 $_px2dist var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _px2dist $itk_option(-px2dist)
-
-    if {"" != $_px2dist} {
-        upvar #0 $_px2dist var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -units
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoParticle::units {
-    set _units $itk_option(-units)
-    # _fixValue
-}
-
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -bindings
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoParticle::bindings {
-    _fixBindings $itk_option(-bindings)
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -framerange
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoParticle::framerange {
-    if {"" == $itk_option(-framerange)} {
-        return
-    }
-    if {[llength $itk_option(-framerange)] != 2} {
-        error "bad value \"$itk_option(-framerange)\": should be 2 integers"
-    }
-    foreach {min max} $itk_option(-framerange) break
-    if {!([string is integer $min]) || !([string is integer $max])} {
-        error "bad value \"$itk_option(-framerange)\": should be 2 integers"
-    }
-    set controls [$itk_component(menu) component inner]
-    $controls.framenume configure -min $min -max $max
-}
-
-# ----------------------------------------------------------------------
Index: trunk/gui/scripts/videopreview.tcl
===================================================================
--- trunk/gui/scripts/videopreview.tcl	(revision 6716)
+++ 	(revision )
@@ -1,568 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: videopreview - previewing movies
-#
-# ======================================================================
-#  AUTHOR:  Derrick Kearney, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-# See the file "license.terms" for information on usage and redistribution of
-# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-package require Itk
-package require BLT
-package require Img
-package require Rappture
-package require RapptureGUI
-
-option add *Video.width 300 widgetDefault
-option add *Video.height 300 widgetDefault
-option add *Video.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::VideoPreview {
-    inherit itk::Widget
-
-    itk_option define -width width Width -1
-    itk_option define -height height Height -1
-    itk_option define -variable variable Variable ""
-
-    constructor { args } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method load {type data}
-    public method loadcb {args}
-    public method video {args}
-    public method query {type}
-
-    protected method Play {}
-    protected method Seek {n}
-    protected method fixSize {}
-    protected method _fixValue {args}
-    protected method Upload {args}
-    protected method eventually {args}
-
-
-    private common   _settings
-    private common   _pendings
-
-    private variable _variable ""   ;# quick way to change movie
-    private variable _path  ""      ;# path of movie
-    private variable _width -1      ;# start x for rubberbanding
-    private variable _height -1     ;# start x for rubberbanding
-    private variable _movie ""      ;# movie we grab images from
-    private variable _lastFrame 0   ;# last frame in the movie
-    private variable _imh ""        ;# current image being displayed
-    private variable _id ""         ;# id of the next play command from after
-    private variable _framerate 30  ;# video frame rate
-    private variable _mspf  7       ;# milliseconds per frame wait time
-    private variable _ofrd  19      ;# observed frame retrieval delay of
-                                    ;# underlying c lib in milliseconds
-    private variable _delay  0      ;# milliseconds between play calls
-    private variable _nextframe 0   ;#
-}
-
-
-itk::usual VideoPreview {
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::constructor {args} {
-
-    array set _settings [subst {
-        $this-framenum          0
-        $this-play              0
-    }]
-
-    array set _pendings [subst {
-        play 0
-    }]
-
-    itk_component add main {
-        canvas $itk_interior.main \
-            -background black
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    bind $itk_component(main) <Configure> [itcl::code $this fixSize]
-
-    # hold the video frames in an image on the canvas
-    set _imh [image create photo]
-    $itk_component(main) create image 0 0 -anchor nw -image $_imh
-
-    # setup movie controls
-    itk_component add moviecontrols {
-        frame $itk_interior.moviecontrols
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-
-    # setup frame number frame
-    itk_component add frnumfr {
-        frame $itk_component(moviecontrols).frnumfr
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-
-    set imagesDir [file join $RapptureGUI::library scripts images]
-
-
-    # Play
-    itk_component add play {
-        Rappture::PushButton $itk_component(moviecontrols).play \
-            -onimage [Rappture::icon flow-pause] \
-            -offimage [Rappture::icon flow-play] \
-            -disabledimage [Rappture::icon flow-play] \
-            -variable [itcl::scope _settings($this-play)] \
-            -command [itcl::code $this video play]
-    }
-    set fg [option get $itk_component(hull) font Font]
-    Rappture::Tooltip::for $itk_component(play) \
-        "Play/Pause movie"
-    $itk_component(play) disable
-
-    # Video Dial Major
-    itk_component add dialmajor {
-        Rappture::Videodial1 $itk_component(moviecontrols).dialmajor \
-            -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \
-            -linecolor "" -activelinecolor "" \
-            -min 0 -max 1 \
-            -variable [itcl::scope _settings($this-framenum)] \
-            -dialoutlinecolor black \
-            -knobimage [Rappture::icon knob2] -knobposition center@middle
-    } {
-        usual
-        ignore -dialprogresscolor
-        rename -background -controlbackground controlBackground Background
-    }
-    $itk_component(dialmajor) current 0
-    bind $itk_component(dialmajor) <<Value>> [itcl::code $this video update]
-
-    itk_component add framenumlabel {
-        label $itk_component(frnumfr).framenuml -text "Frame:" -font $fg \
-            -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-
-    # Current Frame Number
-    itk_component add framenum {
-        label $itk_component(frnumfr).framenum \
-            -width 5 -font "arial 9" \
-            -textvariable [itcl::scope _settings($this-framenum)]
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-    Rappture::Tooltip::for $itk_component(framenum) \
-        "Current frame number"
-
-
-    pack $itk_component(framenumlabel) -side left
-    pack $itk_component(framenum) -side right
-
-
-    blt::table $itk_component(moviecontrols) \
-        0,0 $itk_component(play) -padx {2 0} \
-        0,1 $itk_component(dialmajor) -fill x -padx {2 2} \
-        0,2 $itk_component(frnumfr) -padx {2 4}
-
-    blt::table configure $itk_component(moviecontrols) c* -resize none
-    blt::table configure $itk_component(moviecontrols) c1 -resize both
-    blt::table configure $itk_component(moviecontrols) r0 -pady 1
-
-
-    blt::table $itk_interior \
-        0,0 $itk_component(main) -fill both \
-        1,0 $itk_component(moviecontrols) -fill x
-    blt::table configure $itk_interior c* -resize both
-    blt::table configure $itk_interior r0 -resize both
-    blt::table configure $itk_interior r1 -resize both
-
-    eval itk_initialize $args
-
-    $itk_component(main) configure -background black
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::destructor {} {
-    array unset _settings $this-*
-    if {[info exists _imh]} {
-        image delete $_imh
-    }
-}
-
-# ----------------------------------------------------------------------
-# load - load a video file
-#   type - type of data, "data" or "file"
-#   data - what to load.
-#       if type == "data", data is treated like binary data
-#       if type == "file", data is treated like the name of a file
-#           and is opened and then loaded.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::load {type data} {
-
-    # open the file
-
-    set fname ""
-    switch $type {
-        "data" {
-            set fname "/tmp/tmpVV[pid].video"
-            set fid [open $fname "w"]
-            fconfigure $fid -translation binary -encoding binary
-            puts $fid $data
-            close $fid
-            set type "file"
-            set data $fname
-        }
-        "file" {
-            # do nothing
-        }
-        default {
-            error "bad value: \"$type\": should be \"load \[data|file\] <data>\""
-        }
-    }
-
-    video stop
-
-    if {([info exists _movie]) && ("" != ${_movie})} {
-        ${_movie} release
-    }
-
-    set _movie [Rappture::Video $type $data]
-    file delete $fname
-    set _framerate [${_movie} framerate]
-    set _mspf [expr round(((1.0/${_framerate})*1000))]
-    set _delay [expr {${_mspf} - ${_ofrd}}]
-
-    video seek 0
-
-    # update the dial and framenum widgets
-    set _settings($this-framenum) 0
-
-    # setup the image display
-
-    foreach {w h} [query dimensions] break
-    if {${_width} == -1} {
-        set _width $w
-    }
-    if {${_height} == -1} {
-        set _height $h
-    }
-
-    set _lastFrame [${_movie} get position end]
-
-    # update the dial with video information
-    $itk_component(dialmajor) configure -min 0 -max ${_lastFrame}
-    $itk_component(play) enable
-
-    fixSize
-}
-
-# ----------------------------------------------------------------------
-# loadcb - load callback
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::loadcb {args} {
-    video stop
-    Rappture::filexfer::upload {piv tool} {id label desc} [itcl::code $this Upload]
-}
-
-# ----------------------------------------------------------------------
-# Upload -
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::Upload {args} {
-    array set data $args
-    video stop
-
-    if {[info exists data(error)]} {
-        Rappture::Tooltip::cue $itk::component(main) $data(error)
-        puts stderr $data(error)
-    }
-
-    if {[info exists data(path)] && [info exists data(data)]} {
-        Rappture::Tooltip::cue hide  ;# take down note about the popup window
-
-        # load data
-        load "data" $data(data)
-    }
-
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _fixValue ?<name1> <name2> <op>?
-#
-# Invoked automatically whenever the -variable associated with this
-# widget is modified.  Copies the value to the current settings for
-# the widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::_fixValue {args} {
-    if {"" == $itk_option(-variable)} {
-        return
-    }
-    upvar #0 $itk_option(-variable) var
-    if {[file readable $var]} {
-        # load and start playing the video
-        set _path $var
-        load file ${_path}
-        set _settings($this-play) 1
-        video play
-    }
-}
-
-# ----------------------------------------------------------------------
-# fixSize
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::fixSize {} {
-
-    if {[string compare "" ${_movie}] == 0} {
-        return
-    }
-
-    if {![winfo ismapped $itk_component(hull)]} {
-        return
-    }
-
-    set cw [winfo width $itk_component(main)]
-    set ch [winfo height $itk_component(main)]
-
-    # FIXME: right now we only deal with 16:9 ratio videos
-    # always keep the aspect ratio correct
-    set _width [expr int(int($cw/16.0)*16.0)]
-    set _height [expr int(${_width}/(16.0/9.0))]
-    if {${_height} > $ch} {
-        # if height is limiting us, shrink some more
-        set _height [expr int(int($ch/9.0)*9.0)]
-        set _width [expr int(${_height}*(16.0/9.0))]
-    }
-
-    # get an image with the new size
-    ${_imh} blank
-    ${_imh} put [${_movie} get image ${_width} ${_height}]
-
-    # make the canvas fit the image
-    $itk_component(main) configure -width ${_width} -height ${_height}
-}
-
-# ----------------------------------------------------------------------
-# video - play, stop, rewind, fastforward the video
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::video { args } {
-    set option [lindex $args 0]
-    switch -- $option {
-        "play" {
-            if {$_settings($this-play) == 1} {
-                eventually play
-            } else {
-                # pause/stop
-                after cancel $_id
-                set _pendings(play) 0
-                set _settings($this-play) 0
-            }
-        }
-        "seek" {
-            Seek [lreplace $args 0 0]
-        }
-        "stop" {
-            after cancel $_id
-            set _settings($this-play) 0
-        }
-        "update" {
-            # eventually seek [expr round($_settings($this-framenum))]
-            Seek [expr round($_settings($this-framenum))]
-        }
-        default {
-            error "bad option \"$option\": should be play, stop, toggle, position, or reset."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# query - query things about the video
-#
-#   dimensions  - returns width and height as a list
-#   frames      - number of frames in video (last frame + 1)
-#   framenum    - current position
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::query { type } {
-    set ret ""
-    switch -- $type {
-        "dimensions" {
-            set ret [${_movie} size]
-        }
-        "frames" {
-            set ret [expr [${_movie} get position end] + 1]
-        }
-        "framenum" {
-            set ret [${_movie} get position cur]
-        }
-        default {
-            error "bad type \"$type\": should be dimensions, frames, framenum."
-        }
-    }
-    return $ret
-}
-
-# ----------------------------------------------------------------------
-# Play - get the next video frame
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::Play {} {
-
-    set cur ${_nextframe}
-
-    # time how long it takes to retrieve the next frame
-    set _ofrd [time {
-        # use seek instead of next fxn incase the ${_nextframe} is
-        # not the current frame+1. this happens when we skip frames
-        # because the underlying c lib is too slow at reading.
-        $_movie seek $cur
-        $_imh put [${_movie} get image ${_width} ${_height}]
-    } 1]
-    regexp {(\d+\.?\d*) microseconds per iteration} ${_ofrd} match _ofrd
-    set _ofrd [expr {round(${_ofrd}/1000)}]
-
-    # calculate the delay we shoud see
-    # between frames being placed on screen
-    # taking into account the cost of retrieving the frame
-    set _delay [expr {${_mspf}-${_ofrd}}]
-    if {0 > ${_delay}} {
-        set _delay 0
-    }
-
-    set cur [${_movie} get position cur]
-
-    # update the dial and framenum widgets
-    set _settings($this-framenum) $cur
-
-    # no play cmds pending
-    set _pendings(play) 0
-
-    # schedule the next frame to be displayed
-    if {$cur < ${_lastFrame}} {
-        set _id [after ${_delay} [itcl::code $this eventually play]]
-    } else {
-        video stop
-    }
-
-    event generate $itk_component(hull) <<Frame>>
-}
-
-
-# ----------------------------------------------------------------------
-# Seek - go to a frame in the video
-#   Seek +5
-#   Seek -5
-#   Seek 35
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::Seek {args} {
-    set val [lindex $args 0]
-    if {"" == $val} {
-        error "bad value: \"$val\": should be \"seek value\""
-    }
-    set cur [${_movie} get position cur]
-    if {[string compare $cur $val] == 0} {
-        # already at the frame to seek to
-        return
-    }
-    ${_movie} seek $val
-    ${_imh} put [${_movie} get image ${_width} ${_height}]
-
-    # update the dial and framenum widgets
-    set _settings($this-framenum) [${_movie} get position cur]
-    event generate $itk_component(main) <<Frame>>
-
-}
-
-
-# ----------------------------------------------------------------------
-# eventually -
-#   seek
-#   play
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoPreview::eventually {args} {
-    set option [lindex $args 0]
-    switch -- $option {
-        "seek" {
-            if {$_pendings(seek) == 0} {
-                # no seek pending, schedule one
-                set $_pendings(seek) 1
-                after idle [itcl::code $this Seek [lindex $args 1]]
-            } else {
-                # there is a seek pending, update its seek value
-            }
-        }
-        "play" {
-            if {0 == $_pendings(play)} {
-                # no play pending schedule one
-                set _pendings(play) 1
-                set _nextframe [expr {[${_movie} get position cur] + 1}]
-                after idle [itcl::code $this Play]
-            } else {
-                # there is a play pending, update its frame value
-                incr _nextframe
-            }
-        }
-        default {
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURE: -variable
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoPreview::variable {
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace remove variable var write [itcl::code $this _fixValue]
-    }
-
-    set _variable $itk_option(-variable)
-
-    if {"" != $_variable} {
-        upvar #0 $_variable var
-        trace add variable var write [itcl::code $this _fixValue]
-
-        # sync to the current value of this variable
-        if {[info exists var]} {
-            _fixValue
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -width
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoPreview::width {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-width)] == 0} {
-        error "bad value: \"$itk_option(-width)\": width should be an integer"
-    }
-    set _width $itk_option(-width)
-    after idle [itcl::code $this fixSize]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -height
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoPreview::height {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-height)] == 0} {
-        error "bad value: \"$itk_option(-height)\": height should be an integer"
-    }
-    set _height $itk_option(-height)
-    after idle [itcl::code $this fixSize]
-}
Index: trunk/gui/scripts/videoscreen.tcl
===================================================================
--- trunk/gui/scripts/videoscreen.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1297 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: video - viewing movies
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-# See the file "license.terms" for information on usage and redistribution of
-# this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-package require Itk
-package require BLT
-package require Img
-package require Rappture
-package require RapptureGUI
-
-option add *Video.width -1 widgetDefault
-option add *Video.height -1 widgetDefault
-option add *Video.foreground black widgetDefault
-option add *Video.controlBackground gray widgetDefault
-option add *Video.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-itcl::class Rappture::VideoScreen {
-    inherit itk::Widget
-
-    itk_option define -width width Width -1
-    itk_option define -height height Height -1
-    itk_option define -fileopen fileopen Fileopen ""
-
-    constructor { args } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-
-    public method load {type data}
-    public method loadcb {args}
-    public method video {args}
-    public method query {type}
-
-    protected method Play {}
-    protected method Seek {n}
-    protected method fixSize {}
-    protected method Upload {args}
-    protected method eventually {args}
-
-    private method togglePtrCtrl {pbvar}
-    private method whatPtrCtrl {}
-    private method togglePtrBind {pbvar}
-
-    # drawing tools
-    private method Rubberband {status win x y}
-    private method updateMeasurements {}
-    private method Measure {status win x y}
-    private method Particle {status win x y}
-    private method Trajectory {args}
-    private method calculateTrajectory {args}
-    private method writeText {x y text color tags width}
-    private method clearDrawings {}
-
-    # video dial tools
-    private method toggleloop {}
-
-    private common   _settings
-    private common   _pendings
-    private common   _pbvars
-    private common   _counters
-
-    private variable _width -1      ;# width of the movie
-    private variable _height -1     ;# height of the movie
-    private variable _movie ""      ;# movie we grab images from
-    private variable _lastFrame 0   ;# last frame in the movie
-    private variable _imh ""        ;# current image being displayed
-    private variable _id ""         ;# id of the next play command from after
-    private variable _framerate 30  ;# video frame rate
-    private variable _mspf  7       ;# milliseconds per frame wait time
-    private variable _ofrd  19      ;# observed frame retrieval delay of
-                                    ;# underlying c lib in milliseconds
-    private variable _delay  0      ;# milliseconds between play calls
-    private variable _nextframe 0   ;#
-
-    private variable _px2dist 0     ;# conversion for pixels to user specified distance
-    private variable _particles ""  ;# list of particles
-    private variable _measurements "" ;# list of all measurement lines
-    private variable _obj ""        ;# temp var holding the last created object
-}
-
-
-itk::usual VideoScreen {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::constructor {args} {
-
-    array set _settings [subst {
-        framenum          0
-        loop              0
-        play              0
-        speed             1
-    }]
-
-    array set _pendings {
-        seek 0
-        play 0
-    }
-
-    array set _counters {
-        particle 0
-        measure 0
-    }
-
-    # Create flow controls...
-
-    itk_component add main {
-        canvas $itk_interior.main
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    bind $itk_component(main) <Configure> [itcl::code $this fixSize]
-
-    # setup the image display
-    # hold the video frames in an image on the canvas
-    set _imh [image create photo]
-
-    $itk_component(main) create image 0 0 \
-        -anchor center \
-        -image ${_imh} \
-        -tags videoframe
-
-    # setup movie controls
-    itk_component add moviecontrols {
-        frame $itk_interior.moviecontrols
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-
-    # setup frame number frame
-    itk_component add frnumfr {
-        frame $itk_component(moviecontrols).frnumfr
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-
-    set imagesDir [file join $RapptureGUI::library scripts images]
-
-    # ==== fileopen ====
-    itk_component add fileopen {
-        button $itk_component(moviecontrols).fileopen \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -image [Rappture::icon upload] \
-            -command [itcl::code $this loadcb]
-    } {
-        usual
-    }
-    Rappture::Tooltip::for $itk_component(fileopen) \
-        "Open file"
-
-    # ==== measuring tool ====
-    set measImg [image create photo -file [file join $imagesDir "line_darrow_green.png"]]
-    itk_component add measure {
-        Rappture::PushButton $itk_component(moviecontrols).measurepb \
-            -onimage $measImg \
-            -offimage $measImg \
-            -disabledimage $measImg \
-            -command [itcl::code $this togglePtrCtrl "measure"] \
-            -variable [itcl::scope _pbvars(measure)]
-    } {
-        usual
-    }
-    $itk_component(measure) disable
-    Rappture::Tooltip::for $itk_component(measure) \
-        "Measure the distance of a structure"
-
-    # ==== particle mark tool ====
-    set particleImg [image create photo -file [file join $imagesDir "volume-on.gif"]]
-    itk_component add particle {
-        Rappture::PushButton $itk_component(moviecontrols).particlepb \
-            -onimage $particleImg \
-            -offimage $particleImg \
-            -disabledimage $particleImg \
-            -command [itcl::code $this togglePtrCtrl "particle"] \
-            -variable [itcl::scope _pbvars(particle)]
-    } {
-        usual
-    }
-    $itk_component(particle) disable
-    Rappture::Tooltip::for $itk_component(particle) \
-        "Mark the location of a particle to follow"
-
-
-    # Rewind
-    itk_component add rewind {
-        button $itk_component(moviecontrols).rewind \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -image [Rappture::icon video-rewind] \
-            -command [itcl::code $this video seek 0]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground \
-            Background
-    }
-    $itk_component(rewind) configure -state disabled
-    Rappture::Tooltip::for $itk_component(rewind) \
-        "Rewind movie"
-
-    # Seek back
-    itk_component add seekback {
-        button $itk_component(moviecontrols).seekback \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -image [Rappture::icon flow-rewind] \
-            -command [itcl::code $this video seek -1]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground \
-            Background
-    }
-    $itk_component(seekback) configure -state disabled
-    Rappture::Tooltip::for $itk_component(rewind) \
-        "Seek backwards 1 frame"
-
-    # Play
-    itk_component add play {
-        Rappture::PushButton $itk_component(moviecontrols).play \
-            -onimage [Rappture::icon flow-pause] \
-            -offimage [Rappture::icon flow-play] \
-            -disabledimage [Rappture::icon flow-play] \
-            -variable [itcl::scope _settings(play)] \
-            -command [itcl::code $this video play]
-    }
-    $itk_component(play) disable
-    Rappture::Tooltip::for $itk_component(play) \
-        "Play/Pause movie"
-
-    # Seek forward
-    itk_component add seekforward {
-        button $itk_component(moviecontrols).seekforward \
-            -borderwidth 1 -padx 1 -pady 1 \
-            -image [Rappture::icon flow-forward] \
-            -command [itcl::code $this video seek +1]
-    } {
-        usual
-        ignore -borderwidth
-        rename -highlightbackground -controlbackground controlBackground \
-            Background
-    }
-    $itk_component(seekforward) configure -state disabled
-    Rappture::Tooltip::for $itk_component(seekforward) \
-        "Seek forward 1 frame"
-
-    # Loop
-    itk_component add loop {
-        Rappture::PushButton $itk_component(moviecontrols).loop \
-            -onimage [Rappture::icon flow-loop] \
-            -offimage [Rappture::icon flow-loop] \
-            -disabledimage [Rappture::icon flow-loop] \
-            -variable [itcl::scope _settings(loop)] \
-            -command [itcl::code $this toggleloop]
-    }
-    $itk_component(loop) disable
-    Rappture::Tooltip::for $itk_component(loop) \
-        "Play continuously between marked sections"
-
-    itk_component add dial {
-        frame $itk_interior.dial
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-
-    # Video Dial Major
-    itk_component add dialmajor {
-        Rappture::Videodial1 $itk_component(dial).dialmajor \
-            -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \
-            -linecolor "" -activelinecolor "" \
-            -min 0 -max 1 \
-            -variable [itcl::scope _settings(framenum)] \
-            -dialoutlinecolor black \
-            -knobimage [Rappture::icon knob2] -knobposition center@middle
-    } {
-        usual
-        ignore -dialprogresscolor
-        rename -background -controlbackground controlBackground Background
-    }
-    $itk_component(dialmajor) current 0
-    bind $itk_component(dialmajor) <<Value>> [itcl::code $this video update]
-
-    # Video Dial Minor
-    itk_component add dialminor {
-        Rappture::Videodial2 $itk_component(dial).dialminor \
-            -padding 0 \
-            -min 0 -max 1 \
-            -minortick 1 -majortick 5 \
-            -variable [itcl::scope _settings(framenum)] \
-            -dialoutlinecolor black
-    } {
-        usual
-        rename -background -controlbackground controlBackground Background
-    }
-    $itk_component(dialminor) current 0
-    bind $itk_component(dialminor) <<Value>> [itcl::code $this video update]
-
-    set fg [option get $itk_component(hull) font Font]
-
-    itk_component add framenumlabel {
-        label $itk_component(frnumfr).framenuml -text "Frame:" -font "arial 9" \
-            -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-
-    # Current Frame Number
-    itk_component add framenum {
-        label $itk_component(frnumfr).framenum \
-            -background white -font "arial 9" \
-            -textvariable [itcl::scope _settings(framenum)]
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-    Rappture::Tooltip::for $itk_component(framenum) \
-        "Current frame number"
-
-
-    pack $itk_component(framenumlabel) -side left
-    pack $itk_component(framenum) -side right
-
-
-    itk_component add speedlabel {
-        label $itk_component(moviecontrols).speedl -text "Speed:" -font $fg \
-            -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-
-    # Speed
-    itk_component add speed {
-        Rappture::Videospeed $itk_component(moviecontrols).speed \
-            -min 0 -max 1 -width 4 -font "arial 9" -factor 2
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -controlbackground controlBackground Background
-    }
-    Rappture::Tooltip::for $itk_component(speed) \
-        "Change speed of movie"
-
-    $itk_component(speed) value 0.25
-    bind $itk_component(speed) <<Value>> [itcl::code $this video speed]
-
-
-    blt::table $itk_component(dial) \
-        0,0 $itk_component(dialmajor) -fill x \
-        1,0 $itk_component(dialminor) -fill x
-
-    blt::table $itk_component(moviecontrols) \
-        0,0 $itk_component(fileopen) -padx {2 0}  \
-        0,1 $itk_component(measure) -padx {4 0}  \
-        0,2 $itk_component(particle) -padx {4 0} \
-        0,5 $itk_component(dial) -fill x -padx {2 4} -rowspan 3 \
-        1,0 $itk_component(rewind) -padx {2 0} \
-        1,1 $itk_component(seekback) -padx {4 0} \
-        1,2 $itk_component(play) -padx {4 0} \
-        1,3 $itk_component(seekforward) -padx {4 0} \
-        1,4 $itk_component(loop) -padx {4 0} \
-        2,0 $itk_component(frnumfr) -padx {0 0} -cspan 3 \
-        2,3 $itk_component(speed) -padx {2 0} -cspan 2
-
-    blt::table configure $itk_component(moviecontrols) c* -resize none
-    blt::table configure $itk_component(moviecontrols) c5 -resize both
-    blt::table configure $itk_component(moviecontrols) r0 -pady 1
-
-
-    blt::table $itk_interior \
-        0,0 $itk_component(main) -fill both \
-        1,0 $itk_component(moviecontrols) -fill x
-    blt::table configure $itk_interior c* -resize both
-    blt::table configure $itk_interior r0 -resize both
-    blt::table configure $itk_interior r1 -resize none
-
-    eval itk_initialize $args
-
-    $itk_component(main) configure -background black
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::destructor {} {
-    array unset _settings *
-    array unset _pendings *
-    array unset _pbvars *
-    array unset _counters *
-
-
-    if {[info exists _imh] && ("" != ${_imh})} {
-        image delete ${_imh}
-        set _imh ""
-    }
-
-    if {[info exists measImg]} {
-        image delete $measImg
-        set measImg ""
-    }
-
-    if {[info exists particleImg]} {
-        image delete $particleImg
-        set particleImg ""
-    }
-
-    if {("" != [info commands ${_movie}])} {
-        # clear the movie if it is still open
-        ${_movie} release
-        set _movie ""
-    }
-
-    clearDrawings
-}
-
-# ----------------------------------------------------------------------
-# clearDrawings - delete all particle and measurement objects
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::clearDrawings {} {
-
-    # delete all previously placed particles
-    set obj [lindex ${_particles} end]
-    while {"" != [info commands $obj]} {
-        itcl::delete object $obj
-        set _particles [lreplace ${_particles} end end]
-        if {[llength ${_particles}] == 0} {
-            break
-        }
-        set obj [lindex ${_particles} end]
-    }
-
-    # delete all previously placed measurements
-    set obj [lindex ${_measurements} end]
-    while {"" != [info commands $obj]} {
-        itcl::delete object $obj
-        set _measurements [lreplace ${_measurements} end end]
-        if {[llength ${_measurements}] == 0} {
-            break
-        }
-        set obj [lindex ${_measurements} end]
-    }
-}
-
-# ----------------------------------------------------------------------
-# load - load a video file
-#   type - type of data, "data" or "file"
-#   data - what to load.
-#       if type == "data", data is treated like binary data
-#       if type == "file", data is treated like the name of a file
-#           and is opened and then loaded.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::load {type data} {
-
-    video stop
-
-    # open the file
-    set fname ""
-    switch $type {
-        "data" {
-            if {"" == $data} {
-                error "bad value \"$data\": data should be a movie"
-            }
-
-            set fname "/tmp/tmpVV[pid].video"
-            set fid [open $fname "w"]
-            fconfigure $fid -translation binary -encoding binary
-            puts $fid $data
-            close $fid
-            set type "file"
-            set data $fname
-        }
-        "file" {
-            if {"" == $data} {
-                error "bad value \"$data\": data should be a movie file path"
-            }
-            # do nothing
-        }
-        default {
-            error "bad value: \"$type\": should be \"load \[data|file\] <data>\""
-        }
-    }
-
-    if {"file" == $type} {
-        if {("" != [info commands ${_movie}])} {
-            # compare the new file name to the name of the file
-            # we already have open in our _movie object.
-            # if they are the same, do not reopen the video.
-            # if they are different, close the old movie
-            # and clear out all old drawings from the canvas.
-            set err [catch {${_movie} filename} filename]
-            if {($err == 0)&& ($data == $filename)} {
-                # video file already open, don't reopen it.
-                return
-            } else {
-                # clear the old movie
-                ${_movie} release
-                set _width -1
-                set _height -1
-
-                # delete drawings objects from canvas
-                clearDrawings
-            }
-        }
-    }
-
-    set _movie [Rappture::Video $type $data]
-    if {"" != $fname} {
-        file delete $fname
-    }
-    set _framerate [${_movie} framerate]
-    video speed
-    puts stderr "framerate: ${_framerate}"
-
-    set _lastFrame [${_movie} get position end]
-
-    # update the dial with video information
-    $itk_component(dialmajor) configure -min 0 -max ${_lastFrame}
-    $itk_component(dialminor) configure -min 0 -max ${_lastFrame}
-
-    # turn on the buttons and dials
-    $itk_component(measure) enable
-    $itk_component(particle) enable
-    $itk_component(rewind) configure -state normal
-    $itk_component(seekback) configure -state normal
-    $itk_component(play) enable
-    $itk_component(seekforward) configure -state normal
-    $itk_component(loop) enable
-
-    # make sure looping is off
-    set _settings(loop) 0
-    $itk_component(dialminor) loop disable
-
-    fixSize
-
-    # goto the first frame
-    # update the dial and framenum widgets
-    video seek 0
-    set _settings(framenum) 0
-}
-
-# ----------------------------------------------------------------------
-# loadcb - load callback
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::loadcb {args} {
-    video stop
-    Rappture::filexfer::upload {piv tool} {id label desc} [itcl::code $this Upload]
-}
-
-# ----------------------------------------------------------------------
-# Upload -
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::Upload {args} {
-    array set data $args
-    video stop
-
-    if {[info exists data(error)]} {
-        Rappture::Tooltip::cue $itk::component(main) $data(error)
-        puts stderr $data(error)
-    }
-
-    if {[info exists data(path)] && [info exists data(data)]} {
-        Rappture::Tooltip::cue hide  ;# take down note about the popup window
-
-        # load data
-        load "data" $data(data)
-    }
-
-}
-
-
-# ----------------------------------------------------------------------
-# fixSize
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::fixSize {} {
-
-    if {[string compare "" ${_movie}] == 0} {
-        return
-    }
-
-    if {![winfo ismapped $itk_component(hull)]} {
-        return
-    }
-
-    # get dimensions for the new image
-    # adjust the aspect ratio, if necessary
-
-    puts stderr "aspect ratio: [query aspectratio]"
-
-    foreach {w h} [query dimensions] break
-    foreach {num den} [query aspectratio] break
-
-    if {[expr 1.0*$w/$h] != [expr 1.0*$num/$den]} {
-        # we need to adjust the frame height and width
-        # to keep the correct aspect ratio
-        # hold the height constant,
-        # adjust the width as close as we can
-        # to the correct aspect ratio
-        set w [expr int(1.0*$num/$den*$h)]
-    }
-
-    if {-1 == ${_width}} {
-        set _width $w
-    }
-    if {-1 == ${_height}} {
-        set _height $h
-    }
-
-    # get an image with the new size
-    ${_imh} blank
-    ${_imh} configure -width 1 -height 1
-    ${_imh} configure -width 0 -height 0
-    ${_imh} put [${_movie} get image ${_width} ${_height}]
-
-    # place the image in the center of the canvas
-    set ccw [winfo width $itk_component(main)]
-    set cch [winfo height $itk_component(main)]
-    $itk_component(main) coords videoframe [expr $ccw/2.0] [expr $cch/2.0]
-
-    puts stderr "----------------------------"
-    puts stderr "adjusted = $w $h"
-    puts stderr "data     = ${_width} ${_height}"
-    puts stderr "image    = [image width ${_imh}] [image height ${_imh}]"
-    foreach {x0 y0 x1 y1} [$itk_component(main) bbox videoframe] break
-    puts stderr "bbox     = $x0 $y0 $x1 $y1"
-    puts stderr "ccw cch  = [expr $ccw/2.0] [expr $cch/2.0]"
-    puts stderr "main     = [winfo width $itk_component(main)] [winfo height $itk_component(main)]"
-    puts stderr "hull     = [winfo width $itk_component(hull)] [winfo height $itk_component(hull)]"
-}
-
-# ----------------------------------------------------------------------
-# video - play, stop, rewind, fastforward the video
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::video { args } {
-    set option [lindex $args 0]
-    switch -- $option {
-        "play" {
-            if {$_settings(play) == 1} {
-                eventually play
-            } else {
-                # pause/stop
-                after cancel $_id
-                set _pendings(play) 0
-                set _settings(play) 0
-            }
-        }
-        "seek" {
-            Seek [lreplace $args 0 0]
-        }
-        "stop" {
-            after cancel $_id
-            set _settings(play) 0
-        }
-        "speed" {
-            set speed [$itk_component(speed) value]
-            set _mspf [expr round(((1.0/${_framerate})*1000)/$speed)]
-            set _delay [expr {${_mspf} - ${_ofrd}}]
-            puts stderr "_mspf = ${_mspf} | $speed | ${_ofrd} | ${_delay}"
-        }
-        "update" {
-            eventually seek [expr round($_settings(framenum))]
-            # Seek [expr round($_settings(framenum))]
-        }
-        default {
-            error "bad option \"$option\": should be play, stop, toggle, position, or reset."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# query - query things about the video
-#
-#   dimensions  - returns width and height as a list
-#   frames      - number of frames in video (last frame + 1)
-#   framenum    - current position
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::query { type } {
-    set ret ""
-    switch -- $type {
-        "aspectratio" {
-            set ret [${_movie} aspect display]
-        }
-        "dimensions" {
-            set ret [${_movie} size]
-        }
-        "frames" {
-            set ret [expr [${_movie} get position end] + 1]
-        }
-        "framenum" {
-            set ret [${_movie} get position cur]
-        }
-        default {
-            error "bad type \"$type\": should be dimensions, frames, framenum."
-        }
-    }
-    return $ret
-}
-
-# ----------------------------------------------------------------------
-# Play - get the next video frame
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::Play {} {
-
-    set cur ${_nextframe}
-
-    # time how long it takes to retrieve the next frame
-    set _ofrd [time {
-        # use seek instead of next fxn incase the ${_nextframe} is
-        # not the current frame+1. this happens when we skip frames
-        # because the underlying c lib is too slow at reading.
-        ${_movie} seek $cur
-        ${_imh} put [${_movie} get image ${_width} ${_height}]
-    } 1]
-    regexp {(\d+\.?\d*) microseconds per iteration} ${_ofrd} match _ofrd
-    set _ofrd [expr {round(${_ofrd}/1000)}]
-
-    # calculate the delay we shoud see
-    # between frames being placed on screen
-    # taking into account the cost of retrieving the frame
-    set _delay [expr {${_mspf}-${_ofrd}}]
-    if {0 > ${_delay}} {
-        set _delay 0
-    }
-
-    set cur [${_movie} get position cur]
-
-    # update the dial and framenum widgets
-    set _settings(framenum) $cur
-
-
-    # no play cmds pending
-    set _pendings(play) 0
-
-    # if looping is turned on and markers setup,
-    # then loop back to loopstart when cur hits loopend
-    if {$_settings(loop)} {
-        if {$cur == [$itk_component(dialminor) mark position loopend]} {
-            Seek [$itk_component(dialminor) mark position loopstart]
-        }
-    }
-
-    # schedule the next frame to be displayed
-    if {$cur < ${_lastFrame}} {
-        set _id [after ${_delay} [itcl::code $this eventually play]]
-    } else {
-        video stop
-    }
-
-    event generate $itk_component(hull) <<Frame>>
-}
-
-
-# ----------------------------------------------------------------------
-# Seek - go to a frame in the video
-#   Seek +5
-#   Seek -5
-#   Seek 35
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::Seek {args} {
-    set val [lindex $args 0]
-    if {"" == $val} {
-        error "bad value: \"$val\": should be \"seek value\""
-    }
-    set cur [${_movie} get position cur]
-    if {[string compare $cur $val] == 0} {
-        # already at the frame to seek to
-        set _pendings(seek) 0
-        return
-    }
-    ${_movie} seek $val
-    ${_imh} put [${_movie} get image ${_width} ${_height}]
-
-    # update the dial and framenum widgets
-    set _settings(framenum) [${_movie} get position cur]
-    event generate $itk_component(main) <<Frame>>
-
-    # removing pending
-    set _pendings(seek) 0
-}
-
-
-# ----------------------------------------------------------------------
-# eventually -
-#   seek
-#   play
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::eventually {args} {
-    set option [lindex $args 0]
-    switch -- $option {
-        "seek" {
-            if {0 == $_pendings(seek)} {
-                # no seek pending, schedule one
-                set _pendings(seek) 1
-                after idle [itcl::code $this Seek [lindex $args 1]]
-            } else {
-                # there is a seek pending, update its seek value
-            }
-        }
-        "play" {
-            if {0 == $_pendings(play)} {
-                # no play pending schedule one
-                set _pendings(play) 1
-                set _nextframe [expr {[${_movie} get position cur] + 1}]
-                after idle [itcl::code $this Play]
-            } else {
-                # there is a play pending, update its frame value
-                incr _nextframe
-            }
-        }
-        default {
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# togglePtrCtrl - choose pointer mode:
-#                 rectangle, measure, particlemark
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::togglePtrCtrl {tool} {
-
-    if {[info exists _pbvars($tool)] == 0} {
-        return
-    }
-
-    if {$_pbvars($tool) == 1} {
-        # unpush previously pushed buttons
-        foreach pbv [array names _pbvars] {
-            if {[string compare $tool $pbv] != 0} {
-                set _pbvars($pbv) 0
-            }
-        }
-    }
-    togglePtrBind $tool
-}
-
-
-# ----------------------------------------------------------------------
-# whatPtrCtrl - figure out the current pointer mode:
-#                 rectangle,  measure, particlemark
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::whatPtrCtrl {} {
-    foreach pbv [array names _pbvars] {
-        if {$_pbvars($pbv) != 0} {
-            return $pbv
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# togglePtrBind - update the bindings based on pointer controls
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::togglePtrBind {pbvar} {
-
-    if {[string compare $pbvar current] == 0} {
-        set pbvar [whatPtrCtrl]
-    }
-
-    if {[string compare $pbvar rectangle] == 0} {
-
-        # Bindings for selecting rectangle
-        $itk_component(main) configure -cursor ""
-
-        bind $itk_component(main) <ButtonPress-1> \
-            [itcl::code $this Rubberband new %W %x %y]
-        bind $itk_component(main) <B1-Motion> \
-            [itcl::code $this Rubberband drag %W %x %y]
-        bind $itk_component(main) <ButtonRelease-1> \
-            [itcl::code $this Rubberband release %W %x %y]
-
-    } elseif {[string compare $pbvar measure] == 0} {
-
-        # Bindings for measuring distance
-        $itk_component(main) configure -cursor ""
-
-        bind $itk_component(main) <ButtonPress-1> \
-            [itcl::code $this Measure new %W %x %y]
-        bind $itk_component(main) <B1-Motion> \
-            [itcl::code $this Measure drag %W %x %y]
-        bind $itk_component(main) <ButtonRelease-1> \
-            [itcl::code $this Measure release %W %x %y]
-
-    } elseif {[string compare $pbvar particle] == 0} {
-
-        # Bindings for marking particle locations
-        $itk_component(main) configure -cursor ""
-
-        bind $itk_component(main) <ButtonPress-1> \
-            [itcl::code $this Particle new %W %x %y]
-        bind $itk_component(main) <B1-Motion> ""
-        bind $itk_component(main) <ButtonRelease-1> ""
-
-
-    } elseif {[string compare $pbvar object] == 0} {
-
-        # Bindings for interacting with objects
-        $itk_component(main) configure -cursor hand2
-
-        bind $itk_component(main) <ButtonPress-1> { }
-        bind $itk_component(main) <B1-Motion> { }
-        bind $itk_component(main) <ButtonRelease-1> { }
-
-    } else {
-
-        # invalid pointer mode
-
-    }
-}
-
-
-
-
-
-###### DRAWING TOOLS #####
-
-
-
-
-
-# ----------------------------------------------------------------------
-# Rubberband - draw a rubberband around something in the canvas
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::Rubberband {status win x y} {
-    switch -- $status {
-        "new" {
-            $win delete "rubbershape"
-            set _x0 $x
-            set _y0 $y
-            $win create rectangle \
-                $x $y $x $y -outline white -width 2  \
-                -tags "rubbershape" -dash {4 4}
-        }
-        "drag" {
-            foreach { x0 y0 x1 y1 } [$win coords "rubbershape"] break
-
-            if {$_x0 > $x} {
-                # backward direction
-                set x0 $x
-                set x1 $_x0
-            } else {
-                set x1 $x
-            }
-
-            if {$_y0 >= $y} {
-                # backward direction
-                set y0 $y
-                set y1 $_y0
-            } else {
-                set y1 $y
-            }
-
-            eval $win coords "rubbershape" [list $x0 $y0 $x1 $y1]
-        }
-        "release" {
-            Rubberband drag $win $x $y
-        }
-        default {
-            error "bad status \"$status\": should be new, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Measure - draw a line to measure something on the canvas,
-#           when user releases the line, user is given the
-#           calculated measurement.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::Measure {status win x y} {
-    switch -- $status {
-        "new" {
-            set name "measure[incr _counters(measure)]"
-
-            set _obj [Rappture::VideoDistance $itk_component(main).$name $name $win \
-                        -fncallback [itcl::code $this query framenum] \
-                        -bindentercb [itcl::code $this togglePtrBind object] \
-                        -bindleavecb [itcl::code $this togglePtrBind current] \
-                        -writetextcb [itcl::code $this writeText] \
-                        -ondelete [itcl::code $itk_component(dialminor) mark remove $name] \
-                        -onframe [itcl::code $itk_component(dialminor) mark add $name] \
-                        -px2dist [itcl::scope _px2dist] \
-                        -units "m" \
-                        -color green \
-                        -bindings disable]
-            ${_obj} Coords $x $y $x $y
-            ${_obj} Show object
-            lappend _measurements ${_obj}
-        }
-        "drag" {
-            # FIXME: something wrong with the bindings, if the objects menu is
-            #        open, and you click on the canvas off the menu, a "drag"
-            #        or "release" call is made. need to figure out how to
-            #        disable bindings while obj's menu is open. for now
-            #        we set _obj to "" when we are finished creating it and
-            #        check to see if it's valid when we do a drag or release
-
-            if {"" == ${_obj}} {
-                return
-            }
-
-            ${_obj} Coords [lreplace [${_obj} Coords] 2 3 $x $y]
-        }
-        "release" {
-            # if we enable ${_obj}'s bindings when we create it,
-            # probably never entered because the object's <Enter>
-            # bindings kick in before the window's release bindings do
-
-            if {"" == ${_obj}} {
-                return
-            }
-
-            Measure drag $win $x $y
-
-            if {${_px2dist} == 0} {
-                ${_obj} Menu activate $x $y
-            }
-            ${_obj} configure -bindings enable
-
-            set _obj ""
-        }
-        default {
-            error "bad status \"$status\": should be new, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Particle - mark a particle in the video, a new particle object is
-#            created from information like the name, which video
-#            frames it lives in, it's coords in the canvas in each
-#            frame, it's color...
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::Particle {status win x y} {
-    switch -- $status {
-        "new" {
-            set name "particle[incr _counters(particle)]"
-            set _obj [Rappture::VideoParticle $itk_component(main).$name $name $win \
-                        -fncallback [itcl::code $this query framenum] \
-                        -bindentercb [itcl::code $this togglePtrBind object] \
-                        -bindleavecb [itcl::code $this togglePtrBind current] \
-                        -trajcallback [itcl::code $this Trajectory] \
-                        -ondelete [itcl::code $itk_component(dialminor) mark remove $name] \
-                        -onframe [itcl::code $itk_component(dialminor) mark add $name] \
-                        -framerange "0 ${_lastFrame}" \
-                        -halo 5 \
-                        -color green \
-                        -px2dist [itcl::scope _px2dist] \
-                        -units "m/s"]
-            ${_obj} Coords $x $y
-            ${_obj} Show object
-            #$itk_component(dialminor) mark add $name current
-            # bind $itk_component(hull) <<Frame>> [itcl::code $itk_component(main).$name UpdateFrame]
-
-            # link the new particle to the last particle added, if it exists
-            set lastp [lindex ${_particles} end]
-            while {"" == [info commands $lastp]} {
-                set _particles [lreplace ${_particles} end end]
-                if {[llength ${_particles}] == 0} {
-                    break
-                }
-                set lastp [lindex ${_particles} end]
-            }
-            if {"" != [info commands $lastp]} {
-                $lastp Link ${_obj}
-            }
-
-            # add the particle to the list
-            lappend _particles ${_obj}
-        }
-        default {
-            error "bad status \"$status\": should be new"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# Trajectory - draw a trajectory between two particles
-#
-#   Trajectory $p0 $p1
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::Trajectory {args} {
-
-    set nargs [llength $args]
-    if {($nargs != 1) && ($nargs != 2)} {
-        error "wrong # args: should be \"Trajectory p0 p1\""
-    }
-
-    set p0 ""
-    set p1 ""
-    foreach {p0 p1} $args break
-
-    if {[string compare "" $p0] == 0} {
-        # p0 does not exist
-        return
-    }
-
-    # remove any old trajectory links from p0
-    set p0name [$p0 name]
-    set oldlink "vec-$p0name"
-    $itk_component(main) delete $oldlink
-
-    # check to see if p1 exists anymore
-    if {[string compare "" $p1] == 0} {
-        # p1 does not exist
-        return
-    }
-
-    foreach {x0 y0} [$p0 Coords] break
-    foreach {x1 y1} [$p1 Coords] break
-    set p1name [$p1 name]
-    set link "vec-$p0name-$p1name"
-    $itk_component(main) create line $x0 $y0 $x1 $y1 \
-        -fill green \
-        -width 2 \
-        -tags "vector $link vec-$p0name" \
-        -dash {4 4} \
-        -arrow last
-    $itk_component(main) lower $link $p0name
-
-    # calculate trajectory, truncate it after 4 sigdigs
-    set t [calculateTrajectory [$p0 Frame] $x0 $y0 [$p1 Frame] $x1 $y1]
-    set tt [string range $t 0 [expr [string first . $t] + 4]]
-
-
-    # calculate coords for text
-    foreach { x0 y0 x1 y1 } [$itk_component(main) bbox $link] break
-    set x [expr "$x0 + (abs($x1-$x0)/2)"]
-    set y [expr "$y0 + (abs($y1-$y0)/2)"]
-
-    set tt "$tt m/s"
-    set tags "vectext $link vec-$p0name"
-    set width [expr sqrt(pow(abs($x1-$x0),2)+pow(abs($y1-$y0),2))]
-
-    writeText $x $y $tt green $tags $width
-    return $link
-}
-
-
-# ----------------------------------------------------------------------
-# writeText - write text to the canvas
-#   writes text to the canvas in the color <color> at <x>,<y>
-#   writes text twice more offset up-left and down right,
-#   to add a shadowing effect so colors can be seen
-#
-#   FIXME: Not sure how the text wrapped due to -width collides with the
-#          offset text.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::writeText {x y text color tags width} {
-    $itk_component(main) create text [expr $x-1] [expr $y] \
-        -tags $tags \
-        -justify center \
-        -text $text \
-        -fill black \
-        -width $width
-
-    $itk_component(main) create text [expr $x+1] [expr $y] \
-        -tags $tags \
-        -justify center \
-        -text $text \
-        -fill black \
-        -width $width
-
-    $itk_component(main) create text [expr $x] [expr $y-1] \
-        -tags $tags \
-        -justify center \
-        -text $text \
-        -fill black \
-        -width $width
-
-    $itk_component(main) create text [expr $x] [expr $y+1] \
-        -tags $tags \
-        -justify center \
-        -text $text \
-        -fill black \
-        -width $width
-
-#    # write text up-left
-#    $itk_component(main) create text [expr $x-1] [expr $y-1] \
-#        -tags $tags \
-#        -justify center \
-#        -text $text \
-#        -fill black \
-#        -width $width
-#
-#    # write text down-right
-#    $itk_component(main) create text [expr $x+1] [expr $y+1] \
-#        -tags $tags \
-#        -justify center \
-#        -text $text \
-#        -fill black \
-#        -width $width
-
-    # write text at x,y
-    $itk_component(main) create text $x $y \
-        -tags $tags \
-        -justify center \
-        -text $text \
-        -fill $color \
-        -width $width
-
-}
-
-# ----------------------------------------------------------------------
-# calculateTrajectory - calculate the value of the trajectory
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::calculateTrajectory {args} {
-    # set framerate 29.97         ;# frames per second
-    # set px2dist    8.00         ;# px per meter
-
-    foreach {f0 x0 y0 f1 x1 y1} $args break
-    set px [expr sqrt(pow(abs($x1-$x0),2)+pow(abs($y1-$y0),2))]
-    set frames [expr $f1 - $f0]
-
-    if {($frames != 0) && (${_px2dist} != 0)} {
-        set t [expr 1.0*$px/$frames*${_px2dist}*${_framerate}]
-    } else {
-        set t 0.0
-    }
-
-    return $t
-}
-
-# ----------------------------------------------------------------------
-# toggleloop - add/remove a start/end loop mark to video dial.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VideoScreen::toggleloop {} {
-    if {$_settings(loop) == 0} {
-        $itk_component(dialminor) loop disable
-    } else {
-        set cur [${_movie} get position cur]
-        set end [${_movie} get position end]
-
-        set startframe [expr $cur-10]
-        if {$startframe < 0} {
-            set startframe 0
-        }
-
-        set endframe [expr $cur+10]
-        if {$endframe > $end} {
-            set endframe $end
-        }
-
-        $itk_component(dialminor) loop between $startframe $endframe
-    }
-
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -width - width of the video
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoScreen::width {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-width)] == 0} {
-        error "bad value: \"$itk_option(-width)\": width should be an integer"
-    }
-    set _width $itk_option(-width)
-    after idle [itcl::code $this fixSize]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -height - height of the video
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoScreen::height {
-    # $_dispatcher event -idle !fixsize
-    if {[string is integer $itk_option(-height)] == 0} {
-        error "bad value: \"$itk_option(-height)\": height should be an integer"
-    }
-    set _height $itk_option(-height)
-    after idle [itcl::code $this fixSize]
-}
-
-# ----------------------------------------------------------------------
-# OPTION: -fileopen
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VideoScreen::fileopen {
-    $itk_component(fileopen) configure -command $itk_option(-fileopen)
-}
Index: trunk/gui/scripts/videospeed.tcl
===================================================================
--- trunk/gui/scripts/videospeed.tcl	(revision 6716)
+++ 	(revision )
@@ -1,180 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: spinint - spinner for integer values
-#
-#  This widget is a spinner with up/down arrows for managing integer
-#  values.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Videospeed.width 5 widgetDefault
-option add *Videospeed.textBackground white widgetDefault
-
-blt::bitmap define Videospeed-up {
-#define up_width 8
-#define up_height 4
-static unsigned char up_bits[] = {
-   0x10, 0x38, 0x7c, 0xfe};
-}
-
-blt::bitmap define Videospeed-down {
-#define arrow_width 8
-#define arrow_height 4
-static unsigned char arrow_bits[] = {
-   0xfe, 0x7c, 0x38, 0x10};
-}
-
-itcl::class Rappture::Videospeed {
-    inherit itk::Widget
-
-    itk_option define -min min Min ""
-    itk_option define -max max Max ""
-    itk_option define -factor factor Factor 1
-
-    constructor {args} { # defined below }
-
-    public method value {args}
-    public method bump {{factor up}}
-    protected method _validate {char}
-    protected variable _value ""
-}
-
-itk::usual Videospeed {
-    keep -cursor -font
-    keep -foreground -background
-    keep -textforeground -textbackground
-    keep -selectbackground -selectforeground -selectborderwidth
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videospeed::constructor {args} {
-    itk_component add entry {
-        entry $itk_interior.entry
-    } {
-        usual
-        keep -width
-        rename -background -textbackground textBackground Background
-        rename -foreground -textforeground textForeground Foreground
-        rename -highlightbackground -background background Background
-    }
-    pack $itk_component(entry) -side left -expand yes -fill x
-
-    bind $itk_component(entry) <KeyPress> \
-        [itcl::code $this _validate %A]
-    bind $itk_component(entry) <KeyPress-Return> \
-        "$this value \[$itk_component(entry) get\]"
-    bind $itk_component(entry) <KeyPress-Tab> \
-        "$this value \[$itk_component(entry) get\]"
-
-    itk_component add controls {
-        frame $itk_interior.cntls
-    }
-    pack $itk_component(controls) -side right
-
-    itk_component add up {
-        button $itk_component(controls).spinup -bitmap Videospeed-up \
-            -borderwidth 1 -relief raised -highlightthickness 0 \
-            -command [itcl::code $this bump up]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(up) -side top -expand yes -fill both
-
-    itk_component add down {
-        button $itk_component(controls).spindn -bitmap Videospeed-down \
-            -borderwidth 1 -relief raised -highlightthickness 0 \
-            -command [itcl::code $this bump down]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(down) -side bottom -expand yes -fill both
-
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: value ?<newval>?
-#
-# Clients use this to query/set the value for this widget.  With
-# no args, it returns the current value for the widget.  If the
-# <newval> is specified, it sets the value of the widget and
-# sends a <<Value>> event.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videospeed::value {args} {
-    if {[llength $args] == 1} {
-        set string [lindex $args 0]
-        # allow for floating point values
-        if { [regexp {^ *([0-9]+\.?[0-9]*|\.[0-9]+)x *$} $string match newval] } {
-        } elseif { [regexp {^ *([0-9]+\.?[0-9]*|\.[0-9]+) *$} $string match newval] } {
-        } else {
-            bell
-            return
-        }
-        if {"" != $newval} {
-            if {"" != $itk_option(-min) && $newval < $itk_option(-min)} {
-                set newval $itk_option(-min)
-            }
-            if {"" != $itk_option(-max) && $newval > $itk_option(-max)} {
-                set newval $itk_option(-max)
-            }
-        }
-        set _value $newval
-        $itk_component(entry) delete 0 end
-        $itk_component(entry) insert 0 ${newval}x
-        after 10 \
-            [list catch [list event generate $itk_component(hull) <<Value>>]]
-    } elseif {[llength $args] != 0} {
-        error "wrong # args: should be \"value ?newval?\""
-    }
-    return $_value
-}
-
-# ----------------------------------------------------------------------
-# USAGE: bump ?<factor>?
-#
-# Used internally when you click on the up/down arrows.  Clients
-# can also use it directly to bump values up/down.  The optional
-# <factor> can be an integer value or the keyword "up" or "down".
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videospeed::bump {{factor up}} {
-    if {"up" == $factor} {
-        set factor $itk_option(-factor)
-    } elseif {"down" == $factor} {
-        set factor [expr {1.0/$itk_option(-factor)}]
-    } elseif {![string is integer $factor]} {
-        error "bad factor \"$factor\": should be up, down, or integer"
-    }
-
-    set val [$itk_component(entry) get]
-    if {$val == ""} {
-        set val 0
-    }
-    value [expr {$_value*$factor}]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: _validate <char>
-#
-# Validates each character as it is typed into the spinner.
-# If the <char> is not a digit, then this procedure beeps and
-# prevents the character from being inserted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::Videospeed::_validate {char} {
-    if {[string match "\[ -~\]" $char]} {
-        if {![string match "\[0-9\]" $char]} {
-            bell
-            return -code break
-        }
-    }
-}
Index: trunk/gui/scripts/visviewer.tcl
===================================================================
--- trunk/gui/scripts/visviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1222 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  VisViewer -
-#
-#  This class is the base class for the various visualization viewers
-#  that use the nanoserver render farm.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-
-itcl::class ::Rappture::VisViewer {
-    inherit itk::Widget
-
-    itk_option define -sendcommand sendCommand SendCommand ""
-    itk_option define -receivecommand receiveCommand ReceiveCommand ""
-
-    constructor { args } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc GetServerList { type } {
-        return $_servers($type)
-    }
-    public proc SetServerList { type namelist } {
-        # Convert the comma separated list into a Tcl list.  OGRE also adds
-        # a trailing comma that we want to ignore.
-        regsub -all "," $namelist " " namelist
-        CheckNameList $namelist
-        set _servers($type) $namelist
-    }
-    public proc RemoveServerFromList { type server } {
-        if { ![info exists _servers($type)] } {
-            error "unknown server type \"$type\""
-        }
-        set i [lsearch $_servers($type) $server]
-        if { $i < 0 } {
-            return
-        }
-        set _servers($type) [lreplace $_servers($type) $i $i]
-    }
-    public proc SetPymolServerList { namelist } {
-        SetServerList "pymol" $namelist
-    }
-    public proc SetNanovisServerList { namelist } {
-        SetServerList "nanovis" $namelist
-    }
-    public proc SetVtkServerList { namelist } {
-        SetServerList "vtk" $namelist
-    }
-
-    protected method CheckConnection {}
-    protected method Color2RGB { color }
-    protected method ColorsToColormap { colors }
-    protected method Connect { servers }
-    protected method DebugOff {} {
-        set _debug 0
-    }
-    protected method DebugOn {} {
-        set _debug 1
-    }
-    protected method DebugTrace { args } {
-        if { $_debug } {
-            puts stderr "[info level -1]: $args"
-        }
-    }
-    protected method DisableWaitDialog {}
-    protected method Disconnect {}
-    protected method EnableWaitDialog { timeout }
-    protected method Euler2XYZ { theta phi psi }
-    protected method Flush {}
-    protected method GetColormapList { args }
-    protected method HandleError { args }
-    protected method HandleOk { args }
-    protected method IsConnected {}
-    protected method ReceiveBytes { nbytes }
-    protected method ReceiveEcho { channel {data ""} }
-    protected method SendBytes { bytes }
-    protected method SendCmd { string }
-    protected method SendData { bytes }
-    protected method SendEcho { channel {data ""} }
-    protected method StartBufferingCommands {}
-    protected method StartWaiting {}
-    protected method StopBufferingCommands {}
-    protected method StopWaiting {}
-    protected method ToggleConsole {}
-
-    protected variable _debug 0
-    protected variable _serverType "???";# Type of server.
-    protected variable _sid "";         # socket connection to server
-    protected variable _maxConnects 100
-    protected variable _buffering 0
-    protected variable _cmdSeq 0;       # Command sequence number
-    protected variable _dispatcher "";  # dispatcher for !events
-    protected variable _hosts "";       # list of hosts for server
-    protected variable _parser "";      # interpreter for incoming commands
-    protected variable _image
-    protected variable _hostname
-    protected variable _numConnectTries 0
-    protected variable _debugConsole 0
-    protected variable _reportClientInfo 1
-    # Number of milliscends to wait for server reply before displaying wait
-    # dialog.  If set to 0, dialog is never displayed.
-    protected variable _waitTimeout 0
-
-    private method BuildConsole {}
-    private method DebugConsole {}
-    private method HideConsole {}
-    private method ReceiveHelper {}
-    private method SendDebugCommand {}
-    private method SendHelper {}
-    private method ServerDown {}
-    private method Shuffle { servers }
-    private method TraceComm { channel {data {}} }
-    private method WaitDialog { state }
-    private method Waiting { option widget }
-
-    private proc CheckNameList { namelist }  {
-        foreach host $namelist {
-            set pattern {^[a-zA-Z0-9\.]+:[0-9]}
-            if { ![regexp $pattern $host match] } {
-                error "bad visualization server address \"$host\": should be host:port,host:port,..."
-            }
-        }
-    }
-
-    private variable _buffer;           # buffer for incoming/outgoing commands
-    private variable _outbuf;           # buffer for outgoing commands
-    private variable _blockOnWrite 0;   # Should writes to socket block?
-    private variable _initialized
-    private variable _isOpen 0
-    private variable _afterId -1
-    private variable _icon 0
-    private variable _trace 0;          # Protocol tracing for console
-    private variable _logging 0;        # Command logging to file
-    private variable _console;          # Debug console window path
-    # Number of milliseconds to wait before idle timeout.  If greater than 0,
-    # automatically disconnect from the visualization server when idle timeout
-    # is reached.
-    private variable _idleTimeout 43200000; # 12 hours
-    #private variable _idleTimeout 5000;# 5 seconds
-    #private variable _idleTimeout 0;   # No timeout
-
-    private common _servers;            # array of visualization server lists
-    set _servers(geovis)  "localhost:2015"
-    set _servers(nanovis) "localhost:2000"
-    set _servers(pymol)   "localhost:2020"
-    set _servers(vmdmds)  "localhost:2018"
-    set _servers(vtkvis)  "localhost:2010"
-    private common _done;               # Used to indicate status of send.
-    private common _consoleCnt 0;
-}
-
-itk::usual Panedwindow {
-    keep -background -cursor
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VisViewer::constructor { args } {
-
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !serverDown
-    $_dispatcher dispatch $this !serverDown "[itcl::code $this ServerDown]; list"
-    $_dispatcher register !timeout
-    $_dispatcher dispatch $this !timeout "[itcl::code $this Disconnect]; list"
-
-    $_dispatcher register !waiting
-
-    set _buffer(in) ""
-    set _buffer(out) ""
-    #
-    # Create a parser to handle incoming requests
-    #
-    set _parser [interp create -safe]
-    foreach cmd [$_parser eval {info commands}] {
-        $_parser hide $cmd
-    }
-    # Add default handlers for "ok" acknowledgement and server errors.
-    $_parser alias ok       [itcl::code $this HandleOk]
-    $_parser alias viserror [itcl::code $this HandleError]
-
-    #
-    # Set up the widgets in the main body
-    #
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add main {
-        Rappture::SidebarFrame $itk_interior.main -resizeframe 1
-    }
-    pack $itk_component(main) -expand yes -fill both
-    set f [$itk_component(main) component frame]
-
-    itk_component add plotarea {
-        frame $f.plotarea -highlightthickness 0 -background black
-    } {
-        ignore -background
-    }
-    pack $itk_component(plotarea) -fill both -expand yes
-    set _image(plot) [image create photo]
-
-    global env
-    if { [info exists env(VISRECORDER)] } {
-        set _logging 1
-        if { [file exists /tmp/recording.log] } {
-            file delete /tmp/recording.log
-        }
-    }
-    if { [info exists env(VISTRACE)] } {
-        set _trace 1
-    }
-    incr _consoleCnt
-    set _console ".renderconsole$_consoleCnt"
-
-    eval itk_initialize $args
-}
-
-#
-# destructor --
-#
-itcl::body Rappture::VisViewer::destructor {} {
-    $_dispatcher cancel !timeout
-    interp delete $_parser
-    array unset _done $this
-    if {[winfo exists $_console]} {
-        destroy $_console
-    }
-}
-
-#
-# Shuffle --
-#
-#   Shuffle the list of server hosts.
-#
-itcl::body Rappture::VisViewer::Shuffle { hosts } {
-    set randomHosts {}
-    set ticks [clock clicks]
-    expr {srand($ticks)}
-    for { set i [llength $hosts] } { $i > 0 } { incr i -1 } {
-        set index [expr {round(rand()*$i - 0.5)}]
-        if { $index == $i } {
-            set index [expr $i - 1]
-        }
-        lappend randomHosts [lindex $hosts $index]
-        set hosts [lreplace $hosts $index $index]
-    }
-    return $randomHosts
-}
-
-#
-# ServerDown --
-#
-#    Used internally to let the user know when the connection to the
-#    visualization server has been lost.  Puts up a tip encouraging the
-#    user to press any control to reconnect.
-#
-itcl::body Rappture::VisViewer::ServerDown {} {
-    if { [info exists itk_component(plotarea)] } {
-        set x [expr {[winfo rootx $itk_component(plotarea)]+10}]
-        set y [expr {[winfo rooty $itk_component(plotarea)]+10}]
-    } else {
-        set x 0; set y 0
-    }
-    Rappture::Tooltip::cue @$x,$y "Lost connection to visualization server.  This happens sometimes when there are too many users and the system runs out of memory.\n\nTo reconnect, reset the view or press any other control.  Your picture should come right back up."
-}
-
-#
-# Connect --
-#
-#    Connect to the visualization server (e.g. nanovis, pymolproxy).
-#    Creates an event callback that is triggered when we are idle
-#    (no I/O with the server) for some specified time.
-#
-itcl::body Rappture::VisViewer::Connect { servers } {
-    blt::busy hold $itk_component(hull) -cursor watch
-
-    if { $_numConnectTries > $_maxConnects } {
-        blt::busy release $itk_component(hull)
-        set x [expr {[winfo rootx $itk_component(hull)]+10}]
-        set y [expr {[winfo rooty $itk_component(hull)]+10}]
-        Rappture::Tooltip::cue @$x,$y "Exceeded maximum number of connection attmepts to any $_serverType visualization server. Please contact support."
-        return 0;
-    }
-    foreach server [Shuffle $servers] {
-        puts stderr "connecting to $server..."
-        foreach {hostname port} [split $server ":"] break
-        if { [catch {socket $hostname $port} _sid] != 0 } {
-            set _sid ""
-            RemoveServerFromList $_serverType $server
-            continue
-        }
-        incr _numConnectTries
-        set _hostname $server
-        fconfigure $_sid -translation binary -encoding binary
-
-        # Read back the server identification string.
-        if { [gets $_sid data] <= 0 } {
-            set _sid ""
-            puts stderr "ERORR reading from server data=($data)"
-            RemoveServerFromList $_serverType $server
-            continue
-        }
-        puts stderr "Render server is $data"
-        # We're connected. Cancel any pending serverDown events and
-        # release the busy window over the hull.
-        $_dispatcher cancel !serverDown
-        if { $_idleTimeout > 0 } {
-            $_dispatcher event -after $_idleTimeout !timeout
-        }
-        blt::busy release $itk_component(hull)
-        fconfigure $_sid -buffering line
-        fileevent $_sid readable [itcl::code $this ReceiveHelper]
-        return 1
-    }
-    blt::busy release $itk_component(hull)
-    set x [expr {[winfo rootx $itk_component(hull)]+10}]
-    set y [expr {[winfo rooty $itk_component(hull)]+10}]
-    Rappture::Tooltip::cue @$x,$y "Can't connect to any $_serverType visualization server.  This may be a network problem.  Wait a few moments and try resetting the view."
-    return 0
-}
-
-#
-# Disconnect --
-#
-#    Clients use this method to disconnect from the current rendering
-#    server.  Cancel any pending idle timeout events.
-#
-itcl::body Rappture::VisViewer::Disconnect {} {
-    after cancel $_afterId
-    $_dispatcher cancel !timeout
-    catch {close $_sid}
-    set _sid ""
-    set _buffer(in) ""
-    set _buffer(out) ""
-    set _outbuf ""
-    set _cmdSeq 0
-}
-
-#
-# IsConnected --
-#
-#    Indicates if we are currently connected to a server.
-#
-itcl::body Rappture::VisViewer::IsConnected {} {
-    if { $_sid == "" } {
-        return 0
-    }
-    if { [eof $_sid] } {
-        set _sid ""
-        return 0
-    }
-    return 1
-}
-
-#
-# CheckConection --
-#
-#   This routine is called whenever we're about to send/receive data on
-#   the socket connection to the visualization server.  If we're connected,
-#   then reset the timeout event.  Otherwise try to reconnect to the
-#   visualization server.
-#
-itcl::body Rappture::VisViewer::CheckConnection {} {
-    $_dispatcher cancel !timeout
-    if { $_idleTimeout > 0 } {
-        $_dispatcher event -after $_idleTimeout !timeout
-    }
-    if { [IsConnected] } {
-        return 1
-    }
-    if { $_sid != "" } {
-        fileevent $_sid writable ""
-    }
-    # If we aren't connected, assume it's because the connection to the
-    # visualization server broke. Try to open a connection and trigger a
-    # rebuild.
-    $_dispatcher cancel !serverDown
-    set x [expr {[winfo rootx $itk_component(plotarea)]+10}]
-    set y [expr {[winfo rooty $itk_component(plotarea)]+10}]
-    Rappture::Tooltip::cue @$x,$y "Connecting..."
-    set code [catch { Connect } ok]
-    if { $code == 0 && $ok} {
-        $_dispatcher event -idle !rebuild
-        Rappture::Tooltip::cue hide
-    } else {
-        Rappture::Tooltip::cue @$x,$y "Can't connect to any $_serverType visualization server.  This may be a network problem.  Wait a few moments and try resetting the view."
-        return 0
-    }
-    return 1
-}
-
-#
-# Flush --
-#
-#    Flushes the socket.
-#
-itcl::body Rappture::VisViewer::Flush {} {
-    if { [CheckConnection] } {
-        flush $_sid
-    }
-}
-
-
-#
-# SendHelper --
-#
-#   Helper routine called from a file event to send data when the
-#   connection is writable (i.e. not blocked).  Sets a magic variable
-#   _done($this) when we're done.
-#
-itcl::body Rappture::VisViewer::SendHelper {} {
-    if { ![CheckConnection] } {
-        return 0
-    }
-    puts -nonewline $_sid $_buffer(out)
-    flush $_sid
-    set _buffer(out) ""
-    set _done($this) 1;                 # Success
-}
-
-#
-# SendBytes --
-#
-#   Send a a string to the visualization server.
-#
-itcl::body Rappture::VisViewer::SendBytes { bytes } {
-    SendEcho >>line $bytes
-    if { ![CheckConnection] } {
-        return 0
-    }
-    StartWaiting
-    # Even though the data is sent in only 1 "puts", we need to verify that
-    # the server is ready first.  Wait for the socket to become writable
-    # before sending anything.
-    set _done($this) 1
-    if { $_debug && [string bytelength $_buffer(out)] > 0 } {
-        puts stderr "SendBytes: appending to output buffer"
-    }
-    # Append to the buffer, since we may have been called recursively
-    append _buffer(out) $bytes
-    # There's problem when the user is interacting with the GUI at the
-    # same time we're trying to write to the server.  Don't want to
-    # block because, the GUI will look like it's dead.  We can start
-    # by putting a busy window over plot so that inadvertent things like
-    # mouse movements aren't received.
-    if {$_blockOnWrite} {
-        # Allow a write to block.  In this case we won't re-enter SendBytes.
-        SendHelper
-    } else {
-        # NOTE: This can cause us to re-enter SendBytes during the tkwait.
-        # For this reason, we append to the buffer in the code above.
-        if { [info exists itk_component(main)] } {
-            blt::busy hold $itk_component(main) -cursor ""
-        }
-        fileevent $_sid writable [itcl::code $this SendHelper]
-        tkwait variable ::Rappture::VisViewer::_done($this)
-        if { [info exists itk_component(main)] } {
-            blt::busy release $itk_component(main)
-        }
-    }
-    set _buffer(out) ""
-    if { [IsConnected] } {
-        # The connection may have closed while we were writing to the server.
-        # This can happen if what we sent the server caused it to barf.
-        fileevent $_sid writable ""
-        flush $_sid
-    }
-    return $_done($this)
-}
-
-#
-# StartWaiting --
-#
-#    Display a waiting dialog after a timeout has passed
-#
-itcl::body Rappture::VisViewer::StartWaiting {} {
-    if { $_waitTimeout > 0 } {
-        after cancel $_afterId
-        set _afterId [after $_waitTimeout [itcl::code $this WaitDialog on]]
-    }
-}
-
-#
-# StopWaiting --
-#
-#    Take down waiting dialog
-#
-itcl::body Rappture::VisViewer::StopWaiting {} {
-    if { $_waitTimeout > 0 } {
-        WaitDialog off
-    }
-}
-
-itcl::body Rappture::VisViewer::EnableWaitDialog { value } {
-    set _waitTimeout $value
-}
-
-itcl::body Rappture::VisViewer::DisableWaitDialog {} {
-    set _waitTimeout 0
-}
-
-#
-# ReceiveBytes --
-#
-#    Read some number of bytes from the visualization server.
-#
-itcl::body Rappture::VisViewer::ReceiveBytes { size } {
-    if { ![CheckConnection] } {
-        return 0
-    }
-    set bytes [read $_sid $size]
-    ReceiveEcho <<line "<read $size bytes"
-    StopWaiting
-    return $bytes
-}
-
-#
-# ReceiveHelper --
-#
-#   Helper routine called from a file event when the connection is readable
-#   (i.e. a command response has been sent by the rendering server.  Reads
-#   the incoming command and executes it in a safe interpreter to handle the
-#   action.
-#
-#       Note: This routine currently only handles command responses from
-#         the visualization server.  It doesn't handle non-blocking
-#         reads from the visualization server.
-#
-#       nv>image -bytes 100000      yes
-#       ...following 100000 bytes...    no
-#
-#   Note: All commands from the render server are on one line.
-#         This is because the render server can send anything
-#         as an error message (restricted again to one line).
-#
-itcl::body Rappture::VisViewer::ReceiveHelper {} {
-    if { ![CheckConnection] } {
-        return 0
-    }
-    set n [gets $_sid line]
-
-    if { $n < 0 } {
-        Disconnect
-        return 0
-    }
-    set line [string trim $line]
-    if { $line == "" } {
-        return
-    }
-    if { [string compare -length 3 $line "nv>"] == 0 } {
-        ReceiveEcho <<line $line
-        if ($_trace) {
-            puts stderr "<<[string range $line 0 70]"
-        }
-        append _buffer(in) [string range $line 3 end]
-        append _buffer(in) "\n"
-        if {[info complete $_buffer(in)]} {
-            set request $_buffer(in)
-            set _buffer(in) ""
-            if { [catch {$_parser eval $request} err]  != 0 } {
-                global errorInfo
-                puts stderr "err=$err errorInfo=$errorInfo"
-            }
-        }
-    } elseif { [string compare -length 21 $line "NanoVis Server Error:"] == 0 ||
-               [string compare -length 20 $line "VtkVis Server Error:"] == 0} {
-        # this shows errors coming back from the engine
-        ReceiveEcho <<error $line
-        puts stderr "Render Server Error: $line\n"
-    } else {
-        # this shows errors coming back from the engine
-        ReceiveEcho <<error $line
-        puts stderr "Garbled message: $line\n"
-    }
-}
-
-#
-# Color2RGB --
-#
-#   Converts a color name to a list of r,g,b values needed for the engine.
-#   Each r/g/b component is scaled in the # range 0-1.
-#
-itcl::body Rappture::VisViewer::Color2RGB {color} {
-    foreach {r g b} [winfo rgb $itk_component(hull) $color] break
-    set r [expr {$r/65535.0}]
-    set g [expr {$g/65535.0}]
-    set b [expr {$b/65535.0}]
-    return [list $r $g $b]
-}
-
-#
-# Euler2XYZ --
-#
-#   Converts euler angles for the camera placement the to angles of
-#   rotation about the x/y/z axes, used by the engine.  Returns a list:
-#   {xangle, yangle, zangle}.
-#
-itcl::body Rappture::VisViewer::Euler2XYZ {theta phi psi} {
-    set xangle [expr {$theta-90.0}]
-    set yangle [expr {180.0-$phi}]
-    set zangle $psi
-    return [list $xangle $yangle $zangle]
-}
-
-#
-# SendEcho --
-#
-#     Used internally to echo sent data to clients interested in this widget.
-#     If the -sendcommand option is set, then it is invoked in the global scope
-#     with the <channel> and <data> values as arguments.  Otherwise, this does
-#     nothing.
-#
-itcl::body Rappture::VisViewer::SendEcho {channel {data ""}} {
-    if { $_logging }  {
-        set f [open "/tmp/recording.log" "a"]
-        fconfigure $f -translation binary -encoding binary
-        puts -nonewline $f $data
-        close $f
-    }
-    #puts stderr ">>($data)"
-    if {[string length $itk_option(-sendcommand)] > 0} {
-        uplevel #0 $itk_option(-sendcommand) [list $channel $data]
-    }
-}
-
-#
-# ReceiveEcho --
-#
-#     Echoes received data to clients interested in this widget.  If the
-#     -receivecommand option is set, then it is invoked in the global scope
-#     with the <channel> and <data> values as arguments.  Otherwise, this
-#     does nothing.
-#
-itcl::body Rappture::VisViewer::ReceiveEcho {channel {data ""}} {
-    #puts stderr "<<line $data"
-    if {[string length $itk_option(-receivecommand)] > 0} {
-        uplevel #0 $itk_option(-receivecommand) [list $channel $data]
-    }
-}
-
-itcl::body Rappture::VisViewer::WaitDialog { state } {
-    after cancel $_afterId
-    set _afterId -1
-    if { $state } {
-        if { [winfo exists $itk_component(plotarea).view.splash] } {
-            return
-        }
-        set inner [frame $itk_component(plotarea).view.splash]
-        $inner configure -relief raised -bd 2
-        label $inner.text1 -text "Working...\nPlease wait." \
-            -font "Arial 10"
-        label $inner.icon
-        pack $inner -expand yes -anchor c
-        blt::table $inner \
-            0,0 $inner.text1 -anchor w \
-            0,1 $inner.icon
-        Waiting start $inner.icon
-    } else {
-        if { ![winfo exists $itk_component(plotarea).view.splash] } {
-            return
-        }
-        Waiting stop $itk_component(plotarea).view.splash
-        destroy $itk_component(plotarea).view.splash
-    }
-}
-
-itcl::body Rappture::VisViewer::Waiting { option widget } {
-    switch -- $option {
-        "start" {
-            $_dispatcher dispatch $this !waiting \
-                "[itcl::code $this Waiting "next" $widget] ; list"
-            set _icon 0
-            $widget configure -image [Rappture::icon bigroller${_icon}]
-            $_dispatcher event -after 150 !waiting
-        }
-        "next" {
-            incr _icon
-            if { $_icon >= 8 } {
-                set _icon 0
-            }
-            $widget configure -image [Rappture::icon bigroller${_icon}]
-            $_dispatcher event -after 150 !waiting
-        }
-        "stop" {
-            $_dispatcher cancel !waiting
-        }
-    }
-}
-
-#
-# HideConsole --
-#
-#    Hide the debug console by withdrawing its toplevel window.
-#
-itcl::body Rappture::VisViewer::HideConsole {} {
-    set _debugConsole 0
-    DebugConsole
-}
-
-#
-# BuildConsole --
-#
-#    Create and pack the widgets that make up the debug console: a text
-#    widget to display the communication and an entry widget to type
-#    in commands to send to the render server.
-#
-itcl::body Rappture::VisViewer::BuildConsole {} {
-    toplevel $_console
-    wm protocol $_console WM_DELETE_WINDOW [itcl::code $this HideConsole]
-    set f $_console
-    frame $f.send
-    pack $f.send -side bottom -fill x
-    label $f.send.l -text "Send:"
-    pack $f.send.l -side left
-    itk_component add command {
-        entry $f.send.e -background white
-    } {
-        ignore -background
-    }
-    pack $f.send.e -side left -expand yes -fill x
-    bind $f.send.e <Return> [itcl::code $this SendDebugCommand]
-    bind $f.send.e <KP_Enter> [itcl::code $this SendDebugCommand]
-    scrollbar $f.sb -orient vertical -command "$f.comm yview"
-    pack $f.sb -side right -fill y
-    itk_component add trace {
-        text $f.comm -wrap char -yscrollcommand "$f.sb set" -background white
-    } {
-        ignore -background
-    }
-    pack $f.comm -expand yes -fill both
-    bind $f.comm <Control-F1> [itcl::code $this ToggleConsole]
-    bind $f.comm <Enter> [list focus %W]
-    bind $f.send.e <Control-F1> [itcl::code $this ToggleConsole]
-
-    $itk_component(trace) tag configure error -foreground red \
-        -font -*-courier-medium-o-normal-*-*-120-*
-    $itk_component(trace) tag configure incoming -foreground blue
-}
-
-#
-# ToggleConsole --
-#
-#    This is used by derived classes to turn on/off debuging.  It's
-#    up the to derived class to decide how to turn on/off debugging.
-#
-itcl::body Rappture::VisViewer::ToggleConsole {} {
-    if { $_debugConsole } {
-        set _debugConsole 0
-    } else {
-        set _debugConsole 1
-    }
-    DebugConsole
-}
-
-#
-# DebugConsole --
-#
-#    Based on the value of the variable _debugConsole, turns on/off
-#    debugging. This is done by setting/unsetting a procedure that
-#    is called whenever new characters are received or sent on the
-#    socket to the render server.  Additionally, the debug console
-#    is created if necessary and hidden/shown.
-#
-itcl::body Rappture::VisViewer::DebugConsole {} {
-    if { ![winfo exists $_console] } {
-        BuildConsole
-    }
-    if { $_debugConsole } {
-        $this configure -sendcommand [itcl::code $this TraceComm]
-        $this configure -receivecommand [itcl::code $this TraceComm]
-        wm deiconify $_console
-    } else {
-        $this configure -sendcommand ""
-        $this configure -receivecommand ""
-        wm withdraw $_console
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: TraceComm <channel> <data>
-#
-# Invoked automatically whenever there is communication between
-# the rendering widget and the server.  Eavesdrops on the communication
-# and posts the commands in a text viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VisViewer::TraceComm {channel {data ""}} {
-    $itk_component(trace) configure -state normal
-    switch -- $channel {
-        closed {
-            $itk_component(trace) insert end "--CLOSED--\n" error
-        }
-        <<line {
-            $itk_component(trace) insert end $data incoming "\n" incoming
-        }
-        >>line {
-            $itk_component(trace) insert end $data outgoing "\n" outgoing
-        }
-        error {
-            $itk_component(trace) insert end $data error "\n" error
-        }
-        default {
-            $itk_component(trace) insert end "$data\n"
-        }
-    }
-    $itk_component(trace) configure -state disabled
-    $itk_component(trace) see end
-}
-
-# ----------------------------------------------------------------------
-# USAGE: SendDebugCommand
-#
-# Invoked automatically whenever the user enters a command and
-# presses <Return>.  Sends the command along to the rendering
-# widget.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VisViewer::SendDebugCommand {} {
-    incr _cmdSeq
-    set cmd [$itk_component(command) get]
-    append cmd "\n"
-    if {$_trace} {
-        puts stderr "$_cmdSeq>>[string range $cmd 0 70]"
-    }
-    SendBytes $cmd
-    $itk_component(command) delete 0 end
-}
-
-#
-# HandleOk --
-#
-#       This handles the "ok" response from the server that acknowledges
-#       the reception of a server command, but does not produce an image.
-#       It may pass an argument such as "-token 9" that could be used to
-#       determine how many commands have been processed by the server.
-#
-itcl::body Rappture::VisViewer::HandleOk { args } {
-    if { $_waitTimeout > 0 } {
-        StopWaiting
-    }
-}
-
-#
-# HandleError --
-#
-#       This handles the "viserror" response from the server that reports
-#       that a client-initiated error has occurred on the server.
-#
-itcl::body Rappture::VisViewer::HandleError { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type "???"
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "error" } {
-        set popup $itk_component(hull).error
-        if { ![winfo exists $popup] } {
-            Rappture::Balloon $popup \
-                -title "Render Server Error"
-            set inner [$popup component inner]
-            label $inner.summary -text "" -anchor w
-
-            Rappture::Scroller $inner.scrl \
-                -xscrollmode auto -yscrollmode auto
-            text $inner.scrl.text \
-                -font "Arial 9" -background white -relief sunken -bd 1 \
-                -height 5 -wrap word -width 60
-            $inner.scrl contents $inner.scrl.text
-            button $inner.ok -text "Dismiss" -command [list $popup deactivate] \
-                -font "Arial 9"
-            blt::table $inner \
-                0,0 $inner.scrl -fill both \
-                1,0 $inner.ok
-            $inner.scrl.text tag configure normal -font "Arial 9"
-            $inner.scrl.text tag configure italic -font "Arial 9 italic"
-            $inner.scrl.text tag configure bold -font "Arial 10 bold"
-            $inner.scrl.text tag configure code -font "Courier 10 bold"
-        } else {
-            $popup deactivate
-        }
-        update
-        set inner [$popup component inner]
-        $inner.scrl.text delete 0.0 end
-
-        $inner.scrl.text configure -state normal
-        $inner.scrl.text insert end "The following error was reported by the render server:\n\n" bold
-        $inner.scrl.text insert end $bytes code
-        $inner.scrl.text configure -state disabled
-        update
-        $popup activate $itk_component(hull) below
-    } else {
-        ReceiveEcho <<error $bytes
-        puts stderr "Render server error:\n$bytes"
-    }
-}
-
-itcl::body Rappture::VisViewer::GetColormapList { args } {
-    array set opts {
-        -includeDefault 0
-        -includeElementDefault 0
-        -includeNone 0
-    }
-    if {[llength $args] > 0} {
-        foreach opt $args {
-            set opts($opt) 1
-        }
-    }
-    set colormaps [list]
-    if {$opts(-includeDefault)} {
-        lappend colormaps "default" "default"
-    }
-    if {$opts(-includeElementDefault)} {
-        lappend colormaps "elementDefault" "elementDefault"
-    }
-    lappend colormaps \
-        "BCGYR"              "BCGYR"            \
-        "BGYOR"              "BGYOR"            \
-        "blue-to-brown"      "blue-to-brown"    \
-        "blue-to-orange"     "blue-to-orange"   \
-        "blue-to-grey"       "blue-to-grey"     \
-        "green-to-magenta"   "green-to-magenta" \
-        "greyscale"          "greyscale"        \
-        "nanohub"            "nanohub"          \
-        "rainbow"            "rainbow"          \
-        "spectral"           "spectral"         \
-        "ROYGB"              "ROYGB"            \
-        "RYGCB"              "RYGCB"            \
-        "white-to-blue"      "white-to-blue"    \
-        "brown-to-blue"      "brown-to-blue"    \
-        "grey-to-blue"       "grey-to-blue"     \
-        "orange-to-blue"     "orange-to-blue"
-    if {$opts(-includeNone)} {
-        lappend colormaps "none" "none"
-    }
-    return $colormaps
-}
-
-itcl::body Rappture::VisViewer::ColorsToColormap { colors } {
-    set cmap {}
-    switch -- $colors {
-        "grey-to-blue" {
-            set cmap {
-                0.0                      0.200 0.200 0.200
-                0.14285714285714285      0.400 0.400 0.400
-                0.2857142857142857       0.600 0.600 0.600
-                0.42857142857142855      0.900 0.900 0.900
-                0.5714285714285714       0.800 1.000 1.000
-                0.7142857142857143       0.600 1.000 1.000
-                0.8571428571428571       0.400 0.900 1.000
-                1.0                      0.000 0.600 0.800
-            }
-        }
-        "blue-to-grey" {
-            set cmap {
-                0.0                     0.000 0.600 0.800
-                0.14285714285714285     0.400 0.900 1.000
-                0.2857142857142857      0.600 1.000 1.000
-                0.42857142857142855     0.800 1.000 1.000
-                0.5714285714285714      0.900 0.900 0.900
-                0.7142857142857143      0.600 0.600 0.600
-                0.8571428571428571      0.400 0.400 0.400
-                1.0                     0.200 0.200 0.200
-            }
-        }
-        "white-to-blue" {
-            set cmap {
-                0.0                     0.900 1.000 1.000
-                0.1111111111111111      0.800 0.983 1.000
-                0.2222222222222222      0.700 0.950 1.000
-                0.3333333333333333      0.600 0.900 1.000
-                0.4444444444444444      0.500 0.833 1.000
-                0.5555555555555556      0.400 0.750 1.000
-                0.6666666666666666      0.300 0.650 1.000
-                0.7777777777777778      0.200 0.533 1.000
-                0.8888888888888888      0.100 0.400 1.000
-                1.0                     0.000 0.250 1.000
-            }
-        }
-        "brown-to-blue" {
-            set cmap {
-                0.0                             0.200   0.100   0.000
-                0.09090909090909091             0.400   0.187   0.000
-                0.18181818181818182             0.600   0.379   0.210
-                0.2727272727272727              0.800   0.608   0.480
-                0.36363636363636365             0.850   0.688   0.595
-                0.45454545454545453             0.950   0.855   0.808
-                0.5454545454545454              0.800   0.993   1.000
-                0.6363636363636364              0.600   0.973   1.000
-                0.7272727272727273              0.400   0.940   1.000
-                0.8181818181818182              0.200   0.893   1.000
-                0.9090909090909091              0.000   0.667   0.800
-                1.0                             0.000   0.480   0.600
-            }
-        }
-        "blue-to-brown" {
-            set cmap {
-                0.0                             0.000   0.480   0.600
-                0.09090909090909091             0.000   0.667   0.800
-                0.18181818181818182             0.200   0.893   1.000
-                0.2727272727272727              0.400   0.940   1.000
-                0.36363636363636365             0.600   0.973   1.000
-                0.45454545454545453             0.800   0.993   1.000
-                0.5454545454545454              0.950   0.855   0.808
-                0.6363636363636364              0.850   0.688   0.595
-                0.7272727272727273              0.800   0.608   0.480
-                0.8181818181818182              0.600   0.379   0.210
-                0.9090909090909091              0.400   0.187   0.000
-                1.0                             0.200   0.100   0.000
-            }
-        }
-        "blue-to-orange" {
-            set cmap {
-                0.0                             0.000   0.167   1.000
-                0.09090909090909091             0.100   0.400   1.000
-                0.18181818181818182             0.200   0.600   1.000
-                0.2727272727272727              0.400   0.800   1.000
-                0.36363636363636365             0.600   0.933   1.000
-                0.45454545454545453             0.800   1.000   1.000
-                0.5454545454545454              1.000   1.000   0.800
-                0.6363636363636364              1.000   0.933   0.600
-                0.7272727272727273              1.000   0.800   0.400
-                0.8181818181818182              1.000   0.600   0.200
-                0.9090909090909091              1.000   0.400   0.100
-                1.0                             1.000   0.167   0.000
-            }
-        }
-        "orange-to-blue" {
-            set cmap {
-                0.0                             1.000   0.167   0.000
-                0.09090909090909091             1.000   0.400   0.100
-                0.18181818181818182             1.000   0.600   0.200
-                0.2727272727272727              1.000   0.800   0.400
-                0.36363636363636365             1.000   0.933   0.600
-                0.45454545454545453             1.000   1.000   0.800
-                0.5454545454545454              0.800   1.000   1.000
-                0.6363636363636364              0.600   0.933   1.000
-                0.7272727272727273              0.400   0.800   1.000
-                0.8181818181818182              0.200   0.600   1.000
-                0.9090909090909091              0.100   0.400   1.000
-                1.0                             0.000   0.167   1.000
-            }
-        }
-        "rainbow" {
-            set clist {
-                "#EE82EE"
-                "#4B0082"
-                "blue"
-                "#008000"
-                "yellow"
-                "#FFA500"
-                "red"
-            }
-        }
-        "BGYOR" {
-            set clist {
-                "blue"
-                "#008000"
-                "yellow"
-                "#FFA500"
-                "red"
-            }
-        }
-        "ROYGB" {
-            set clist {
-                "red"
-                "#FFA500"
-                "yellow"
-                "#008000"
-                "blue"
-            }
-        }
-        "RYGCB" {
-            set clist {
-                "red"
-                "yellow"
-                "green"
-                "cyan"
-                "blue"
-            }
-        }
-        "BCGYR" {
-            set clist {
-                "blue"
-                "cyan"
-                "green"
-                "yellow"
-                "red"
-            }
-        }
-        "spectral" {
-            set cmap {
-                0.0 0.150 0.300 1.000
-                0.1 0.250 0.630 1.000
-                0.2 0.450 0.850 1.000
-                0.3 0.670 0.970 1.000
-                0.4 0.880 1.000 1.000
-                0.5 1.000 1.000 0.750
-                0.6 1.000 0.880 0.600
-                0.7 1.000 0.680 0.450
-                0.8 0.970 0.430 0.370
-                0.9 0.850 0.150 0.196
-                1.0 0.650 0.000 0.130
-            }
-        }
-        "green-to-magenta" {
-            set cmap {
-                0.0 0.000 0.316 0.000
-                0.06666666666666667 0.000 0.526 0.000
-                0.13333333333333333 0.000 0.737 0.000
-                0.2 0.000 0.947 0.000
-                0.26666666666666666 0.316 1.000 0.316
-                0.3333333333333333 0.526 1.000 0.526
-                0.4 0.737 1.000 0.737
-                0.4666666666666667 1.000 1.000 1.000
-                0.5333333333333333 1.000 0.947 1.000
-                0.6 1.000 0.737 1.000
-                0.6666666666666666 1.000 0.526 1.000
-                0.7333333333333333 1.000 0.316 1.000
-                0.8 0.947 0.000 0.947
-                0.8666666666666667 0.737 0.000 0.737
-                0.9333333333333333 0.526 0.000 0.526
-                1.0 0.316 0.000 0.316
-            }
-        }
-        "greyscale" {
-            set cmap {
-                0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0
-            }
-        }
-        "nanohub" {
-            set clist "white yellow green cyan blue magenta"
-        }
-        default {
-            set clist [split $colors ":"]
-        }
-    }
-    if {$cmap == ""} {
-        if { [llength $clist] == 1 } {
-            set rgb [Color2RGB $clist]
-            append cmap "0.0 $rgb 1.0 $rgb"
-        } else {
-            for {set i 0} {$i < [llength $clist]} {incr i} {
-                set x [expr {double($i)/([llength $clist]-1)}]
-                set color [lindex $clist $i]
-                append cmap "$x [Color2RGB $color] "
-            }
-        }
-    } else {
-        regsub -all "\[ \t\r\n\]+" [string trim $cmap] " " cmap
-    }
-    return $cmap
-}
-
-
-#
-# StartBufferingCommands --
-#
-itcl::body Rappture::VisViewer::StartBufferingCommands { } {
-    incr _buffering
-    if { $_buffering == 1 } {
-        set _outbuf ""
-    }
-}
-
-#
-# StopBufferingCommands --
-#
-#       This gets called when we want to stop buffering the commands for
-#       the server and actually send then to the server.  Note that there's
-#       a reference count on buffering.  This is so that you can can
-#       Start/Stop multiple times without worrying about the current state.
-#
-itcl::body Rappture::VisViewer::StopBufferingCommands { } {
-    incr _buffering -1
-    if { $_buffering == 0 && $_outbuf != "" } {
-        SendBytes $_outbuf
-        set _outbuf ""
-    }
-}
-
-#
-# SendCmd
-#
-#       Send command off to the rendering server.  If we're currently
-#       buffering, the command is queued to be sent later.
-#
-itcl::body Rappture::VisViewer::SendCmd {string} {
-    incr _cmdSeq
-    if {$_trace} {
-        puts stderr "$_cmdSeq>>[string range $string 0 70]"
-    }
-    if { $_buffering } {
-        append _outbuf $string "\n"
-    } else {
-        SendBytes "$string\n"
-    }
-}
-
-#
-# SendData
-#
-#       Send data off to the rendering server.  If we're currently
-#       buffering, the data is queued to be sent later.
-#
-itcl::body Rappture::VisViewer::SendData {bytes} {
-    if {$_trace} {
-        puts stderr "$_cmdSeq>>data payload"
-    }
-    if { $_buffering } {
-        append _outbuf $bytes
-    } else {
-        SendBytes $bytes
-    }
-}
Index: trunk/gui/scripts/vtkglyphviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkglyphviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,3121 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtkglyphviewer - Vtk 3D glyphs object viewer
-#
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *VtkGlyphViewer.width 4i widgetDefault
-option add *VtkGlyphViewer*cursor crosshair widgetDefault
-option add *VtkGlyphViewer.height 4i widgetDefault
-option add *VtkGlyphViewer.foreground black widgetDefault
-option add *VtkGlyphViewer.controlBackground gray widgetDefault
-option add *VtkGlyphViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkGlyphViewer.plotBackground black widgetDefault
-option add *VtkGlyphViewer.plotForeground white widgetDefault
-option add *VtkGlyphViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkGlyphViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkGlyphViewer::SetServerList
-}
-
-itcl::class Rappture::VtkGlyphViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildColormap { name }
-    private method BuildCutplanesTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildGlyphTab {}
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method DisableMouseRotationBindings {}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method DrawLegend {}
-    private method EnterLegend { x y }
-    private method EventuallyRequestLegend {}
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method EventuallySetCutplane { axis args }
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method LeaveLegend {}
-    private method LegendPointToValue { x y }
-    private method LegendRangeAction { option args }
-    private method LegendRangeValidate { widget which value }
-    private method LegendTitleAction { option }
-    private method MotionLegend { x y }
-    private method MouseOver2Which {}
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { colormap title min max size }
-    private method RequestLegend {}
-    private method Rotate {option x y}
-    private method SetCurrentColormap { color }
-    private method SetCurrentFieldName { dataobj }
-    private method SetLegendTip { x y }
-    private method SetMinMaxGauges { min max }
-    private method SetObjectStyle { dataobj comp }
-    private method SetOrientation { side }
-    private method SetupKeyboardBindings {}
-    private method SetupMousePanningBindings {}
-    private method SetupMouseRotationBindings {}
-    private method SetupMouseZoomBindings {}
-    private method Slice {option args}
-    private method ToggleCustomRange { args }
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _colormaps;        # contains all the colormaps
-                                        # in the server.
-    # The name of the current colormap used.  The colormap is global to all
-    # heightmaps displayed.
-    private variable _currentColormap ""
-
-    private variable _click;            # info used for rotate operations
-    private variable _limits;           # autoscale min/max for all axes
-    private variable _view;             # view params for 3D view
-    private variable _settings
-    private variable _changed
-    private variable _reset 1;          # Connection to server has been reset.
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _title ""
-    private variable _widget
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _legendPending 0
-    private variable _rotatePending 0
-    private variable _cutplanePending 0
-    private variable _fields
-    private variable _curFldName ""
-    private variable _curFldLabel ""
-    private variable _curFldComp 3
-    private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar)
-    private variable _mouseOver "";     # what called LegendRangeAction:
-                                        # vmin or vmax
-    private variable _customRangeClick 1; # what called ToggleCustomRange
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkGlyphViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::constructor {args} {
-    set _serverType "vtkvis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    # X-Cutplane event
-    $_dispatcher register !xcutplane
-    $_dispatcher dispatch $this !xcutplane \
-        "[itcl::code $this AdjustSetting -xcutplaneposition]; list"
-
-    # Y-Cutplane event
-    $_dispatcher register !ycutplane
-    $_dispatcher dispatch $this !ycutplane \
-        "[itcl::code $this AdjustSetting -ycutplaneposition]; list"
-
-    # Z-Cutplane event
-    $_dispatcher register !zcutplane
-    $_dispatcher dispatch $this !zcutplane \
-        "[itcl::code $this AdjustSetting -zcutplaneposition]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _settings {
-        -axesvisible            1
-        -axislabels             1
-        -axisminorticks         1
-        -axismode               "static"
-        -background             black
-        -colormap               BCGYR
-        -colormapvisible        1
-        -customrange            0
-        -customrangemin         0
-        -customrangemax         1
-        -cutplaneedges          0
-        -cutplanelighting       1
-        -cutplaneopacity        1.0
-        -cutplanepreinterp      1
-        -cutplanesvisible       0
-        -cutplanewireframe      0
-        -field                  "Default"
-        -glyphedges             0
-        -glyphlighting          1
-        -glyphnormscale         1
-        -glyphopacity           1.0
-        -glyphorient            1
-        -glyphscale             1
-        -glyphscalemode         "vmag"
-        -glyphshape             "arrow"
-        -glyphsvisible          1
-        -glyphwireframe         0
-        -legendvisible          1
-        -outline                0
-        -xcutplaneposition      50
-        -xcutplanevisible       1
-        -xgrid                  0
-        -ycutplaneposition      50
-        -ycutplanevisible       1
-        -ygrid                  0
-        -zcutplaneposition      50
-        -zcutplanevisible       1
-        -zgrid                  0
-    }
-    array set _changed {
-        -colormap               0
-        -cutplaneedges          0
-        -cutplanelighting       0
-        -cutplaneopacity        0
-        -cutplanepreinterp      0
-        -cutplanesvisible       0
-        -cutplanewireframe      0
-        -glyphedges             0
-        -glyphlighting          0
-        -glyphnormscale         0
-        -glyphopacity           0
-        -glyphorient            0
-        -glyphscale             0
-        -glyphscalemode         0
-        -glyphshape             0
-        -glyphsvisible          0
-        -glyphwireframe         0
-        -outline                0
-        -xcutplaneposition      0
-        -xcutplanevisible       0
-        -ycutplaneposition      0
-        -ycutplanevisible       0
-        -zcutplaneposition      0
-        -zcutplanevisible       0
-    }
-    array set _widget {
-        -cutplaneopacity        100
-        -glyphopacity           100
-    }
-
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    itk_component add fieldmenu {
-        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
-            -tearoff 0
-    } {
-        usual
-        ignore -background -foreground -relief -tearoff
-    }
-
-    # add an editor for adjusting the legend min and max values
-    itk_component add editor {
-        Rappture::Editor $itk_interior.editor \
-            -activatecommand [itcl::code $this LegendRangeAction activate] \
-            -validatecommand [itcl::code $this LegendRangeAction validate] \
-            -applycommand [itcl::code $this LegendRangeAction apply]
-    }
-
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add glyphs {
-        Rappture::PushButton $f.glyphs \
-            -onimage [Rappture::icon volume-on] \
-            -offimage [Rappture::icon volume-off] \
-            -variable [itcl::scope _settings(-glyphsvisible)] \
-            -command [itcl::code $this AdjustSetting -glyphsvisible]
-    }
-    $itk_component(glyphs) select
-    Rappture::Tooltip::for $itk_component(glyphs) \
-        "Hide the glyphs"
-    pack $itk_component(glyphs) -padx 2 -pady 2
-
-    if {0} {
-    itk_component add cutplane {
-        Rappture::PushButton $f.cutplane \
-            -onimage [Rappture::icon cutbutton] \
-            -offimage [Rappture::icon cutbutton] \
-            -variable [itcl::scope _settings(-cutplanesvisible)] \
-            -command [itcl::code $this AdjustSetting -cutplanesvisible]
-    }
-    Rappture::Tooltip::for $itk_component(cutplane) \
-        "Show the cutplanes"
-    pack $itk_component(cutplane) -padx 2 -pady 2
-    }
-
-    if { [catch {
-        BuildGlyphTab
-        #BuildCutplanesTab
-        BuildAxisTab
-        BuildCameraTab
-    } errs] != 0 } {
-        puts stderr errs=$errs
-    }
-
-    # Legend
-    set _image(legend) [image create photo]
-    itk_component add legend {
-        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -plotbackground plotBackground Background
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    SetupMouseRotationBindings
-    SetupMousePanningBindings
-    SetupMouseZoomBindings
-    SetupKeyboardBindings
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::destructor {} {
-    Disconnect
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkGlyphViewer::SetupMouseRotationBindings {} {
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-}
-
-itcl::body Rappture::VtkGlyphViewer::DisableMouseRotationBindings {} {
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> ""
-    bind $itk_component(view) <B1-Motion> ""
-    bind $itk_component(view) <ButtonRelease-1> ""
-}
-
-itcl::body Rappture::VtkGlyphViewer::SetupMousePanningBindings {} {
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-}
-
-itcl::body Rappture::VtkGlyphViewer::SetupMouseZoomBindings {} {
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::SetupKeyboardBindings {} {
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-}
-
-itcl::body Rappture::VtkGlyphViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size $_width $_height"
-
-    EventuallyRequestLegend
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkGlyphViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkGlyphViewer::EventuallyRequestLegend {} {
-    if { !$_legendPending } {
-        set _legendPending 1
-        $_dispatcher event -idle !legend
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 400 !resize
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after 100 !rotate
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::EventuallySetCutplane { axis args } {
-    if { !$_cutplanePending } {
-        set _cutplanePending 1
-        $_dispatcher event -after 100 !${axis}cutplane
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::add {dataobj {settings ""}} {
-    if { ![$dataobj isvalid] } {
-        return;                         # Object doesn't contain valid data.
-    }
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::delete {args} {
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::scale { args } {
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                   # Object doesn't contain valid data.
-        }
-        foreach axis { x y z } {
-            set lim [$dataobj limits $axis]
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {amin amax} $_limits($axis) break
-            if { $amin > $min } {
-                set amin $min
-            }
-            if { $amax < $max } {
-                set amax $max
-            }
-            set _limits($axis) [list $amin $amax]
-        }
-        foreach { fname lim } [$dataobj fieldlimits] {
-            if { ![info exists _limits($fname)] } {
-                set _limits($fname) $lim
-
-                # set reasonable defaults for
-                # customrangevmin and customrangevmax
-                foreach {min max} $lim break
-                SetMinMaxGauges $min $max
-                set _settings(-customrangemin) $min
-                set _settings(-customrangemax) $max
-
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {fmin fmax} $_limits($fname) break
-            if { ! $_settings(-customrange) } {
-                SetMinMaxGauges $fmin $fmax
-            }
-            if { $fmin > $min } {
-                set fmin $min
-            }
-            if { $fmax < $max } {
-                set fmax $max
-            }
-            set _limits($fname) [list $fmin $fmax]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::Connect {} {
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtkglyphviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkGlyphViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkGlyphViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkGlyphViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    $_dispatcher cancel !xcutplane
-    $_dispatcher cancel !ycutplane
-    $_dispatcher cancel !zcutplane
-    $_dispatcher cancel !legend
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    array unset _colormaps
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::ReceiveImage { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        #set time [clock seconds]
-        #set date [clock format $time]
-        #set w [image width $_image(plot)]
-        #set h [image height $_image(plot)]
-        #puts stderr "$date: received image ${w}x${h} image"
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            #puts stderr "round trip time [expr $finish -$_start] milliseconds"
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkGlyphViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-
-        # Reset the camera and other view parameters
-        $_arcball quaternion [ViewToQuaternion]
-        InitSettings -ortho
-        DoRotate
-        PanCamera
-        set _first ""
-        InitSettings -background \
-            -xgrid -ygrid -zgrid -axismode \
-            -axesvisible -axislabels -axisminorticks
-        #SendCmd "axis lformat all %g"
-        StopBufferingCommands
-        SendCmd "imgflush"
-        StartBufferingCommands
-    }
-    set _first ""
-    SendCmd "dataset visible 0"
-    eval scale $_dlist
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-            SetCurrentFieldName $dataobj
-        }
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { ![info exists _datasets($tag)] } {
-                set bytes [$dataobj vtkdata $comp]
-                if 0 {
-                    set f [open "/tmp/glyph.vtk" "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $bytes
-                    close $f
-                }
-                set length [string length $bytes]
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $length
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "dataset add $tag data follows $length"
-                SendData $bytes
-                set _datasets($tag) 1
-                SetObjectStyle $dataobj $comp
-            }
-            if { [info exists _obj2ovride($dataobj-raise)] } {
-                SendCmd "glyphs visible 1 $tag"
-            }
-        }
-    }
-
-    InitSettings -glyphsvisible -outline
-        #-cutplanesvisible
-    if { $_reset } {
-        # These are settings that rely on a dataset being loaded.
-        InitSettings \
-            -field -range \
-            -glyphedges -glyphlighting -glyphnormscale -glyphopacity \
-            -glyphorient -glyphscale -glyphscalemode -glyphshape -glyphwireframe
-
-        #-xcutplaneposition -ycutplaneposition -zcutplaneposition \
-            -xcutplanevisible -ycutplanevisible -zcutplanevisible \
-            -cutplanepreinterp
-
-        Zoom reset
-        foreach axis { x y z } {
-            set label ""
-            if { $_first != "" } {
-                set label [$_first hints ${axis}label]
-            }
-            if { $label == "" } {
-                set label [string toupper $axis]
-            }
-            # There may be a space in the axis label.
-            SendCmd [list axis name $axis $label]
-        }
-        if { [array size _fields] < 2 } {
-            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
-        }
-        set _reset 0
-    }
-    #DrawLegend
-
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands;              # Turn off buffering and send commands.
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _datasets($tag)] && $_datasets($tag) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            $_arcball quaternion [ViewToQuaternion]
-            DoRotate
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::InitSettings { args } {
-    foreach spec $args {
-        AdjustSetting $spec
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkGlyphViewer::AdjustSetting {what {value ""}} {
-    DebugTrace "Enter"
-    if { ![isconnected] } {
-        DebugTrace "Not connected"
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            set bool $_settings($what)
-            SendCmd "axis visible all $bool"
-        }
-        "-axislabels" {
-            set bool $_settings($what)
-            SendCmd "axis labels all $bool"
-        }
-        "-axisminorticks" {
-            set bool $_settings($what)
-            SendCmd "axis minticks all $bool"
-        }
-        "-axismode" {
-            set mode [$itk_component(axisMode) value]
-            set mode [$itk_component(axisMode) translate $mode]
-            set _settings($what) $mode
-            SendCmd "axis flymode $mode"
-        }
-        "-background" {
-            set bgcolor [$itk_component(background) value]
-            array set fgcolors {
-                "black" "white"
-                "white" "black"
-                "grey"  "black"
-            }
-            configure -plotbackground $bgcolor \
-                -plotforeground $fgcolors($bgcolor)
-            $itk_component(view) delete "legend"
-            DrawLegend
-        }
-        "-colormap" {
-            set _changed($what) 1
-            StartBufferingCommands
-            set color [$itk_component(colormap) value]
-            set _settings($what) $color
-            if { $color == "none" } {
-                if { $_settings(-colormapvisible) } {
-                    SendCmd "glyphs colormode constant {}"
-                    set _settings(-colormapvisible) 0
-                }
-            } else {
-                if { !$_settings(-colormapvisible) } {
-                    SendCmd [list glyphs colormode $_colorMode $_curFldName]
-                    set _settings(-colormapvisible) 1
-                }
-                SetCurrentColormap $color
-            }
-            StopBufferingCommands
-            EventuallyRequestLegend
-        }
-        "-cutplaneedges" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane edges $bool"
-        }
-        "-cutplanelighting" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane lighting $bool"
-        }
-        "-cutplaneopacity" {
-            set _changed($what) 1
-            set _settings($what) [expr $_widget($what) * 0.01]
-            SendCmd "cutplane opacity $_settings($what)"
-        }
-        "-cutplanepreinterp" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane preinterp $bool"
-        }
-        "-cutplanesvisible" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane visible 0"
-            if { $bool } {
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "cutplane visible $bool $tag"
-                }
-            }
-            if { $bool } {
-                Rappture::Tooltip::for $itk_component(cutplane) \
-                    "Hide the cutplanes"
-            } else {
-                Rappture::Tooltip::for $itk_component(cutplane) \
-                    "Show the cutplanes"
-            }
-        }
-        "-cutplanewireframe" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane wireframe $bool"
-        }
-        "-field" {
-            set label [$itk_component(field) value]
-            set fname [$itk_component(field) translate $label]
-            set _settings($what) $fname
-            if { [info exists _fields($fname)] } {
-                foreach { label units components } $_fields($fname) break
-                if { $components > 1 } {
-                    set _colorMode vmag
-                } else {
-                    set _colorMode scalar
-                }
-                set _curFldName $fname
-                set _curFldLabel $label
-                set _curFldComp $components
-            } else {
-                puts stderr "unknown field \"$fname\""
-                return
-            }
-            if { ![info exists _limits($_curFldName)] } {
-                SendCmd "dataset maprange all"
-            } else {
-                if { $_settings(-customrange) } {
-                    set vmin [$itk_component(min) value]
-                    set vmax [$itk_component(max) value]
-                } else {
-                    foreach { vmin vmax } $_limits($_curFldName) break
-                    # set the min / max gauges with limits from the field
-                    # the legend's min and max text will be updated
-                    # when the legend is redrawn in DrawLegend
-                    SetMinMaxGauges $vmin $vmax
-                }
-                SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName point_data $_curFldComp]
-            }
-            #SendCmd [list cutplane colormode $_colorMode $_curFldName]
-            SendCmd [list glyphs colormode $_colorMode $_curFldName]
-            DrawLegend
-        }
-        "-glyphedges" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "glyphs edges $bool"
-        }
-        "-glyphlighting" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "glyphs lighting $bool"
-        }
-        "-glyphnormscale" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "glyphs normscale $bool"
-        }
-        "-glyphopacity" {
-            set _changed($what) 1
-            set _settings($what) [expr $_widget($what) * 0.01]
-            SendCmd "glyphs opacity $_settings($what)"
-        }
-        "-glyphorient" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "glyphs gorient $bool {}"
-        }
-        "-glyphscale" {
-            set _changed($what) 1
-            set val $_settings($what)
-            if { [string is double $val] } {
-                SendCmd "glyphs gscale $val"
-            }
-        }
-        "-glyphscalemode" {
-            set _changed($what) 1
-            set label [$itk_component(scaleMode) value]
-            set mode [$itk_component(scaleMode) translate $label]
-            set _settings($what) $mode
-            SendCmd "glyphs smode $mode {}"
-        }
-        "-glyphshape" {
-            set _changed($what) 1
-            set label [$itk_component(gshape) value]
-            set shape [$itk_component(gshape) translate $label]
-            set _settings($what) $shape
-            SendCmd "glyphs shape $shape"
-        }
-        "-glyphsvisible" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "glyphs visible 0"
-            if { $bool } {
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "glyphs visible $bool $tag"
-                }
-                Rappture::Tooltip::for $itk_component(glyphs) \
-                    "Hide the glyphs"
-            } else {
-                Rappture::Tooltip::for $itk_component(glyphs) \
-                    "Show the glyphs"
-            }
-            DrawLegend
-        }
-        "-glyphwireframe" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "glyphs wireframe $bool"
-        }
-        "-legendvisible" {
-            if { !$_settings($what) } {
-                $itk_component(view) delete legend
-            }
-            DrawLegend
-        }
-        "-ortho" {
-            set bool $_view($what)
-            if { $bool } {
-                SendCmd "camera mode ortho"
-            } else {
-                SendCmd "camera mode persp"
-            }
-        }
-        "-outline" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "outline visible 0"
-            if { $bool } {
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "outline visible $bool $tag"
-                }
-            }
-        }
-        "-range" {
-            if { $_settings(-customrange) } {
-                set vmin [$itk_component(min) value]
-                set vmax [$itk_component(max) value]
-            } else {
-                foreach { vmin vmax } $_limits($_curFldName) break
-            }
-            SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName point_data $_curFldComp]
-            DrawLegend
-        }
-        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
-            set _changed($what) 1
-            set axis [string tolower [string range $what 1 1]]
-            set bool $_settings($what)
-            if { $bool } {
-                $itk_component(${axis}position) configure -state normal \
-                    -troughcolor white
-            } else {
-                $itk_component(${axis}position) configure -state disabled \
-                    -troughcolor grey82
-            }
-            SendCmd "cutplane axis $axis $bool"
-        }
-        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
-            set _changed($what) 1
-            set axis [string tolower [string range $what 1 1]]
-            set pos [expr $_settings($what) * 0.01]
-            SendCmd "cutplane slice ${axis} ${pos}"
-            set _cutplanePending 0
-        }
-        "-xgrid" - "-ygrid" - "-zgrid" {
-            set axis [string tolower [string range $what 1 1]]
-            set bool $_settings($what)
-            SendCmd "axis grid $axis $bool"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-#
-# RequestLegend --
-#
-# Request a new legend from the server.  The size of the legend
-# is determined from the height of the canvas.
-#
-# This should be called when
-#   1.  A new current colormap is set.
-#   2.  Window is resized.
-#   3.  The limits of the data have changed.  (Just need a redraw).
-#   4.  Legend becomes visible (Just need a redraw).
-#
-itcl::body Rappture::VtkGlyphViewer::RequestLegend {} {
-    set _legendPending 0
-    if { ![info exists _fields($_curFldName)] } {
-        return
-    }
-    set fname $_curFldName
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-    set w 12
-    set h [expr {$_height - 2 * ($lineht + 2)}]
-    if { $h < 1 } {
-        return
-    }
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a title too, subtract one more line
-    if { $title != "" } {
-        incr h -$lineht
-    }
-    # Set the legend on the first dataset.
-    if { $_currentColormap != "" } {
-        set cmap $_currentColormap
-        if { ![info exists _colormaps($cmap)] } {
-            BuildColormap $cmap
-            set _colormaps($cmap) 1
-        }
-        #SendCmd [list legend $cmap $_colorMode $_curFldName {} $w $h 0]
-        SendCmd "legend2 $cmap $w $h"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkGlyphViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        SendCmd "screen bgcolor $rgb"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkGlyphViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        SendCmd "axis color all $rgb"
-        SendCmd "outline color $rgb"
-        #SendCmd "cutplane color $rgb"
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::BuildGlyphTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Glyph Settings" \
-        -icon [Rappture::icon volume-on]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.glyphs \
-        -text "Glyphs" \
-        -variable [itcl::scope _settings(-glyphsvisible)] \
-        -command [itcl::code $this AdjustSetting -glyphsvisible] \
-        -font "Arial 9"
-
-    label $inner.gshape_l -text "Glyph shape" -font "Arial 9"
-    itk_component add gshape {
-        Rappture::Combobox $inner.gshape -width 10 -editable 0
-    }
-    $inner.gshape choices insert end \
-        "arrow"              "arrow"           \
-        "cone"               "cone"            \
-        "cube"               "cube"            \
-        "cylinder"           "cylinder"        \
-        "dodecahedron"       "dodecahedron"    \
-        "icosahedron"        "icosahedron"     \
-        "line"               "line"            \
-        "octahedron"         "octahedron"      \
-        "point"              "point"           \
-        "sphere"             "sphere"          \
-        "tetrahedron"        "tetrahedron"
-
-    $itk_component(gshape) value $_settings(-glyphshape)
-    bind $inner.gshape <<Value>> [itcl::code $this AdjustSetting -glyphshape]
-
-    label $inner.scaleMode_l -text "Scale by" -font "Arial 9"
-    itk_component add scaleMode {
-        Rappture::Combobox $inner.scaleMode -width 10 -editable 0
-    }
-    $inner.scaleMode choices insert end \
-        "scalar" "Scalar"            \
-        "vmag"   "Vector magnitude"  \
-        "vcomp"  "Vector components" \
-        "off"    "Constant size"
-
-    $itk_component(scaleMode) value "[$itk_component(scaleMode) label $_settings(-glyphscalemode)]"
-    bind $inner.scaleMode <<Value>> [itcl::code $this AdjustSetting -glyphscalemode]
-
-    checkbutton $inner.normscale \
-        -text "Normalize scaling" \
-        -variable [itcl::scope _settings(-glyphnormscale)] \
-        -command [itcl::code $this AdjustSetting -glyphnormscale] \
-        -font "Arial 9"
-    Rappture::Tooltip::for $inner.normscale "If enabled, field values are normalized to \[0,1\] before scaling and scale factor is relative to a default size"
-
-    checkbutton $inner.gorient \
-        -text "Orient" \
-        -variable [itcl::scope _settings(-glyphorient)] \
-        -command [itcl::code $this AdjustSetting -glyphorient] \
-        -font "Arial 9"
-    Rappture::Tooltip::for $inner.gorient "Orient glyphs by vector field directions"
-
-    checkbutton $inner.wireframe \
-        -text "Wireframe" \
-        -variable [itcl::scope _settings(-glyphwireframe)] \
-        -command [itcl::code $this AdjustSetting -glyphwireframe] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-glyphlighting)] \
-        -command [itcl::code $this AdjustSetting -glyphlighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.edges \
-        -text "Edges" \
-        -variable [itcl::scope _settings(-glyphedges)] \
-        -command [itcl::code $this AdjustSetting -glyphedges] \
-        -font "Arial 9"
-
-    checkbutton $inner.outline \
-        -text "Outline" \
-        -variable [itcl::scope _settings(-outline)] \
-        -command [itcl::code $this AdjustSetting -outline] \
-        -font "Arial 9"
-
-    checkbutton $inner.legend \
-        -text "Legend" \
-        -variable [itcl::scope _settings(-legendvisible)] \
-        -command [itcl::code $this AdjustSetting -legendvisible] \
-        -font "Arial 9"
-
-    label $inner.background_l -text "Background" -font "Arial 9"
-    itk_component add background {
-        Rappture::Combobox $inner.background -width 10 -editable 0
-    }
-    $inner.background choices insert end \
-        "black"              "black"            \
-        "white"              "white"            \
-        "grey"               "grey"
-
-    $itk_component(background) value $_settings(-background)
-    bind $inner.background <<Value>> \
-        [itcl::code $this AdjustSetting -background]
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _widget(-glyphopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -glyphopacity]
-    $inner.opacity set [expr $_settings(-glyphopacity) * 100.0]
-
-    label $inner.gscale_l -text "Scale factor" -font "Arial 9"
-    if {0} {
-    ::scale $inner.gscale -from 1 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-glyphscale)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -glyphscale]
-    } else {
-    itk_component add gscale {
-        entry $inner.gscale -font "Arial 9" -bg white \
-            -textvariable [itcl::scope _settings(-glyphscale)]
-    } {
-        ignore -font -background
-    }
-    bind $inner.gscale <Return> \
-        [itcl::code $this AdjustSetting -glyphscale]
-    bind $inner.gscale <KP_Enter> \
-        [itcl::code $this AdjustSetting -glyphscale]
-    }
-    Rappture::Tooltip::for $inner.gscale "Set scaling multiplier (or constant size)"
-
-    itk_component add field_l {
-        label $inner.field_l -text "Color By" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add field {
-        Rappture::Combobox $inner.field -width 10 -editable 0
-    }
-    bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting -field]
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9"
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList -includeNone]
-    $itk_component(colormap) value "BCGYR"
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -colormap]
-
-    # add widgets for setting a custom range on the legend
-
-    itk_component add crange {
-        checkbutton $inner.crange \
-            -text "Use Custom Range:" \
-            -variable [itcl::scope _settings(-customrange)] \
-            -command [itcl::code $this ToggleCustomRange] \
-            -font "Arial 9"
-    }
-
-    itk_component add l_min {
-        label $inner.l_min -text "Min" -font "Arial 9"
-    }
-    itk_component add min {
-        Rappture::Gauge $inner.min -font "Arial 9" \
-            -validatecommand [itcl::code $this LegendRangeValidate "" vmin]
-    }
-    bind $itk_component(min) <<Value>> \
-        [itcl::code $this AdjustSetting -range]
-
-    itk_component add l_max {
-        label $inner.l_max -text "Max" -font "Arial 9"
-    }
-    itk_component add max {
-        Rappture::Gauge $inner.max -font "Arial 9" \
-            -validatecommand [itcl::code $this LegendRangeValidate "" vmax]
-    }
-    bind $itk_component(max) <<Value>> \
-        [itcl::code $this AdjustSetting -range]
-
-    $itk_component(min) configure -state disabled
-    $itk_component(max) configure -state disabled
-
-    blt::table $inner \
-        0,0 $inner.field_l      -anchor w -pady 2 \
-        0,1 $inner.field        -anchor w -pady 2 -fill x \
-        1,0 $inner.colormap_l   -anchor w -pady 2 \
-        1,1 $inner.colormap     -anchor w -pady 2 -fill x \
-        2,0 $inner.gshape_l     -anchor w -pady 2 \
-        2,1 $inner.gshape       -anchor w -pady 2 -fill x \
-        3,0 $inner.background_l -anchor w -pady 2 \
-        3,1 $inner.background   -anchor w -pady 2 -fill x \
-        4,0 $inner.scaleMode_l  -anchor w -pady 2 \
-        4,1 $inner.scaleMode    -anchor w -pady 2 -fill x \
-        5,0 $inner.gscale_l     -anchor w -pady 2 \
-        5,1 $inner.gscale       -anchor w -pady 2 -fill x \
-        6,0 $inner.normscale    -anchor w -pady 2 -cspan 2 \
-        7,0 $inner.gorient      -anchor w -pady 2 -cspan 2 \
-        8,0 $inner.wireframe    -anchor w -pady 2 -cspan 2 \
-        9,0 $inner.lighting     -anchor w -pady 2 -cspan 2 \
-        10,0 $inner.edges       -anchor w -pady 2 -cspan 2 \
-        11,0 $inner.outline     -anchor w -pady 2 -cspan 2 \
-        12,0 $inner.legend      -anchor w -pady 2 \
-        13,0 $inner.opacity_l   -anchor w -pady 2 \
-        13,1 $inner.opacity     -anchor w -pady 2 -fill x \
-        14,0 $inner.crange      -anchor w -pady 2 -cspan 2 \
-        15,0 $inner.l_min       -anchor w -pady 2 \
-        15,1 $inner.min         -anchor w -pady 2 -fill x \
-        16,0 $inner.l_max       -anchor w -pady 2 \
-        16,1 $inner.max         -anchor w -pady 2 -fill x \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r17 c1 -resize expand
-}
-
-itcl::body Rappture::VtkGlyphViewer::BuildAxisTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _settings(-axislabels)] \
-        -command [itcl::code $this AdjustSetting -axislabels] \
-        -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9"
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _settings(-xgrid)] \
-        -command [itcl::code $this AdjustSetting -xgrid] \
-        -font "Arial 9"
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _settings(-ygrid)] \
-        -command [itcl::code $this AdjustSetting -ygrid] \
-        -font "Arial 9"
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _settings(-zgrid)] \
-        -command [itcl::code $this AdjustSetting -zgrid] \
-        -font "Arial 9"
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _settings(-axisminorticks)] \
-        -command [itcl::code $this AdjustSetting -axisminorticks] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-
-    itk_component add axisMode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axisMode) value $_settings(-axismode)
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
-
-    blt::table $inner \
-        0,0 $inner.visible    -anchor w -cspan 4 \
-        1,0 $inner.labels     -anchor w -cspan 4 \
-        2,0 $inner.minorticks -anchor w -cspan 4 \
-        4,0 $inner.grid_l     -anchor w \
-        4,1 $inner.xgrid      -anchor w \
-        4,2 $inner.ygrid      -anchor w \
-        4,3 $inner.zgrid      -anchor w \
-        5,0 $inner.mode_l     -anchor w -padx { 2 0 } \
-        5,1 $inner.mode       -fill x   -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-itcl::body Rappture::VtkGlyphViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set labels { qx qy qz qw xpan ypan zoom }
-    set row 1
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this AdjustSetting -ortho] \
-        -font "Arial 9"
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-itcl::body Rappture::VtkGlyphViewer::BuildCutplanesTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Cutplane Settings" \
-        -icon [Rappture::icon cutbutton]]
-
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Cutplanes" \
-        -variable [itcl::scope _settings(-cutplanesvisible)] \
-        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.wireframe \
-        -text "Wireframe" \
-        -variable [itcl::scope _settings(-cutplanewireframe)] \
-        -command [itcl::code $this AdjustSetting -cutplanewireframe] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-cutplanelighting)] \
-        -command [itcl::code $this AdjustSetting -cutplanelighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.edges \
-        -text "Edges" \
-        -variable [itcl::scope _settings(-cutplaneedges)] \
-        -command [itcl::code $this AdjustSetting -cutplaneedges] \
-        -font "Arial 9"
-
-    checkbutton $inner.preinterp \
-        -text "Interpolate Scalars" \
-        -variable [itcl::scope _settings(-cutplanepreinterp)] \
-        -command [itcl::code $this AdjustSetting -cutplanepreinterp] \
-        -font "Arial 9"
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _widget(-cutplaneopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -cutplaneopacity]
-    $inner.opacity set [expr $_settings(-cutplaneopacity) * 100.0]
-
-    # X-value slicer...
-    itk_component add xbutton {
-        Rappture::PushButton $inner.xbutton \
-            -onimage [Rappture::icon x-cutplane-red] \
-            -offimage [Rappture::icon x-cutplane-red] \
-            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
-            -variable [itcl::scope _settings(-xcutplanevisible)] \
-    }
-    Rappture::Tooltip::for $itk_component(xbutton) \
-        "Toggle the X-axis cutplane on/off"
-    $itk_component(xbutton) select
-    itk_component add xposition {
-        ::scale $inner.xval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane x] \
-            -variable [itcl::scope _settings(-xcutplaneposition)] \
-            -foreground red2 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font -background
-    }
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(xposition) set 50
-    $itk_component(xposition) configure -state disabled
-    Rappture::Tooltip::for $itk_component(xposition) \
-        "@[itcl::code $this Slice tooltip x]"
-
-    # Y-value slicer...
-    itk_component add ybutton {
-        Rappture::PushButton $inner.ybutton \
-            -onimage [Rappture::icon y-cutplane-green] \
-            -offimage [Rappture::icon y-cutplane-green] \
-            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
-            -variable [itcl::scope _settings(-ycutplanevisible)] \
-    }
-    Rappture::Tooltip::for $itk_component(ybutton) \
-        "Toggle the Y-axis cutplane on/off"
-    $itk_component(ybutton) select
-
-    itk_component add yposition {
-        ::scale $inner.yval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane y] \
-            -variable [itcl::scope _settings(-ycutplaneposition)] \
-            -foreground green3 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font
-    }
-    Rappture::Tooltip::for $itk_component(yposition) \
-        "@[itcl::code $this Slice tooltip y]"
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(yposition) set 50
-    $itk_component(yposition) configure -state disabled
-
-    # Z-value slicer...
-    itk_component add zbutton {
-        Rappture::PushButton $inner.zbutton \
-            -onimage [Rappture::icon z-cutplane-blue] \
-            -offimage [Rappture::icon z-cutplane-blue] \
-            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
-            -variable [itcl::scope _settings(-zcutplanevisible)] \
-    } {
-        usual
-        ignore -foreground
-    }
-    Rappture::Tooltip::for $itk_component(zbutton) \
-        "Toggle the Z-axis cutplane on/off"
-    $itk_component(zbutton) select
-
-    itk_component add zposition {
-        ::scale $inner.zval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane z] \
-            -variable [itcl::scope _settings(-zcutplaneposition)] \
-            -foreground blue3 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font
-    }
-    $itk_component(zposition) set 50
-    $itk_component(zposition) configure -state disabled
-    Rappture::Tooltip::for $itk_component(zposition) \
-        "@[itcl::code $this Slice tooltip z]"
-
-    blt::table $inner \
-        0,0 $inner.visible   -anchor w -pady 2 -cspan 3 \
-        1,0 $inner.lighting  -anchor w -pady 2 -cspan 3 \
-        2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \
-        3,0 $inner.edges     -anchor w -pady 2 -cspan 3 \
-        4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \
-        5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \
-        5,1 $inner.opacity   -fill x   -pady 2 -cspan 3 \
-        6,0 $inner.xbutton   -anchor w -padx 2 -pady 2 \
-        7,0 $inner.ybutton   -anchor w -padx 2 -pady 2 \
-        8,0 $inner.zbutton   -anchor w -padx 2 -pady 2 \
-        6,1 $inner.xval      -fill y -rspan 4 \
-        6,2 $inner.yval      -fill y -rspan 4 \
-        6,3 $inner.zval      -fill y -rspan 4 \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r9 c4 -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkGlyphViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        foreach cname [$dataobj components] {
-            set tag $dataobj-$cname
-            set contents [$dataobj vtkdata $cname]
-            append bytes "$contents\n"
-        }
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkGlyphViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkGlyphViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::VtkGlyphViewer::SetObjectStyle { dataobj comp } {
-    DebugTrace "Enter"
-    # Parse style string.
-    set tag $dataobj-$comp
-    array set style {
-        -color                  BCGYR
-        -constcolor             white
-        -colormode              vmag
-        -cutplaneedges          0
-        -cutplanelighting       1
-        -cutplaneopacity        1.0
-        -cutplanepreinterp      1
-        -cutplanesvisible       0
-        -cutplanewireframe      0
-        -edgecolor              black
-        -edges                  0
-        -glyphsvisible          1
-        -gscale                 1
-        -lighting               1
-        -linewidth              1.0
-        -normscale              1
-        -opacity                1.0
-        -orientglyphs           1
-        -outline                0
-        -ptsize                 1.0
-        -quality                1
-        -scalemode              vmag
-        -shape                  arrow
-        -wireframe              0
-        -xcutplaneposition      50
-        -xcutplanevisible       1
-        -ycutplaneposition      50
-        -ycutplanevisible       1
-        -zcutplaneposition      50
-        -zcutplanevisible       1
-    }
-    set style(-constcolor) $itk_option(-plotforeground)
-    set numComponents [$dataobj numComponents $comp]
-    if {$numComponents == 3} {
-        set style(-shape) "arrow"
-        set style(-orientglyphs) 1
-        set style(-scalemode) "vmag"
-        set style(-colormode) "vmag"
-    } else {
-        set style(-shape) "sphere"
-        set style(-orientglyphs) 0
-        set style(-scalemode) "scalar"
-        set style(-colormode) "scalar"
-    }
-    array set style [$dataobj style $comp]
-    # Backwards compat with camel case style option
-    if { [info exists style(-orientGlyphs)] } {
-        set style(-orientglyphs) $style(-orientGlyphs)
-        array unset style -orientGlyphs
-    }
-    # Backwards compat with camel case style option
-    if { [info exists style(-scaleMode)] } {
-        set style(-scalemode) $style(-scaleMode)
-        array unset style -scaleMode
-    }
-
-    # This is too complicated.  We want to set the colormap and opacity
-    # for the dataset.  They can be the default values,
-    # the style hints loaded with the dataset, or set by user controls.  As
-    # datasets get loaded, they first use the defaults that are overidden
-    # by the style hints.  If the user changes the global controls, then that
-    # overrides everything else.  I don't know what it means when global
-    # controls are specified as style hints by each dataset.  It complicates
-    # the code to handle aberrant cases.
-
-    if { $_changed(-glyphedges) } {
-        set style(-edges) $_settings(-glyphedges)
-    }
-    if { $_changed(-glyphlighting) } {
-        set style(-lighting) $_settings(-glyphlighting)
-    }
-    if { $_changed(-glyphnormscale) } {
-        set style(-normscale) $_settings(-glyphnormscale)
-    }
-    if { $_changed(-glyphopacity) } {
-        set style(-opacity) $_settings(-glyphopacity)
-    }
-    if { $_changed(-glyphorient) } {
-        set style(-orientglyphs) $_settings(-glyphorient)
-    }
-    if { $_changed(-glyphscale) } {
-        set style(-gscale) $_settings(-glyphscale)
-    }
-    if { $_changed(-glyphwireframe) } {
-        set style(-wireframe) $_settings(-glyphwireframe)
-    }
-    if { $_changed(-colormap) } {
-        set style(-color) $_settings(-colormap)
-    }
-    if { $_currentColormap == "" } {
-        $itk_component(colormap) value $style(-color)
-    }
-    foreach setting {-outline -glyphsvisible -cutplanesvisible \
-                     -xcutplanevisible -ycutplanevisible -zcutplanevisible \
-                     -xcutplaneposition -ycutplaneposition -zcutplaneposition \
-                     -cutplaneedges -cutplanelighting -cutplaneopacity \
-                     -cutplanepreinterp -cutplanewireframe} {
-        if {$_changed($setting)} {
-            # User-modified UI setting overrides style
-            set style($setting) $_settings($setting)
-        } else {
-            # Set UI control to style setting (tool provided or default)
-            set _settings($setting) $style($setting)
-        }
-    }
-
-    if 0 {
-    SendCmd "cutplane add $tag"
-    SendCmd "cutplane visible 0 $tag"
-    foreach axis {x y z} {
-        set pos [expr $style(-${axis}cutplaneposition) * 0.01]
-        set visible $style(-${axis}cutplanevisible)
-        SendCmd "cutplane slice $axis $pos $tag"
-        SendCmd "cutplane axis $axis $visible $tag"
-    }
-    SendCmd "cutplane edges $style(-cutplaneedges) $tag"
-    SendCmd "cutplane lighting $style(-cutplanelighting) $tag"
-    SendCmd "cutplane opacity $style(-cutplaneopacity) $tag"
-    set _widget(-cutplaneopacity) [expr $style(-cutplaneopacity) * 100]
-    SendCmd "cutplane preinterp $style(-cutplanepreinterp) $tag"
-    SendCmd "cutplane wireframe $style(-cutplanewireframe) $tag"
-    SendCmd "cutplane visible $style(-cutplanesvisible) $tag"
-    }
-
-    SendCmd "outline add $tag"
-    SendCmd "outline color [Color2RGB $style(-constcolor)] $tag"
-    SendCmd "outline visible $style(-outline) $tag"
-
-    SendCmd "glyphs add $style(-shape) $tag"
-    set _settings(-glyphshape) $style(-shape)
-    $itk_component(gshape) value $style(-shape)
-    SendCmd "glyphs visible $style(-glyphsvisible) $tag"
-    SendCmd "glyphs edges $style(-edges) $tag"
-    set _settings(-glyphedges) $style(-edges)
-
-    # normscale=1 and gscale=1 are defaults
-    if {$style(-normscale) != 1} {
-        SendCmd "glyphs normscale $style(-normscale) $tag"
-    }
-    if {$style(-gscale) != 1} {
-        SendCmd "glyphs gscale $style(-gscale) $tag"
-    }
-    set _settings(-glyphnormscale) $style(-normscale)
-    set _settings(-glyphscale) $style(-gscale)
-
-    if {$style(-colormode) == "constant" || $style(-color) == "none"} {
-        SendCmd "glyphs colormode constant {} $tag"
-        set _settings(-colormapvisible) 0
-        set _settings(-colormap) "none"
-    } else {
-        SendCmd [list glyphs colormode $style(-colormode) $_curFldName $tag]
-        set _settings(-colormapvisible) 1
-        set _settings(-colormap) $style(-color)
-        SetCurrentColormap $style(-color)
-    }
-    $itk_component(colormap) value $_settings(-colormap)
-    set _colorMode $style(-colormode)
-    # constant color only used if colormode set to constant
-    SendCmd "glyphs color [Color2RGB $style(-constcolor)] $tag"
-    # Omitting field name for gorient and smode commands
-    # defaults to active scalars or vectors depending on mode
-    SendCmd "glyphs gorient $style(-orientglyphs) {} $tag"
-    set _settings(-glyphorient) $style(-orientglyphs)
-    SendCmd "glyphs smode $style(-scalemode) {} $tag"
-    set _settings(-glyphscalemode) $style(-scalemode)
-    $itk_component(scaleMode) value "[$itk_component(scaleMode) label $style(-scalemode)]"
-    SendCmd "glyphs quality $style(-quality) $tag"
-    SendCmd "glyphs lighting $style(-lighting) $tag"
-    set _settings(-glyphlighting) $style(-lighting)
-    SendCmd "glyphs linecolor [Color2RGB $style(-edgecolor)] $tag"
-    SendCmd "glyphs linewidth $style(-linewidth) $tag"
-    SendCmd "glyphs ptsize $style(-ptsize) $tag"
-    SendCmd "glyphs opacity $style(-opacity) $tag"
-    set _settings(-glyphopacity) $style(-opacity)
-    set _widget(-glyphopacity) [expr $style(-opacity) * 100.0]
-    SendCmd "glyphs wireframe $style(-wireframe) $tag"
-    set _settings(-glyphwireframe) $style(-wireframe)
-}
-
-itcl::body Rappture::VtkGlyphViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-#
-# EnterLegend --
-#
-itcl::body Rappture::VtkGlyphViewer::EnterLegend { x y } {
-    SetLegendTip $x $y
-}
-
-#
-# MotionLegend --
-#
-itcl::body Rappture::VtkGlyphViewer::MotionLegend { x y } {
-    Rappture::Tooltip::tooltip cancel
-    set c $itk_component(view)
-    set cw [winfo width $c]
-    set ch [winfo height $c]
-    if { $x >= 0 && $x < $cw && $y >= 0 && $y < $ch } {
-        SetLegendTip $x $y
-    }
-}
-
-#
-# LeaveLegend --
-#
-itcl::body Rappture::VtkGlyphViewer::LeaveLegend { } {
-    Rappture::Tooltip::tooltip cancel
-    .rappturetooltip configure -icon ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendPointToValue <x> <y>
-#
-# Convert an x,y point on the legend to a numeric field value.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::LegendPointToValue { x y } {
-    set fname $_curFldName
-
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set ih [image height $_image(legend)]
-    set iy [expr $y - ($lineht + 2)]
-
-    # Compute the value of the point
-    if { [info exists _limits($fname)] } {
-        if { $_settings(-customrange) } {
-            set vmin [$itk_component(min) value]
-            set vmax [$itk_component(max) value]
-        } else {
-            foreach { vmin vmax } $_limits($fname) break
-        }
-        set t [expr 1.0 - (double($iy) / double($ih-1))]
-        set value [expr $t * ($vmax - $vmin) + $vmin]
-    } else {
-        set value 0.0
-    }
-    return $value
-}
-
-#
-# SetLegendTip --
-#
-itcl::body Rappture::VtkGlyphViewer::SetLegendTip { x y } {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set ih [image height $_image(legend)]
-    set iy [expr $y - ($lineht + 2)]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a legend title, increase the offset by the line height.
-    if { $title != "" } {
-        incr iy -$lineht
-    }
-    # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
-        return
-    }
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    set color [eval format "\#%02x%02x%02x" $pixel]
-    $_image(swatch) put black  -to 0 0 23 23
-    $_image(swatch) put $color -to 1 1 22 22
-    .rappturetooltip configure -icon $_image(swatch)
-
-    # Compute the value of the point
-    set value [LegendPointToValue $x $y]
-
-    # Setup the location of the tooltip
-    set tx [expr $x + 15]
-    set ty [expr $y - 5]
-
-    # Setup the text for the tooltip
-    Rappture::Tooltip::text $c [format "$title %g" $value]
-
-    # Show the tooltip
-    Rappture::Tooltip::tooltip show $c +$tx,+$ty
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Slice move x|y|z <newval>
-#
-# Called automatically when the user drags the slider to move the
-# cut plane that slices 3D data.  Gets the current value from the
-# slider and moves the cut plane to the appropriate point in the
-# data set.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::Slice {option args} {
-    switch -- $option {
-        "move" {
-            set axis [lindex $args 0]
-            set newval [lindex $args 1]
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Slice move x|y|z newval\""
-            }
-            set newpos [expr {0.01*$newval}]
-            SendCmd "cutplane slice $axis $newpos"
-        }
-        "tooltip" {
-            set axis [lindex $args 0]
-            set val [$itk_component(${axis}position) get]
-            return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
-        }
-        default {
-            error "bad option \"$option\": should be axis, move, or tooltip"
-        }
-    }
-}
-
-#
-# ReceiveLegend --
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-#
-itcl::body Rappture::VtkGlyphViewer::ReceiveLegend { colormap title min max size } {
-    DebugTrace "Enter"
-    set _title $title
-    regsub {\(mag\)} $title "" _title
-    if { [IsConnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend)] } {
-            set _image(legend) [image create photo]
-        }
-        $_image(legend) configure -data $bytes
-        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-        if { [catch {DrawLegend} errs] != 0 } {
-            global errorInfo
-            puts stderr "errs=$errs errorInfo=$errorInfo"
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-# Draws the legend on the canvas on the right side of the plot area.
-#
-itcl::body Rappture::VtkGlyphViewer::DrawLegend {} {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    set x [expr $w - 2]
-    if { !$_settings(-legendvisible) } {
-        $c delete legend
-        return
-    }
-    if { [$c find withtag "legend"] == "" } {
-        set y 2
-        # If there's a legend title, create a text item for the title.
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "title legend" \
-            -font $font
-        if { $title != "" } {
-            incr y $lineht
-        }
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "vmax legend" \
-            -font $font
-        incr y $lineht
-        $c create image $x $y \
-            -anchor ne \
-            -image $_image(legend) -tags "colormap legend"
-        $c create rectangle $x $y 1 1 \
-            -fill "" -outline "" -tags "sensor legend"
-        $c create text $x [expr {$h-2}] \
-            -anchor se \
-            -fill $itk_option(-plotforeground) -tags "vmin legend" \
-            -font $font
-        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
-        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
-        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
-    }
-    set x2 $x
-    set iw [image width $_image(legend)]
-    set ih [image height $_image(legend)]
-    set x1 [expr $x2 - ($iw*12)/10]
-
-    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
-    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
-    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
-    # Reset the item coordinates according the current size of the plot.
-    $c itemconfigure title -text $title
-    if { [info exists _limits($_curFldName)] } {
-        if { $_settings(-customrange) } {
-            set vmin [$itk_component(min) value]
-            set vmax [$itk_component(max) value]
-        } else {
-            foreach { vmin vmax } $_limits($_curFldName) break
-        }
-        $c itemconfigure vmin -text [format %g $vmin]
-        $c itemconfigure vmax -text [format %g $vmax]
-    }
-    set y 2
-    # If there's a legend title, move the title to the correct position
-    if { $title != "" } {
-        $c itemconfigure title -text $title
-        $c coords title $x $y
-        incr y $lineht
-        $c raise title
-    }
-    $c coords vmax $x $y
-    incr y $lineht
-    $c coords colormap $x $y
-    $c coords sensor [expr $x - $iw] $y $x [expr $y + $ih]
-    $c raise sensor
-    $c coords vmin $x [expr {$h - 2}]
-
-    $c bind vmin <ButtonPress> [itcl::code $this LegendRangeAction popup vmin]
-    $c bind vmin <Enter> [itcl::code $this LegendRangeAction enter vmin]
-    $c bind vmin <Leave> [itcl::code $this LegendRangeAction leave vmin]
-
-    $c bind vmax <ButtonPress> [itcl::code $this LegendRangeAction popup vmax]
-    $c bind vmax <Enter> [itcl::code $this LegendRangeAction enter vmax]
-    $c bind vmax <Leave> [itcl::code $this LegendRangeAction leave vmax]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendTitleAction post
-# USAGE: LegendTitleAction enter
-# USAGE: LegendTitleAction leave
-# USAGE: LegendTitleAction save
-#
-# Used internally to handle the dropdown list for the fields menu combobox.
-# The post option is invoked when the field title is pressed to launch the
-# dropdown.  The enter option is invoked when the user mouses over the field
-# title. The leave option is invoked when the user moves the mouse away
-# from the field title.  The save option is invoked whenever there is a
-# selection from the list, to alert the visualization server.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::LegendTitleAction {option} {
-    set c $itk_component(view)
-    switch -- $option {
-        post {
-            foreach { x1 y1 x2 y2 } [$c bbox title] break
-            set cw [winfo width $itk_component(view)]
-            set mw [winfo reqwidth $itk_component(fieldmenu)]
-            set x1 [expr $cw - $mw]
-            set x [expr $x1 + [winfo rootx $itk_component(view)]]
-            set y [expr $y2 + [winfo rooty $itk_component(view)]]
-            tk_popup $itk_component(fieldmenu) $x $y
-        }
-        enter {
-            $c itemconfigure title -fill red
-        }
-        leave {
-            $c itemconfigure title -fill $itk_option(-plotforeground)
-        }
-        save {
-            $itk_component(field) value $_curFldLabel
-            AdjustSetting -field
-        }
-        default {
-            error "bad option \"$option\": should be post, enter, leave or save"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendRangeValidate <widget> <which> <value>
-#
-# Used internally to validate a legend range min/max value.
-# Returns a boolean value telling if <value> was accepted (1) or rejected (0)
-# If the value is rejected, a tooltip/warning message is popped up
-# near the widget that asked for the validation, specified by <widget>
-#
-# <widget> is the widget where a tooltip/warning message should show up on
-# <which> is either "vmin" or "vmax".
-# <value> is the value to be validated.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::LegendRangeValidate {widget which value} {
-    #check for a valid value
-    if {[string is double $value] != 1} {
-        set msg "should be valid number"
-        if {$widget != ""} {
-            Rappture::Tooltip::cue $widget $msg
-        } else {
-            # error "bad value \"$value\": $msg"
-            error $msg
-        }
-        return 0
-    }
-
-    switch -- $which {
-        vmin {
-            # check for min > max
-            if {$value > [$itk_component(max) value]} {
-                set msg "min > max, change max first"
-                if {$widget != ""} {
-                    Rappture::Tooltip::cue $widget $msg
-                } else {
-                    # error "bad value \"$value\": $msg"
-                    error $msg
-                }
-                return 0
-            }
-        }
-        vmax {
-            # check for max < min
-            if {$value < [$itk_component(min) value]} {
-                set msg "max < min, change min first"
-                if {$widget != ""} {
-                    Rappture::Tooltip::cue $widget $msg
-                } else {
-                    # error "bad value \"$value\": $msg"
-                    error $msg
-                }
-                return 0
-            }
-        }
-        default {
-            error "bad option \"$which\": should be vmin, vmax"
-        }
-    }
-}
-
-itcl::body Rappture::VtkGlyphViewer::MouseOver2Which {} {
-    switch -- $_mouseOver {
-        vmin {
-            set which min
-        }
-        vmax {
-            set which max
-        }
-        default {
-            error "bad _mouseOver \"$_mouseOver\": should be vmin, vmax"
-        }
-    }
-    return $which
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendRangeAction enter <which>
-# USAGE: LegendRangeAction leave <which>
-#
-# USAGE: LegendRangeAction popup <which>
-# USAGE: LegendRangeAction activate
-# USAGE: LegendRangeAction validate <value>
-# USAGE: LegendRangeAction apply <value>
-#
-# Used internally to handle the mouseover and popup entry for the field range
-# inputs.  The enter option is invoked when the user moves the mouse over the
-# min or max field range. The leave option is invoked when the user moves the
-# mouse away from the min or max field range. The popup option is invoked when
-# the user click's on a field range. The popup option stores internally which
-# widget is requesting a popup ( in the _mouseOver variable) and calls the
-# activate command of the widget. The widget's activate command calls back to
-# this method to get the xywh dimensions of the popup editor. After the user
-# changes focus or sets the value in the editor, the editor calls this methods
-# validate and apply options to set the value.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::LegendRangeAction {option args} {
-    set c $itk_component(view)
-
-    switch -- $option {
-        enter {
-            set which [lindex $args 0]
-            $c itemconfigure $which -fill red
-        }
-        leave {
-            set which [lindex $args 0]
-            $c itemconfigure $which -fill $itk_option(-plotforeground)
-        }
-        popup {
-            DisableMouseRotationBindings
-            set which [lindex $args 0]
-            set _mouseOver $which
-            $itk_component(editor) activate
-        }
-        activate {
-            foreach { x1 y1 x2 y2 } [$c bbox $_mouseOver] break
-            set which [MouseOver2Which]
-            set info(text) [$itk_component($which) value]
-            set info(x) [expr $x1 + [winfo rootx $c]]
-            set info(y) [expr $y1 + [winfo rooty $c]]
-            set info(w) [expr $x2 - $x1]
-            set info(h) [expr $y2 - $y1]
-            return [array get info]
-        }
-        validate {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"editor validate value\""
-            }
-
-            set value [lindex $args 0]
-            if {[LegendRangeValidate $itk_component(editor) $_mouseOver $value] == 0} {
-                return 0
-            }
-
-            # value was good, apply it
-            # reset the mouse rotation bindings
-            SetupMouseRotationBindings
-        }
-        apply {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"editor apply value\""
-            }
-            set value [string trim [lindex $args 0]]
-
-            set which [MouseOver2Which]
-
-            # only set custom range if value changed
-            if {[$itk_component($which) value] != $value} {
-                # set the flag stating the custom range came from the legend
-                # change the value in the gauge
-                # turn on crange to enable the labels and gauges
-                # call AdjustSetting -range (inside ToggleCustomRange)
-                # to update drawing and legend
-                set _customRangeClick 0
-                $itk_component($which) value $value
-                $itk_component(crange) select
-                ToggleCustomRange
-            }
-        }
-        default {
-            error "bad option \"$option\": should be enter, leave, activate, validate, apply"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ToggleCustomRange
-#
-# Called whenever the custom range is turned on or off. Used to save
-# the custom min and custom max set by the user. When the -customrange
-# setting is turned on, the range min and range max gauges are set
-# with the last value set by the user, or the default range if no
-# previous min and max were set.
-#
-# When the custom range is turned on, we check how it was turned on
-# by querying _customRangeClick. If the variable is 1, this means
-# the user clicked the crange checkbutton and we should pull the
-# custom range values from our backup variables. If the variable is 0,
-# the custom range was enabled through the user manipulating the
-# min and max value in the legend.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::ToggleCustomRange {args} {
-    if { ! $_settings(-customrange) } {
-        # custom range was turned off
-
-        # disable the min/max labels and gauge widgets
-        $itk_component(l_min) configure -state disabled
-        $itk_component(min) configure -state disabled
-        $itk_component(l_max) configure -state disabled
-        $itk_component(max) configure -state disabled
-
-        # backup the custom range
-        set _settings(-customrangemin) [$itk_component(min) value]
-        set _settings(-customrangemax) [$itk_component(max) value]
-
-        # set the gauges to dataset's min and max
-        foreach { vmin vmax } $_limits($_curFldName) break
-        SetMinMaxGauges $vmin $vmax
-    } else {
-        # custom range was turned on
-
-        # enable the min/max labels and gauge widgets
-        $itk_component(l_min) configure -state normal
-        $itk_component(min) configure -state normal
-        $itk_component(l_max) configure -state normal
-        $itk_component(max) configure -state normal
-
-        # if the custom range is being turned on by clicking the
-        # checkbox, restore the min and max gauges from the backup
-        # variables. otherwise, new values for the min and max
-        # widgets will be set later from the legend's editor.
-        if { $_customRangeClick } {
-            SetMinMaxGauges $_settings(-customrangemin) $_settings(-customrangemax)
-        }
-
-        # reset the click flag
-        set _customRangeClick 1
-    }
-    AdjustSetting -range
-}
-
-# ----------------------------------------------------------------------
-# USAGE: SetMinMaxGauges <min> <max>
-#
-# Set the min and max gauges in the correct order, avoiding the
-# error where you try to set the min > max before updating the max or
-# set the max < min before updating the min.
-#
-# There are five range cases to consider with our current range validation.
-# For example:
-# [2,3] -> [0,1]       : update min first, max last
-# [2,3] -> [4,5]       : update max first, min last
-# [2,3] -> [0,2.5]     : update min or max first
-# [2,3] -> [2.5,5]     : update min or max first
-# [2,3] -> [2.25,2.75] : update min or max first
-#
-# In 4 of the cases we can update min first and max last, so we only
-# need to check the case where old max < new min, where we update
-# max first and min last.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkGlyphViewer::SetMinMaxGauges {min max} {
-
-    if { [$itk_component(max) value] < $min} {
-        # old max < new min
-        # shift range toward right
-        # extend max first, then update min
-        $itk_component(max) value $max
-        $itk_component(min) value $min
-    } else {
-        # extend min first, then update max
-        $itk_component(min) value $min
-        $itk_component(max) value $max
-    }
-}
-
-#
-# SetCurrentColormap --
-#
-itcl::body Rappture::VtkGlyphViewer::SetCurrentColormap { name } {
-    # Keep track of the colormaps that we build.
-    if { ![info exists _colormaps($name)] } {
-        BuildColormap $name
-        set _colormaps($name) 1
-    }
-    set _currentColormap $name
-    SendCmd "glyphs colormap $_currentColormap"
-    #SendCmd "cutplane colormap $_currentColormap"
-}
-
-#
-# BuildColormap --
-#
-# Build the designated colormap on the server.
-#
-itcl::body Rappture::VtkGlyphViewer::BuildColormap { name } {
-    set cmap [ColorsToColormap $name]
-    if { [llength $cmap] == 0 } {
-        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
-    }
-    set amap "0.0 1.0 1.0 1.0"
-    SendCmd "colormap add $name { $cmap } { $amap }"
-}
-
-itcl::body Rappture::VtkGlyphViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
-
-itcl::body Rappture::VtkGlyphViewer::SetCurrentFieldName { dataobj } {
-    set _first $dataobj
-    $itk_component(field) choices delete 0 end
-    $itk_component(fieldmenu) delete 0 end
-    array unset _fields
-    set _curFldName ""
-    foreach cname [$_first components] {
-        foreach fname [$_first fieldnames $cname] {
-            if { [info exists _fields($fname)] } {
-                continue
-            }
-            foreach { label units components } \
-                [$_first fieldinfo $fname] break
-            $itk_component(field) choices insert end "$fname" "$label"
-            $itk_component(fieldmenu) add radiobutton -label "$label" \
-                -value $label -variable [itcl::scope _curFldLabel] \
-                -selectcolor red \
-                -activebackground $itk_option(-plotbackground) \
-                -activeforeground $itk_option(-plotforeground) \
-                -font "Arial 8" \
-                -command [itcl::code $this LegendTitleAction save]
-            set _fields($fname) [list $label $units $components]
-            if { $_curFldName == "" } {
-                set _curFldName $fname
-                set _curFldLabel $label
-                set _curFldComp $components
-            }
-        }
-    }
-    $itk_component(field) value $_curFldLabel
-    if { $_settings(-customrange) } {
-        set vmin [$itk_component(min) value]
-        set vmax [$itk_component(max) value]
-        SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName point_data $_curFldComp]
-    } else {
-        if { ![info exists _limits($_curFldName)] } {
-            SendCmd "dataset maprange all"
-        } else {
-            foreach { vmin vmax } $_limits($_curFldName) break
-            SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName point_data $_curFldComp]
-        }
-    }
-}
Index: trunk/gui/scripts/vtkheightmapviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkheightmapviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,2682 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtkheightmapviewer - Vtk heightmap viewer
-#
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *VtkHeightmapViewer.width 4i widgetDefault
-option add *VtkHeightmapViewer*cursor crosshair widgetDefault
-option add *VtkHeightmapViewer.height 4i widgetDefault
-option add *VtkHeightmapViewer.foreground black widgetDefault
-option add *VtkHeightmapViewer.controlBackground gray widgetDefault
-option add *VtkHeightmapViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkHeightmapViewer.plotBackground black widgetDefault
-option add *VtkHeightmapViewer.plotForeground white widgetDefault
-option add *VtkHeightmapViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkHeightmapViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkHeightmapViewer::SetServerList
-}
-
-itcl::class Rappture::VtkHeightmapViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-    itk_option define -mode mode Mode "contour"
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildColormap { name }
-    private method BuildContourTab {}
-    private method BuildDownloadPopup { widget command }
-    private method CameraReset {}
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method DrawLegend {}
-    private method EnterLegend { x y }
-    private method EventuallyRequestLegend {}
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method GetHeightmapScale {}
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method LeaveLegend {}
-    private method LegendTitleAction { option }
-    private method MotionLegend { x y }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { colormap title min max size }
-    private method RequestLegend {}
-    private method ResetAxes {}
-    private method Rotate {option x y}
-    private method SetCurrentColormap { color }
-    private method SetCurrentFieldName { dataobj }
-    private method SetLegendTip { x y }
-    private method SetObjectStyle { dataobj comp }
-    private method SetOrientation { side }
-    private method UpdateContourList {}
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _comp2scale;       # maps dataset to the heightmap scale.
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _colormaps;        # contains all the colormaps
-                                        # in the server.
-
-    # The name of the current colormap used.  The colormap is global to all
-    # heightmaps displayed.
-    private variable _currentColormap ""
-    private variable _currentNumIsolines -1
-
-    private variable _maxScale 100;     # This is the # of times the x-axis
-                                        # and y-axis ranges can differ before
-                                        # automatically turning on
-                                        # -stretchtofit
-
-    private variable _click;            # info used for rotate operations
-    private variable _limits;           # Holds overall limits for all dataobjs
-                                        # using the viewer.
-    private variable _view;             # view params for 3D view
-    private variable _settings
-    private variable _changed
-    private variable _reset 1;          # Connection to server has been reset.
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _isolines
-    private variable _contourList ""
-    private variable _width 0
-    private variable _height 0
-    private variable _legendWidth 0
-    private variable _legendHeight 0
-    private variable _resizePending 0
-    private variable _legendPending 0
-    private variable _rotatePending 0
-    private variable _fields
-    private variable _curFldName ""
-    private variable _curFldLabel ""
-    private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkHeightmapViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground -mode
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::constructor {args} {
-    set _serverType "vtkvis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Create image for legend colorbar.
-    set _image(legend) [image create photo]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.36
-        -qx       0.25
-        -qy       0.50
-        -qz       0.70
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _settings {
-        -axesvisible            1
-        -axislabels             1
-        -axisminorticks         1
-        -axismode               "static"
-        -colormap               BCGYR
-        -colormapdiscrete       0
-        -colormapvisible        1
-        -edges                  0
-        -field                  "Default"
-        -heightmapscale         50
-        -isheightmap            0
-        -isolinecolor           black
-        -isolinesvisible        1
-        -legendvisible          1
-        -lighting               1
-        -numisolines            10
-        -opacity                100
-        -outline                0
-        -savelighting           1
-        -saveopacity            100
-        -saveoutline            0
-        -stretchtofit           0
-        -wireframe              0
-        -xgrid                  0
-        -ygrid                  0
-        -zgrid                  0
-    }
-    array set _changed {
-        -colormap               0
-        -colormapdiscrete       0
-        -colormapvisible        0
-        -edges                  0
-        -isolinecolor           0
-        -isolinesvisible        0
-        -numisolines            0
-        -opacity                0
-        -wireframe              0
-    }
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    itk_component add fieldmenu {
-        menu $itk_component(plotarea).menu -relief flat -tearoff 0
-    } {
-        usual
-        ignore -background -foreground -relief -tearoff
-    }
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this CameraReset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady { 2 0 }
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady { 2 0 }
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady { 2 0 }
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add mode {
-        Rappture::PushButton $f.mode \
-            -onimage [Rappture::icon surface] \
-            -offimage [Rappture::icon surface] \
-            -variable [itcl::scope _settings(-isheightmap)] \
-            -command [itcl::code $this AdjustSetting -isheightmap] \
-    }
-    Rappture::Tooltip::for $itk_component(mode) \
-        "Toggle the surface/contour on/off"
-    pack $itk_component(mode) -padx 2 -pady { 2 0 }
-
-    itk_component add stretchtofit {
-        Rappture::PushButton $f.stretchtofit \
-            -onimage [Rappture::icon stretchtofit] \
-            -offimage [Rappture::icon stretchtofit] \
-            -variable [itcl::scope _settings(-stretchtofit)] \
-            -command [itcl::code $this AdjustSetting -stretchtofit] \
-    }
-    Rappture::Tooltip::for $itk_component(stretchtofit) \
-        "Stretch plot to fit window on/off"
-    pack $itk_component(stretchtofit) -padx 2 -pady 2
-
-    if { [catch {
-        BuildContourTab
-        BuildAxisTab
-        BuildCameraTab
-    } errs] != 0 } {
-        global errorInfo
-        puts stderr "errs=$errs errorInfo=$errorInfo"
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-    eval itk_initialize $args
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::destructor {} {
-    Disconnect
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size [expr $_width - 20] $_height"
-
-    set font "Arial 8"
-    set lh [font metrics $font -linespace]
-    set h [expr {$_height - 2 * ($lh + 2)}]
-    if { $h != $_legendHeight } {
-        EventuallyRequestLegend
-    } else {
-        DrawLegend
-    }
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkHeightmapViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkHeightmapViewer::EventuallyRequestLegend {} {
-    if { !$_legendPending } {
-        set _legendPending 1
-        $_dispatcher event -idle !legend
-    }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 250 !resize
-    }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after 100 !rotate
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::add {dataobj {settings ""}} {
-    if { ![$dataobj isvalid] } {
-        return;                         # Object doesn't contain valid data.
-    }
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) white
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::delete {args} {
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-#
-# scale  --
-#
-# This gets called either incrementally as new simulations are
-# added or all at once as a sequence of heightmaps.
-# This  accounts for all objects--even those not showing on the
-# screen.  Because of this, the limits are appropriate for all
-# objects as the user scans through data in the ResultSet viewer.
-#
-itcl::body Rappture::VtkHeightmapViewer::scale {args} {
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                   # Object doesn't contain valid data.
-        }
-        foreach axis { x y } {
-            set units [$dataobj hints ${axis}units]
-            set found($units) 1
-            set lim [$dataobj limits $axis]
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {amin amax} $_limits($axis) break
-            if { $amin > $min } {
-                set amin $min
-            }
-            if { $amax < $max } {
-                set amax $max
-            }
-            set _limits($axis) [list $amin $amax]
-        }
-        foreach { fname lim } [$dataobj fieldlimits] {
-            if { ![info exists _limits($fname)] } {
-                set _limits($fname) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {fmin fmax} $_limits($fname) break
-            if { $fmin > $min } {
-                set fmin $min
-            }
-            if { $fmax < $max } {
-                set fmax $max
-            }
-            set _limits($fname) [list $fmin $fmax]
-        }
-    }
-    if { [array size found] > 1 } {
-        set _settings(-stretchtofit) 1
-    } else {
-        # Check if the range of the x and y axes requires that we stretch
-        # the contour to fit the plotting area.  This can happen when the
-        # x and y scales differ greatly (> 100x)
-        foreach {xmin xmax} $_limits(x) break
-        foreach {ymin ymax} $_limits(y) break
-        if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) ||
-             ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } {
-            set _settings(-stretchtofit) 1
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::Connect {} {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtkheightmapviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkHeightmapViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkHeightmapViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkHeightmapViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    $_dispatcher cancel !legend
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    array unset _colormaps
-    global readyForNextFrame
-    set readyForNextFrame 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::ReceiveImage { args } {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        set time [clock seconds]
-        set date [clock format $time]
-        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            #puts stderr "round trip time [expr $finish -$_start] milliseconds"
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkHeightmapViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_width != $w || $_height != $h || $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-        if { $_settings(-stretchtofit) } {
-            AdjustSetting -stretchtofit
-        }
-    }
-    if { $_reset } {
-        #
-        # Reset the camera and other view parameters
-        #
-        InitSettings -isheightmap -background \
-            -xgrid -ygrid -zgrid -axismode \
-            -axesvisible -axislabels -axisminorticks
-
-        # Setting a custom exponent and label format for axes is causing
-        # a problem with rounding.  Near zero ticks aren't rounded by
-        # the %g format.  The VTK CubeAxes seem to currently work best
-        # when allowed to automatically set the exponent and precision
-        # based on the axis ranges.  This does tend to result in less
-        # visual clutter, so I think it is best to use the automatic
-        # settings by default.  We can test more fine-grained
-        # controls on the axis settings tab if necessary.
-        # -Leif
-        #SendCmd "axis exp 0 0 0 1"
-
-        SendCmd "axis tickpos outside"
-        SendCmd "axis lrot z 90"
-        $_arcball quaternion [ViewToQuaternion]
-        if {$_settings(-isheightmap) } {
-            if { $_view(-ortho)} {
-                SendCmd "camera mode ortho"
-            } else {
-                SendCmd "camera mode persp"
-            }
-            DoRotate
-            SendCmd "camera reset"
-        }
-        PanCamera
-        StopBufferingCommands
-        SendCmd "imgflush"
-        StartBufferingCommands
-    }
-
-    set _first ""
-    # Start off with no datasets visible.
-    SendCmd "dataset visible 0"
-    set scale [GetHeightmapScale]
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-            SetCurrentFieldName $dataobj
-        }
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { ![info exists _datasets($tag)] } {
-                set bytes [$dataobj vtkdata $comp]
-                if 0 {
-                    set f [open /tmp/vtkheightmap.vtk "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $bytes
-                    close $f
-                }
-                set length [string length $bytes]
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $length
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "dataset add $tag data follows $length"
-                SendData $bytes
-                set _datasets($tag) 1
-                SetObjectStyle $dataobj $comp
-            }
-            if { [info exists _obj2ovride($dataobj-raise)] } {
-                # Setting dataset visible enables outline
-                # and heightmap
-                SendCmd "dataset visible 1 $tag"
-            }
-            if { ![info exists _comp2scale($tag)] ||
-                 $_comp2scale($tag) != $scale } {
-                SendCmd "heightmap heightscale $scale $tag"
-                set _comp2scale($tag) $scale
-            }
-        }
-    }
-
-    InitSettings -stretchtofit -outline
-    if { $_reset } {
-        foreach axis { x y z } {
-            set label ""
-            if { $_first != "" } {
-                if { $axis == "z" } {
-                    set label [$_first hints label]
-                } else {
-                    set label [$_first hints ${axis}label]
-                }
-            }
-            if { $label == "" } {
-                if {$axis == "z"} {
-                    if { [string match "component*" $_curFldName] } {
-                        set label [string toupper $axis]
-                    } else {
-                        set label $_curFldLabel
-                    }
-                } else {
-                    set label [string toupper $axis]
-                }
-            }
-            # May be a space in the axis label.
-            SendCmd [list axis name $axis $label]
-
-            set units ""
-            if { $_first != "" } {
-                if { $axis == "z" } {
-                    set units [$_first hints units]
-                } else {
-                    set units [$_first hints ${axis}units]
-                }
-            }
-            if { $units == "" && $axis == "z" } {
-                if { $_first != "" && [$_first hints zunits] != "" } {
-                    set units [$_first hints zunits]
-                } elseif { [info exists _fields($_curFldName)] } {
-                    set units [lindex $_fields($_curFldName) 1]
-                }
-            }
-            # May be a space in the axis units.
-            SendCmd [list axis units $axis $units]
-        }
-        #
-        # Reset the camera and other view parameters
-        #
-        ResetAxes
-        $_arcball quaternion [ViewToQuaternion]
-        if {$_settings(-isheightmap) } {
-            if { $_view(-ortho)} {
-                SendCmd "camera mode ortho"
-            } else {
-                SendCmd "camera mode persp"
-            }
-            DoRotate
-            SendCmd "camera reset"
-        }
-        PanCamera
-        InitSettings -heightmapscale -field -isheightmap -numisolines
-        if { [array size _fields] < 2 } {
-            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
-        }
-        RequestLegend
-        set _reset 0
-    }
-    global readyForNextFrame
-    set readyForNextFrame 0;                # Don't advance to the next frame
-
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _datasets($tag)] && $_datasets($tag) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-itcl::body Rappture::VtkHeightmapViewer::CameraReset {} {
-    array set _view {
-        -qw      0.36
-        -qx      0.25
-        -qy      0.50
-        -qz      0.70
-        -xpan    0
-        -ypan    0
-        -zoom    1.0
-    }
-    if { $_first != "" } {
-        set location [$_first hints camera]
-        if { $location != "" } {
-            array set _view $location
-        }
-    }
-    $_arcball quaternion [ViewToQuaternion]
-    if {$_settings(-isheightmap) } {
-        DoRotate
-    }
-    SendCmd "camera reset"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } {
-    foreach spec $args {
-        AdjustSetting $spec
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkHeightmapViewer::AdjustSetting {what {value ""}} {
-    if { ![isconnected] } {
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            set bool $_settings($what)
-            SendCmd "axis visible all $bool"
-        }
-        "-axislabels" {
-            set bool $_settings($what)
-            SendCmd "axis labels all $bool"
-        }
-        "-axisminorticks" {
-            set bool $_settings($what)
-            SendCmd "axis minticks all $bool"
-        }
-        "-axismode" {
-            set mode [$itk_component(axismode) value]
-            set mode [$itk_component(axismode) translate $mode]
-            set _settings($what) $mode
-            SendCmd "axis flymode $mode"
-        }
-        "-background" {
-            set bg [$itk_component(background) value]
-            array set fgcolors {
-                "black" "white"
-                "white" "black"
-                "grey"  "black"
-            }
-            set fg $fgcolors($bg)
-            configure -plotbackground $bg -plotforeground $fg
-            $itk_component(view) delete "legend"
-            SendCmd "screen bgcolor [Color2RGB $bg]"
-            SendCmd "outline color [Color2RGB $fg]"
-            SendCmd "axis color all [Color2RGB $fg]"
-            DrawLegend
-        }
-        "-colormap" {
-            set _changed($what) 1
-            StartBufferingCommands
-            set color [$itk_component(colormap) value]
-            set _settings($what) $color
-            if { $color == "none" } {
-                if { $_settings(-colormapvisible) } {
-                    set _changed(-colormapvisible) 1
-                    SendCmd "heightmap surface 0"
-                    set _settings(-colormapvisible) 0
-                }
-            } else {
-                if { !$_settings(-colormapvisible) } {
-                    set _changed(-colormapvisible) 1
-                    SendCmd "heightmap surface 1"
-                    set _settings(-colormapvisible) 1
-                }
-                SetCurrentColormap $color
-                if {$_settings(-colormapdiscrete)} {
-                    set numColors [expr $_settings(-numisolines) + 1]
-                    SendCmd "colormap res $numColors $color"
-                }
-            }
-            StopBufferingCommands
-            EventuallyRequestLegend
-        }
-        "-colormapdiscrete" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            set numColors [expr $_settings(-numisolines) + 1]
-            StartBufferingCommands
-            if {$bool} {
-                SendCmd "colormap res $numColors"
-                # Discrete colormap requires preinterp on
-                SendCmd "heightmap preinterp on"
-            } else {
-                SendCmd "colormap res default"
-                # FIXME: add setting for preinterp (default on)
-                SendCmd "heightmap preinterp on"
-            }
-            StopBufferingCommands
-            EventuallyRequestLegend
-        }
-        "-colormapvisible" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "heightmap surface $bool"
-        }
-        "-edges" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "heightmap edges $bool"
-        }
-        "-field" {
-            set label [$itk_component(field) value]
-            set fname [$itk_component(field) translate $label]
-            set _settings($what) $fname
-            if { [info exists _fields($fname)] } {
-                foreach { label units components } $_fields($fname) break
-                if { $components > 1 } {
-                    set _colorMode vmag
-                } else {
-                    set _colorMode scalar
-                }
-                set _curFldName $fname
-                set _curFldLabel $label
-            } else {
-                puts stderr "unknown field \"$fname\""
-                return
-            }
-            set label ""
-            if { $_first != "" } {
-                set label [$_first hints label]
-            }
-            if { $label == "" } {
-                if { [string match "component*" $_curFldName] } {
-                    set label Z
-                } else {
-                    set label $_curFldLabel
-                }
-            }
-            # May be a space in the axis label.
-            SendCmd [list axis name z $label]
-
-            set units ""
-            if { $_first != "" } {
-                set units [$_first hints units]
-            }
-            if { $units == "" } {
-                if { $_first != "" && [$_first hints zunits] != "" } {
-                    set units [$_first hints zunits]
-                } elseif { [info exists _fields($_curFldName)] } {
-                    set units [lindex $_fields($_curFldName) 1]
-                }
-            }
-            # May be a space in the axis units.
-            SendCmd [list axis units z $units]
-            # Get the new limits because the field changed.
-            ResetAxes
-            SendCmd [list dataset scalar $_curFldName]
-            SendCmd [list heightmap colormode $_colorMode $_curFldName]
-            UpdateContourList
-            SendCmd "heightmap contourlist [list $_contourList]"
-            Zoom reset
-            DrawLegend
-        }
-        "-heightmapscale" {
-            if { $_settings(-isheightmap) } {
-                set scale [GetHeightmapScale]
-                # Have to set the datasets individually because we are
-                # tracking them in _comp2scale.
-                foreach dataset [CurrentDatasets -all] {
-                    SendCmd "heightmap heightscale $scale $dataset"
-                    set _comp2scale($dataset) $scale
-                }
-                ResetAxes
-            }
-        }
-        "-isheightmap" {
-            set bool $_settings($what)
-            set c $itk_component(view)
-            StartBufferingCommands
-            # Fix heightmap scale: 0 for contours, 1 for heightmaps.
-            if { $bool } {
-                set _settings(-heightmapscale) 50
-                set _settings(-opacity) $_settings(-saveopacity)
-                set _settings(-lighting) $_settings(-savelighting)
-                set _settings(-outline) 0
-            } else {
-                set _settings(-heightmapscale) 0
-                set _settings(-lighting) 0
-                set _settings(-opacity) 100
-                set _settings(-outline)  $_settings(-saveoutline)
-            }
-            InitSettings -lighting -opacity -outline
-            set scale [GetHeightmapScale]
-            # Have to set the datasets individually because we are
-            # tracking them in _comp2scale.
-            foreach dataset [CurrentDatasets -all] {
-                SendCmd "heightmap heightscale $scale $dataset"
-                set _comp2scale($dataset) $scale
-            }
-            if { $bool } {
-                $itk_component(lighting) configure -state normal
-                $itk_component(opacity) configure -state normal
-                $itk_component(scale) configure -state normal
-                $itk_component(opacity_l) configure -state normal
-                $itk_component(scale_l) configure -state normal
-                $itk_component(outline) configure -state disabled
-                if {$_view(-ortho)} {
-                    SendCmd "camera mode ortho"
-                } else {
-                    SendCmd "camera mode persp"
-                }
-            } else {
-                $itk_component(lighting) configure -state disabled
-                $itk_component(opacity) configure -state disabled
-                $itk_component(scale) configure -state disabled
-                $itk_component(opacity_l) configure -state disabled
-                $itk_component(scale_l) configure -state disabled
-                $itk_component(outline) configure -state normal
-                SendCmd "camera mode image"
-            }
-            if {$_settings(-stretchtofit)} {
-                if {$scale == 0} {
-                    SendCmd "camera aspect window"
-                } else {
-                    SendCmd "camera aspect square"
-                }
-            }
-            ResetAxes
-            if { $bool } {
-                set q [ViewToQuaternion]
-                $_arcball quaternion $q
-                SendCmd "camera orient $q"
-            } else {
-                bind $c <ButtonPress-1> {}
-                bind $c <B1-Motion> {}
-                bind $c <ButtonRelease-1> {}
-            }
-            Zoom reset
-            # Fix the mouse bindings for rotation/panning and the
-            # camera mode. Ideally we'd create a bindtag for these.
-            if { $bool } {
-                # Bindings for rotation via mouse
-                bind $c <ButtonPress-1> \
-                    [itcl::code $this Rotate click %x %y]
-                bind $c <B1-Motion> \
-                    [itcl::code $this Rotate drag %x %y]
-                bind $c <ButtonRelease-1> \
-                    [itcl::code $this Rotate release %x %y]
-            }
-            StopBufferingCommands
-        }
-        "-isolinecolor" {
-            set _changed($what) 1
-            set color [$itk_component(isolinecolor) value]
-            if { $color == "none" } {
-                if { $_settings(-isolinesvisible) } {
-                    set _changed(-isolinesvisible) 1
-                    SendCmd "heightmap isolines 0"
-                    set _settings(-isolinesvisible) 0
-                }
-            } else {
-                set _settings($what) $color
-                if { !$_settings(-isolinesvisible) } {
-                    set _changed(-isolinesvisible) 1
-                    SendCmd "heightmap isolines 1"
-                    set _settings(-isolinesvisible) 1
-                }
-                SendCmd "heightmap isolinecolor [Color2RGB $color]"
-            }
-            DrawLegend
-        }
-        "-isolinesvisible" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            set color [$itk_component(isolinecolor) value]
-            if { $bool && $color != $_settings(-isolinecolor)} {
-                $itk_component(isolinecolor) value $_settings(-isolinecolor)
-            }
-            SendCmd "heightmap isolines $bool"
-            DrawLegend
-        }
-        "-legendvisible" {
-            if { !$_settings($what) } {
-                $itk_component(view) delete legend
-            }
-            DrawLegend
-        }
-        "-lighting" {
-            if { $_settings(-isheightmap) } {
-                set _settings(-savelighting) $_settings($what)
-                set bool $_settings($what)
-                SendCmd "heightmap lighting $bool"
-            } else {
-                SendCmd "heightmap lighting 0"
-            }
-        }
-        "-numisolines" {
-            set _settings($what) [$itk_component(numisolines) value]
-            set _currentNumIsolines $_settings($what)
-            UpdateContourList
-            set _changed($what) 1
-            SendCmd "heightmap contourlist [list $_contourList]"
-            if {$_settings(-colormapdiscrete)} {
-                set numColors [expr $_settings($what) + 1]
-                SendCmd "colormap res $numColors"
-                EventuallyRequestLegend
-            } else {
-                DrawLegend
-            }
-        }
-        "-opacity" {
-            set _changed($what) 1
-            set val [expr $_settings($what) * 0.01]
-            if { $_settings(-isheightmap) } {
-                set _settings(-saveopacity) $_settings($what)
-                SendCmd "heightmap opacity $val"
-            } else {
-                SendCmd "heightmap opacity 1.0"
-            }
-        }
-        "-outline" {
-            set _changed($what) 1
-            if { $_settings(-isheightmap) } {
-                SendCmd "outline visible 0"
-            } else {
-                set _settings(-saveoutline) $_settings($what)
-                set bool $_settings($what)
-                SendCmd "outline visible $bool"
-            }
-        }
-        "-stretchtofit" {
-            set bool $_settings($what)
-            if { $bool } {
-                set heightScale [GetHeightmapScale]
-                if {$heightScale == 0} {
-                    SendCmd "camera aspect window"
-                } else {
-                    SendCmd "camera aspect square"
-                }
-            } else {
-                SendCmd "camera aspect native"
-            }
-            Zoom reset
-        }
-        "-wireframe" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "heightmap wireframe $bool"
-        }
-        "-xgrid" - "-ygrid" - "-zgrid" {
-            set axis [string tolower [string range $what 1 1]]
-            set bool $_settings($what)
-            SendCmd "axis grid $axis $bool"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-#
-# RequestLegend --
-#
-# Request a new legend from the server.  The size of the legend
-# is determined from the height of the canvas.
-#
-# This should be called when
-#   1.  A new current colormap is set.
-#   2.  Window is resized.
-#   3.  The limits of the data have changed.  (Just need a redraw).
-#   4.  Number of isolines have changed. (Just need a redraw).
-#   5.  Legend becomes visible (Just need a redraw).
-#
-itcl::body Rappture::VtkHeightmapViewer::RequestLegend {} {
-    set _legendPending 0
-    set font "Arial 8"
-    set w 12
-    set lineht [font metrics $font -linespace]
-    # color ramp height = (canvas height) - (min and max value lines) - 2
-    set h [expr {$_height - 2 * ($lineht + 2)}]
-    set _legendHeight $h
-
-    set fname $_curFldName
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a title too, subtract one more line
-    if { $title != "" } {
-        incr h -$lineht
-    }
-    if { $h < 1 } {
-        return
-    }
-    # Set the legend on the first dataset.
-    if { $_currentColormap != "" } {
-        set cmap $_currentColormap
-        if { ![info exists _colormaps($cmap)] } {
-            BuildColormap $cmap
-            set _colormaps($cmap) 1
-        }
-        #SendCmd [list legend $cmap scalar $_curFldName {} $w $h 0]
-        SendCmd "legend2 $cmap $w $h"
-    }
-}
-
-#
-# ResetAxes --
-#
-# Set axis z bounds and range
-#
-itcl::body Rappture::VtkHeightmapViewer::ResetAxes {} {
-    if { ![info exists _limits($_curFldName)]} {
-        SendCmd "dataset maprange all"
-        SendCmd "axis autorange z on"
-        SendCmd "axis autobounds z on"
-        return
-    }
-    foreach { xmin xmax } $_limits(x) break
-    foreach { ymin ymax } $_limits(y) break
-    foreach { vmin vmax } $_limits($_curFldName) break
-
-    global tcl_precision
-    set tcl_precision 17
-    set xr [expr $xmax - $xmin]
-    set yr [expr $ymax - $ymin]
-    set vr [expr $vmax - $vmin]
-    set r  [expr ($yr > $xr) ? $yr : $xr]
-    if { $vr < 1.0e-17 } {
-        set dataScale 1.0
-    } else {
-        set dataScale [expr $r / $vr]
-    }
-    set heightScale [GetHeightmapScale]
-    set bmin [expr $heightScale * $dataScale * $vmin]
-    set bmax [expr $heightScale * $dataScale * $vmax]
-    if {$heightScale > 0} {
-        set zpos [expr - $bmin]
-        SendCmd "heightmap pos 0 0 $zpos"
-    } else {
-        SendCmd "heightmap pos 0 0 0"
-    }
-    set bmax [expr $bmax - $bmin]
-    set bmin 0
-    SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName]
-    SendCmd "axis bounds z $bmin $bmax"
-    SendCmd "axis range z $_limits($_curFldName)"
-}
-
-#
-# SetCurrentColormap --
-#
-itcl::body Rappture::VtkHeightmapViewer::SetCurrentColormap { name } {
-    # Keep track of the colormaps that we build.
-    if { $name != "none" && ![info exists _colormaps($name)] } {
-        BuildColormap $name
-        set _colormaps($name) 1
-    }
-    set _currentColormap $name
-    SendCmd "heightmap colormap $_currentColormap"
-}
-
-#
-# BuildColormap --
-#
-# Build the designated colormap on the server.
-#
-itcl::body Rappture::VtkHeightmapViewer::BuildColormap { name } {
-    set cmap [ColorsToColormap $name]
-    if { [llength $cmap] == 0 } {
-        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
-    }
-    set amap "0.0 1.0 1.0 1.0"
-    SendCmd "colormap add $name { $cmap } { $amap }"
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -mode
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkHeightmapViewer::mode {
-    switch -- $itk_option(-mode) {
-        "heightmap" {
-            set _settings(-isheightmap) 1
-        }
-        "contour" {
-            set _settings(-isheightmap) 0
-        }
-        default {
-            error "unknown mode settings \"$itk_option(-mode)\""
-        }
-    }
-    if { !$_reset } {
-        AdjustSetting -isheightmap
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkHeightmapViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        if { !$_reset } {
-            SendCmd "screen bgcolor $rgb"
-        }
-        $itk_component(view) configure -background $itk_option(-plotbackground)
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkHeightmapViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        if { !$_reset } {
-            SendCmd "axis color all $rgb"
-            SendCmd "outline color $rgb"
-        }
-    }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::BuildContourTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Contour/Surface Settings" \
-        -icon [Rappture::icon contour2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.legend \
-        -text "Legend" \
-        -variable [itcl::scope _settings(-legendvisible)] \
-        -command [itcl::code $this AdjustSetting -legendvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.wireframe \
-        -text "Wireframe" \
-        -variable [itcl::scope _settings(-wireframe)] \
-        -command [itcl::code $this AdjustSetting -wireframe] \
-        -font "Arial 9"
-
-    itk_component add lighting {
-        checkbutton $inner.lighting \
-            -text "Enable Lighting" \
-            -variable [itcl::scope _settings(-lighting)] \
-            -command [itcl::code $this AdjustSetting -lighting] \
-            -font "Arial 9"
-    } {
-        ignore -font
-    }
-    checkbutton $inner.edges \
-        -text "Edges" \
-        -variable [itcl::scope _settings(-edges)] \
-        -command [itcl::code $this AdjustSetting -edges] \
-        -font "Arial 9"
-
-    itk_component add outline {
-        checkbutton $inner.outline \
-            -text "Outline" \
-            -variable [itcl::scope _settings(-outline)] \
-            -command [itcl::code $this AdjustSetting -outline] \
-            -font "Arial 9"
-    } {
-        ignore -font
-    }
-    checkbutton $inner.stretch \
-        -text "Stretch to fit" \
-        -variable [itcl::scope _settings(-stretchtofit)] \
-        -command [itcl::code $this AdjustSetting -stretchtofit] \
-        -font "Arial 9"
-
-    checkbutton $inner.isolines \
-        -text "Isolines" \
-        -variable [itcl::scope _settings(-isolinesvisible)] \
-        -command [itcl::code $this AdjustSetting -isolinesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.colormapDiscrete \
-        -text "Discrete Colormap" \
-        -variable [itcl::scope _settings(-colormapdiscrete)] \
-        -command [itcl::code $this AdjustSetting -colormapdiscrete] \
-        -font "Arial 9"
-
-    itk_component add field_l {
-        label $inner.field_l -text "Field" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add field {
-        Rappture::Combobox $inner.field -width 10 -editable 0
-    }
-    bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting -field]
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9"
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList -includeNone]
-    $itk_component(colormap) value $_settings(-colormap)
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -colormap]
-
-    label $inner.isolinecolor_l -text "Isolines Color" -font "Arial 9"
-    itk_component add isolinecolor {
-        Rappture::Combobox $inner.isolinecolor -width 10 -editable 0
-    }
-    $inner.isolinecolor choices insert end \
-        "black"              "black"            \
-        "blue"               "blue"             \
-        "cyan"               "cyan"             \
-        "green"              "green"            \
-        "grey"               "grey"             \
-        "magenta"            "magenta"          \
-        "orange"             "orange"           \
-        "red"                "red"              \
-        "white"              "white"            \
-        "none"               "none"
-
-    $itk_component(isolinecolor) value $_settings(-isolinecolor)
-    bind $inner.isolinecolor <<Value>> \
-        [itcl::code $this AdjustSetting -isolinecolor]
-
-    label $inner.background_l -text "Background Color" -font "Arial 9"
-    itk_component add background {
-        Rappture::Combobox $inner.background -width 10 -editable 0
-    }
-    $inner.background choices insert end \
-        "black"              "black"            \
-        "white"              "white"            \
-        "grey"               "grey"
-
-    $itk_component(background) value "white"
-    bind $inner.background <<Value>> \
-        [itcl::code $this AdjustSetting -background]
-
-    itk_component add opacity_l {
-        label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add opacity {
-        ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-            -variable [itcl::scope _settings(-opacity)] \
-            -showvalue off \
-            -command [itcl::code $this AdjustSetting -opacity]
-    }
-    itk_component add scale_l {
-        label $inner.scale_l -text "Scale" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add scale {
-        ::scale $inner.scale -from 0 -to 100 -orient horizontal \
-            -variable [itcl::scope _settings(-heightmapscale)] \
-            -showvalue off \
-            -command [itcl::code $this AdjustSetting -heightmapscale]
-    }
-    label $inner.numisolines_l -text "Number of Isolines" -font "Arial 9"
-    itk_component add numisolines {
-        Rappture::Spinint $inner.numisolines \
-            -min 0 -max 50 -font "arial 9"
-    }
-    $itk_component(numisolines) value $_settings(-numisolines)
-    bind $itk_component(numisolines) <<Value>> \
-        [itcl::code $this AdjustSetting -numisolines]
-
-    frame $inner.separator1 -height 2 -relief sunken -bd 1
-    frame $inner.separator2 -height 2 -relief sunken -bd 1
-
-    blt::table $inner \
-        0,0 $inner.field_l -anchor w -pady 2 \
-        0,1 $inner.field -anchor w -pady 2 -fill x \
-        1,0 $inner.colormap_l -anchor w -pady 2  \
-        1,1 $inner.colormap   -anchor w -pady 2 -fill x  \
-        2,0 $inner.isolinecolor_l  -anchor w -pady 2  \
-        2,1 $inner.isolinecolor    -anchor w -pady 2 -fill x  \
-        3,0 $inner.background_l -anchor w -pady 2 \
-        3,1 $inner.background -anchor w -pady 2  -fill x \
-        4,0 $inner.numisolines_l -anchor w -pady 2 \
-        4,1 $inner.numisolines -anchor w -pady 2 \
-        5,0 $inner.stretch    -anchor w -pady 2 -cspan 2 \
-        6,0 $inner.edges      -anchor w -pady 2 -cspan 2 \
-        7,0 $inner.legend     -anchor w -pady 2 -cspan 2 \
-        8,0 $inner.colormapDiscrete -anchor w -pady 2 -cspan 2 \
-        9,0 $inner.wireframe  -anchor w -pady 2 -cspan 2\
-        10,0 $inner.isolines   -anchor w -pady 2 -cspan 2 \
-        11,0 $inner.separator1 -padx 2 -fill x -cspan 2 \
-        12,0 $inner.outline    -anchor w -pady 2 -cspan 2 \
-        13,0 $inner.separator2 -padx 2 -fill x -cspan 2 \
-        14,0 $inner.lighting   -anchor w -pady 2 -cspan 2 \
-        15,0 $inner.opacity_l -anchor w -pady 2 \
-        15,1 $inner.opacity   -fill x   -pady 2 \
-        16,0 $inner.scale_l   -anchor w -pady 2 -cspan 2 \
-        16,1 $inner.scale     -fill x   -pady 2 -cspan 2 \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r17 c1 -resize expand
-}
-
-itcl::body Rappture::VtkHeightmapViewer::BuildAxisTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _settings(-axislabels)] \
-        -command [itcl::code $this AdjustSetting -axislabels] \
-        -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9"
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _settings(-xgrid)] \
-        -command [itcl::code $this AdjustSetting -xgrid] \
-        -font "Arial 9"
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _settings(-ygrid)] \
-        -command [itcl::code $this AdjustSetting -ygrid] \
-        -font "Arial 9"
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _settings(-zgrid)] \
-        -command [itcl::code $this AdjustSetting -zgrid] \
-        -font "Arial 9"
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _settings(-axisminorticks)] \
-        -command [itcl::code $this AdjustSetting -axisminorticks] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-
-    itk_component add axismode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axismode) value $_settings(-axismode)
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
-
-    blt::table $inner \
-        0,0 $inner.visible -anchor w -cspan 4 \
-        1,0 $inner.labels  -anchor w -cspan 4 \
-        2,0 $inner.minorticks  -anchor w -cspan 4 \
-        4,0 $inner.grid_l  -anchor w \
-        4,1 $inner.xgrid   -anchor w \
-        4,2 $inner.ygrid   -anchor w \
-        4,3 $inner.zgrid   -anchor w \
-        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
-        5,1 $inner.mode    -fill x -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-itcl::body Rappture::VtkHeightmapViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set labels { qx qy qz qw xpan ypan zoom }
-    set row 1
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this camera set -ortho] \
-        -font "Arial 9"
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkHeightmapViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            set contents [$dataobj vtkdata $comp]
-            append bytes "$contents\n"
-        }
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkHeightmapViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkHeightmapViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-#
-# SetObjectStyle --
-#
-# Set the style of the heightmap/contour object.  This gets calls
-# for each dataset once as it is loaded.  It can overridden by
-# the user controls.
-#
-itcl::body Rappture::VtkHeightmapViewer::SetObjectStyle { dataobj comp } {
-    # Parse style string.
-    set tag $dataobj-$comp
-    array set style {
-        -color            BCGYR
-        -colormapdiscrete 0
-        -colormapvisible  1
-        -edgecolor        black
-        -edges            0
-        -isolinecolor     black
-        -isolinesvisible  1
-        -isolinewidth     1.0
-        -levels           10
-        -linewidth        1.0
-        -opacity          1.0
-        -outline          0
-        -wireframe        0
-    }
-    set stylelist [$dataobj style $comp]
-    if { $stylelist != "" } {
-        array set style $stylelist
-    }
-    # This is too complicated.  We want to set the colormap, number of
-    # isolines and opacity for the dataset.  They can be the default values,
-    # the style hints loaded with the dataset, or set by user controls.  As
-    # datasets get loaded, they first use the defaults that are overidden
-    # by the style hints.  If the user changes the global controls, then that
-    # overrides everything else.  I don't know what it means when global
-    # controls are specified as style hints by each dataset.  It complicates
-    # the code to handle aberrant cases.
-
-    if { $_changed(-opacity) } {
-        set style(-opacity) [expr $_settings(-opacity) * 0.01]
-    }
-    if { $_changed(-numisolines) } {
-        set style(-levels) $_settings(-numisolines)
-    }
-    if { $_changed(-colormap) } {
-        set style(-color) $_settings(-colormap)
-    }
-    if { $_currentColormap == "" } {
-        $itk_component(colormap) value $style(-color)
-    }
-    if { [info exists style(-stretchtofit)] } {
-        set _settings(-stretchtofit) $style(-stretchtofit)
-        AdjustSetting -stretchtofit
-    }
-    if { $_currentNumIsolines != $style(-levels) } {
-        set _currentNumIsolines $style(-levels)
-        set _settings(-numisolines) $_currentNumIsolines
-        $itk_component(numisolines) value $_currentNumIsolines
-        UpdateContourList
-        DrawLegend
-    }
-    foreach setting {-edges -outline -wireframe -colormapdiscrete \
-                     -colormapvisible -isolinecolor -isolinesvisible} {
-        if {$_changed($setting)} {
-            # User-modified UI setting overrides style
-            set style($setting) $_settings($setting)
-        } else {
-            # Set UI control to style setting (tool provided or default)
-            set _settings($setting) $style($setting)
-        }
-    }
-
-    SendCmd "outline add $tag"
-    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
-    SendCmd "outline visible $style(-outline) $tag"
-
-    set scale [GetHeightmapScale]
-    SendCmd "[list heightmap add contourlist $_contourList $scale $tag]"
-    set _comp2scale($tag) $_settings(-heightmapscale)
-    SendCmd "heightmap edges $style(-edges) $tag"
-    SendCmd "heightmap linecolor [Color2RGB $style(-edgecolor)] $tag"
-    SendCmd "heightmap linewidth $style(-linewidth) $tag"
-    SendCmd "heightmap wireframe $style(-wireframe) $tag"
-    SetCurrentColormap $style(-color)
-    if {$style(-colormapdiscrete)} {
-        SendCmd "heightmap preinterp 1 $tag"
-        set numColors [expr $style(-levels) + 1]
-        SendCmd "colormap res $numColors $style(-color)"
-    }
-    SendCmd "heightmap isolinecolor [Color2RGB $style(-isolinecolor)] $tag"
-    $itk_component(isolinecolor) value $style(-isolinecolor)
-    SendCmd "heightmap isolinewidth $style(-isolinewidth) $tag"
-    SendCmd "heightmap lighting $_settings(-isheightmap) $tag"
-    SendCmd "heightmap isolines $style(-isolinesvisible) $tag"
-    SendCmd "heightmap surface $style(-colormapvisible) $tag"
-    SendCmd "heightmap opacity $style(-opacity) $tag"
-    set _settings(-opacity) [expr $style(-opacity) * 100.0]
-}
-
-itcl::body Rappture::VtkHeightmapViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::ReceiveLegend { colormap title min max size } {
-    #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size"
-    if { [isconnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend)] } {
-            set _image(legend) [image create photo]
-        }
-        $_image(legend) configure -data $bytes
-        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-        if { [catch {DrawLegend} errs] != 0 } {
-            global errorInfo
-            puts stderr "errs=$errs errorInfo=$errorInfo"
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-# Draws the legend in its own canvas on the right side of the plot area.
-#
-itcl::body Rappture::VtkHeightmapViewer::DrawLegend {} {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    set x [expr $w - 2]
-    if { !$_settings(-legendvisible) } {
-        $c delete legend
-        return
-    }
-    if { [$c find withtag "legend"] == "" } {
-        set y 2
-        # If there's a legend title, create a text item for the title.
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "title legend" \
-            -font $font
-        if { $title != "" } {
-            incr y $lineht
-        }
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "vmax legend" \
-            -font $font
-        incr y $lineht
-        $c create image $x $y \
-            -anchor ne \
-            -image $_image(legend) -tags "colormap legend"
-        $c create rectangle $x $y 1 1 \
-            -fill "" -outline "" -tags "sensor legend"
-        $c create text $x [expr {$h-2}] \
-            -anchor se \
-            -fill $itk_option(-plotforeground) -tags "vmin legend" \
-            -font $font
-        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
-        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
-        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
-    }
-    $c delete isoline
-    set x2 $x
-    set iw [image width $_image(legend)]
-    set ih [image height $_image(legend)]
-    set x1 [expr $x2 - ($iw*12)/10]
-    set color [$itk_component(isolinecolor) value]
-
-    # Draw the isolines on the legend.
-    array unset _isolines
-    if { $color != "none"  && [info exists _limits($_curFldName)] &&
-         $_settings(-isolinesvisible) && $_currentNumIsolines > 0 } {
-
-        foreach { vmin vmax } $_limits($_curFldName) break
-        set range [expr double($vmax - $vmin)]
-        if { $range <= 0.0 } {
-            set range 1.0;              # Min is greater or equal to max.
-        }
-        set tags "isoline legend"
-        set offset [expr 2 + $lineht]
-        if { $title != "" } {
-            incr offset $lineht
-        }
-        foreach value $_contourList {
-            set norm [expr 1.0 - (($value - $vmin) / $range)]
-            set y1 [expr int(round(($norm * $ih) + $offset))]
-            for { set off 0 } { $off < 3 } { incr off } {
-                set _isolines([expr $y1 + $off]) $value
-                set _isolines([expr $y1 - $off]) $value
-            }
-            $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
-        }
-    }
-
-    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
-    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
-    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
-    # Reset the item coordinates according the current size of the plot.
-    if { [info exists _limits($_curFldName)] } {
-        foreach { vmin vmax } $_limits($_curFldName) break
-        $c itemconfigure vmin -text [format %g $vmin]
-        $c itemconfigure vmax -text [format %g $vmax]
-    }
-    set y 2
-    # If there's a legend title, move the title to the correct position
-    if { $title != "" } {
-        $c itemconfigure title -text $title
-        $c coords title $x $y
-        incr y $lineht
-    }
-    $c coords vmax $x $y
-    incr y $lineht
-    $c coords colormap $x $y
-    $c coords sensor [expr $x - $iw] $y $x [expr $y + $ih]
-    $c raise sensor
-    $c coords vmin $x [expr {$h - 2}]
-}
-
-#
-# EnterLegend --
-#
-itcl::body Rappture::VtkHeightmapViewer::EnterLegend { x y } {
-    SetLegendTip $x $y
-}
-
-#
-# MotionLegend --
-#
-itcl::body Rappture::VtkHeightmapViewer::MotionLegend { x y } {
-    Rappture::Tooltip::tooltip cancel
-    set c $itk_component(view)
-    set cw [winfo width $c]
-    set ch [winfo height $c]
-    if { $x >= 0 && $x < $cw && $y >= 0 && $y < $ch } {
-        SetLegendTip $x $y
-    }
-}
-
-#
-# LeaveLegend --
-#
-itcl::body Rappture::VtkHeightmapViewer::LeaveLegend { } {
-    Rappture::Tooltip::tooltip cancel
-    .rappturetooltip configure -icon ""
-}
-
-#
-# SetLegendTip --
-#
-itcl::body Rappture::VtkHeightmapViewer::SetLegendTip { x y } {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set ih [image height $_image(legend)]
-    # Subtract off the offset of the color ramp from the top of the canvas
-    set iy [expr $y - ($lineht + 2)]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a legend title, increase the offset by the line height.
-    if { $title != "" } {
-        incr iy -$lineht
-    }
-
-    # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
-        return
-    }
-
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    set color [eval format "\#%02x%02x%02x" $pixel]
-    $_image(swatch) put black  -to 0 0 23 23
-    $_image(swatch) put $color -to 1 1 22 22
-
-    # Compute the value of the point
-    if { [info exists _limits($fname)] } {
-        foreach { vmin vmax } $_limits($fname) break
-        set t [expr 1.0 - (double($iy) / double($ih-1))]
-        set value [expr $t * ($vmax - $vmin) + $vmin]
-    } else {
-        set value 0.0
-    }
-    set tipx [expr $x + 15]
-    set tipy [expr $y - 5]
-    .rappturetooltip configure -icon $_image(swatch)
-    if { [info exists _isolines($y)] } {
-        Rappture::Tooltip::text $c [format "$title %g (isoline)" $_isolines($y)]
-    } else {
-        Rappture::Tooltip::text $c [format "$title %g" $value]
-    }
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendTitleAction post
-# USAGE: LegendTitleAction enter
-# USAGE: LegendTitleAction leave
-# USAGE: LegendTitleAction save
-#
-# Used internally to handle the dropdown list for the fields menu combobox.
-# The post option is invoked when the field title is pressed to launch the
-# dropdown.  The enter option is invoked when the user mouses over the field
-# title. The leave option is invoked when the user moves the mouse away
-# from the field title.  The save option is invoked whenever there is a
-# selection from the list, to alert the visualization server.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkHeightmapViewer::LegendTitleAction {option} {
-    set c $itk_component(view)
-    switch -- $option {
-        post {
-            foreach { x1 y1 x2 y2 } [$c bbox title] break
-            set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]]
-            set x [expr $x1 + [winfo rootx $itk_component(view)]]
-            set y [expr $y2 + [winfo rooty $itk_component(view)]]
-            tk_popup $itk_component(fieldmenu) $x $y
-        }
-        enter {
-            $c itemconfigure title -fill red
-        }
-        leave {
-            $c itemconfigure title -fill $itk_option(-plotforeground)
-        }
-        save {
-            $itk_component(field) value $_curFldLabel
-            AdjustSetting -field
-        }
-        default {
-            error "bad option \"$option\": should be post, enter, leave or save"
-        }
-    }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::GetHeightmapScale {} {
-    if {  $_settings(-isheightmap) } {
-        set val $_settings(-heightmapscale)
-        set sval [expr { $val >= 50 ? double($val)/50.0 : 1.0/(2.0-(double($val)/50.0)) }]
-        return $sval
-    }
-    return 0
-}
-
-itcl::body Rappture::VtkHeightmapViewer::SetOrientation { side } {
-    array set positions {
-        front  "0.707107 0.707107 0 0"
-        back   "0 0 0.707107 0.707107"
-        left   "0.5 0.5 -0.5 -0.5"
-        right  "0.5 0.5 0.5 0.5"
-        top    "1 0 0 0"
-        bottom "0 1 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
-
-itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} {
-    if {$_currentNumIsolines == 0} {
-        set _contourList ""
-        return
-    }
-    if { ![info exists _limits($_curFldName)] } {
-        return
-    }
-    foreach { vmin vmax } $_limits($_curFldName) break
-    set v [blt::vector create \#auto]
-    $v seq $vmin $vmax [expr $_currentNumIsolines+2]
-    $v delete end 0
-    set _contourList [$v range 0 end]
-    blt::vector destroy $v
-}
-
-itcl::body Rappture::VtkHeightmapViewer::SetCurrentFieldName { dataobj } {
-    set _first $dataobj
-    $itk_component(field) choices delete 0 end
-    $itk_component(fieldmenu) delete 0 end
-    array unset _fields
-    set _curFldName ""
-    foreach cname [$_first components] {
-        foreach fname [$_first fieldnames $cname] {
-            if { [info exists _fields($fname)] } {
-                continue
-            }
-            foreach { label units components } \
-                [$_first fieldinfo $fname] break
-            $itk_component(field) choices insert end "$fname" "$label"
-            $itk_component(fieldmenu) add radiobutton -label "$label" \
-                -value $label -variable [itcl::scope _curFldLabel] \
-                -selectcolor red \
-                -activebackground $itk_option(-plotbackground) \
-                -activeforeground $itk_option(-plotforeground) \
-                -font "Arial 8" \
-                -command [itcl::code $this LegendTitleAction save]
-            set _fields($fname) [list $label $units $components]
-            if { $_curFldName == "" } {
-                set _curFldName $fname
-                set _curFldLabel $label
-            }
-        }
-    }
-    $itk_component(field) value $_curFldLabel
-}
Index: trunk/gui/scripts/vtkimageviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkimageviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,2325 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtkimageviewer - Vtk image viewer
-#
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *VtkImageViewer.width 4i widgetDefault
-option add *VtkImageViewer*cursor crosshair widgetDefault
-option add *VtkImageViewer.height 4i widgetDefault
-option add *VtkImageViewer.foreground black widgetDefault
-option add *VtkImageViewer.controlBackground gray widgetDefault
-option add *VtkImageViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkImageViewer.plotBackground black widgetDefault
-option add *VtkImageViewer.plotForeground white widgetDefault
-option add *VtkImageViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkImageViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkImageViewer::SetServerList
-}
-
-itcl::class Rappture::VtkImageViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-    itk_option define -mode mode Mode "vtkimage"
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildColormap { name }
-    private method BuildImageTab {}
-    private method BuildDownloadPopup { widget command }
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method DrawLegend {}
-    private method EnterLegend { x y }
-    private method EventuallyRequestLegend {}
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method LeaveLegend {}
-    private method LegendTitleAction { option }
-    private method MotionLegend { x y }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { colormap title min max size }
-    private method RequestLegend {}
-    private method Rotate {option x y}
-    private method SetCurrentColormap { color }
-    private method SetCurrentFieldName { dataobj }
-    private method SetLegendTip { x y }
-    private method SetObjectStyle { dataobj comp }
-    private method SetOrientation { side }
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _colormaps;        # contains all the colormaps
-                                        # in the server.
-
-    # The name of the current colormap used.  The colormap is global to all
-    # images displayed.
-    private variable _currentColormap ""
-    private variable _currentNumIsolines -1
-
-    private variable _maxScale 100;     # This is the # of times the x-axis
-                                        # and y-axis ranges can differ before
-                                        # automatically turning on
-                                        # -stretchtofit
-
-    private variable _click;            # info used for rotate operations
-    private variable _limits;           # Holds overall limits for all dataobjs
-                                        # using the viewer.
-    private variable _view;             # view params for 3D view
-    private variable _settings
-    private variable _changed
-    private variable _reset 1;          # Connection to server has been reset.
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _isolines
-    private variable _contourList ""
-    private variable _width 0
-    private variable _height 0
-    private variable _legendWidth 0
-    private variable _legendHeight 0
-    private variable _resizePending 0
-    private variable _legendPending 0
-    private variable _rotatePending 0
-    private variable _fields
-    private variable _curFldName ""
-    private variable _curFldLabel ""
-    private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkImageViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground -mode
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::constructor {args} {
-    set _serverType "vtkvis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Create image for legend colorbar.
-    set _image(legend) [image create photo]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.36
-        -qx       0.25
-        -qy       0.50
-        -qz       0.70
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _settings {
-        -axesvisible            1
-        -axislabels             1
-        -axisminorticks         1
-        -axismode               "static"
-        -backingcolor           white
-        -backingvisible         1
-        -colormapdiscrete       0
-        -field                  "Default"
-        -legendvisible          0
-        -level                  127.5
-        -numcolors              256
-        -opacity                100
-        -outline                0
-        -saveopacity            100
-        -stretchtofit           0
-        -view3d                 0
-        -window                 255.0
-        -xgrid                  0
-        -ygrid                  0
-        -zgrid                  0
-    }
-    array set _changed {
-        -colormap               0
-        -opacity                0
-    }
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    itk_component add fieldmenu {
-        menu $itk_component(plotarea).menu -relief flat -tearoff 0
-    } {
-        usual
-        ignore -background -foreground -relief -tearoff
-    }
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady { 2 0 }
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady { 2 0 }
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady { 2 0 }
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add mode {
-        Rappture::PushButton $f.mode \
-            -onimage [Rappture::icon surface] \
-            -offimage [Rappture::icon surface] \
-            -variable [itcl::scope _settings(-view3d)] \
-            -command [itcl::code $this AdjustSetting -view3d] \
-    }
-    Rappture::Tooltip::for $itk_component(mode) \
-        "Toggle the surface/contour on/off"
-    pack $itk_component(mode) -padx 2 -pady { 2 0 }
-
-    itk_component add stretchtofit {
-        Rappture::PushButton $f.stretchtofit \
-            -onimage [Rappture::icon stretchtofit] \
-            -offimage [Rappture::icon stretchtofit] \
-            -variable [itcl::scope _settings(-stretchtofit)] \
-            -command [itcl::code $this AdjustSetting -stretchtofit] \
-    }
-    Rappture::Tooltip::for $itk_component(stretchtofit) \
-        "Stretch plot to fit window on/off"
-    pack $itk_component(stretchtofit) -padx 2 -pady 2
-
-    if { [catch {
-        BuildImageTab
-        BuildAxisTab
-        BuildCameraTab
-    } errs] != 0 } {
-        global errorInfo
-        puts stderr "errs=$errs errorInfo=$errorInfo"
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::destructor {} {
-    Disconnect
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkImageViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size [expr $_width - 20] $_height"
-
-    set font "Arial 8"
-    set lh [font metrics $font -linespace]
-    set h [expr {$_height - 2 * ($lh + 2)}]
-    if { $h != $_legendHeight } {
-        EventuallyRequestLegend
-    } else {
-        DrawLegend
-    }
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkImageViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkImageViewer::EventuallyRequestLegend {} {
-    if { !$_legendPending } {
-        set _legendPending 1
-        $_dispatcher event -idle !legend
-    }
-}
-
-itcl::body Rappture::VtkImageViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 250 !resize
-    }
-}
-
-itcl::body Rappture::VtkImageViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after 100 !rotate
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::add {dataobj {settings ""}} {
-    if { ![$dataobj isvalid] } {
-        return;                         # Object doesn't contain valid data.
-    }
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) white
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::delete {args} {
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-#
-# scale  --
-#
-# This gets called either incrementally as new simulations are
-# added or all at once as a sequence of images.
-# This  accounts for all objects--even those not showing on the
-# screen.  Because of this, the limits are appropriate for all
-# objects as the user scans through data in the ResultSet viewer.
-#
-itcl::body Rappture::VtkImageViewer::scale {args} {
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                   # Object doesn't contain valid data.
-        }
-        foreach axis { x y } {
-            set units [$dataobj hints ${axis}units]
-            set found($units) 1
-            set lim [$dataobj limits $axis]
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {amin amax} $_limits($axis) break
-            if { $amin > $min } {
-                set amin $min
-            }
-            if { $amax < $max } {
-                set amax $max
-            }
-            set _limits($axis) [list $amin $amax]
-        }
-        foreach { fname lim } [$dataobj fieldlimits] {
-            if { ![info exists _limits($fname)] } {
-                set _limits($fname) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {fmin fmax} $_limits($fname) break
-            if { $fmin > $min } {
-                set fmin $min
-            }
-            if { $fmax < $max } {
-                set fmax $max
-            }
-            set _limits($fname) [list $fmin $fmax]
-        }
-    }
-    if { [array size found] > 1 } {
-        set _settings(-stretchtofit) 1
-    } else {
-        # Check if the range of the x and y axes requires that we stretch
-        # the contour to fit the plotting area.  This can happen when the
-        # x and y scales differ greatly (> 100x)
-        foreach {xmin xmax} $_limits(x) break
-        foreach {ymin ymax} $_limits(y) break
-        if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) ||
-             ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } {
-            set _settings(-stretchtofit) 1
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::Connect {} {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtkimageviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkImageViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkImageViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkImageViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    $_dispatcher cancel !legend
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    array unset _colormaps
-    global readyForNextFrame
-    set readyForNextFrame 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::ReceiveImage { args } {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        set time [clock seconds]
-        set date [clock format $time]
-        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            #puts stderr "round trip time [expr $finish -$_start] milliseconds"
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkImageViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_width != $w || $_height != $h || $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-        if { $_settings(-stretchtofit) } {
-            AdjustSetting -stretchtofit
-        }
-    }
-    if { $_reset } {
-        #
-        # Reset the camera and other view parameters
-        #
-        InitSettings -view3d -background \
-            -xgrid -ygrid -zgrid -axismode \
-            -axesvisible -axislabels -axisminorticks
-
-        SendCmd "axis tickpos outside"
-        SendCmd "axis lrot z 90"
-        $_arcball quaternion [ViewToQuaternion]
-        if {$_settings(-view3d) } {
-            if { $_view(-ortho)} {
-                SendCmd "camera mode ortho"
-            } else {
-                SendCmd "camera mode persp"
-            }
-            DoRotate
-            SendCmd "camera reset"
-        }
-        PanCamera
-        StopBufferingCommands
-        SendCmd "imgflush"
-        StartBufferingCommands
-    }
-
-    set _first ""
-    # Start off with no datasets visible.
-    SendCmd "dataset visible 0"
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-            SetCurrentFieldName $dataobj
-        }
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { ![info exists _datasets($tag)] } {
-                set bytes [$dataobj vtkdata $comp]
-                if 0 {
-                    set f [open /tmp/vtkimage.vtk "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $bytes
-                    close $f
-                }
-                set length [string length $bytes]
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $length
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "dataset add $tag data follows $length"
-                SendData $bytes
-                set _datasets($tag) 1
-                SetObjectStyle $dataobj $comp
-            }
-            if { [info exists _obj2ovride($dataobj-raise)] } {
-                # Setting dataset visible enables outline
-                # and image
-                SendCmd "dataset visible 1 $tag"
-            }
-        }
-    }
-
-    InitSettings -stretchtofit -outline
-    if { $_reset } {
-        foreach axis { x y z } {
-            set label ""
-            if { $_first != "" } {
-                set label [$_first hints ${axis}label]
-            }
-            if { $label == "" } {
-                set label [string toupper $axis]
-            }
-            # May be a space in the axis label.
-            SendCmd [list axis name $axis $label]
-
-            set units ""
-            if { $_first != "" } {
-                if {$axis == "z" && [$_first hints ${axis}units] == ""} {
-                    if {$_curFldName != ""} {
-                        set units [lindex $_fields($_curFldName) 1]
-                    }
-                } else {
-                    set units [$_first hints ${axis}units]
-                }
-            }
-            if { $units != "" } {
-                # May be a space in the axis units.
-                SendCmd [list axis units $axis $units]
-            }
-        }
-        #
-        # Reset the camera and other view parameters
-        #
-        $_arcball quaternion [ViewToQuaternion]
-        if {$_settings(-view3d) } {
-            if { $_view(-ortho)} {
-                SendCmd "camera mode ortho"
-            } else {
-                SendCmd "camera mode persp"
-            }
-            DoRotate
-            SendCmd "camera reset"
-        }
-        PanCamera
-        InitSettings -field -view3d
-        if { [array size _fields] < 2 } {
-            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
-        }
-        RequestLegend
-        set _reset 0
-    }
-    global readyForNextFrame
-    set readyForNextFrame 0;                # Don't advance to the next frame
-
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _datasets($tag)] && $_datasets($tag) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.36
-                -qx      0.25
-                -qy      0.50
-                -qz      0.70
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            $_arcball quaternion [ViewToQuaternion]
-            if {$_settings(-view3d) } {
-                DoRotate
-            }
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkImageViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkImageViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::InitSettings { args } {
-    foreach spec $args {
-        AdjustSetting $spec
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkImageViewer::AdjustSetting {what {value ""}} {
-    if { ![isconnected] } {
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            set bool $_settings($what)
-            SendCmd "axis visible all $bool"
-        }
-        "-axislabels" {
-            set bool $_settings($what)
-            SendCmd "axis labels all $bool"
-        }
-        "-axisminorticks" {
-            set bool $_settings($what)
-            SendCmd "axis minticks all $bool"
-        }
-        "-axismode" {
-            set mode [$itk_component(axismode) value]
-            set mode [$itk_component(axismode) translate $mode]
-            set _settings($what) $mode
-            SendCmd "axis flymode $mode"
-        }
-        "-background" {
-            set bg [$itk_component(background) value]
-            array set fgcolors {
-                "black" "white"
-                "white" "black"
-                "grey"  "black"
-            }
-            set fg $fgcolors($bg)
-            configure -plotbackground $bg -plotforeground $fg
-            $itk_component(view) delete "legend"
-            SendCmd "screen bgcolor [Color2RGB $bg]"
-            SendCmd "outline color [Color2RGB $fg]"
-            SendCmd "axis color all [Color2RGB $fg]"
-            DrawLegend
-        }
-        "-backingcolor" {
-            set color [$itk_component(backingcolor) value]
-            if { $color == "none" } {
-                if { $_settings(-backingvisible) } {
-                    SendCmd "image backing 0"
-                    set _settings(-backingvisible) 0
-                }
-            } else {
-                if { !$_settings(-backingvisible) } {
-                    SendCmd "image backing 1"
-                    set _settings(-backingvisible) 1
-                }
-                SendCmd "image color [Color2RGB $color]"
-            }
-        }
-        "-backingvisible" {
-            set bool $_settings($what)
-            SendCmd "image backing $bool"
-        }
-        "-colormap" {
-            set _changed($what) 1
-            StartBufferingCommands
-            set color [$itk_component(colormap) value]
-            set _settings($what) $color
-            SetCurrentColormap $color
-            if {$_settings(-colormapdiscrete)} {
-                 SendCmd "colormap res $_settings(-numcolors) $color"
-            }
-            StopBufferingCommands
-            EventuallyRequestLegend
-        }
-        "-colormapdiscrete" {
-            set bool $_settings($what)
-            StartBufferingCommands
-            if {$bool} {
-                SendCmd "colormap res $_settings(-numcolors)"
-            } else {
-                SendCmd "colormap res default"
-            }
-            StopBufferingCommands
-            EventuallyRequestLegend
-        }
-        "-field" {
-            set label [$itk_component(field) value]
-            set fname [$itk_component(field) translate $label]
-            set _settings($what) $fname
-            if { [info exists _fields($fname)] } {
-                foreach { label units components } $_fields($fname) break
-                if { $components > 1 } {
-                    set _colorMode vmag
-                } else {
-                    set _colorMode scalar
-                }
-                set _curFldName $fname
-                set _curFldLabel $label
-            } else {
-                puts stderr "unknown field \"$fname\""
-                return
-            }
-
-            # Get the new limits because the field changed.
-            SendCmd [list dataset scalar $_curFldName]
-            #SendCmd [list image colormode scalar $_curFldName]
-            SendCmd "camera reset"
-            DrawLegend
-        }
-        "-legendvisible" {
-            if { !$_settings($what) } {
-                $itk_component(view) delete legend
-            }
-            DrawLegend
-        }
-        "-level" {
-            set val $_settings($what)
-            SendCmd "image level $val"
-        }
-        "-opacity" {
-            set _changed($what) 1
-            if { $_settings(-view3d) } {
-                set _settings(-saveopacity) $_settings($what)
-                set val [expr $_settings($what) * 0.01]
-                SendCmd "image opacity $val"
-            } else {
-                SendCmd "image opacity 1.0"
-            }
-        }
-        "-outline" {
-            set bool $_settings($what)
-            SendCmd "outline visible $bool"
-        }
-        "-stretchtofit" {
-            set bool $_settings($what)
-            if { $bool } {
-                if { $_settings(-view3d) } {
-                    SendCmd "camera aspect native"
-                } else {
-                    SendCmd "camera aspect window"
-                }
-            } else {
-                SendCmd "camera aspect native"
-            }
-        }
-        "-view3d" {
-            set bool $_settings($what)
-            set c $itk_component(view)
-            StartBufferingCommands
-            # Fix image scale: 0 for contours, 1 for images.
-            if { $bool } {
-                set _settings(-opacity) $_settings(-saveopacity)
-            } else {
-                set _settings(-opacity) 100
-            }
-            AdjustSetting -opacity
-            if { $bool } {
-                $itk_component(opacity) configure -state normal
-                $itk_component(opacity_l) configure -state normal
-                if {$_view(-ortho)} {
-                    SendCmd "camera mode ortho"
-                } else {
-                    SendCmd "camera mode persp"
-                }
-                SendCmd "camera aspect native"
-            } else {
-                $itk_component(opacity) configure -state disabled
-                $itk_component(opacity_l) configure -state disabled
-                SendCmd "camera mode image"
-                if {$_settings(-stretchtofit)} {
-                    SendCmd "camera aspect window"
-                }
-            }
-            if { $bool } {
-                set q [ViewToQuaternion]
-                $_arcball quaternion $q
-                SendCmd "camera orient $q"
-            } else {
-                bind $c <ButtonPress-1> {}
-                bind $c <B1-Motion> {}
-                bind $c <ButtonRelease-1> {}
-            }
-            SendCmd "camera reset"
-            # Fix the mouse bindings for rotation/panning and the
-            # camera mode. Ideally we'd create a bindtag for these.
-            if { $bool } {
-                # Bindings for rotation via mouse
-                bind $c <ButtonPress-1> \
-                    [itcl::code $this Rotate click %x %y]
-                bind $c <B1-Motion> \
-                    [itcl::code $this Rotate drag %x %y]
-                bind $c <ButtonRelease-1> \
-                    [itcl::code $this Rotate release %x %y]
-            }
-            StopBufferingCommands
-        }
-        "-window" {
-            set val $_settings($what)
-            SendCmd "image window $val"
-        }
-        "-xgrid" - "-ygrid" - "-zgrid" {
-            set axis [string tolower [string range $what 1 1]]
-            set bool $_settings($what)
-            SendCmd "axis grid $axis $bool"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-#
-# RequestLegend --
-#
-# Request a new legend from the server.  The size of the legend
-# is determined from the height of the canvas.
-#
-# This should be called when
-#   1.  A new current colormap is set.
-#   2.  Window is resized.
-#   3.  The limits of the data have changed.  (Just need a redraw).
-#   4.  Number of isolines have changed. (Just need a redraw).
-#   5.  Legend becomes visible (Just need a redraw).
-#
-itcl::body Rappture::VtkImageViewer::RequestLegend {} {
-    set _legendPending 0
-    set font "Arial 8"
-    set w 12
-    set lineht [font metrics $font -linespace]
-    # color ramp height = (canvas height) - (min and max value lines) - 2
-    set h [expr {$_height - 2 * ($lineht + 2)}]
-    set _legendHeight $h
-
-    set fname $_curFldName
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a title too, subtract one more line
-    if { $title != "" } {
-        incr h -$lineht
-    }
-    if { $h < 1 } {
-        return
-    }
-    # Set the legend on the first dataset.
-    if { $_currentColormap != "" && $_currentColormap != "none" } {
-        set cmap $_currentColormap
-        if { ![info exists _colormaps($cmap)] } {
-            BuildColormap $cmap
-            set _colormaps($cmap) 1
-        }
-        #SendCmd [list legend $cmap scalar $_curFldName {} $w $h 0]
-        SendCmd "legend2 $cmap $w $h"
-    }
-}
-
-#
-# SetCurrentColormap --
-#
-itcl::body Rappture::VtkImageViewer::SetCurrentColormap { name } {
-    # Keep track of the colormaps that we build.
-    if { $name != "none" && ![info exists _colormaps($name)] } {
-        BuildColormap $name
-        set _colormaps($name) 1
-    }
-    set _currentColormap $name
-    SendCmd "image colormap $_currentColormap"
-}
-
-
-#
-# BuildColormap --
-#
-# Build the designated colormap on the server.
-#
-itcl::body Rappture::VtkImageViewer::BuildColormap { name } {
-    set cmap [ColorsToColormap $name]
-    if { [llength $cmap] == 0 } {
-        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
-    }
-    set amap "0.0 1.0 1.0 1.0"
-    SendCmd "colormap add $name { $cmap } { $amap }"
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -mode
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkImageViewer::mode {
-    switch -- $itk_option(-mode) {
-        "volume" {
-            set _settings(-view3d) 1
-        }
-        "vtkimage" {
-            set _settings(-view3d) 0
-        }
-        default {
-            error "unknown mode settings \"$itk_option(-mode)\""
-        }
-    }
-    if { !$_reset } {
-        AdjustSetting -view3d
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkImageViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        if { !$_reset } {
-            SendCmd "screen bgcolor $rgb"
-        }
-        $itk_component(view) configure -background $itk_option(-plotbackground)
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkImageViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        if { !$_reset } {
-            SendCmd "axis color all $rgb"
-            SendCmd "outline color $rgb"
-        }
-    }
-}
-
-itcl::body Rappture::VtkImageViewer::BuildImageTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Image Settings" \
-        -icon [Rappture::icon contour2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.legend \
-        -text "Legend" \
-        -variable [itcl::scope _settings(-legendvisible)] \
-        -command [itcl::code $this AdjustSetting -legendvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.outline \
-        -text "Outline" \
-        -variable [itcl::scope _settings(-outline)] \
-        -command [itcl::code $this AdjustSetting -outline] \
-        -font "Arial 9"
-
-    checkbutton $inner.backing \
-        -text "Backing" \
-        -variable [itcl::scope _settings(-backingvisible)] \
-        -command [itcl::code $this AdjustSetting -backingvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.stretch \
-        -text "Stretch to fit" \
-        -variable [itcl::scope _settings(-stretchtofit)] \
-        -command [itcl::code $this AdjustSetting -stretchtofit] \
-        -font "Arial 9"
-
-    checkbutton $inner.colormapDiscrete \
-        -text "Discrete Colormap" \
-        -variable [itcl::scope _settings(-colormapdiscrete)] \
-        -command [itcl::code $this AdjustSetting -colormapdiscrete] \
-        -font "Arial 9"
-
-    itk_component add field_l {
-        label $inner.field_l -text "Field" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add field {
-        Rappture::Combobox $inner.field -width 10 -editable 0
-    }
-    bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting -field]
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9"
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList -includeNone]
-
-    $itk_component(colormap) value "BCGYR"
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -colormap]
-
-    label $inner.backingcolor_l -text "Backing Color" -font "Arial 9"
-    itk_component add backingcolor {
-        Rappture::Combobox $inner.backingcolor -width 10 -editable 0
-    }
-    $inner.backingcolor choices insert end \
-        "black"              "black"            \
-        "blue"               "blue"             \
-        "cyan"               "cyan"             \
-        "green"              "green"            \
-        "grey"               "grey"             \
-        "magenta"            "magenta"          \
-        "orange"             "orange"           \
-        "red"                "red"              \
-        "white"              "white"            \
-        "none"               "none"
-
-    $itk_component(backingcolor) value $_settings(-backingcolor)
-    bind $inner.backingcolor <<Value>> \
-        [itcl::code $this AdjustSetting -backingcolor]
-
-    label $inner.background_l -text "Background Color" -font "Arial 9"
-    itk_component add background {
-        Rappture::Combobox $inner.background -width 10 -editable 0
-    }
-    $inner.background choices insert end \
-        "black"              "black"            \
-        "white"              "white"            \
-        "grey"               "grey"
-
-    $itk_component(background) value "white"
-    bind $inner.background <<Value>> \
-        [itcl::code $this AdjustSetting -background]
-
-    itk_component add opacity_l {
-        label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add opacity {
-        ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-            -variable [itcl::scope _settings(-opacity)] \
-            -showvalue off \
-            -command [itcl::code $this AdjustSetting -opacity]
-    }
-
-    itk_component add window_l {
-        label $inner.window_l -text "Window" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add window {
-        ::scale $inner.window -from 0 -to 255 -orient horizontal \
-            -variable [itcl::scope _settings(-window)] \
-            -showvalue off \
-            -command [itcl::code $this AdjustSetting -window]
-    }
-    itk_component add level_l {
-        label $inner.level_l -text "Level" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add level {
-        ::scale $inner.level -from 0 -to 255 -orient horizontal \
-            -variable [itcl::scope _settings(-level)] \
-            -showvalue off \
-            -command [itcl::code $this AdjustSetting -level]
-    }
-
-    frame $inner.separator1 -height 2 -relief sunken -bd 1
-    frame $inner.separator2 -height 2 -relief sunken -bd 1
-
-    blt::table $inner \
-        0,0 $inner.field_l -anchor w -pady 2 \
-        0,1 $inner.field -anchor w -pady 2 -fill x \
-        1,0 $inner.colormap_l -anchor w -pady 2  \
-        1,1 $inner.colormap   -anchor w -pady 2 -fill x  \
-        2,0 $inner.backingcolor_l  -anchor w -pady 2  \
-        2,1 $inner.backingcolor    -anchor w -pady 2 -fill x  \
-        3,0 $inner.background_l -anchor w -pady 2 \
-        3,1 $inner.background -anchor w -pady 2  -fill x \
-        4,0 $inner.backing -anchor w -pady 2 -cspan 2 \
-        5,0 $inner.stretch    -anchor w -pady 2 -cspan 2 \
-        7,0 $inner.legend     -anchor w -pady 2 -cspan 2 \
-        8,0 $inner.colormapDiscrete -anchor w -pady 2 -cspan 2 \
-        11,0 $inner.separator1 -padx 2 -fill x -cspan 2 \
-        12,0 $inner.outline    -anchor w -pady 2 -cspan 2 \
-        13,0 $inner.separator2 -padx 2 -fill x -cspan 2 \
-        15,0 $inner.opacity_l -anchor w -pady 2 \
-        15,1 $inner.opacity   -fill x   -pady 2 \
-        16,0 $inner.window_l -anchor w -pady 2 \
-        16,1 $inner.window   -fill x   -pady 2 \
-        17,0 $inner.level_l -anchor w -pady 2 \
-        17,1 $inner.level   -fill x   -pady 2
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r19 c1 -resize expand
-}
-
-itcl::body Rappture::VtkImageViewer::BuildAxisTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _settings(-axislabels)] \
-        -command [itcl::code $this AdjustSetting -axislabels] \
-        -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9"
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _settings(-xgrid)] \
-        -command [itcl::code $this AdjustSetting -xgrid] \
-        -font "Arial 9"
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _settings(-ygrid)] \
-        -command [itcl::code $this AdjustSetting -ygrid] \
-        -font "Arial 9"
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _settings(-zgrid)] \
-        -command [itcl::code $this AdjustSetting -zgrid] \
-        -font "Arial 9"
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _settings(-axisminorticks)] \
-        -command [itcl::code $this AdjustSetting -axisminorticks] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-
-    itk_component add axismode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axismode) value $_settings(-axismode)
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
-
-    blt::table $inner \
-        0,0 $inner.visible -anchor w -cspan 4 \
-        1,0 $inner.labels  -anchor w -cspan 4 \
-        2,0 $inner.minorticks  -anchor w -cspan 4 \
-        4,0 $inner.grid_l  -anchor w \
-        4,1 $inner.xgrid   -anchor w \
-        4,2 $inner.ygrid   -anchor w \
-        4,3 $inner.zgrid   -anchor w \
-        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
-        5,1 $inner.mode    -fill x -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-itcl::body Rappture::VtkImageViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set labels { qx qy qz qw xpan ypan zoom }
-    set row 1
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this camera set -ortho] \
-        -font "Arial 9"
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkImageViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkImageViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            set contents [$dataobj vtkdata $comp]
-            append bytes "$contents\n"
-        }
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkImageViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkImageViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-#
-# SetObjectStyle --
-#
-# Set the style of the image/contour object.  This gets calls
-# for each dataset once as it is loaded.  It can overridden by
-# the user controls.
-#
-itcl::body Rappture::VtkImageViewer::SetObjectStyle { dataobj comp } {
-    # Parse style string.
-    set tag $dataobj-$comp
-    array set style {
-        -color none
-        -opacity 1.0
-    }
-    set stylelist [$dataobj style $comp]
-    if { $stylelist != "" } {
-        array set style $stylelist
-    }
-    # This is too complicated.  We want to set the colormap, number of
-    # isolines and opacity for the dataset.  They can be the default values,
-    # the style hints loaded with the dataset, or set by user controls.  As
-    # datasets get loaded, they first use the defaults that are overidden
-    # by the style hints.  If the user changes the global controls, then that
-    # overrides everything else.  I don't know what it means when global
-    # controls are specified as style hints by each dataset.  It complicates
-    # the code to handle aberrant cases.
-
-    if { $_changed(-opacity) } {
-        set style(-opacity) [expr $_settings(-opacity) * 0.01]
-    }
-    if { $_changed(-colormap) } {
-        set style(-color) $_settings(-colormap)
-    }
-    if { $_currentColormap == "" } {
-        $itk_component(colormap) value $style(-color)
-    }
-    if { [info exists style(-stretchtofit)] } {
-        set _settings(-stretchtofit) $style(-stretchtofit)
-        AdjustSetting -stretchtofit
-    }
-    SendCmd "outline add $tag"
-    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
-    SendCmd "outline visible $_settings(-outline) $tag"
-    SendCmd "image add $tag"
-    SetCurrentColormap $style(-color)
-    set color [$itk_component(backingcolor) value]
-    SendCmd "image color [Color2RGB $color] $tag"
-    SendCmd "image opacity $style(-opacity) $tag"
-    set _settings(-opacity) [expr $style(-opacity) * 100.0]
-}
-
-itcl::body Rappture::VtkImageViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::ReceiveLegend { colormap title min max size } {
-    #puts stderr "ReceiveLegend colormap=$colormap title=$title range=$min,$max size=$size"
-    if { [isconnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend)] } {
-            set _image(legend) [image create photo]
-        }
-        $_image(legend) configure -data $bytes
-        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-        if { [catch {DrawLegend} errs] != 0 } {
-            global errorInfo
-            puts stderr "errs=$errs errorInfo=$errorInfo"
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-# Draws the legend in its own canvas on the right side of the plot area.
-#
-itcl::body Rappture::VtkImageViewer::DrawLegend {} {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    set x [expr $w - 2]
-    if { !$_settings(-legendvisible) } {
-        $c delete legend
-        return
-    }
-    if { [$c find withtag "legend"] == "" } {
-        set y 2
-        # If there's a legend title, create a text item for the title.
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "title legend" \
-            -font $font
-        if { $title != "" } {
-            incr y $lineht
-        }
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "vmax legend" \
-            -font $font
-        incr y $lineht
-        $c create image $x $y \
-            -anchor ne \
-            -image $_image(legend) -tags "colormap legend"
-        $c create rectangle $x $y 1 1 \
-            -fill "" -outline "" -tags "sensor legend"
-        $c create text $x [expr {$h-2}] \
-            -anchor se \
-            -fill $itk_option(-plotforeground) -tags "vmin legend" \
-            -font $font
-        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
-        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
-        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
-    }
-
-    set x2 $x
-    set iw [image width $_image(legend)]
-    set ih [image height $_image(legend)]
-    set x1 [expr $x2 - ($iw*12)/10]
-
-    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
-    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
-    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
-    # Reset the item coordinates according the current size of the plot.
-    if { [info exists _limits($_curFldName)] } {
-        foreach { vmin vmax } $_limits($_curFldName) break
-        $c itemconfigure vmin -text [format %g $vmin]
-        $c itemconfigure vmax -text [format %g $vmax]
-    }
-    set y 2
-    # If there's a legend title, move the title to the correct position
-    if { $title != "" } {
-        $c itemconfigure title -text $title
-        $c coords title $x $y
-        incr y $lineht
-    }
-    $c coords vmax $x $y
-    incr y $lineht
-    $c coords colormap $x $y
-    $c coords sensor [expr $x - $iw] $y $x [expr $y + $ih]
-    $c raise sensor
-    $c coords vmin $x [expr {$h - 2}]
-}
-
-#
-# EnterLegend --
-#
-itcl::body Rappture::VtkImageViewer::EnterLegend { x y } {
-    SetLegendTip $x $y
-}
-
-#
-# MotionLegend --
-#
-itcl::body Rappture::VtkImageViewer::MotionLegend { x y } {
-    Rappture::Tooltip::tooltip cancel
-    set c $itk_component(view)
-    set cw [winfo width $c]
-    set ch [winfo height $c]
-    if { $x >= 0 && $x < $cw && $y >= 0 && $y < $ch } {
-        SetLegendTip $x $y
-    }
-}
-
-#
-# LeaveLegend --
-#
-itcl::body Rappture::VtkImageViewer::LeaveLegend { } {
-    Rappture::Tooltip::tooltip cancel
-    .rappturetooltip configure -icon ""
-}
-
-#
-# SetLegendTip --
-#
-itcl::body Rappture::VtkImageViewer::SetLegendTip { x y } {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set ih [image height $_image(legend)]
-    # Subtract off the offset of the color ramp from the top of the canvas
-    set iy [expr $y - ($lineht + 2)]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a legend title, increase the offset by the line height.
-    if { $title != "" } {
-        incr iy -$lineht
-    }
-
-    # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
-        return
-    }
-
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    set color [eval format "\#%02x%02x%02x" $pixel]
-    $_image(swatch) put black  -to 0 0 23 23
-    $_image(swatch) put $color -to 1 1 22 22
-
-    # Compute the value of the point
-    if { [info exists _limits($fname)] } {
-        foreach { vmin vmax } $_limits($fname) break
-        set t [expr 1.0 - (double($iy) / double($ih-1))]
-        set value [expr $t * ($vmax - $vmin) + $vmin]
-    } else {
-        set value 0.0
-    }
-    set tipx [expr $x + 15]
-    set tipy [expr $y - 5]
-    .rappturetooltip configure -icon $_image(swatch)
-    if { [info exists _isolines($y)] } {
-        Rappture::Tooltip::text $c [format "$title %g (isoline)" $_isolines($y)]
-    } else {
-        Rappture::Tooltip::text $c [format "$title %g" $value]
-    }
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendTitleAction post
-# USAGE: LegendTitleAction enter
-# USAGE: LegendTitleAction leave
-# USAGE: LegendTitleAction save
-#
-# Used internally to handle the dropdown list for the fields menu combobox.
-# The post option is invoked when the field title is pressed to launch the
-# dropdown.  The enter option is invoked when the user mouses over the field
-# title. The leave option is invoked when the user moves the mouse away
-# from the field title.  The save option is invoked whenever there is a
-# selection from the list, to alert the visualization server.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkImageViewer::LegendTitleAction {option} {
-    set c $itk_component(view)
-    switch -- $option {
-        post {
-            foreach { x1 y1 x2 y2 } [$c bbox title] break
-            set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]]
-            set x [expr $x1 + [winfo rootx $itk_component(view)]]
-            set y [expr $y2 + [winfo rooty $itk_component(view)]]
-            tk_popup $itk_component(fieldmenu) $x $y
-        }
-        enter {
-            $c itemconfigure title -fill red
-        }
-        leave {
-            $c itemconfigure title -fill $itk_option(-plotforeground)
-        }
-        save {
-            $itk_component(field) value $_curFldLabel
-            AdjustSetting -field
-        }
-        default {
-            error "bad option \"$option\": should be post, enter, leave or save"
-        }
-    }
-}
-
-itcl::body Rappture::VtkImageViewer::SetOrientation { side } {
-    array set positions {
-        front  "0.707107 0.707107 0 0"
-        back   "0 0 0.707107 0.707107"
-        left   "0.5 0.5 -0.5 -0.5"
-        right  "0.5 0.5 0.5 0.5"
-        top    "1 0 0 0"
-        bottom "0 1 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
-
-itcl::body Rappture::VtkImageViewer::SetCurrentFieldName { dataobj } {
-    set _first $dataobj
-    $itk_component(field) choices delete 0 end
-    $itk_component(fieldmenu) delete 0 end
-    array unset _fields
-    set _curFldName ""
-    foreach cname [$_first components] {
-        foreach fname [$_first fieldnames $cname] {
-            if { [info exists _fields($fname)] } {
-                continue
-            }
-            foreach { label units components } \
-                [$_first fieldinfo $fname] break
-            $itk_component(field) choices insert end "$fname" "$label"
-            $itk_component(fieldmenu) add radiobutton -label "$label" \
-                -value $label -variable [itcl::scope _curFldLabel] \
-                -selectcolor red \
-                -activebackground $itk_option(-plotbackground) \
-                -activeforeground $itk_option(-plotforeground) \
-                -font "Arial 8" \
-                -command [itcl::code $this LegendTitleAction save]
-            set _fields($fname) [list $label $units $components]
-            if { $_curFldName == "" } {
-                set _curFldName $fname
-                set _curFldLabel $label
-            }
-        }
-    }
-    $itk_component(field) value $_curFldLabel
-}
Index: trunk/gui/scripts/vtkisosurfaceviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkisosurfaceviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,3159 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtkisosurfaceviewer - Vtk 3D contour object viewer
-#
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *VtkIsosurfaceViewer.width 4i widgetDefault
-option add *VtkIsosurfaceViewer*cursor crosshair widgetDefault
-option add *VtkIsosurfaceViewer.height 4i widgetDefault
-option add *VtkIsosurfaceViewer.foreground black widgetDefault
-option add *VtkIsosurfaceViewer.controlBackground gray widgetDefault
-option add *VtkIsosurfaceViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkIsosurfaceViewer.plotBackground black widgetDefault
-option add *VtkIsosurfaceViewer.plotForeground white widgetDefault
-option add *VtkIsosurfaceViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkIsosurfaceViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkIsosurfaceViewer::SetServerList
-}
-
-itcl::class Rappture::VtkIsosurfaceViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildColormap { name }
-    private method BuildCutplanesTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildIsosurfaceTab {}
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method DisableMouseRotationBindings {}
-    private method Disconnect {}
-    private method DoChangeContourLevels {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method DrawLegend {}
-    private method EnterLegend { x y }
-    private method EventuallyChangeContourLevels {}
-    private method EventuallyRequestLegend {}
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method EventuallySetCutplane { axis args }
-    private method GenerateContourList {}
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method LeaveLegend {}
-    private method LegendB1Motion {status x y}
-    private method LegendPointToValue { x y }
-    private method LegendProbeSingleContour { x y }
-    private method LegendRangeAction { option args }
-    private method LegendRangeValidate { widget which value }
-    private method LegendTitleAction { option }
-    private method MotionLegend { x y }
-    private method MouseOver2Which {}
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { colormap title min max size }
-    private method RequestLegend {}
-    private method Rotate {option x y}
-    private method SetCurrentColormap { color }
-    private method SetCurrentFieldName { dataobj }
-    private method SetLegendTip { x y }
-    private method SetMinMaxGauges { min max }
-    private method SetObjectStyle { dataobj comp }
-    private method SetOrientation { side }
-    private method SetupKeyboardBindings {}
-    private method SetupMousePanningBindings {}
-    private method SetupMouseRotationBindings {}
-    private method SetupMouseZoomBindings {}
-    private method Slice {option args}
-    private method ToggleCustomRange { args }
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _colormaps;        # contains all the colormaps
-                                        # in the server.
-    # The name of the current colormap used.  The colormap is global to all
-    # heightmaps displayed.
-    private variable _currentColormap ""
-    private variable _currentNumContours -1
-
-    private variable _click;            # info used for rotate operations
-    private variable _limits;           # autoscale min/max for all axes
-    private variable _view;             # view params for 3D view
-    private variable _settings
-    private variable _changed
-    private variable _reset 1;          # Connection to server has been reset.
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _title ""
-    private variable _isolines
-    private variable _contourList
-    private variable _currentLimits ""
-    private variable _widget
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _legendPending 0
-    private variable _rotatePending 0
-    private variable _cutplanePending 0
-    private variable _fields
-    private variable _curFldName ""
-    private variable _curFldLabel ""
-    private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
-    private variable _mouseOver "";     # what called LegendRangeAction:
-                                        # vmin or vmax
-    private variable _customRangeClick 1; # what called ToggleCustomRange
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkIsosurfaceViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::constructor {args} {
-    set _serverType "vtkvis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    # Contour levels event
-    $_dispatcher register !contours
-    $_dispatcher dispatch $this !contours \
-        "[itcl::code $this DoChangeContourLevels]; list"
-
-    # X-Cutplane event
-    $_dispatcher register !xcutplane
-    $_dispatcher dispatch $this !xcutplane \
-        "[itcl::code $this AdjustSetting -xcutplaneposition]; list"
-
-    # Y-Cutplane event
-    $_dispatcher register !ycutplane
-    $_dispatcher dispatch $this !ycutplane \
-        "[itcl::code $this AdjustSetting -ycutplaneposition]; list"
-
-    # Z-Cutplane event
-    $_dispatcher register !zcutplane
-    $_dispatcher dispatch $this !zcutplane \
-        "[itcl::code $this AdjustSetting -zcutplaneposition]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _contourList {
-        numLevels       10
-        reqValues       ""
-        updatePending   0
-        values          ""
-    }
-    array set _settings {
-        -axesvisible            1
-        -axislabels             1
-        -axisminorticks         1
-        -axismode               "static"
-        -background             black
-        -colormap               BCGYR
-        -colormapvisible        1
-        -customrange            0
-        -customrangemin         0
-        -customrangemax         1
-        -cutplaneedges          0
-        -cutplanelighting       1
-        -cutplaneopacity        1.0
-        -cutplanepreinterp      1
-        -cutplanesvisible       0
-        -cutplanewireframe      0
-        -field                  "Default"
-        -isolinecolor           white
-        -isosurfaceedges        0
-        -isosurfacelighting     1
-        -isosurfaceopacity      0.6
-        -isosurfacevisible      1
-        -isosurfacewireframe    0
-        -legendvisible          1
-        -numcontours            10
-        -outline                0
-        -xcutplaneposition      50
-        -xcutplanevisible       1
-        -xgrid                  0
-        -ycutplaneposition      50
-        -ycutplanevisible       1
-        -ygrid                  0
-        -zcutplaneposition      50
-        -zcutplanevisible       1
-        -zgrid                  0
-    }
-    array set _changed {
-        -colormap               0
-        -cutplaneedges          0
-        -cutplanelighting       0
-        -cutplaneopacity        0
-        -cutplanepreinterp      0
-        -cutplanesvisible       0
-        -cutplanewireframe      0
-        -isosurfaceedges        0
-        -isosurfacelighting     0
-        -isosurfaceopacity      0
-        -isosurfacevisible      0
-        -isosurfacewireframe    0
-        -numcontours            0
-        -outline                0
-        -xcutplaneposition      0
-        -xcutplanevisible       0
-        -ycutplaneposition      0
-        -ycutplanevisible       0
-        -zcutplaneposition      0
-        -zcutplanevisible       0
-    }
-    array set _widget {
-        -isosurfaceopacity      60
-        -cutplaneopacity        100
-    }
-
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    itk_component add fieldmenu {
-        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
-            -tearoff 0
-    } {
-        usual
-        ignore -background -foreground -relief -tearoff
-    }
-
-    # add an editor for adjusting the legend min and max values
-    itk_component add editor {
-        Rappture::Editor $itk_interior.editor \
-            -activatecommand [itcl::code $this LegendRangeAction activate] \
-            -validatecommand [itcl::code $this LegendRangeAction validate] \
-            -applycommand [itcl::code $this LegendRangeAction apply]
-    }
-
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add contour {
-        Rappture::PushButton $f.contour \
-            -onimage [Rappture::icon volume-on] \
-            -offimage [Rappture::icon volume-off] \
-            -variable [itcl::scope _settings(-isosurfacevisible)] \
-            -command [itcl::code $this AdjustSetting -isosurfacevisible]
-    }
-    $itk_component(contour) select
-    Rappture::Tooltip::for $itk_component(contour) \
-        "Hide the isosurface"
-    pack $itk_component(contour) -padx 2 -pady 2
-
-    itk_component add cutplane {
-        Rappture::PushButton $f.cutplane \
-            -onimage [Rappture::icon cutbutton] \
-            -offimage [Rappture::icon cutbutton] \
-            -variable [itcl::scope _settings(-cutplanesvisible)] \
-            -command [itcl::code $this AdjustSetting -cutplanesvisible]
-    }
-    Rappture::Tooltip::for $itk_component(cutplane) \
-        "Show the cutplanes"
-    pack $itk_component(cutplane) -padx 2 -pady 2
-
-    if { [catch {
-        BuildIsosurfaceTab
-        BuildCutplanesTab
-        BuildAxisTab
-        BuildCameraTab
-    } errs] != 0 } {
-        puts stderr errs=$errs
-    }
-
-    # Legend
-    set _image(legend) [image create photo]
-    itk_component add legend {
-        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -plotbackground plotBackground Background
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    SetupMouseRotationBindings
-    SetupMousePanningBindings
-    SetupMouseZoomBindings
-    SetupKeyboardBindings
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::destructor {} {
-    Disconnect
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::SetupMouseRotationBindings {} {
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::DisableMouseRotationBindings {} {
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> ""
-    bind $itk_component(view) <B1-Motion> ""
-    bind $itk_component(view) <ButtonRelease-1> ""
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::SetupMousePanningBindings {} {
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::SetupMouseZoomBindings {} {
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::SetupKeyboardBindings {} {
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size $_width $_height"
-
-    EventuallyRequestLegend
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::DoChangeContourLevels {} {
-    GenerateContourList
-    SendCmd [list contour3d contourlist $_contourList(values)]
-    SendCmd [list camera reset]
-    DrawLegend
-    set _contourList(updatePending) 0
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::EventuallyRequestLegend {} {
-    if { !$_legendPending } {
-        set _legendPending 1
-        $_dispatcher event -idle !legend
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 400 !resize
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after 100 !rotate
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::EventuallySetCutplane { axis args } {
-    if { !$_cutplanePending } {
-        set _cutplanePending 1
-        $_dispatcher event -after 100 !${axis}cutplane
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::EventuallyChangeContourLevels {} {
-    set n $_contourList(numLevels)
-    set _contourList(values) ""
-    if { !$_contourList(updatePending) } {
-        set _contourList(updatePending) 1
-        $_dispatcher event -after 100 !contours
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::add {dataobj {settings ""}} {
-    if { ![$dataobj isvalid] } {
-        return;                         # Object doesn't contain valid data.
-    }
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::delete {args} {
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::scale { args } {
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                   # Object doesn't contain valid data.
-        }
-        foreach axis { x y z } {
-            set lim [$dataobj limits $axis]
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {amin amax} $_limits($axis) break
-            if { $amin > $min } {
-                set amin $min
-            }
-            if { $amax < $max } {
-                set amax $max
-            }
-            set _limits($axis) [list $amin $amax]
-        }
-        foreach { fname lim } [$dataobj fieldlimits] {
-            if { ![info exists _limits($fname)] } {
-                set _limits($fname) $lim
-
-                # set reasonable defaults for
-                # customrangevmin and customrangevmax
-                foreach {min max} $lim break
-                SetMinMaxGauges $min $max
-                set _settings(-customrangemin) $min
-                set _settings(-customrangemax) $max
-
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {fmin fmax} $_limits($fname) break
-            if { ! $_settings(-customrange) } {
-                SetMinMaxGauges $fmin $fmax
-            }
-            if { $fmin > $min } {
-                set fmin $min
-            }
-            if { $fmax < $max } {
-                set fmax $max
-            }
-            set _limits($fname) [list $fmin $fmax]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::Connect {} {
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtkisosurfaceviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkIsosurfaceViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkIsosurfaceViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkIsosurfaceViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    $_dispatcher cancel !xcutplane
-    $_dispatcher cancel !ycutplane
-    $_dispatcher cancel !zcutplane
-    $_dispatcher cancel !legend
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    array unset _colormaps
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::ReceiveImage { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        #set time [clock seconds]
-        #set date [clock format $time]
-        #set w [image width $_image(plot)]
-        #set h [image height $_image(plot)]
-        #puts stderr "$date: received image ${w}x${h} image"
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            #puts stderr "round trip time [expr $finish -$_start] milliseconds"
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkIsosurfaceViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-
-        # Reset the camera and other view parameters
-        $_arcball quaternion [ViewToQuaternion]
-        InitSettings -ortho
-        DoRotate
-        PanCamera
-        set _first ""
-        InitSettings -background \
-            -xgrid -ygrid -zgrid -axismode \
-            -axesvisible -axislabels -axisminorticks
-        #SendCmd "axis lformat all %g"
-        StopBufferingCommands
-        SendCmd "imgflush"
-        StartBufferingCommands
-    }
-    set _first ""
-    SendCmd "dataset visible 0"
-    eval scale $_dlist
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-            SetCurrentFieldName $dataobj
-        }
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { ![info exists _datasets($tag)] } {
-                set bytes [$dataobj vtkdata $comp]
-                if 0 {
-                    set f [open "/tmp/isosurface.vtk" "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $bytes
-                    close $f
-                }
-                set length [string length $bytes]
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $length
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "dataset add $tag data follows $length"
-                SendData $bytes
-                set _datasets($tag) 1
-                SetObjectStyle $dataobj $comp
-            }
-            if { [info exists _obj2ovride($dataobj-raise)] } {
-                SendCmd "contour3d visible 1 $tag"
-            }
-        }
-    }
-
-    InitSettings -cutplanesvisible -isosurfacevisible -outline
-    if { $_reset } {
-        # These are settings that rely on a dataset being loaded.
-        InitSettings \
-            -field -range \
-            -isosurfaceedges -isosurfacelighting -isosurfaceopacity \
-            -isosurfacewireframe \
-            -xcutplaneposition -ycutplaneposition -zcutplaneposition \
-            -xcutplanevisible -ycutplanevisible -zcutplanevisible \
-            -cutplanepreinterp -numcontours
-
-        Zoom reset
-        foreach axis { x y z } {
-            set label ""
-            if { $_first != "" } {
-                set label [$_first hints ${axis}label]
-            }
-            if { $label == "" } {
-                set label [string toupper $axis]
-            }
-            # There may be a space in the axis label.
-            SendCmd [list axis name $axis $label]
-        }
-        if { [array size _fields] < 2 } {
-            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
-        }
-        set _reset 0
-    }
-    # Redraw the legend even if we're using the same colormap. The position
-    # of the isolines may have changed because the range of data changed.
-    DrawLegend
-
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands;              # Turn off buffering and send commands.
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _datasets($tag)] && $_datasets($tag) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            $_arcball quaternion [ViewToQuaternion]
-            DoRotate
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::InitSettings { args } {
-    foreach spec $args {
-        AdjustSetting $spec
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkIsosurfaceViewer::AdjustSetting {what {value ""}} {
-    DebugTrace "Enter"
-    if { ![isconnected] } {
-        DebugTrace "Not connected"
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            set bool $_settings($what)
-            SendCmd "axis visible all $bool"
-        }
-        "-axislabels" {
-            set bool $_settings($what)
-            SendCmd "axis labels all $bool"
-        }
-        "-axisminorticks" {
-            set bool $_settings($what)
-            SendCmd "axis minticks all $bool"
-        }
-        "-axismode" {
-            set mode [$itk_component(axisMode) value]
-            set mode [$itk_component(axisMode) translate $mode]
-            set _settings($what) $mode
-            SendCmd "axis flymode $mode"
-        }
-        "-background" {
-            set bgcolor [$itk_component(background) value]
-            array set fgcolors {
-                "black" "white"
-                "white" "black"
-                "grey"  "black"
-            }
-            configure -plotbackground $bgcolor \
-                -plotforeground $fgcolors($bgcolor)
-            $itk_component(view) delete "legend"
-            DrawLegend
-        }
-        "-colormap" {
-            set _changed($what) 1
-            StartBufferingCommands
-            set color [$itk_component(colormap) value]
-            set _settings($what) $color
-            if { $color == "none" } {
-                if { $_settings(-colormapvisible) } {
-                    SendCmd "contour3d colormode constant {}"
-                    set _settings(-colormapvisible) 0
-                }
-            } else {
-                if { !$_settings(-colormapvisible) } {
-                    SendCmd [list contour3d colormode $_colorMode $_curFldName]
-                    set _settings(-colormapvisible) 1
-                }
-                SetCurrentColormap $color
-            }
-            StopBufferingCommands
-            EventuallyRequestLegend
-        }
-        "-cutplaneedges" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane edges $bool"
-        }
-        "-cutplanelighting" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane lighting $bool"
-        }
-        "-cutplaneopacity" {
-            set _changed($what) 1
-            set _settings($what) [expr $_widget($what) * 0.01]
-            SendCmd "cutplane opacity $_settings($what)"
-        }
-        "-cutplanepreinterp" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane preinterp $bool"
-        }
-        "-cutplanesvisible" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane visible 0"
-            if { $bool } {
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "cutplane visible $bool $tag"
-                }
-            }
-            if { $bool } {
-                Rappture::Tooltip::for $itk_component(cutplane) \
-                    "Hide the cutplanes"
-            } else {
-                Rappture::Tooltip::for $itk_component(cutplane) \
-                    "Show the cutplanes"
-            }
-        }
-        "-cutplanewireframe" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "cutplane wireframe $bool"
-        }
-        "-field" {
-            set label [$itk_component(field) value]
-            set fname [$itk_component(field) translate $label]
-            set _settings($what) $fname
-            if { [info exists _fields($fname)] } {
-                foreach { label units components } $_fields($fname) break
-                if { $components > 1 } {
-                    set _colorMode vmag
-                } else {
-                    set _colorMode scalar
-                }
-                set _curFldName $fname
-                set _curFldLabel $label
-            } else {
-                puts stderr "unknown field \"$fname\""
-                return
-            }
-            SendCmd [list dataset scalar $_curFldName]
-            if { ![info exists _limits($_curFldName)] } {
-                SendCmd "dataset maprange all"
-            } else {
-                if { $_settings(-customrange) } {
-                    set vmin [$itk_component(min) value]
-                    set vmax [$itk_component(max) value]
-                } else {
-                    foreach { vmin vmax } $_limits($_curFldName) break
-                    # set the min / max gauges with limits from the field
-                    # the legend's min and max text will be updated
-                    # when the legend is redrawn in DrawLegend
-                    SetMinMaxGauges $vmin $vmax
-                }
-                SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName]
-            }
-            SendCmd [list cutplane colormode $_colorMode $_curFldName]
-            SendCmd [list contour3d colormode $_colorMode $_curFldName]
-            GenerateContourList
-            SendCmd [list contour3d contourlist $_contourList(values)]
-            SendCmd "camera reset"
-            DrawLegend
-        }
-        "-isolinecolor" {
-            set color [$itk_component(isolinecolor) value]
-            set _settings($what) $color
-            DrawLegend
-        }
-        "-isosurfaceedges" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "contour3d edges $bool"
-        }
-        "-isosurfacelighting" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "contour3d lighting $bool"
-        }
-        "-isosurfaceopacity" {
-            set _changed($what) 1
-            set _settings($what) [expr $_widget($what) * 0.01]
-            SendCmd "contour3d opacity $_settings($what)"
-        }
-        "-isosurfacevisible" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "contour3d visible 0"
-            if { $bool } {
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "contour3d visible $bool $tag"
-                }
-                Rappture::Tooltip::for $itk_component(contour) \
-                    "Hide the isosurface"
-            } else {
-                Rappture::Tooltip::for $itk_component(contour) \
-                    "Show the isosurface"
-            }
-        }
-        "-isosurfacewireframe" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "contour3d wireframe $bool"
-        }
-        "-legendvisible" {
-            if { !$_settings($what) } {
-                $itk_component(view) delete legend
-            }
-            DrawLegend
-        }
-        "-numcontours" {
-            set _changed($what) 1
-            set _settings($what) [$itk_component(numcontours) value]
-            if { $_contourList(numLevels) != $_settings($what) } {
-                set _contourList(numLevels) $_settings($what)
-                EventuallyChangeContourLevels
-            }
-        }
-        "-ortho" {
-            set bool $_view($what)
-            if { $bool } {
-                SendCmd "camera mode ortho"
-            } else {
-                SendCmd "camera mode persp"
-            }
-        }
-        "-outline" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "outline visible 0"
-            if { $bool } {
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "outline visible $bool $tag"
-                }
-            }
-        }
-        "-range" {
-            if { $_settings(-customrange) } {
-                set vmin [$itk_component(min) value]
-                set vmax [$itk_component(max) value]
-            } else {
-                foreach { vmin vmax } $_limits($_curFldName) break
-            }
-            GenerateContourList
-            SendCmd [list contour3d contourlist $_contourList(values)]
-            SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName]
-            DrawLegend
-        }
-        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
-            set _changed($what) 1
-            set axis [string tolower [string range $what 1 1]]
-            set bool $_settings($what)
-            if { $bool } {
-                $itk_component(${axis}position) configure -state normal \
-                    -troughcolor white
-            } else {
-                $itk_component(${axis}position) configure -state disabled \
-                    -troughcolor grey82
-            }
-            SendCmd "cutplane axis $axis $bool"
-        }
-        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
-            set _changed($what) 1
-            set axis [string tolower [string range $what 1 1]]
-            set pos [expr $_settings($what) * 0.01]
-            SendCmd "cutplane slice ${axis} ${pos}"
-            set _cutplanePending 0
-        }
-        "-xgrid" - "-ygrid" - "-zgrid" {
-            set axis [string tolower [string range $what 1 1]]
-            set bool $_settings($what)
-            SendCmd "axis grid $axis $bool"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-#
-# RequestLegend --
-#
-# Request a new legend from the server.  The size of the legend
-# is determined from the height of the canvas.
-#
-# This should be called when
-#   1.  A new current colormap is set.
-#   2.  Window is resized.
-#   3.  The limits of the data have changed.  (Just need a redraw).
-#   4.  Number of isolines have changed. (Just need a redraw).
-#   5.  Legend becomes visible (Just need a redraw).
-#
-itcl::body Rappture::VtkIsosurfaceViewer::RequestLegend {} {
-    set _legendPending 0
-    if { ![info exists _fields($_curFldName)] } {
-        return
-    }
-    set fname $_curFldName
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-    set w 12
-    set h [expr {$_height - 2 * ($lineht + 2)}]
-    if { $h < 1 } {
-        return
-    }
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a title too, subtract one more line
-    if { $title != "" } {
-        incr h -$lineht
-    }
-    # Set the legend on the first dataset.
-    if { $_currentColormap != "" } {
-        set cmap $_currentColormap
-        if { ![info exists _colormaps($cmap)] } {
-            BuildColormap $cmap
-            set _colormaps($cmap) 1
-        }
-        #SendCmd [list legend $cmap $_colorMode $_curFldName {} $w $h 0]
-        SendCmd "legend2 $cmap $w $h"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkIsosurfaceViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        SendCmd "screen bgcolor $rgb"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkIsosurfaceViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        SendCmd "axis color all $rgb"
-        SendCmd "outline color $rgb"
-        SendCmd "cutplane color $rgb"
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::BuildIsosurfaceTab {} {
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Isosurface Settings" \
-        -icon [Rappture::icon volume-on]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.contour \
-        -text "Isosurfaces" \
-        -variable [itcl::scope _settings(-isosurfacevisible)] \
-        -command [itcl::code $this AdjustSetting -isosurfacevisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.wireframe \
-        -text "Wireframe" \
-        -variable [itcl::scope _settings(-isosurfacewireframe)] \
-        -command [itcl::code $this AdjustSetting -isosurfacewireframe] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-isosurfacelighting)] \
-        -command [itcl::code $this AdjustSetting -isosurfacelighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.edges \
-        -text "Edges" \
-        -variable [itcl::scope _settings(-isosurfaceedges)] \
-        -command [itcl::code $this AdjustSetting -isosurfaceedges] \
-        -font "Arial 9"
-
-    checkbutton $inner.outline \
-        -text "Outline" \
-        -variable [itcl::scope _settings(-outline)] \
-        -command [itcl::code $this AdjustSetting -outline] \
-        -font "Arial 9"
-
-    checkbutton $inner.legend \
-        -text "Legend" \
-        -variable [itcl::scope _settings(-legendvisible)] \
-        -command [itcl::code $this AdjustSetting -legendvisible] \
-        -font "Arial 9"
-
-    label $inner.linecolor_l -text "Isolines" -font "Arial 9"
-    itk_component add isolinecolor {
-        Rappture::Combobox $inner.linecolor -width 10 -editable 0
-    }
-    $inner.linecolor choices insert end \
-        "black"              "black"            \
-        "blue"               "blue"             \
-        "cyan"               "cyan"             \
-        "green"              "green"            \
-        "grey"               "grey"             \
-        "magenta"            "magenta"          \
-        "orange"             "orange"           \
-        "red"                "red"              \
-        "white"              "white"            \
-        "none"               "none"
-
-    $itk_component(isolinecolor) value $_settings(-isolinecolor)
-    bind $inner.linecolor <<Value>> \
-        [itcl::code $this AdjustSetting -isolinecolor]
-
-    label $inner.background_l -text "Background" -font "Arial 9"
-    itk_component add background {
-        Rappture::Combobox $inner.background -width 10 -editable 0
-    }
-    $inner.background choices insert end \
-        "black"              "black"            \
-        "white"              "white"            \
-        "grey"               "grey"
-
-    $itk_component(background) value $_settings(-background)
-    bind $inner.background <<Value>> \
-        [itcl::code $this AdjustSetting -background]
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _widget(-isosurfaceopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -isosurfaceopacity]
-    $inner.opacity set [expr $_settings(-isosurfaceopacity) * 100.0]
-
-    itk_component add field_l {
-        label $inner.field_l -text "Field" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add field {
-        Rappture::Combobox $inner.field -width 10 -editable 0
-    }
-    bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting -field]
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9"
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList]
-    $itk_component(colormap) value "BCGYR"
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -colormap]
-
-    label $inner.numcontours_l -text "Number of Isosurfaces" -font "Arial 9"
-    itk_component add numcontours {
-        Rappture::Spinint $inner.numcontours \
-            -min 0 -max 50 -font "arial 9"
-    }
-    $itk_component(numcontours) value $_settings(-numcontours)
-    bind $itk_component(numcontours) <<Value>> \
-        [itcl::code $this AdjustSetting -numcontours]
-
-    # add widgets for setting a custom range on the legend
-
-    itk_component add crange {
-        checkbutton $inner.crange \
-            -text "Use Custom Range:" \
-            -variable [itcl::scope _settings(-customrange)] \
-            -command [itcl::code $this ToggleCustomRange] \
-            -font "Arial 9"
-    }
-
-    itk_component add l_min {
-        label $inner.l_min -text "Min" -font "Arial 9"
-    }
-    itk_component add min {
-        Rappture::Gauge $inner.min -font "Arial 9" \
-            -validatecommand [itcl::code $this LegendRangeValidate "" vmin]
-    }
-    bind $itk_component(min) <<Value>> \
-        [itcl::code $this AdjustSetting -range]
-
-    itk_component add l_max {
-        label $inner.l_max -text "Max" -font "Arial 9"
-    }
-    itk_component add max {
-        Rappture::Gauge $inner.max -font "Arial 9" \
-            -validatecommand [itcl::code $this LegendRangeValidate "" vmax]
-    }
-    bind $itk_component(max) <<Value>> \
-        [itcl::code $this AdjustSetting -range]
-
-    $itk_component(min) configure -state disabled
-    $itk_component(max) configure -state disabled
-
-    blt::table $inner \
-        0,0 $inner.field_l      -anchor w -pady 2 \
-        0,1 $inner.field        -anchor w -pady 2 -fill x \
-        1,0 $inner.colormap_l   -anchor w -pady 2 \
-        1,1 $inner.colormap     -anchor w -pady 2 -fill x \
-        2,0 $inner.linecolor_l  -anchor w -pady 2 \
-        2,1 $inner.linecolor    -anchor w -pady 2 -fill x \
-        3,0 $inner.background_l -anchor w -pady 2 \
-        3,1 $inner.background   -anchor w -pady 2 -fill x \
-        4,0 $inner.numcontours_l -anchor w -pady 2 \
-        4,1 $inner.numcontours  -anchor w -pady 2 \
-        5,0 $inner.wireframe    -anchor w -pady 2 -cspan 2 \
-        6,0 $inner.lighting     -anchor w -pady 2 -cspan 2 \
-        7,0 $inner.edges        -anchor w -pady 2 -cspan 2 \
-        8,0 $inner.outline      -anchor w -pady 2 -cspan 2 \
-        9,0 $inner.legend       -anchor w -pady 2 \
-        10,0 $inner.opacity_l   -anchor w -pady 2 \
-        10,1 $inner.opacity     -fill x   -pady 2 -fill x \
-        11,0 $inner.crange      -anchor w -pady 2 -cspan 2 \
-        12,0 $inner.l_min       -anchor w -pady 2 \
-        12,1 $inner.min         -anchor w -pady 2 -fill x \
-        13,0 $inner.l_max       -anchor w -pady 2 \
-        13,1 $inner.max         -anchor w -pady 2 -fill x \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r14 c1 -resize expand
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::BuildAxisTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _settings(-axislabels)] \
-        -command [itcl::code $this AdjustSetting -axislabels] \
-        -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9"
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _settings(-xgrid)] \
-        -command [itcl::code $this AdjustSetting -xgrid] \
-        -font "Arial 9"
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _settings(-ygrid)] \
-        -command [itcl::code $this AdjustSetting -ygrid] \
-        -font "Arial 9"
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _settings(-zgrid)] \
-        -command [itcl::code $this AdjustSetting -zgrid] \
-        -font "Arial 9"
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _settings(-axisminorticks)] \
-        -command [itcl::code $this AdjustSetting -axisminorticks] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-
-    itk_component add axisMode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axisMode) value $_settings(-axismode)
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
-
-    blt::table $inner \
-        0,0 $inner.visible    -anchor w -cspan 4 \
-        1,0 $inner.labels     -anchor w -cspan 4 \
-        2,0 $inner.minorticks -anchor w -cspan 4 \
-        4,0 $inner.grid_l     -anchor w \
-        4,1 $inner.xgrid      -anchor w \
-        4,2 $inner.ygrid      -anchor w \
-        4,3 $inner.zgrid      -anchor w \
-        5,0 $inner.mode_l     -anchor w -padx { 2 0 } \
-        5,1 $inner.mode       -fill x   -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-
-itcl::body Rappture::VtkIsosurfaceViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set labels { qx qy qz qw xpan ypan zoom }
-    set row 1
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this AdjustSetting -ortho] \
-        -font "Arial 9"
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::BuildCutplanesTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Cutplane Settings" \
-        -icon [Rappture::icon cutbutton]]
-
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Cutplanes" \
-        -variable [itcl::scope _settings(-cutplanesvisible)] \
-        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.wireframe \
-        -text "Wireframe" \
-        -variable [itcl::scope _settings(-cutplanewireframe)] \
-        -command [itcl::code $this AdjustSetting -cutplanewireframe] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-cutplanelighting)] \
-        -command [itcl::code $this AdjustSetting -cutplanelighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.edges \
-        -text "Edges" \
-        -variable [itcl::scope _settings(-cutplaneedges)] \
-        -command [itcl::code $this AdjustSetting -cutplaneedges] \
-        -font "Arial 9"
-
-    checkbutton $inner.preinterp \
-        -text "Interpolate Scalars" \
-        -variable [itcl::scope _settings(-cutplanepreinterp)] \
-        -command [itcl::code $this AdjustSetting -cutplanepreinterp] \
-        -font "Arial 9"
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _widget(-cutplaneopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -cutplaneopacity]
-    $inner.opacity set [expr $_settings(-cutplaneopacity) * 100.0]
-
-    # X-value slicer...
-    itk_component add xbutton {
-        Rappture::PushButton $inner.xbutton \
-            -onimage [Rappture::icon x-cutplane-red] \
-            -offimage [Rappture::icon x-cutplane-red] \
-            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
-            -variable [itcl::scope _settings(-xcutplanevisible)] \
-    }
-    Rappture::Tooltip::for $itk_component(xbutton) \
-        "Toggle the X-axis cutplane on/off"
-    $itk_component(xbutton) select
-    itk_component add xposition {
-        ::scale $inner.xval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane x] \
-            -variable [itcl::scope _settings(-xcutplaneposition)] \
-            -foreground red2 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font -background
-    }
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(xposition) set 50
-    $itk_component(xposition) configure -state disabled
-    Rappture::Tooltip::for $itk_component(xposition) \
-        "@[itcl::code $this Slice tooltip x]"
-
-    # Y-value slicer...
-    itk_component add ybutton {
-        Rappture::PushButton $inner.ybutton \
-            -onimage [Rappture::icon y-cutplane-green] \
-            -offimage [Rappture::icon y-cutplane-green] \
-            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
-            -variable [itcl::scope _settings(-ycutplanevisible)] \
-    }
-    Rappture::Tooltip::for $itk_component(ybutton) \
-        "Toggle the Y-axis cutplane on/off"
-    $itk_component(ybutton) select
-
-    itk_component add yposition {
-        ::scale $inner.yval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane y] \
-            -variable [itcl::scope _settings(-ycutplaneposition)] \
-            -foreground green3 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font
-    }
-    Rappture::Tooltip::for $itk_component(yposition) \
-        "@[itcl::code $this Slice tooltip y]"
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(yposition) set 50
-    $itk_component(yposition) configure -state disabled
-
-    # Z-value slicer...
-    itk_component add zbutton {
-        Rappture::PushButton $inner.zbutton \
-            -onimage [Rappture::icon z-cutplane-blue] \
-            -offimage [Rappture::icon z-cutplane-blue] \
-            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
-            -variable [itcl::scope _settings(-zcutplanevisible)] \
-    } {
-        usual
-        ignore -foreground
-    }
-    Rappture::Tooltip::for $itk_component(zbutton) \
-        "Toggle the Z-axis cutplane on/off"
-    $itk_component(zbutton) select
-
-    itk_component add zposition {
-        ::scale $inner.zval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane z] \
-            -variable [itcl::scope _settings(-zcutplaneposition)] \
-            -foreground blue3 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font
-    }
-    $itk_component(zposition) set 50
-    $itk_component(zposition) configure -state disabled
-    Rappture::Tooltip::for $itk_component(zposition) \
-        "@[itcl::code $this Slice tooltip z]"
-
-    blt::table $inner \
-        0,0 $inner.visible   -anchor w -pady 2 -cspan 3 \
-        1,0 $inner.lighting  -anchor w -pady 2 -cspan 3 \
-        2,0 $inner.wireframe -anchor w -pady 2 -cspan 3 \
-        3,0 $inner.edges     -anchor w -pady 2 -cspan 3 \
-        4,0 $inner.preinterp -anchor w -pady 2 -cspan 3 \
-        5,0 $inner.opacity_l -anchor w -pady 2 -cspan 1 \
-        5,1 $inner.opacity   -fill x   -pady 2 -cspan 3 \
-        6,0 $inner.xbutton   -anchor w -padx 2 -pady 2 \
-        7,0 $inner.ybutton   -anchor w -padx 2 -pady 2 \
-        8,0 $inner.zbutton   -anchor w -padx 2 -pady 2 \
-        6,1 $inner.xval      -fill y -rspan 4 \
-        6,2 $inner.yval      -fill y -rspan 4 \
-        6,3 $inner.zval      -fill y -rspan 4 \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r9 c4 -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkIsosurfaceViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        foreach cname [$dataobj components] {
-            set tag $dataobj-$cname
-            set contents [$dataobj vtkdata $cname]
-            append bytes "$contents\n"
-        }
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::SetObjectStyle { dataobj comp } {
-    DebugTrace "Enter"
-    # Parse style string.
-    set tag $dataobj-$comp
-    array set style {
-        -color                  BCGYR
-        -constcolor             white
-        -cutplaneedges          0
-        -cutplanelighting       1
-        -cutplaneopacity        1.0
-        -cutplanepreinterp      1
-        -cutplanesvisible       0
-        -cutplanewireframe      0
-        -edgecolor              black
-        -edges                  0
-        -isosurfacevisible      1
-        -levels                 10
-        -lighting               1
-        -linewidth              1.0
-        -opacity                0.6
-        -outline                0
-        -wireframe              0
-        -xcutplaneposition      50
-        -xcutplanevisible       1
-        -ycutplaneposition      50
-        -ycutplanevisible       1
-        -zcutplaneposition      50
-        -zcutplanevisible       1
-    }
-    if { $style(-levels) == 1 } {
-        set style(-opacity) 1.0
-    }
-    set style(-constcolor) $itk_option(-plotforeground)
-    array set style [$dataobj style $comp]
-    #DebugTrace [array get style]
-
-    # This is too complicated.  We want to set the colormap, number of
-    # isolines and opacity for the dataset.  They can be the default values,
-    # the style hints loaded with the dataset, or set by user controls.  As
-    # datasets get loaded, they first use the defaults that are overidden
-    # by the style hints.  If the user changes the global controls, then that
-    # overrides everything else.  I don't know what it means when global
-    # controls are specified as style hints by each dataset.  It complicates
-    # the code to handle aberrant cases.
-
-    if { $_changed(-isosurfaceedges) } {
-        set style(-edges) $_settings(-isosurfaceedges)
-    }
-    if { $_changed(-isosurfacelighting) } {
-        set style(-lighting) $_settings(-isosurfacelighting)
-    }
-    if { $_changed(-isosurfaceopacity) } {
-        set style(-opacity) $_settings(-isosurfaceopacity)
-    }
-    if { $_changed(-isosurfacewireframe) } {
-        set style(-wireframe) $_settings(-isosurfacewireframe)
-    }
-    if { $_changed(-numcontours) } {
-        set style(-levels) $_settings(-numcontours)
-    }
-    if { $_changed(-colormap) } {
-        set style(-color) $_settings(-colormap)
-    }
-    if { $_currentColormap == "" } {
-        $itk_component(colormap) value $style(-color)
-    }
-    if { $_contourList(numLevels) != $style(-levels) } {
-        if { [llength $style(-levels)] > 1 } {
-            set _contourList(reqValues) [lsort -real $style(-levels)]
-        } else {
-            set _settings(-numcontours) $style(-levels)
-            $itk_component(numcontours) value $style(-levels)
-            set _contourList(numLevels) $style(-levels)
-        }
-        EventuallyChangeContourLevels
-    }
-    foreach setting {-outline -isosurfacevisible -cutplanesvisible \
-                     -xcutplanevisible -ycutplanevisible -zcutplanevisible \
-                     -xcutplaneposition -ycutplaneposition -zcutplaneposition \
-                     -cutplaneedges -cutplanelighting -cutplaneopacity \
-                     -cutplanepreinterp -cutplanewireframe} {
-        if {$_changed($setting)} {
-            # User-modified UI setting overrides style
-            set style($setting) $_settings($setting)
-        } else {
-            # Set UI control to style setting (tool provided or default)
-            set _settings($setting) $style($setting)
-        }
-    }
-
-    SendCmd "cutplane add $tag"
-    SendCmd "cutplane color [Color2RGB $style(-constcolor)] $tag"
-    foreach axis {x y z} {
-        set pos [expr $style(-${axis}cutplaneposition) * 0.01]
-        set visible $style(-${axis}cutplanevisible)
-        SendCmd "cutplane slice $axis $pos $tag"
-        SendCmd "cutplane axis $axis $visible $tag"
-    }
-    SendCmd "cutplane edges $style(-cutplaneedges) $tag"
-    SendCmd "cutplane lighting $style(-cutplanelighting) $tag"
-    SendCmd "cutplane opacity $style(-cutplaneopacity) $tag"
-    set _widget(-cutplaneopacity) [expr $style(-cutplaneopacity) * 100]
-    SendCmd "cutplane preinterp $style(-cutplanepreinterp) $tag"
-    SendCmd "cutplane wireframe $style(-cutplanewireframe) $tag"
-    SendCmd "cutplane visible $style(-cutplanesvisible) $tag"
-
-    SendCmd "outline add $tag"
-    SendCmd "outline color [Color2RGB $style(-constcolor)] $tag"
-    SendCmd "outline visible $style(-outline) $tag"
-
-    GenerateContourList
-    SendCmd [list contour3d add contourlist $_contourList(values) $tag]
-    SendCmd "contour3d visible $style(-isosurfacevisible) $tag"
-    SendCmd "contour3d edges $style(-edges) $tag"
-    set _settings(-isosurfaceedges) $style(-edges)
-    SendCmd "contour3d color [Color2RGB $style(-constcolor)] $tag"
-    SendCmd "contour3d lighting $style(-lighting) $tag"
-    set _settings(-isosurfacelighting) $style(-lighting)
-    SendCmd "contour3d linecolor [Color2RGB $style(-edgecolor)] $tag"
-    SendCmd "contour3d linewidth $style(-linewidth) $tag"
-    SendCmd "contour3d opacity $style(-opacity) $tag"
-    set _settings(-isosurfaceopacity) $style(-opacity)
-    set _widget(-isosurfaceopacity) [expr $style(-opacity) * 100]
-    SetCurrentColormap $style(-color)
-    SendCmd "contour3d wireframe $style(-wireframe) $tag"
-    set _settings(-isosurfacewireframe) $style(-wireframe)
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-#
-# EnterLegend --
-#
-itcl::body Rappture::VtkIsosurfaceViewer::EnterLegend { x y } {
-    SetLegendTip $x $y
-}
-
-#
-# MotionLegend --
-#
-itcl::body Rappture::VtkIsosurfaceViewer::MotionLegend { x y } {
-    Rappture::Tooltip::tooltip cancel
-    set c $itk_component(view)
-    set cw [winfo width $c]
-    set ch [winfo height $c]
-    if { $x >= 0 && $x < $cw && $y >= 0 && $y < $ch } {
-        SetLegendTip $x $y
-    }
-}
-
-#
-# LeaveLegend --
-#
-itcl::body Rappture::VtkIsosurfaceViewer::LeaveLegend { } {
-    Rappture::Tooltip::tooltip cancel
-    .rappturetooltip configure -icon ""
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendB1Motion press <x> <y>
-# USAGE: LegendB1Motion motion <x> <y>
-# USAGE: LegendB1Motion release <x> <y>
-#
-# Manage actions for Button 1 presses that happen over the legend.
-# Pressing mouse Button 1 on the legend sends a command to the
-# visualization server to show a specific isosurface.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::LegendB1Motion { status x y } {
-
-    switch -- $status {
-        "press" {
-            DisableMouseRotationBindings
-            LegendProbeSingleContour $x $y
-        }
-        "motion" {
-            DisableMouseRotationBindings
-            LegendProbeSingleContour $x $y
-        }
-        "release" {
-            AdjustSetting -range
-            SetupMouseRotationBindings
-        }
-        default {
-            error "bad option \"$option\": should be one of press, motion, release."
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendPointToValue <x> <y>
-#
-# Convert an x,y point on the legend to a numeric field value.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::LegendPointToValue { x y } {
-    set fname $_curFldName
-
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set ih [image height $_image(legend)]
-    set iy [expr $y - ($lineht + 2)]
-
-    # Compute the value of the point
-    if { [info exists _limits($fname)] } {
-        if { $_settings(-customrange) } {
-            set vmin [$itk_component(min) value]
-            set vmax [$itk_component(max) value]
-        } else {
-            foreach { vmin vmax } $_limits($fname) break
-        }
-        set t [expr 1.0 - (double($iy) / double($ih-1))]
-        set value [expr $t * ($vmax - $vmin) + $vmin]
-    } else {
-        set value 0.0
-    }
-    return $value
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendProbeSingleContour <x> <y>
-#
-# Calculate the isosurface value for the x,y point and send a commands
-# to the visualization server to show that isosurface.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::LegendProbeSingleContour { x y } {
-
-    set value [LegendPointToValue $x $y]
-    SendCmd [list contour3d contourlist $value]
-}
-
-#
-# SetLegendTip --
-#
-itcl::body Rappture::VtkIsosurfaceViewer::SetLegendTip { x y } {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set ih [image height $_image(legend)]
-    set iy [expr $y - ($lineht + 2)]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a legend title, increase the offset by the line height.
-    if { $title != "" } {
-        incr iy -$lineht
-    }
-    # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
-        return
-    }
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    set color [eval format "\#%02x%02x%02x" $pixel]
-    $_image(swatch) put black  -to 0 0 23 23
-    $_image(swatch) put $color -to 1 1 22 22
-    .rappturetooltip configure -icon $_image(swatch)
-
-    # Compute the value of the point
-    set value [LegendPointToValue $x $y]
-
-    # Setup the location of the tooltip
-    set tx [expr $x + 15]
-    set ty [expr $y - 5]
-
-    # Setup the text for the tooltip
-    if { [info exists _isolines($y)] } {
-        Rappture::Tooltip::text $c [format "$title %g (isosurface)" $_isolines($y)]
-    } else {
-        Rappture::Tooltip::text $c [format "$title %g" $value]
-    }
-
-    # Show the tooltip
-    Rappture::Tooltip::tooltip show $c +$tx,+$ty
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Slice move x|y|z <newval>
-#
-# Called automatically when the user drags the slider to move the
-# cut plane that slices 3D data.  Gets the current value from the
-# slider and moves the cut plane to the appropriate point in the
-# data set.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::Slice {option args} {
-    switch -- $option {
-        "move" {
-            set axis [lindex $args 0]
-            set newval [lindex $args 1]
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Slice move x|y|z newval\""
-            }
-            set newpos [expr {0.01*$newval}]
-            SendCmd "cutplane slice $axis $newpos"
-        }
-        "tooltip" {
-            set axis [lindex $args 0]
-            set val [$itk_component(${axis}position) get]
-            return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
-        }
-        default {
-            error "bad option \"$option\": should be axis, move, or tooltip"
-        }
-    }
-}
-
-#
-# ReceiveLegend --
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-#
-itcl::body Rappture::VtkIsosurfaceViewer::ReceiveLegend { colormap title min max size } {
-    DebugTrace "Enter"
-    set _title $title
-    regsub {\(mag\)} $title "" _title
-    if { [IsConnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend)] } {
-            set _image(legend) [image create photo]
-        }
-        $_image(legend) configure -data $bytes
-        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-        if { [catch {DrawLegend} errs] != 0 } {
-            global errorInfo
-            puts stderr "errs=$errs errorInfo=$errorInfo"
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-# Draws the legend on the canvas on the right side of the plot area.
-#
-itcl::body Rappture::VtkIsosurfaceViewer::DrawLegend {} {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    set x [expr $w - 2]
-    if { !$_settings(-legendvisible) } {
-        $c delete legend
-        return
-    }
-    if { [$c find withtag "legend"] == "" } {
-        set y 2
-        # If there's a legend title, create a text item for the title.
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "title legend" \
-            -font $font
-        if { $title != "" } {
-            incr y $lineht
-        }
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "vmax legend" \
-            -font $font
-        incr y $lineht
-        $c create image $x $y \
-            -anchor ne \
-            -image $_image(legend) -tags "colormap legend"
-        $c create rectangle $x $y 1 1 \
-            -fill "" -outline "" -tags "sensor legend"
-        $c create text $x [expr {$h-2}] \
-            -anchor se \
-            -fill $itk_option(-plotforeground) -tags "vmin legend" \
-            -font $font
-        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
-        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
-        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
-#        $c bind sensor <ButtonPress-1>   [itcl::code $this LegendB1Motion press %x %y]
-#        $c bind sensor <B1-Motion>       [itcl::code $this LegendB1Motion motion %x %y]
-#        $c bind sensor <ButtonRelease-1> [itcl::code $this LegendB1Motion release %x %y]
-    }
-    $c delete isoline
-    set x2 $x
-    set iw [image width $_image(legend)]
-    set ih [image height $_image(legend)]
-    set x1 [expr $x2 - ($iw*12)/10]
-    set color $_settings(-isolinecolor)
-    # Draw the isolines on the legend.
-    array unset _isolines
-    if { $color != "none"  && [info exists _limits($_curFldName)] &&
-         $_settings(-numcontours) > 0 } {
-
-        if { $_settings(-customrange) } {
-            set vmin [$itk_component(min) value]
-            set vmax [$itk_component(max) value]
-        } else {
-            foreach { vmin vmax } $_limits($_curFldName) break
-        }
-        set range [expr double($vmax - $vmin)]
-        if { $range <= 0.0 } {
-            set range 1.0;              # Min is greater or equal to max.
-        }
-        set tags "isoline legend"
-        set offset [expr 2 + $lineht]
-        if { $title != "" } {
-            incr offset $lineht
-        }
-        foreach value $_contourList(values) {
-            set norm [expr 1.0 - (($value - $vmin) / $range)]
-            set y1 [expr int(round(($norm * $ih) + $offset))]
-            for { set off 0 } { $off < 3 } { incr off } {
-                set _isolines([expr $y1 + $off]) $value
-                set _isolines([expr $y1 - $off]) $value
-            }
-            $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
-        }
-    }
-
-    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
-    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
-    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
-    # Reset the item coordinates according the current size of the plot.
-    $c itemconfigure title -text $title
-    if { [info exists _limits($_curFldName)] } {
-        if { $_settings(-customrange) } {
-            set vmin [$itk_component(min) value]
-            set vmax [$itk_component(max) value]
-        } else {
-            foreach { vmin vmax } $_limits($_curFldName) break
-        }
-        $c itemconfigure vmin -text [format %g $vmin]
-        $c itemconfigure vmax -text [format %g $vmax]
-    }
-    set y 2
-    # If there's a legend title, move the title to the correct position
-    if { $title != "" } {
-        $c itemconfigure title -text $title
-        $c coords title $x $y
-        incr y $lineht
-        $c raise title
-    }
-    $c coords vmax $x $y
-    incr y $lineht
-    $c coords colormap $x $y
-    $c coords sensor [expr $x - $iw] $y $x [expr $y + $ih]
-    $c raise sensor
-    $c coords vmin $x [expr {$h - 2}]
-
-    $c bind vmin <ButtonPress> [itcl::code $this LegendRangeAction popup vmin]
-    $c bind vmin <Enter> [itcl::code $this LegendRangeAction enter vmin]
-    $c bind vmin <Leave> [itcl::code $this LegendRangeAction leave vmin]
-
-    $c bind vmax <ButtonPress> [itcl::code $this LegendRangeAction popup vmax]
-    $c bind vmax <Enter> [itcl::code $this LegendRangeAction enter vmax]
-    $c bind vmax <Leave> [itcl::code $this LegendRangeAction leave vmax]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendTitleAction post
-# USAGE: LegendTitleAction enter
-# USAGE: LegendTitleAction leave
-# USAGE: LegendTitleAction save
-#
-# Used internally to handle the dropdown list for the fields menu combobox.
-# The post option is invoked when the field title is pressed to launch the
-# dropdown.  The enter option is invoked when the user mouses over the field
-# title. The leave option is invoked when the user moves the mouse away
-# from the field title.  The save option is invoked whenever there is a
-# selection from the list, to alert the visualization server.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::LegendTitleAction {option} {
-    set c $itk_component(view)
-    switch -- $option {
-        post {
-            foreach { x1 y1 x2 y2 } [$c bbox title] break
-            set cw [winfo width $itk_component(view)]
-            set mw [winfo reqwidth $itk_component(fieldmenu)]
-            set x1 [expr $cw - $mw]
-            set x [expr $x1 + [winfo rootx $itk_component(view)]]
-            set y [expr $y2 + [winfo rooty $itk_component(view)]]
-            tk_popup $itk_component(fieldmenu) $x $y
-        }
-        enter {
-            $c itemconfigure title -fill red
-        }
-        leave {
-            $c itemconfigure title -fill $itk_option(-plotforeground)
-        }
-        save {
-            $itk_component(field) value $_curFldLabel
-            AdjustSetting -field
-        }
-        default {
-            error "bad option \"$option\": should be post, enter, leave or save"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendRangeValidate <widget> <which> <value>
-#
-# Used internally to validate a legend range min/max value.
-# Returns a boolean value telling if <value> was accepted (1) or rejected (0)
-# If the value is rejected, a tooltip/warning message is popped up
-# near the widget that asked for the validation, specified by <widget>
-#
-# <widget> is the widget where a tooltip/warning message should show up on
-# <which> is either "vmin" or "vmax".
-# <value> is the value to be validated.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::LegendRangeValidate {widget which value} {
-    #check for a valid value
-    if {[string is double $value] != 1} {
-        set msg "should be valid number"
-        if {$widget != ""} {
-            Rappture::Tooltip::cue $widget $msg
-        } else {
-            # error "bad value \"$value\": $msg"
-            error $msg
-        }
-        return 0
-    }
-
-    switch -- $which {
-        vmin {
-            # check for min > max
-            if {$value > [$itk_component(max) value]} {
-                set msg "min > max, change max first"
-                if {$widget != ""} {
-                    Rappture::Tooltip::cue $widget $msg
-                } else {
-                    # error "bad value \"$value\": $msg"
-                    error $msg
-                }
-                return 0
-            }
-        }
-        vmax {
-            # check for max < min
-            if {$value < [$itk_component(min) value]} {
-                set msg "max < min, change min first"
-                if {$widget != ""} {
-                    Rappture::Tooltip::cue $widget $msg
-                } else {
-                    # error "bad value \"$value\": $msg"
-                    error $msg
-                }
-                return 0
-            }
-        }
-        default {
-            error "bad option \"$which\": should be vmin, vmax"
-        }
-    }
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::MouseOver2Which {} {
-    switch -- $_mouseOver {
-        vmin {
-            set which min
-        }
-        vmax {
-            set which max
-        }
-        default {
-            error "bad _mouseOver \"$_mouseOver\": should be vmin, vmax"
-        }
-    }
-    return $which
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendRangeAction enter <which>
-# USAGE: LegendRangeAction leave <which>
-#
-# USAGE: LegendRangeAction popup <which>
-# USAGE: LegendRangeAction activate
-# USAGE: LegendRangeAction validate <value>
-# USAGE: LegendRangeAction apply <value>
-#
-# Used internally to handle the mouseover and popup entry for the field range
-# inputs.  The enter option is invoked when the user moves the mouse over the
-# min or max field range. The leave option is invoked when the user moves the
-# mouse away from the min or max field range. The popup option is invoked when
-# the user click's on a field range. The popup option stores internally which
-# widget is requesting a popup ( in the _mouseOver variable) and calls the
-# activate command of the widget. The widget's activate command calls back to
-# this method to get the xywh dimensions of the popup editor. After the user
-# changes focus or sets the value in the editor, the editor calls this methods
-# validate and apply options to set the value.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::LegendRangeAction {option args} {
-    set c $itk_component(view)
-
-    switch -- $option {
-        enter {
-            set which [lindex $args 0]
-            $c itemconfigure $which -fill red
-        }
-        leave {
-            set which [lindex $args 0]
-            $c itemconfigure $which -fill $itk_option(-plotforeground)
-        }
-        popup {
-            DisableMouseRotationBindings
-            set which [lindex $args 0]
-            set _mouseOver $which
-            $itk_component(editor) activate
-        }
-        activate {
-            foreach { x1 y1 x2 y2 } [$c bbox $_mouseOver] break
-            set which [MouseOver2Which]
-            set info(text) [$itk_component($which) value]
-            set info(x) [expr $x1 + [winfo rootx $c]]
-            set info(y) [expr $y1 + [winfo rooty $c]]
-            set info(w) [expr $x2 - $x1]
-            set info(h) [expr $y2 - $y1]
-            return [array get info]
-        }
-        validate {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"editor validate value\""
-            }
-
-            set value [lindex $args 0]
-            if {[LegendRangeValidate $itk_component(editor) $_mouseOver $value] == 0} {
-                return 0
-            }
-
-            # value was good, apply it
-            # reset the mouse rotation bindings
-            SetupMouseRotationBindings
-        }
-        apply {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"editor apply value\""
-            }
-            set value [string trim [lindex $args 0]]
-
-            set which [MouseOver2Which]
-
-            # only set custom range if value changed
-            if {[$itk_component($which) value] != $value} {
-                # set the flag stating the custom range came from the legend
-                # change the value in the gauge
-                # turn on crange to enable the labels and gauges
-                # call AdjustSetting -range (inside ToggleCustomRange)
-                # to update drawing and legend
-                set _customRangeClick 0
-                $itk_component($which) value $value
-                $itk_component(crange) select
-                ToggleCustomRange
-            }
-        }
-        default {
-            error "bad option \"$option\": should be enter, leave, activate, validate, apply"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ToggleCustomRange
-#
-# Called whenever the custom range is turned on or off. Used to save
-# the custom min and custom max set by the user. When the -customrange
-# setting is turned on, the range min and range max gauges are set
-# with the last value set by the user, or the default range if no
-# previous min and max were set.
-#
-# When the custom range is turned on, we check how it was turned on
-# by querying _customRangeClick. If the variable is 1, this means
-# the user clicked the crange checkbutton and we should pull the
-# custom range values from our backup variables. If the variable is 0,
-# the custom range was enabled through the user manipulating the
-# min and max value in the legend.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::ToggleCustomRange {args} {
-    if { ! $_settings(-customrange) } {
-        # custom range was turned off
-
-        # disable the min/max labels and gauge widgets
-        $itk_component(l_min) configure -state disabled
-        $itk_component(min) configure -state disabled
-        $itk_component(l_max) configure -state disabled
-        $itk_component(max) configure -state disabled
-
-        # backup the custom range
-        set _settings(-customrangemin) [$itk_component(min) value]
-        set _settings(-customrangemax) [$itk_component(max) value]
-
-        # set the gauges to dataset's min and max
-        foreach { vmin vmax } $_limits($_curFldName) break
-        SetMinMaxGauges $vmin $vmax
-    } else {
-        # custom range was turned on
-
-        # enable the min/max labels and gauge widgets
-        $itk_component(l_min) configure -state normal
-        $itk_component(min) configure -state normal
-        $itk_component(l_max) configure -state normal
-        $itk_component(max) configure -state normal
-
-        # if the custom range is being turned on by clicking the
-        # checkbox, restore the min and max gauges from the backup
-        # variables. otherwise, new values for the min and max
-        # widgets will be set later from the legend's editor.
-        if { $_customRangeClick } {
-            SetMinMaxGauges $_settings(-customrangemin) $_settings(-customrangemax)
-        }
-
-        # reset the click flag
-        set _customRangeClick 1
-    }
-    AdjustSetting -range
-}
-
-# ----------------------------------------------------------------------
-# USAGE: SetMinMaxGauges <min> <max>
-#
-# Set the min and max gauges in the correct order, avoiding the
-# error where you try to set the min > max before updating the max or
-# set the max < min before updating the min.
-#
-# There are five range cases to consider with our current range validation.
-# For example:
-# [2,3] -> [0,1]       : update min first, max last
-# [2,3] -> [4,5]       : update max first, min last
-# [2,3] -> [0,2.5]     : update min or max first
-# [2,3] -> [2.5,5]     : update min or max first
-# [2,3] -> [2.25,2.75] : update min or max first
-#
-# In 4 of the cases we can update min first and max last, so we only
-# need to check the case where old max < new min, where we update
-# max first and min last.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkIsosurfaceViewer::SetMinMaxGauges {min max} {
-
-    if { [$itk_component(max) value] < $min} {
-        # old max < new min
-        # shift range toward right
-        # extend max first, then update min
-        $itk_component(max) value $max
-        $itk_component(min) value $min
-    } else {
-        # extend min first, then update max
-        $itk_component(min) value $min
-        $itk_component(max) value $max
-    }
-}
-
-#
-# SetCurrentColormap --
-#
-itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentColormap { name } {
-    # Keep track of the colormaps that we build.
-    if { ![info exists _colormaps($name)] } {
-        BuildColormap $name
-        set _colormaps($name) 1
-    }
-    set _currentColormap $name
-    SendCmd "contour3d colormap $_currentColormap"
-    SendCmd "cutplane colormap $_currentColormap"
-}
-
-#
-# BuildColormap --
-#
-# Build the designated colormap on the server.
-#
-itcl::body Rappture::VtkIsosurfaceViewer::BuildColormap { name } {
-    set cmap [ColorsToColormap $name]
-    if { [llength $cmap] == 0 } {
-        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
-    }
-    set amap "0.0 1.0 1.0 1.0"
-    SendCmd "colormap add $name { $cmap } { $amap }"
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} {
-    if { ![info exists _limits($_curFldName)] } {
-        puts stderr "no _curFldName"
-        return ""
-    }
-    if { $_contourList(numLevels) < 1 } {
-        # There are tools that set 0 levels to get cutplanes only
-        #puts stderr "numLevels < 1"
-        return ""
-    }
-    if { [llength $_contourList(reqValues)] > 1 } {
-        set values $_contourList(reqValues)
-    } else {
-        # if custom range has been set, use the custom min and max
-        # to generate contour list values
-        if { $_settings(-customrange) } {
-            set vmin [$itk_component(min) value]
-            set vmax [$itk_component(max) value]
-        } else {
-            # use the field limits to calculate the contour list values
-            foreach { vmin vmax } $_limits($_curFldName) break
-        }
-
-        set v [blt::vector create \#auto]
-        $v seq $vmin $vmax [expr $_contourList(numLevels)+2]
-        $v delete end 0
-        set values [$v range 0 end]
-        blt::vector destroy $v
-    }
-    set _contourList(values) $values
-}
-
-itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentFieldName { dataobj } {
-    set _first $dataobj
-    $itk_component(field) choices delete 0 end
-    $itk_component(fieldmenu) delete 0 end
-    array unset _fields
-    set _curFldName ""
-    foreach cname [$_first components] {
-        foreach fname [$_first fieldnames $cname] {
-            if { [info exists _fields($fname)] } {
-                continue
-            }
-            foreach { label units components } \
-                [$_first fieldinfo $fname] break
-            $itk_component(field) choices insert end "$fname" "$label"
-            $itk_component(fieldmenu) add radiobutton -label "$label" \
-                -value $label -variable [itcl::scope _curFldLabel] \
-                -selectcolor red \
-                -activebackground $itk_option(-plotbackground) \
-                -activeforeground $itk_option(-plotforeground) \
-                -font "Arial 8" \
-                -command [itcl::code $this LegendTitleAction save]
-            set _fields($fname) [list $label $units $components]
-            if { $_curFldName == "" } {
-                set _curFldName $fname
-                set _curFldLabel $label
-            }
-        }
-    }
-    $itk_component(field) value $_curFldLabel
-    if { $_settings(-customrange) } {
-        set vmin [$itk_component(min) value]
-        set vmax [$itk_component(max) value]
-        SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName]
-        set limits [list $vmin $vmax]
-        if { $limits != $_currentLimits } {
-            set _currentLimits $limits
-            EventuallyChangeContourLevels
-        }
-    } else {
-        if { ![info exists _limits($_curFldName)] } {
-            SendCmd "dataset maprange all"
-        } else {
-            foreach { vmin vmax } $_limits($_curFldName) break
-            SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName]
-            set limits [list $vmin $vmax]
-            if { $limits != $_currentLimits } {
-                set _currentLimits $limits
-                EventuallyChangeContourLevels
-            }
-        }
-    }
-}
Index: trunk/gui/scripts/vtkmeshviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkmeshviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1579 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtkmeshviewer - Vtk mesh viewer
-#
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *VtkMeshViewer.width 4i widgetDefault
-option add *VtkMeshViewer*cursor crosshair widgetDefault
-option add *VtkMeshViewer.height 4i widgetDefault
-option add *VtkMeshViewer.foreground black widgetDefault
-option add *VtkMeshViewer.controlBackground gray widgetDefault
-option add *VtkMeshViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkMeshViewer.plotBackground black widgetDefault
-option add *VtkMeshViewer.plotForeground white widgetDefault
-option add *VtkMeshViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkMeshViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkMeshViewer::SetServerList
-}
-
-itcl::class Rappture::VtkMeshViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildPolydataTab {}
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method EventuallySetPolydataOpacity {}
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method Rotate {option x y}
-    private method SetObjectStyle { dataobj }
-    private method SetOrientation { side }
-    private method SetPolydataOpacity {}
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _click;            # info used for rotate operations
-    private variable _limits;           # autoscale min/max for all axes
-    private variable _view;             # view params for 3D view
-    private variable _settings
-    private variable _widget
-    private variable _reset 1;          # Connection to server has been reset.
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _title ""
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _rotatePending 0
-    private variable _polydataOpacityPending 0
-    private variable _rotateDelay 150
-    private variable _opacityDelay 150
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkMeshViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::constructor {args} {
-    set _serverType "vtkvis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    # Polydata opacity event
-    $_dispatcher register !polydataOpacity
-    $_dispatcher dispatch $this !polydataOpacity \
-        "[itcl::code $this SetPolydataOpacity]; list"
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _settings {
-        -axesvisible            1
-        -axislabels             1
-        -axisminorticks         1
-        -outline                0
-        -polydataedges          0
-        -polydatalighting       1
-        -polydataopacity        1.0
-        -polydatavisible        1
-        -polydatawireframe      0
-        -xgrid                  0
-        -ygrid                  0
-        -zgrid                  0
-    }
-    array set _widget {
-        -polydataopacity        100
-    }
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    itk_component add fieldmenu {
-        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
-            -tearoff 0
-    } {
-        usual
-        ignore -background -foreground -relief -tearoff
-    }
-
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    BuildPolydataTab
-    BuildAxisTab
-    BuildCameraTab
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::destructor {} {
-    Disconnect
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkMeshViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size $_width $_height"
-
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkMeshViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkMeshViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 200 !resize
-    }
-}
-
-itcl::body Rappture::VtkMeshViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after $_rotateDelay !rotate
-    }
-}
-
-itcl::body Rappture::VtkMeshViewer::SetPolydataOpacity {} {
-    set _polydataOpacityPending 0
-    set val $_settings(-polydataopacity)
-    SendCmd "polydata opacity $val"
-}
-
-itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity {} {
-    if { !$_polydataOpacityPending } {
-        set _polydataOpacityPending 1
-        $_dispatcher event -after $_opacityDelay !polydataOpacity
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::delete {args} {
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::scale {args} {
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                   # Object doesn't contain valid data.
-        }
-        foreach axis { x y z } {
-            set lim [$dataobj limits $axis]
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {amin amax} $_limits($axis) break
-            if { $amin > $min } {
-                set amin $min
-            }
-            if { $amax < $max } {
-                set amax $max
-            }
-            set _limits($axis) [list $amin $amax]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::Connect {} {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtkmeshviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkMeshViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkMeshViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkMeshViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    global readyForNextFrame
-    set readyForNextFrame 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::ReceiveImage { args } {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        set time [clock seconds]
-        set date [clock format $time]
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkMeshViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-        InitSettings -xgrid -ygrid -zgrid -axismode \
-            -axesvisible -axislabels -axisminorticks
-        StopBufferingCommands
-        SendCmd "imgflush"
-        StartBufferingCommands
-    }
-
-    set _first ""
-    SendCmd "dataset visible 0"
-    set count 0
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-        }
-        set tag $dataobj
-        if { ![info exists _datasets($tag)] } {
-            set bytes [$dataobj vtkdata -full]
-            if { $bytes == "" } {
-                continue
-            }
-            if 0 {
-                set f [open /tmp/vtkmesh.vtk "w"]
-                fconfigure $f -translation binary -encoding binary
-                puts -nonewline $f $bytes
-                close $f
-            }
-            set length [string length $bytes]
-            if { $_reportClientInfo }  {
-                set info {}
-                lappend info "tool_id"       [$dataobj hints toolid]
-                lappend info "tool_name"     [$dataobj hints toolname]
-                lappend info "tool_title"    [$dataobj hints tooltitle]
-                lappend info "tool_command"  [$dataobj hints toolcommand]
-                lappend info "tool_revision" [$dataobj hints toolrevision]
-                lappend info "dataset_label" [$dataobj hints label]
-                lappend info "dataset_size"  $length
-                lappend info "dataset_tag"   $tag
-                SendCmd "clientinfo [list $info]"
-            }
-            SendCmd "dataset add $tag data follows $length"
-            SendData $bytes
-            set _datasets($tag) 1
-            SetObjectStyle $dataobj
-        }
-        if { [info exists _obj2ovride($dataobj-raise)] } {
-            SendCmd "dataset visible 1 $tag"
-            EventuallySetPolydataOpacity
-        }
-    }
-    if {"" != $_first} {
-        foreach axis { x y z } {
-            set label [$_first label ${axis}]
-            if { $label != "" } {
-                SendCmd [list axis name $axis $label]
-            }
-            set units [$_first units ${axis}]
-            if { $units != "" } {
-                SendCmd [list axis units $axis $units]
-            }
-        }
-    }
-    InitSettings -outline
-    if { $_reset } {
-        # These are settings that rely on a dataset being loaded.
-        InitSettings -polydataedges -polydatalighting -polydataopacity \
-            -polydatavisible -polydatawireframe
-
-        #SendCmd "axis lformat all %g"
-
-        $_arcball quaternion [ViewToQuaternion]
-        SendCmd "camera reset"
-        if { $_view(-ortho)} {
-            SendCmd "camera mode ortho"
-        } else {
-            SendCmd "camera mode persp"
-        }
-        DoRotate
-        PanCamera
-        Zoom reset
-    }
-
-    set _reset 0
-    global readyForNextFrame
-    set readyForNextFrame 0;            # Don't advance to the next frame
-                                        # until we get an image.
-
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach tag $dlist {
-        if { [info exists _datasets($tag)] && $_datasets($tag) } {
-            lappend rlist $tag
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            $_arcball quaternion [ViewToQuaternion]
-            DoRotate
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkMeshViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkMeshViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkMeshViewer::InitSettings { args } {
-    foreach setting $args {
-        AdjustSetting $setting
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkMeshViewer::AdjustSetting {what {value ""}} {
-    if { ![isconnected] } {
-        return
-    }
-    switch -- $what {
-        "-outline" {
-            set bool $_settings($what)
-            # Only display a outline for the currently visible sets.
-            SendCmd "outline visible 0"
-            foreach dataset [CurrentDatasets -visible] {
-                SendCmd "outline visible $bool $dataset"
-            }
-        }
-        "-polydataopacity" {
-            set _settings($what) [expr $_widget($what) * 0.01]
-            EventuallySetPolydataOpacity
-        }
-        "-polydatawireframe" {
-            set bool $_settings($what)
-            SendCmd "polydata wireframe $bool"
-        }
-        "-polydatavisible" {
-            set bool $_settings($what)
-            # Only change visibility of data sets marked "visible".
-            foreach dataset [CurrentDatasets -visible] {
-                SendCmd "polydata visible $bool $dataset"
-            }
-        }
-        "-polydatalighting" {
-            set bool $_settings($what)
-            SendCmd "polydata lighting $bool"
-        }
-        "-polydataedges" {
-            set bool $_settings($what)
-            SendCmd "polydata edges $bool"
-        }
-        "-axesvisible" {
-            set bool $_settings($what)
-            SendCmd "axis visible all $bool"
-        }
-        "-axislabels" {
-            set bool $_settings($what)
-            SendCmd "axis labels all $bool"
-        }
-        "-axisminorticks" {
-            set bool $_settings($what)
-            SendCmd "axis minticks all $bool"
-        }
-        "-xgrid" {
-            set bool $_settings($what)
-            SendCmd "axis grid x $bool"
-        }
-        "-ygrid" {
-            set bool $_settings($what)
-            SendCmd "axis grid y $bool"
-        }
-        "-zgrid" {
-            set bool $_settings($what)
-            SendCmd "axis grid z $bool"
-        }
-        "-axismode" {
-            set mode [$itk_component(axismode) value]
-            set mode [$itk_component(axismode) translate $mode]
-            SendCmd "axis flymode $mode"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkMeshViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        SendCmd "screen bgcolor $rgb"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkMeshViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        SendCmd "axis color all $rgb"
-        SendCmd "outline color $rgb"
-    }
-}
-
-itcl::body Rappture::VtkMeshViewer::BuildPolydataTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Mesh Settings" \
-        -icon [Rappture::icon mesh]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.mesh \
-        -text "Show Mesh" \
-        -variable [itcl::scope _settings(-polydatavisible)] \
-        -command [itcl::code $this AdjustSetting -polydatavisible] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.outline \
-        -text "Show Outline" \
-        -variable [itcl::scope _settings(-outline)] \
-        -command [itcl::code $this AdjustSetting -outline] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.wireframe \
-        -text "Show Wireframe" \
-        -variable [itcl::scope _settings(-polydatawireframe)] \
-        -command [itcl::code $this AdjustSetting -polydatawireframe] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-polydatalighting)] \
-        -command [itcl::code $this AdjustSetting -polydatalighting] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.edges \
-        -text "Show Edges" \
-        -variable [itcl::scope _settings(-polydataedges)] \
-        -command [itcl::code $this AdjustSetting -polydataedges] \
-        -font "Arial 9" -anchor w
-
-    itk_component add field_l {
-        label $inner.field_l -text "Field" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add field {
-        Rappture::Combobox $inner.field -width 10 -editable 0
-    }
-    bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting -field]
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _widget(-polydataopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -polydataopacity]
-    $inner.opacity set [expr $_settings(-polydataopacity) * 100.0]
-
-    blt::table $inner \
-        0,0 $inner.mesh      -cspan 2  -anchor w -pady 2 \
-        1,0 $inner.outline   -cspan 2  -anchor w -pady 2 \
-        2,0 $inner.wireframe -cspan 2  -anchor w -pady 2 \
-        3,0 $inner.lighting  -cspan 2  -anchor w -pady 2 \
-        4,0 $inner.edges     -cspan 2  -anchor w -pady 2 \
-        5,0 $inner.opacity_l -anchor w -pady 2 \
-        5,1 $inner.opacity   -fill x   -pady 2
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c1 -resize expand
-}
-
-itcl::body Rappture::VtkMeshViewer::BuildAxisTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _settings(-axislabels)] \
-        -command [itcl::code $this AdjustSetting -axislabels] \
-        -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9"
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _settings(-xgrid)] \
-        -command [itcl::code $this AdjustSetting -xgrid] \
-        -font "Arial 9"
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _settings(-ygrid)] \
-        -command [itcl::code $this AdjustSetting -ygrid] \
-        -font "Arial 9"
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _settings(-zgrid)] \
-        -command [itcl::code $this AdjustSetting -zgrid] \
-        -font "Arial 9"
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _settings(-axisminorticks)] \
-        -command [itcl::code $this AdjustSetting -axisminorticks] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-
-    itk_component add axismode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axismode) value "static"
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
-
-    blt::table $inner \
-        0,0 $inner.visible -anchor w -cspan 4 \
-        1,0 $inner.labels  -anchor w -cspan 4 \
-        2,0 $inner.minorticks  -anchor w -cspan 4 \
-        4,0 $inner.grid_l  -anchor w \
-        4,1 $inner.xgrid   -anchor w \
-        4,2 $inner.ygrid   -anchor w \
-        4,3 $inner.zgrid   -anchor w \
-        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
-        5,1 $inner.mode    -fill x   -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-itcl::body Rappture::VtkMeshViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set labels { qx qy qz qw xpan ypan zoom }
-    set row 1
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this camera set -ortho] \
-        -font "Arial 9"
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkMeshViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkMeshViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        set contents [$dataobj vtkdata -full]
-        append bytes "$contents\n"
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkMeshViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkMeshViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::VtkMeshViewer::SetObjectStyle { dataobj } {
-    # Parse style string.
-    set tag $dataobj
-    set type [$dataobj type]
-
-    array set style {
-        -cloudstyle mesh
-        -constcolor white
-        -edgecolor black
-        -edges 1
-        -lighting 1
-        -linewidth 1.0
-        -opacity 1.0
-        -outline 0
-        -ptsize 1.0
-        -visible 1
-        -wireframe 0
-    }
-    if {$type == "cloud"} {
-        set style(-cloudstyle) points
-        set style(-edges) 0
-        set style(-edgecolor) white
-    }
-    array set style [$dataobj hints style]
-
-    if {[$dataobj hints color] != ""} {
-        set style(-constcolor) [$dataobj hints color]
-    }
-    SendCmd "outline add $tag"
-    SendCmd "outline color [Color2RGB $style(-constcolor)] $tag"
-    SendCmd "outline visible $style(-outline) $tag"
-    set _settings(-outline) $style(-outline)
-
-    SendCmd "polydata add $tag"
-    SendCmd "polydata visible $style(-visible) $tag"
-    set _settings(-polydatavisible) $style(-visible)
-    SendCmd "polydata cloudstyle $style(-cloudstyle) $tag"
-    SendCmd "polydata edges $style(-edges) $tag"
-    set _settings(-polydataedges) $style(-edges)
-    SendCmd "polydata color [Color2RGB $style(-constcolor)] $tag"
-    SendCmd "polydata lighting $style(-lighting) $tag"
-    set _settings(-polydatalighting) $style(-lighting)
-    SendCmd "polydata linecolor [Color2RGB $style(-edgecolor)] $tag"
-    SendCmd "polydata linewidth $style(-linewidth) $tag"
-    SendCmd "polydata ptsize $style(-ptsize) $tag"
-    SendCmd "polydata opacity $style(-opacity) $tag"
-    set _settings(-polydataopacity) $style(-opacity)
-    set _widget(-polydataopacity) [expr 100.0 * $style(-opacity)]
-    SendCmd "polydata wireframe $style(-wireframe) $tag"
-    set _settings(-polydatawireframe) $style(-wireframe)
-    set havePolyData 1
-}
-
-itcl::body Rappture::VtkMeshViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Mesh} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-itcl::body Rappture::VtkMeshViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
Index: trunk/gui/scripts/vtkstreamlinesviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkstreamlinesviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,2439 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtkstreamlinesviewer - Vtk streamlines object viewer
-#
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-package require Img
-
-option add *VtkStreamlinesViewer.width 4i widgetDefault
-option add *VtkStreamlinesViewer*cursor crosshair widgetDefault
-option add *VtkStreamlinesViewer.height 4i widgetDefault
-option add *VtkStreamlinesViewer.foreground black widgetDefault
-option add *VtkStreamlinesViewer.controlBackground gray widgetDefault
-option add *VtkStreamlinesViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkStreamlinesViewer.plotBackground black widgetDefault
-option add *VtkStreamlinesViewer.plotForeground white widgetDefault
-option add *VtkStreamlinesViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkStreamlinesViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkStreamlinesViewer::SetServerList
-}
-
-itcl::class Rappture::VtkStreamlinesViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildColormap { name }
-    private method BuildCutplanesTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildStreamsTab {}
-    private method BuildSurfaceTab {}
-    private method DrawLegend {}
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method Disconnect {}
-    private method DoRescale {}
-    private method DoReseed {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method EnterLegend { x y }
-    private method EventuallyRescale { length }
-    private method EventuallyReseed { numPoints }
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method EventuallySetCutplane { axis args }
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method LeaveLegend {}
-    private method LegendTitleAction { option }
-    private method MotionLegend { x y }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { colormap title min max size }
-    private method RequestLegend {}
-    private method Rotate {option x y}
-    private method SetCurrentColormap { color }
-    private method SetCurrentFieldName { dataobj }
-    private method SetLegendTip { x y }
-    private method SetObjectStyle { dataobj comp }
-    private method Slice {option args}
-    private method SetOrientation { side }
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _colormaps;        # contains all the colormaps
-                                        # in the server.
-    private variable _currentColormap ""
-
-    private variable _click;            # info used for rotate operations
-    private variable _limits;           # autoscale min/max for all axes
-    private variable _view;             # view params for 3D view
-    private variable _settings
-    private variable _reset 1;          # Connection to server has been reset.
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _title ""
-    private variable _seeds
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _legendPending 0
-    private variable _rescalePending 0
-    private variable _reseedPending 0
-    private variable _rotatePending 0
-    private variable _cutplanePending 0
-    private variable _fields
-    private variable _curFldName ""
-    private variable _curFldLabel ""
-    private variable _colorMode "vmag"; # Mode of colormap (vmag or scalar)
-    private variable _streamlinesLength 0
-    private variable _numSeeds 200
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkStreamlinesViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::constructor {args} {
-    set _serverType "vtkvis"
-
-    #DebugOn
-    EnableWaitDialog 2000
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
-
-    # Rescale streamlines event
-    $_dispatcher register !rescale
-    $_dispatcher dispatch $this !rescale "[itcl::code $this DoRescale]; list"
-
-    # Reseed event
-    $_dispatcher register !reseed
-    $_dispatcher dispatch $this !reseed "[itcl::code $this DoReseed]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    # X-Cutplane event
-    $_dispatcher register !xcutplane
-    $_dispatcher dispatch $this !xcutplane \
-        "[itcl::code $this AdjustSetting -xcutplaneposition]; list"
-
-    # Y-Cutplane event
-    $_dispatcher register !ycutplane
-    $_dispatcher dispatch $this !ycutplane \
-        "[itcl::code $this AdjustSetting -ycutplaneposition]; list"
-
-    # Z-Cutplane event
-    $_dispatcher register !zcutplane
-    $_dispatcher dispatch $this !zcutplane \
-        "[itcl::code $this AdjustSetting -zcutplaneposition]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _settings {
-        -axesvisible              1
-        -axislabelsvisible        1
-        -axisminorticks           1
-        -axismode                 "static"
-        -cutplaneedges            0
-        -cutplanelighting         1
-        -cutplaneopacity          100
-        -cutplanesvisible         0
-        -cutplanewireframe        0
-        -legendvisible            1
-        -streamlineslighting      1
-        -streamlinesmode          lines
-        -streamlinesnumseeds      200
-        -streamlinesopacity       100
-        -streamlineslength        70
-        -streamlinesseedsvisible  0
-        -streamlinesvisible       1
-        -surfaceedges             0
-        -surfacelighting          1
-        -surfaceopacity           40
-        -surfacevisible           1
-        -surfacewireframe         0
-        -xcutplaneposition        50
-        -xcutplanevisible         1
-        -xgrid                    0
-        -ycutplaneposition        50
-        -ycutplanevisible         1
-        -ygrid                    0
-        -zcutplaneposition        50
-        -zcutplanevisible         1
-        -zgrid                    0
-    }
-
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    itk_component add fieldmenu {
-        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
-            -tearoff 0
-    } {
-        usual
-        ignore -background -foreground -relief -tearoff
-    }
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add surface {
-        Rappture::PushButton $f.surface \
-            -onimage [Rappture::icon volume-on] \
-            -offimage [Rappture::icon volume-off] \
-            -variable [itcl::scope _settings(-surfacevisible)] \
-            -command [itcl::code $this AdjustSetting -surfacevisible]
-    }
-    $itk_component(surface) select
-    Rappture::Tooltip::for $itk_component(surface) \
-        "Show/Hide the boundary surface"
-    pack $itk_component(surface) -padx 2 -pady 2
-
-    itk_component add streamlines {
-        Rappture::PushButton $f.streamlines \
-            -onimage [Rappture::icon streamlines-on] \
-            -offimage [Rappture::icon streamlines-off] \
-            -variable [itcl::scope _settings(-streamlinesvisible)] \
-            -command [itcl::code $this AdjustSetting -streamlinesvisible] \
-    }
-    $itk_component(streamlines) select
-    Rappture::Tooltip::for $itk_component(streamlines) \
-        "Show/Hide the streamlines"
-    pack $itk_component(streamlines) -padx 2 -pady 2
-
-    itk_component add cutplane {
-        Rappture::PushButton $f.cutplane \
-            -onimage [Rappture::icon cutbutton] \
-            -offimage [Rappture::icon cutbutton] \
-            -variable [itcl::scope _settings(-cutplanesvisible)] \
-            -command [itcl::code $this AdjustSetting -cutplanesvisible]
-    }
-    Rappture::Tooltip::for $itk_component(cutplane) \
-        "Show/Hide the cutplanes"
-    pack $itk_component(cutplane) -padx 2 -pady 2
-
-    if { [catch {
-        BuildSurfaceTab
-        BuildStreamsTab
-        BuildCutplanesTab
-        BuildAxisTab
-        BuildCameraTab
-    } errs] != 0 } {
-        puts stderr errs=$errs
-    }
-    # Legend
-
-    set _image(legend) [image create photo]
-    itk_component add legend {
-        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -plotbackground plotBackground Background
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::destructor {} {
-    Disconnect
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size $_width $_height"
-
-    set _legendPending 1
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::DoRescale {} {
-    foreach dataset [CurrentDatasets -visible] {
-        SendCmd "streamlines length $_streamlinesLength $dataset"
-    }
-    set _rescalePending 0
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::DoReseed {} {
-    foreach dataset [CurrentDatasets -visible] {
-        # This command works for either random or fmesh seeds
-        SendCmd "streamlines seed numpts $_numSeeds $dataset"
-    }
-    set _reseedPending 0
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 400 !resize
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::EventuallyRescale { length } {
-    set _streamlinesLength $length
-    if { !$_rescalePending } {
-        set _rescalePending 1
-        $_dispatcher event -after 600 !rescale
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::EventuallyReseed { numPoints } {
-    set _numSeeds $numPoints
-    if { !$_reseedPending } {
-        set _reseedPending 1
-        $_dispatcher event -after 600 !reseed
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after 100 !rotate
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::EventuallySetCutplane { axis args } {
-    if { !$_cutplanePending } {
-        set _cutplanePending 1
-        $_dispatcher event -after 100 !${axis}cutplane
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::delete {args} {
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::scale {args} {
-    foreach dataobj $args {
-        foreach axis { x y z } {
-            set lim [$dataobj limits $axis]
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {amin amax} $_limits($axis) break
-            if { $amin > $min } {
-                set amin $min
-            }
-            if { $amax < $max } {
-                set amax $max
-            }
-            set _limits($axis) [list $amin $amax]
-        }
-        foreach { fname lim } [$dataobj fieldlimits] {
-            if { ![info exists _limits($fname)] } {
-                set _limits($fname) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {fmin fmax} $_limits($fname) break
-            if { $fmin > $min } {
-                set fmin $min
-            }
-            if { $fmax < $max } {
-                set fmax $max
-            }
-            set _limits($fname) [list $fmin $fmax]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::Connect {} {
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtkstreamlinesviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkStreamlinesViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkStreamlinesViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkStreamlinesViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !reseed
-    $_dispatcher cancel !rotate
-    $_dispatcher cancel !xcutplane
-    $_dispatcher cancel !ycutplane
-    $_dispatcher cancel !zcutplane
-    $_dispatcher cancel !legend
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    array unset _colormaps
-    array unset _seeds
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::ReceiveImage { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        set time [clock seconds]
-        set date [clock format $time]
-        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            #puts stderr "round trip time [expr $finish -$_start] milliseconds"
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-    if { $_legendPending } {
-        RequestLegend
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkStreamlinesViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-    set _legendPending 1
-
-    set _first ""
-    if { $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-        InitSettings -xgrid -ygrid -zgrid -axismode \
-            -axesvisible -axislabelsvisible -axisminorticks
-        # This "imgflush" is to force an image returned before vtkvis starts
-        # reading a (big) dataset.  This will display an empty plot with axes
-        # at the correct image size.
-        SendCmd "imgflush"
-    }
-
-    set _first ""
-    SendCmd "dataset visible 0"
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-            SetCurrentFieldName $dataobj
-        }
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { ![info exists _datasets($tag)] } {
-                set bytes [$dataobj vtkdata $comp]
-                set length [string length $bytes]
-                if 0 {
-                    set f [open /tmp/vtkstreamlines.vtk "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $bytes
-                    close $f
-                }
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $length
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "dataset add $tag data follows $length"
-                SendData $bytes
-                set _datasets($tag) 1
-                SetObjectStyle $dataobj $comp
-            }
-            if { [info exists _obj2ovride($dataobj-raise)] } {
-                SendCmd "dataset visible 1 $tag"
-            }
-        }
-    }
-    if {"" != $_first} {
-        foreach axis { x y z } {
-            set label [$_first hints ${axis}label]
-            if { $label != "" } {
-                SendCmd [list axis name $axis $label]
-            }
-            set units [$_first hints ${axis}units]
-            if { $units != "" } {
-                SendCmd [list axis units $axis $units]
-            }
-        }
-    }
-
-    if { $_reset } {
-        InitSettings -streamlinesseedsvisible -streamlinesopacity \
-            -streamlinesvisible \
-            -streamlineslighting \
-            -streamlinescolormap -field \
-            -surfacevisible -surfaceedges -surfacelighting -surfaceopacity \
-            -surfacewireframe \
-            -cutplanesvisible \
-            -xcutplaneposition -ycutplaneposition -zcutplaneposition \
-            -xcutplanevisible -ycutplanevisible -zcutplanevisible
-
-        # Reset the camera and other view parameters
-        $_arcball quaternion [ViewToQuaternion]
-        if {$_view(-ortho)} {
-            SendCmd "camera mode ortho"
-        } else {
-            SendCmd "camera mode persp"
-        }
-        DoRotate
-        PanCamera
-        Zoom reset
-        SendCmd "camera reset"
-        set _reset 0
-    }
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _datasets($tag)] && $_datasets($tag) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            $_arcball quaternion [ViewToQuaternion]
-            DoRotate
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::InitSettings { args } {
-    foreach spec $args {
-        AdjustSetting $spec
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkStreamlinesViewer::AdjustSetting {what {value ""}} {
-    if { ![isconnected] } {
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            set bool $_settings($what)
-            SendCmd "axis visible all $bool"
-        }
-        "-axislabelsvisible" {
-            set bool $_settings($what)
-            SendCmd "axis labels all $bool"
-        }
-        "-axisminorticks" {
-            set bool $_settings($what)
-            SendCmd "axis minticks all $bool"
-        }
-        "-axismode" {
-            set mode [$itk_component(axismode) value]
-            set mode [$itk_component(axismode) translate $mode]
-            set _settings($what) $mode
-            SendCmd "axis flymode $mode"
-        }
-        "-cutplaneedges" {
-            set bool $_settings($what)
-            SendCmd "cutplane edges $bool"
-        }
-        "-cutplanesvisible" {
-            set bool $_settings($what)
-            SendCmd "cutplane visible $bool"
-            if { $bool } {
-                Rappture::Tooltip::for $itk_component(cutplane) \
-                    "Hide the cutplanes"
-            } else {
-                Rappture::Tooltip::for $itk_component(cutplane) \
-                    "Show the cutplanes"
-            }
-        }
-        "-cutplanewireframe" {
-            set bool $_settings($what)
-            SendCmd "cutplane wireframe $bool"
-        }
-        "-cutplanelighting" {
-            set bool $_settings($what)
-            SendCmd "cutplane lighting $bool"
-        }
-        "-cutplaneopacity" {
-            set val $_settings($what)
-            set sval [expr { 0.01 * double($val) }]
-            SendCmd "cutplane opacity $sval"
-        }
-        "-field" {
-            set label [$itk_component(field) value]
-            set fname [$itk_component(field) translate $label]
-            set _settings($what) $fname
-            if { [info exists _fields($fname)] } {
-                foreach { label units components } $_fields($fname) break
-                if { $components > 1 } {
-                    set _colorMode vmag
-                } else {
-                    set _colorMode scalar
-                }
-                set _curFldName $fname
-                set _curFldLabel $label
-            } else {
-                puts stderr "unknown field \"$fname\""
-                return
-            }
-            # Get the new limits because the field changed.
-            if { ![info exists _limits($_curFldName)] } {
-                SendCmd "dataset maprange all"
-            } else {
-                foreach { vmin vmax } $_limits($_curFldName) break
-                SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName]
-            }
-            SendCmd [list streamlines colormode $_colorMode $_curFldName]
-            SendCmd [list cutplane colormode $_colorMode $_curFldName]
-            DrawLegend
-        }
-        "-streamlinesseedsvisible" {
-            set bool $_settings($what)
-            SendCmd "streamlines seed visible $bool"
-        }
-        "-streamlinesnumseeds" {
-            set density $_settings($what)
-            EventuallyReseed $density
-        }
-        "-streamlinesvisible" {
-            set bool $_settings($what)
-            SendCmd "streamlines visible $bool"
-            if { $bool } {
-                Rappture::Tooltip::for $itk_component(streamlines) \
-                    "Hide the streamlines"
-            } else {
-                Rappture::Tooltip::for $itk_component(streamlines) \
-                    "Show the streamlines"
-            }
-        }
-        "-streamlinesmode" {
-            set mode [$itk_component(streammode) value]
-            set _settings($what) $mode
-            switch -- $mode {
-                "lines" {
-                    SendCmd "streamlines lines"
-                }
-                "ribbons" {
-                    SendCmd "streamlines ribbons 3 0"
-                }
-                "tubes" {
-                    SendCmd "streamlines tubes 5 3"
-                }
-            }
-        }
-        "-streamlinescolormap" {
-            set colormap [$itk_component(colormap) value]
-            set _settings($what) $colormap
-            SetCurrentColormap $colormap
-            set _legendPending 1
-        }
-        "-streamlinesopacity" {
-            set val $_settings($what)
-            set sval [expr { 0.01 * double($val) }]
-            SendCmd "streamlines opacity $sval"
-        }
-        "-streamlineslength" {
-            set val $_settings($what)
-            set sval [expr { (0.01 * double($val)) / 0.7 }]
-            foreach axis {x y z} {
-                foreach {min max} $_limits($axis) break
-                set ${axis}len [expr double($max) - double($min)]
-            }
-            set length [expr { $sval * ($xlen + $ylen + $zlen) } ]
-            EventuallyRescale $length
-        }
-        "-streamlineslighting" {
-            set bool $_settings($what)
-            SendCmd "streamlines lighting $bool"
-        }
-        "-surfaceopacity" {
-            set val $_settings($what)
-            set sval [expr { 0.01 * double($val) }]
-            SendCmd "polydata opacity $sval"
-        }
-        "-surfacewireframe" {
-            set bool $_settings($what)
-            SendCmd "polydata wireframe $bool"
-        }
-        "-surfacevisible" {
-            set bool $_settings($what)
-            SendCmd "polydata visible $bool"
-            if { $bool } {
-                Rappture::Tooltip::for $itk_component(surface) \
-                    "Hide the boundary surface"
-            } else {
-                Rappture::Tooltip::for $itk_component(surface) \
-                    "Show the boundary surface"
-            }
-        }
-        "-surfacelighting" {
-            set bool $_settings($what)
-            SendCmd "polydata lighting $bool"
-        }
-        "-surfaceedges" {
-            set bool $_settings($what)
-            SendCmd "polydata edges $bool"
-        }
-        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
-            set axis [string range $what 1 1]
-            set bool $_settings($what)
-            if { $bool } {
-                $itk_component(${axis}CutScale) configure -state normal \
-                    -troughcolor white
-            } else {
-                $itk_component(${axis}CutScale) configure -state disabled \
-                    -troughcolor grey82
-            }
-            SendCmd "cutplane axis $axis $bool"
-        }
-        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
-            set axis [string range $what 1 1]
-            set pos [expr $_settings($what) * 0.01]
-            SendCmd "cutplane slice ${axis} ${pos}"
-            set _cutplanePending 0
-        }
-        "-xgrid" - "-ygrid" - "-zgrid" {
-            set axis [string range $what 1 1]
-            set bool $_settings($what)
-            SendCmd "axis grid $axis $bool"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-#
-# RequestLegend --
-#
-# Request a new legend from the server.  The size of the legend
-# is determined from the height of the canvas.  It will be rotated
-# to be vertical when drawn.
-#
-itcl::body Rappture::VtkStreamlinesViewer::RequestLegend {} {
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-    set w 12
-    set h [expr {$_height - 3 * ($lineht + 2)}]
-    if { $h < 1 } {
-        return
-    }
-    # Set the legend on the first dataset.
-    if { $_currentColormap != "" } {
-        set cmap $_currentColormap
-        if { ![info exists _colormaps($cmap)] } {
-            BuildColormap $cmap
-            set _colormaps($cmap) 1
-        }
-        #SendCmd [list legend $cmap $_colorMode $_curFldName {} $w $h 0]
-        SendCmd "legend2 $cmap $w $h"
-    }
-}
-
-#
-# SetCurrentColormap --
-#
-itcl::body Rappture::VtkStreamlinesViewer::SetCurrentColormap { name } {
-    # Keep track of the colormaps that we build.
-    if { ![info exists _colormaps($name)] } {
-        BuildColormap $name
-        set _colormaps($name) 1
-    }
-    set _currentColormap $name
-    SendCmd "streamlines colormap $_currentColormap"
-    SendCmd "cutplane colormap $_currentColormap"
-}
-
-#
-# BuildColormap --
-#
-itcl::body Rappture::VtkStreamlinesViewer::BuildColormap { name } {
-    set cmap [ColorsToColormap $name]
-    if { [llength $cmap] == 0 } {
-        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
-    }
-    set amap "0.0 1.0 1.0 1.0"
-    SendCmd "colormap add $name { $cmap } { $amap }"
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkStreamlinesViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        SendCmd "screen bgcolor $rgb"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkStreamlinesViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        SendCmd "axis color all $rgb"
-        SendCmd "outline color $rgb"
-        SendCmd "cutplane color $rgb"
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::BuildSurfaceTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Boundary Surface Settings" \
-        -icon [Rappture::icon volume-on]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.surface \
-        -text "Show Surface" \
-        -variable [itcl::scope _settings(-surfacevisible)] \
-        -command [itcl::code $this AdjustSetting -surfacevisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.wireframe \
-        -text "Show Wireframe" \
-        -variable [itcl::scope _settings(-surfacewireframe)] \
-        -command [itcl::code $this AdjustSetting -surfacewireframe] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-surfacelighting)] \
-        -command [itcl::code $this AdjustSetting -surfacelighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.edges \
-        -text "Show Edges" \
-        -variable [itcl::scope _settings(-surfaceedges)] \
-        -command [itcl::code $this AdjustSetting -surfaceedges] \
-        -font "Arial 9"
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-surfaceopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -surfaceopacity]
-
-    blt::table $inner \
-        0,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \
-        1,0 $inner.lighting  -anchor w -pady 2 -cspan 2 \
-        2,0 $inner.edges     -anchor w -pady 2 -cspan 3 \
-        3,0 $inner.opacity_l -anchor w -pady 2 \
-        3,1 $inner.opacity   -fill x   -pady 2
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r4 c1 -resize expand
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::BuildStreamsTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Streams Settings" \
-        -icon [Rappture::icon streamlines-on]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.streamlines \
-        -text "Show Streamlines" \
-        -variable [itcl::scope _settings(-streamlinesvisible)] \
-        -command [itcl::code $this AdjustSetting -streamlinesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-streamlineslighting)] \
-        -command [itcl::code $this AdjustSetting -streamlineslighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.seeds \
-        -text "Show Seeds" \
-        -variable [itcl::scope _settings(-streamlinesseedsvisible)] \
-        -command [itcl::code $this AdjustSetting -streamlinesseedsvisible] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-    itk_component add streammode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "lines"    "lines" \
-        "ribbons"   "ribbons" \
-        "tubes"     "tubes"
-    $itk_component(streammode) value $_settings(-streamlinesmode)
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -streamlinesmode]
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-streamlinesopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -streamlinesopacity]
-
-    label $inner.density_l -text "No. Seeds" -font "Arial 9"
-    ::scale $inner.density -from 1 -to 1000 -orient horizontal \
-        -variable [itcl::scope _settings(-streamlinesnumseeds)] \
-        -width 10 \
-        -showvalue on \
-        -command [itcl::code $this AdjustSetting -streamlinesnumseeds]
-
-    label $inner.scale_l -text "Length" -font "Arial 9"
-    ::scale $inner.scale -from 1 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-streamlineslength)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -streamlineslength]
-
-    label $inner.field_l -text "Color by" -font "Arial 9"
-    itk_component add field {
-        Rappture::Combobox $inner.field -width 10 -editable 0
-    }
-    bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting -field]
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9"
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList]
-
-    $itk_component(colormap) value "BCGYR"
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -streamlinescolormap]
-
-    blt::table $inner \
-        0,0 $inner.field_l     -anchor w -pady 2  \
-        0,1 $inner.field       -fill x   -pady 2  \
-        1,0 $inner.colormap_l  -anchor w -pady 2  \
-        1,1 $inner.colormap    -fill x   -pady 2  \
-        2,0 $inner.mode_l      -anchor w -pady 2  \
-        2,1 $inner.mode        -fill x   -pady 2  \
-        3,0 $inner.scale_l     -anchor w -pady 2  \
-        3,1 $inner.scale       -fill x   -pady 2  \
-        4,0 $inner.opacity_l   -anchor w -pady 2  \
-        4,1 $inner.opacity     -fill x -pady 2 \
-        5,0 $inner.lighting    -anchor w -pady 2 -cspan 2 \
-        6,0 $inner.seeds       -anchor w -pady 2 -cspan 2 \
-        7,0 $inner.density_l   -anchor w -pady 2  \
-        7,1 $inner.density     -fill x   -pady 2  \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r8 c1 c2 -resize expand
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::BuildAxisTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _settings(-axislabelsvisible)] \
-        -command [itcl::code $this AdjustSetting -axislabelsvisible] \
-        -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9"
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _settings(-xgrid)] \
-        -command [itcl::code $this AdjustSetting -xgrid] \
-        -font "Arial 9"
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _settings(-ygrid)] \
-        -command [itcl::code $this AdjustSetting -ygrid] \
-        -font "Arial 9"
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _settings(-zgrid)] \
-        -command [itcl::code $this AdjustSetting -zgrid] \
-        -font "Arial 9"
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _settings(-axisminorticks)] \
-        -command [itcl::code $this AdjustSetting -axisminorticks] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-
-    itk_component add axismode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axismode) value $_settings(-axismode)
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
-
-    blt::table $inner \
-        0,0 $inner.visible -anchor w -cspan 4 \
-        1,0 $inner.labels  -anchor w -cspan 4 \
-        2,0 $inner.minorticks  -anchor w -cspan 4 \
-        4,0 $inner.grid_l  -anchor w \
-        4,1 $inner.xgrid   -anchor w \
-        4,2 $inner.ygrid   -anchor w \
-        4,3 $inner.zgrid   -anchor w \
-        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
-        5,1 $inner.mode    -fill x   -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set labels { qx qy qz qw xpan ypan zoom }
-    set row 1
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this camera set -ortho] \
-        -font "Arial 9"
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::BuildCutplanesTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Cutplane Settings" \
-        -icon [Rappture::icon cutbutton]]
-
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Show Cutplanes" \
-        -variable [itcl::scope _settings(-cutplanesvisible)] \
-        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.wireframe \
-        -text "Show Wireframe" \
-        -variable [itcl::scope _settings(-cutplanewireframe)] \
-        -command [itcl::code $this AdjustSetting -cutplanewireframe] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-cutplanelighting)] \
-        -command [itcl::code $this AdjustSetting -cutplanelighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.edges \
-        -text "Show Edges" \
-        -variable [itcl::scope _settings(-cutplaneedges)] \
-        -command [itcl::code $this AdjustSetting -cutplaneedges] \
-        -font "Arial 9"
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-cutplaneopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -cutplaneopacity]
-    $inner.opacity set $_settings(-cutplaneopacity)
-
-    # X-value slicer...
-    itk_component add xCutButton {
-        Rappture::PushButton $inner.xbutton \
-            -onimage [Rappture::icon x-cutplane-red] \
-            -offimage [Rappture::icon x-cutplane-red] \
-            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
-            -variable [itcl::scope _settings(-xcutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(xCutButton) \
-        "Toggle the X-axis cutplane on/off"
-    $itk_component(xCutButton) select
-
-    itk_component add xCutScale {
-        ::scale $inner.xval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane x] \
-            -variable [itcl::scope _settings(-xcutplaneposition)] \
-            -foreground red3 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font
-    }
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(xCutScale) set 50
-    $itk_component(xCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(xCutScale) \
-        "@[itcl::code $this Slice tooltip x]"
-
-    # Y-value slicer...
-    itk_component add yCutButton {
-        Rappture::PushButton $inner.ybutton \
-            -onimage [Rappture::icon y-cutplane-green] \
-            -offimage [Rappture::icon y-cutplane-green] \
-            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
-            -variable [itcl::scope _settings(-ycutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(yCutButton) \
-        "Toggle the Y-axis cutplane on/off"
-    $itk_component(yCutButton) select
-
-    itk_component add yCutScale {
-        ::scale $inner.yval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane y] \
-            -variable [itcl::scope _settings(-ycutplaneposition)] \
-            -foreground green3 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font
-    }
-    Rappture::Tooltip::for $itk_component(yCutScale) \
-        "@[itcl::code $this Slice tooltip y]"
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(yCutScale) set 50
-    $itk_component(yCutScale) configure -state disabled
-
-    # Z-value slicer...
-    itk_component add zCutButton {
-        Rappture::PushButton $inner.zbutton \
-            -onimage [Rappture::icon z-cutplane-blue] \
-            -offimage [Rappture::icon z-cutplane-blue] \
-            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
-            -variable [itcl::scope _settings(-zcutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(zCutButton) \
-        "Toggle the Z-axis cutplane on/off"
-    $itk_component(zCutButton) select
-
-    itk_component add zCutScale {
-        ::scale $inner.zval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane z] \
-            -variable [itcl::scope _settings(-zcutplaneposition)] \
-            -foreground blue3 -font "Arial 9 bold"
-    } {
-        usual
-        ignore -borderwidth -highlightthickness -foreground -font
-    }
-    $itk_component(zCutScale) set 50
-    $itk_component(zCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(zCutScale) \
-        "@[itcl::code $this Slice tooltip z]"
-
-    blt::table $inner \
-        0,0 $inner.lighting             -anchor w -pady 2 -cspan 4 \
-        1,0 $inner.wireframe            -anchor w -pady 2 -cspan 4 \
-        2,0 $inner.edges                -anchor w -pady 2 -cspan 4 \
-        3,0 $inner.opacity_l            -anchor w -pady 2 -cspan 1 \
-        3,1 $inner.opacity              -fill x   -pady 2 -cspan 3 \
-        4,0 $itk_component(xCutButton)  -anchor w -padx 2 -pady 2 \
-        5,0 $itk_component(yCutButton)  -anchor w -padx 2 -pady 2 \
-        6,0 $itk_component(zCutButton)  -anchor w -padx 2 -pady 2 \
-        4,1 $itk_component(xCutScale)   -fill y -rspan 4 \
-        4,2 $itk_component(yCutScale)   -fill y -rspan 4 \
-        4,3 $itk_component(zCutScale)   -fill y -rspan 4 \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c4 -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkStreamlinesViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            set contents [$dataobj vtkdata $comp]
-            append bytes "$contents\n"
-        }
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::SetObjectStyle { dataobj comp } {
-    # Parse style string.
-    set tag $dataobj-$comp
-    array set style {
-        -color BCGYR
-        -constcolor white
-        -edgecolor black
-        -edges 0
-        -lighting 1
-        -linewidth 1.0
-        -mode lines
-        -numseeds 200
-        -opacity 1.0
-        -seeds 1
-        -seedcolor white
-        -streamlineslength 0.7
-        -surfacecolor white
-        -surfaceedgecolor black
-        -surfaceedges 0
-        -surfacelighting 1
-        -surfaceopacity 0.4
-        -surfacevisible 1
-        -surfacewireframe 0
-        -visible 1
-    }
-    set style(-constcolor) $itk_option(-plotforeground)
-    array set style [$dataobj style $comp]
-
-    StartBufferingCommands
-    SendCmd "streamlines add $tag"
-    SendCmd "streamlines color [Color2RGB $style(-constcolor)] $tag"
-    SendCmd "streamlines edges $style(-edges) $tag"
-    SendCmd "streamlines linecolor [Color2RGB $style(-edgecolor)] $tag"
-    SendCmd "streamlines linewidth $style(-linewidth) $tag"
-    SendCmd "streamlines lighting $style(-lighting) $tag"
-    SendCmd "streamlines opacity $style(-opacity) $tag"
-    SendCmd "streamlines seed color [Color2RGB $style(-seedcolor)] $tag"
-    SendCmd "streamlines seed visible $style(-seeds) $tag"
-    SendCmd "streamlines visible $style(-visible) $tag"
-    set seeds [$dataobj hints seeds]
-    if { $seeds != "" && ![info exists _seeds($dataobj)] } {
-        set length [string length $seeds]
-        SendCmd "streamlines seed fmesh $style(-numseeds) data follows $length $tag"
-        SendData $seeds
-        set _seeds($dataobj) 1
-    }
-    set _settings(-streamlineslighting) $style(-lighting)
-    $itk_component(streammode) value $style(-mode)
-    AdjustSetting -streamlinesmode
-    set _settings(-streamlinesnumseeds) $style(-numseeds)
-    set _settings(-streamlinesopacity) [expr $style(-opacity) * 100.0]
-    set _settings(-streamlineslength) [expr $style(-streamlineslength) * 100.0]
-    set _settings(-streamlinesseedsvisible) $style(-seeds)
-    set _settings(-streamlinesvisible) $style(-visible)
-
-    SendCmd "cutplane add $tag"
-
-    SendCmd "polydata add $tag"
-    SendCmd "polydata color [Color2RGB $style(-surfacecolor)] $tag"
-    SendCmd "polydata colormode constant {} $tag"
-    SendCmd "polydata edges $style(-surfaceedges) $tag"
-    SendCmd "polydata linecolor [Color2RGB $style(-surfaceedgecolor)] $tag"
-    SendCmd "polydata lighting $style(-surfacelighting) $tag"
-    SendCmd "polydata opacity $style(-surfaceopacity) $tag"
-    SendCmd "polydata wireframe $style(-surfacewireframe) $tag"
-    SendCmd "polydata visible $style(-surfacevisible) $tag"
-    set _settings(-surfaceedges) $style(-surfaceedges)
-    set _settings(-surfacelighting) $style(-surfacelighting)
-    set _settings(-surfaceopacity) [expr $style(-surfaceopacity) * 100.0]
-    set _settings(-surfacewireframe) $style(-surfacewireframe)
-    set _settings(-surfacevisible) $style(-surfacevisible)
-    StopBufferingCommands
-    SetCurrentColormap $style(-color)
-    $itk_component(colormap) value $style(-color)
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::ReceiveLegend { colormap title min max size } {
-    set _legendPending 0
-    set _title $title
-    regsub {\(mag\)} $title "" _title
-    if { [IsConnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend)] } {
-            set _image(legend) [image create photo]
-        }
-        $_image(legend) configure -data $bytes
-        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-        if { [catch {DrawLegend} errs] != 0 } {
-            puts stderr errs=$errs
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-# Draws the legend in it's own canvas which resides to the right
-# of the contour plot area.
-#
-itcl::body Rappture::VtkStreamlinesViewer::DrawLegend {} {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    if { [info exists _fields($fname)] } {
-        foreach { title units } $_fields($fname) break
-        if { $units != "" } {
-            set title [format "%s (%s)" $title $units]
-        }
-    } else {
-        set title $fname
-    }
-    if { $_settings(-legendvisible) } {
-        set x [expr $w - 2]
-        if { [$c find withtag "legend"] == "" } {
-            set y 2
-            $c create text $x $y \
-                -anchor ne \
-                -fill $itk_option(-plotforeground) -tags "title legend" \
-                -font $font
-            incr y $lineht
-            $c create text $x $y \
-                -anchor ne \
-                -fill $itk_option(-plotforeground) -tags "vmax legend" \
-                -font $font
-            incr y $lineht
-            $c create image $x $y \
-                -anchor ne \
-                -image $_image(legend) -tags "colormap legend"
-            $c create text $x [expr {$h-2}] \
-                -anchor se \
-                -fill $itk_option(-plotforeground) -tags "vmin legend" \
-                -font $font
-            #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y]
-            $c bind colormap <Leave> [itcl::code $this LeaveLegend]
-            $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
-        }
-        $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
-        $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
-        $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
-        # Reset the item coordinates according the current size of the plot.
-        $c itemconfigure title -text $title
-        if { [info exists _limits($_curFldName)] } {
-            foreach {vmin vmax} $_limits($_curFldName) break
-            $c itemconfigure vmin -text [format %g $vmin]
-            $c itemconfigure vmax -text [format %g $vmax]
-        }
-        set y 2
-        $c coords title $x $y
-        incr y $lineht
-        $c coords vmax $x $y
-        incr y $lineht
-        $c coords colormap $x $y
-        $c coords vmin $x [expr {$h - 2}]
-    }
-}
-
-#
-# EnterLegend --
-#
-itcl::body Rappture::VtkStreamlinesViewer::EnterLegend { x y } {
-    SetLegendTip $x $y
-}
-
-#
-# MotionLegend --
-#
-itcl::body Rappture::VtkStreamlinesViewer::MotionLegend { x y } {
-    Rappture::Tooltip::tooltip cancel
-    set c $itk_component(view)
-    SetLegendTip $x $y
-}
-
-#
-# LeaveLegend --
-#
-itcl::body Rappture::VtkStreamlinesViewer::LeaveLegend { } {
-    Rappture::Tooltip::tooltip cancel
-    .rappturetooltip configure -icon ""
-}
-
-#
-# SetLegendTip --
-#
-itcl::body Rappture::VtkStreamlinesViewer::SetLegendTip { x y } {
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set imgHeight [image height $_image(legend)]
-    set coords [$c coords colormap]
-    set imgX [expr $w - [image width $_image(legend)] - 2]
-    set imgY [expr $y - 2 * ($lineht + 2)]
-
-    if { [info exists _fields($_title)] } {
-        foreach { title units } $_fields($_title) break
-        if { $units != "" } {
-            set title [format "%s (%s)" $title $units]
-        }
-    } else {
-        set title $_title
-    }
-    # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
-        #puts stderr "out of range: $imgY"
-        return
-    }
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    set color [eval format "\#%02x%02x%02x" $pixel]
-    $_image(swatch) put black  -to 0 0 23 23
-    $_image(swatch) put $color -to 1 1 22 22
-    .rappturetooltip configure -icon $_image(swatch)
-
-    # Compute the value of the point
-    if { [info exists _limits($_curFldName)] } {
-        foreach {vmin vmax} $_limits($_curFldName) break
-        set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
-        set value [expr $t * ($vmax - $vmin) + $vmin]
-    } else {
-        set value 0.0
-    }
-    set tipx [expr $x + 15]
-    set tipy [expr $y - 5]
-    Rappture::Tooltip::text $c "$title $value"
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Slice move x|y|z <newval>
-#
-# Called automatically when the user drags the slider to move the
-# cut plane that slices 3D data.  Gets the current value from the
-# slider and moves the cut plane to the appropriate point in the
-# data set.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::Slice {option args} {
-    switch -- $option {
-        "move" {
-            set axis [lindex $args 0]
-            set newval [lindex $args 1]
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Slice move x|y|z newval\""
-            }
-            set newpos [expr {0.01*$newval}]
-            SendCmd "cutplane slice $axis $newpos"
-        }
-        "tooltip" {
-            set axis [lindex $args 0]
-            set val [$itk_component(${axis}CutScale) get]
-            return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
-        }
-        default {
-            error "bad option \"$option\": should be axis, move, or tooltip"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendTitleAction post
-# USAGE: LegendTitleAction enter
-# USAGE: LegendTitleAction leave
-# USAGE: LegendTitleAction save
-#
-# Used internally to handle the dropdown list for the fields menu combobox.
-# The post option is invoked when the field title is pressed to launch the
-# dropdown.  The enter option is invoked when the user mouses over the field
-# title. The leave option is invoked when the user moves the mouse away
-# from the field title.  The save option is invoked whenever there is a
-# selection from the list, to alert the visualization server.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkStreamlinesViewer::LegendTitleAction {option} {
-    set c $itk_component(view)
-    switch -- $option {
-        post {
-            foreach { x1 y1 x2 y2 } [$c bbox title] break
-            set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]]
-            set x [expr $x1 + [winfo rootx $itk_component(view)]]
-            set y [expr $y2 + [winfo rooty $itk_component(view)]]
-            tk_popup $itk_component(fieldmenu) $x $y
-        }
-        enter {
-            $c itemconfigure title -fill red
-        }
-        leave {
-            $c itemconfigure title -fill white
-        }
-        save {
-            $itk_component(field) value $_curFldLabel
-            AdjustSetting -field
-        }
-        default {
-            error "bad option \"$option\": should be post, enter, leave or save"
-        }
-    }
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
-
-itcl::body Rappture::VtkStreamlinesViewer::SetCurrentFieldName { dataobj } {
-    set _first $dataobj
-    $itk_component(field) choices delete 0 end
-    $itk_component(fieldmenu) delete 0 end
-    array unset _fields
-    set _curFldName ""
-    set _curFldLabel ""
-    foreach cname [$_first components] {
-        foreach fname [$_first fieldnames $cname] {
-            if { [info exists _fields($fname)] } {
-                continue
-            }
-            foreach { label units components } \
-                [$_first fieldinfo $fname] break
-            $itk_component(field) choices insert end "$fname" "$label"
-            $itk_component(fieldmenu) add radiobutton -label "$label" \
-                -value $label -variable [itcl::scope _curFldLabel] \
-                -selectcolor red \
-                -activebackground $itk_option(-plotbackground) \
-                -activeforeground $itk_option(-plotforeground) \
-                -font "Arial 8" \
-                -command [itcl::code $this LegendTitleAction save]
-            set _fields($fname) [list $label $units $components]
-            if { $_curFldName == "" && $components == 3 } {
-                set _curFldName $fname
-                set _curFldLabel $label
-            }
-        }
-    }
-    $itk_component(field) value $_curFldLabel
-}
Index: trunk/gui/scripts/vtksurfaceviewer.tcl
===================================================================
--- trunk/gui/scripts/vtksurfaceviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,2349 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtksurfaceviewer - Vtk 3D boundary surface viewer
-#
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *VtkSurfaceViewer.width 4i widgetDefault
-option add *VtkSurfaceViewer*cursor crosshair widgetDefault
-option add *VtkSurfaceViewer.height 4i widgetDefault
-option add *VtkSurfaceViewer.foreground black widgetDefault
-option add *VtkSurfaceViewer.controlBackground gray widgetDefault
-option add *VtkSurfaceViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkSurfaceViewer.plotBackground black widgetDefault
-option add *VtkSurfaceViewer.plotForeground white widgetDefault
-option add *VtkSurfaceViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkSurfaceViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkSurfaceViewer::SetServerList
-}
-
-itcl::class Rappture::VtkSurfaceViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildColormap { name }
-    private method BuildDownloadPopup { widget command }
-    private method BuildSurfaceTab {}
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method DrawLegend {}
-    private method EnterLegend { x y }
-    private method EventuallyRequestLegend {}
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method LeaveLegend {}
-    private method LegendTitleAction { option }
-    private method MotionLegend { x y }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { colormap title min max size }
-    private method RequestLegend {}
-    private method Rotate {option x y}
-    private method SetCurrentColormap { color }
-    private method SetCurrentFieldName { dataobj }
-    private method SetLegendTip { x y }
-    private method SetObjectStyle { dataobj comp }
-    private method SetOrientation { side }
-    private method UpdateContourList {}
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _colormaps;        # contains all the colormaps
-                                        # in the server.
-    # The name of the current colormap used.  The colormap is global to all
-    # heightmaps displayed.
-    private variable _currentColormap ""
-    private variable _currentNumContours -1
-
-    private variable _click;            # info used for rotate operations
-    private variable _limits;           # autoscale min/max for all axes
-    private variable _view;             # view params for 3D view
-    private variable _settings
-    private variable _changed
-    private variable _reset 1;          # Connection to server has been reset.
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _title ""
-    private variable _isolines
-    private variable _contourList ""
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _legendPending 0
-    private variable _rotatePending 0
-    private variable _fields
-    private variable _curFldName ""
-    private variable _curFldLabel ""
-    private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkSurfaceViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::constructor {args} {
-    set _serverType "vtkvis"
-    #DebugOn
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _settings {
-        -axesvisible            1
-        -axislabels             1
-        -axisminorticks         1
-        -axismode               "static"
-        -background             black
-        -colormap               BCGYR
-        -colormapvisible        1
-        -field                  "Default"
-        -isolinecolor           white
-        -isolinesvisible        0
-        -legendvisible          1
-        -numcontours            10
-        -outline                0
-        -surfaceedges           0
-        -surfacelighting        1
-        -surfaceopacity         100
-        -surfacevisible         1
-        -surfacewireframe       0
-        -xgrid                  0
-        -ygrid                  0
-        -zgrid                  0
-    }
-    array set _changed {
-        -colormap               0
-        -isolinecolor           0
-        -isolinesvisible        0
-        -numcontours            0
-        -outline                0
-        -surfaceedges           0
-        -surfacelighting        0
-        -surfaceopacity         0
-        -surfacevisible         0
-        -surfacewireframe       0
-    }
-
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    itk_component add fieldmenu {
-        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
-            -tearoff 0
-    } {
-        usual
-        ignore -background -foreground -relief -tearoff
-    }
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add surface {
-        Rappture::PushButton $f.surface \
-            -onimage [Rappture::icon volume-on] \
-            -offimage [Rappture::icon volume-off] \
-            -variable [itcl::scope _settings(-surfacevisible)] \
-            -command [itcl::code $this AdjustSetting -surfacevisible]
-    }
-    $itk_component(surface) select
-    Rappture::Tooltip::for $itk_component(surface) \
-        "Hide the surface"
-    pack $itk_component(surface) -padx 2 -pady 2
-
-    if { [catch {
-        BuildSurfaceTab
-        BuildAxisTab
-        BuildCameraTab
-    } errs] != 0 } {
-        puts stderr errs=$errs
-    }
-
-    # Legend
-    set _image(legend) [image create photo]
-    itk_component add legend {
-        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -plotbackground plotBackground Background
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-
-    EnableWaitDialog 900
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::destructor {} {
-    Disconnect
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkSurfaceViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size $_width $_height"
-
-    EventuallyRequestLegend
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkSurfaceViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkSurfaceViewer::EventuallyRequestLegend {} {
-    if { !$_legendPending } {
-        set _legendPending 1
-        $_dispatcher event -idle !legend
-    }
-}
-
-itcl::body Rappture::VtkSurfaceViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 400 !resize
-    }
-}
-
-itcl::body Rappture::VtkSurfaceViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after 100 !rotate
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::add {dataobj {settings ""}} {
-    if { ![$dataobj isvalid] } {
-        return;                         # Object doesn't contain valid data.
-    }
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::delete {args} {
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::scale { args } {
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                   # Object doesn't contain valid data.
-        }
-        foreach axis { x y z } {
-            set lim [$dataobj limits $axis]
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {amin amax} $_limits($axis) break
-            if { $amin > $min } {
-                set amin $min
-            }
-            if { $amax < $max } {
-                set amax $max
-            }
-            set _limits($axis) [list $amin $amax]
-        }
-        foreach { fname lim } [$dataobj fieldlimits] {
-            if { ![info exists _limits($fname)] } {
-                set _limits($fname) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {fmin fmax} $_limits($fname) break
-            if { $fmin > $min } {
-                set fmin $min
-            }
-            if { $fmax < $max } {
-                set fmax $max
-            }
-            set _limits($fname) [list $fmin $fmax]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::Connect {} {
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtksurfaceviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkSurfaceViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkSurfaceViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkSurfaceViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    $_dispatcher cancel !legend
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    array unset _colormaps
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::ReceiveImage { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        #set time [clock seconds]
-        #set date [clock format $time]
-        #set w [image width $_image(plot)]
-        #set h [image height $_image(plot)]
-        #puts stderr "$date: received image ${w}x${h} image"
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            #puts stderr "round trip time [expr $finish -$_start] milliseconds"
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkSurfaceViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-        # Reset the camera and other view parameters
-        $_arcball quaternion [ViewToQuaternion]
-        if {$_view(-ortho)} {
-            SendCmd "camera mode ortho"
-        } else {
-            SendCmd "camera mode persp"
-        }
-        DoRotate
-        PanCamera
-        set _first ""
-        InitSettings -background \
-            -xgrid -ygrid -zgrid -axismode \
-            -axesvisible -axislabels -axisminorticks
-        #SendCmd "axis lformat all %g"
-        StopBufferingCommands
-        SendCmd "imgflush"
-        StartBufferingCommands
-    }
-    set _first ""
-    SendCmd "dataset visible 0"
-    eval scale $_dlist
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-            SetCurrentFieldName $dataobj
-        }
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { ![info exists _datasets($tag)] } {
-                set bytes [$dataobj vtkdata $comp]
-                if 0 {
-                    set f [open "/tmp/surface.vtk" "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $bytes
-                    close $f
-                }
-                set length [string length $bytes]
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $length
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "dataset add $tag data follows $length"
-                SendData $bytes
-                set _datasets($tag) 1
-                SetObjectStyle $dataobj $comp
-            }
-            if { [info exists _obj2ovride($dataobj-raise)] } {
-                SendCmd "polydata visible 1 $tag"
-            }
-        }
-    }
-
-    InitSettings -isolinesvisible -surfacevisible -outline
-    if { $_reset } {
-        # These are settings that rely on a dataset being loaded.
-        InitSettings \
-            -surfacelighting \
-            -field \
-            -surfaceedges -surfacelighting -surfaceopacity \
-            -surfacewireframe \
-            -numcontours
-
-        Zoom reset
-        foreach axis { x y z } {
-            set label ""
-            if { $_first != "" } {
-                set label [$_first hints ${axis}label]
-            }
-            if { $label == "" } {
-                set label [string toupper $axis]
-            }
-            # There may be a space in the axis label.
-            SendCmd [list axis name $axis $label]
-        }
-        if { [array size _fields] < 2 } {
-            catch {blt::table forget $itk_component(field) $itk_component(field_l)}
-        }
-        set _reset 0
-    }
-    # Redraw the legend even if we're using the same colormap. The position
-    # of the isolines may have changed because the range of data changed.
-    DrawLegend
-
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands;              # Turn off buffering and send commands.
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _datasets($tag)] && $_datasets($tag) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            $_arcball quaternion [ViewToQuaternion]
-            DoRotate
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkSurfaceViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkSurfaceViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::InitSettings { args } {
-    foreach spec $args {
-        AdjustSetting $spec
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkSurfaceViewer::AdjustSetting {what {value ""}} {
-    if { ![isconnected] } {
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            set bool $_settings($what)
-            SendCmd "axis visible all $bool"
-        }
-        "-axislabels" {
-            set bool $_settings($what)
-            SendCmd "axis labels all $bool"
-        }
-        "-axisminorticks" {
-            set bool $_settings($what)
-            SendCmd "axis minticks all $bool"
-        }
-        "-axismode" {
-            set mode [$itk_component(axisMode) value]
-            set mode [$itk_component(axisMode) translate $mode]
-            set _settings($what) $mode
-            SendCmd "axis flymode $mode"
-        }
-        "-background" {
-            set bgcolor [$itk_component(background) value]
-            array set fgcolors {
-                "black" "white"
-                "white" "black"
-                "grey"  "black"
-            }
-            configure -plotbackground $bgcolor \
-                -plotforeground $fgcolors($bgcolor)
-            $itk_component(view) delete "legend"
-            DrawLegend
-        }
-        "-colormap" {
-            set _changed($what) 1
-            StartBufferingCommands
-            set color [$itk_component(colormap) value]
-            set _settings($what) $color
-            if { $color == "none" } {
-                if { $_settings(-colormapvisible) } {
-                    SendCmd "contour2d colormode constant {}"
-                    SendCmd "polydata colormode constant {}"
-                    set _settings(-colormapvisible) 0
-                }
-            } else {
-                if { !$_settings(-colormapvisible) } {
-                    #SendCmd [list contour2d colormode $_colorMode $_curFldName]
-                    SendCmd [list polydata colormode $_colorMode $_curFldName]
-                    set _settings(-colormapvisible) 1
-                }
-                SetCurrentColormap $color
-                if {$_settings(-colormapdiscrete)} {
-                    set numColors [expr $_settings(-numcontours) + 1]
-                    SendCmd "colormap res $numColors $color"
-                }
-            }
-            StopBufferingCommands
-            EventuallyRequestLegend
-        }
-        "-colormapdiscrete" {
-            set bool $_settings($what)
-            set numColors [expr $_settings(-numcontours) + 1]
-            StartBufferingCommands
-            if {$bool} {
-                SendCmd "colormap res $numColors"
-                # Discrete colormap requires preinterp on
-                SendCmd "polydata preinterp on"
-            } else {
-                SendCmd "colormap res default"
-                # FIXME: add setting for preinterp (default on)
-                SendCmd "polydata preinterp on"
-            }
-            StopBufferingCommands
-            EventuallyRequestLegend
-        }
-        "-field" {
-            set label [$itk_component(field) value]
-            set fname [$itk_component(field) translate $label]
-            set _settings($what) $fname
-            if { [info exists _fields($fname)] } {
-                foreach { label units components } $_fields($fname) break
-                if { $components > 1 } {
-                    set _colorMode vmag
-                } else {
-                    set _colorMode scalar
-                }
-                set _curFldName $fname
-                set _curFldLabel $label
-            } else {
-                puts stderr "unknown field \"$fname\""
-                return
-            }
-            SendCmd [list dataset scalar $_curFldName]
-            if { ![info exists _limits($_curFldName)] } {
-                SendCmd "dataset maprange all"
-            } else {
-                foreach { vmin vmax } $_limits($_curFldName) break
-                SendCmd [list dataset maprange explicit $vmin $vmax $_curFldName]
-            }
-            #SendCmd [list contour2d colormode $_colorMode $_curFldName]
-            SendCmd [list polydata colormode $_colorMode $_curFldName]
-            UpdateContourList
-            SendCmd "contour2d contourlist [list $_contourList]"
-            SendCmd "camera reset"
-            DrawLegend
-        }
-        "-isolinecolor" {
-            set _changed($what) 1
-            set color [$itk_component(isolinecolor) value]
-            if { $color == "none" } {
-                if { $_settings(-isolinesvisible) } {
-                    set _changed(-isolinesvisible) 1
-                    foreach tag [CurrentDatasets -visible] {
-                        SendCmd "contour2d visible 0 $tag"
-                    }
-                    set _settings(-isolinesvisible) 0
-                }
-            } else {
-                set _settings($what) $color
-                if { !$_settings(-isolinesvisible) } {
-                    set _changed(-isolinesvisible) 1
-                    foreach tag [CurrentDatasets -visible] {
-                        SendCmd "contour2d visible 1 $tag"
-                    }
-                    set _settings(-isolinesvisible) 1
-                }
-                SendCmd "contour2d linecolor [Color2RGB $color]"
-            }
-            DrawLegend
-        }
-        "-isolinesvisible" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "contour2d visible 0"
-            if { $bool } {
-                if { [$itk_component(isolinecolor) value] != $_settings(-isolinecolor)} {
-                    $itk_component(isolinecolor) value $_settings(-isolinecolor)
-                }
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "contour2d visible $bool $tag"
-                }
-            }
-            DrawLegend
-        }
-        "-legendvisible" {
-            if { !$_settings($what) } {
-                $itk_component(view) delete legend
-            }
-            DrawLegend
-        }
-        "-numcontours" {
-            set _settings($what) [$itk_component(numcontours) value]
-            set _currentNumContours $_settings($what)
-            UpdateContourList
-            set _changed($what) 1
-            SendCmd "contour2d contourlist [list $_contourList]"
-            if {$_settings(-colormapdiscrete)} {
-                set numColors [expr $_settings($what) + 1]
-                SendCmd "colormap res $numColors"
-                EventuallyRequestLegend
-            } else {
-                DrawLegend
-            }
-        }
-        "-outline" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "outline visible 0"
-            if { $bool } {
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "outline visible $bool $tag"
-                }
-            }
-        }
-        "-surfaceedges" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "polydata edges $bool"
-        }
-        "-surfacelighting" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "polydata lighting $bool"
-        }
-        "-surfaceopacity" {
-            set _changed($what) 1
-            set val $_settings($what)
-            set sval [expr { 0.01 * double($val) }]
-            SendCmd "polydata opacity $sval"
-        }
-        "-surfacevisible" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "polydata visible 0"
-            if { $bool } {
-                foreach tag [CurrentDatasets -visible] {
-                    SendCmd "polydata visible $bool $tag"
-                }
-                Rappture::Tooltip::for $itk_component(surface) \
-                    "Hide the surface"
-            } else {
-                Rappture::Tooltip::for $itk_component(surface) \
-                    "Show the surface"
-            }
-            DrawLegend
-        }
-        "-surfacewireframe" {
-            set _changed($what) 1
-            set bool $_settings($what)
-            SendCmd "polydata wireframe $bool"
-        }
-        "-xgrid" - "-ygrid" - "-zgrid" {
-            set axis [string tolower [string range $what 1 1]]
-            set bool $_settings($what)
-            SendCmd "axis grid $axis $bool"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-#
-# RequestLegend --
-#
-# Request a new legend from the server.  The size of the legend
-# is determined from the height of the canvas.
-#
-# This should be called when
-#   1.  A new current colormap is set.
-#   2.  Window is resized.
-#   3.  The limits of the data have changed.  (Just need a redraw).
-#   4.  Number of isolines have changed. (Just need a redraw).
-#   5.  Legend becomes visible (Just need a redraw).
-#
-itcl::body Rappture::VtkSurfaceViewer::RequestLegend {} {
-    set _legendPending 0
-    if { ![info exists _fields($_curFldName)] } {
-        return
-    }
-    set fname $_curFldName
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-    set w 12
-    set h [expr {$_height - 2 * ($lineht + 2)}]
-    if { $h < 1 } {
-        return
-    }
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a title too, subtract one more line
-    if { $title != "" } {
-        incr h -$lineht
-    }
-    # Set the legend on the first dataset.
-    if { $_currentColormap != "" } {
-        set cmap $_currentColormap
-        if { ![info exists _colormaps($cmap)] } {
-            BuildColormap $cmap
-            set _colormaps($cmap) 1
-        }
-        #SendCmd [list legend $cmap scalar $_curFldName {} $w $h 0]
-        SendCmd "legend2 $cmap $w $h"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkSurfaceViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        SendCmd "screen bgcolor $rgb"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkSurfaceViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        SendCmd "axis color all $rgb"
-        SendCmd "outline color $rgb"
-    }
-}
-
-itcl::body Rappture::VtkSurfaceViewer::BuildSurfaceTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Surface Settings" \
-        -icon [Rappture::icon volume-on]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.surface \
-        -text "Surface" \
-        -variable [itcl::scope _settings(-surfacevisible)] \
-        -command [itcl::code $this AdjustSetting -surfacevisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.isolines \
-        -text "Isolines" \
-        -variable [itcl::scope _settings(-isolinesvisible)] \
-        -command [itcl::code $this AdjustSetting -isolinesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.colormapDiscrete \
-        -text "Discrete Colormap" \
-        -variable [itcl::scope _settings(-colormapdiscrete)] \
-        -command [itcl::code $this AdjustSetting -colormapdiscrete] \
-        -font "Arial 9"
-
-    checkbutton $inner.wireframe \
-        -text "Wireframe" \
-        -variable [itcl::scope _settings(-surfacewireframe)] \
-        -command [itcl::code $this AdjustSetting -surfacewireframe] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-surfacelighting)] \
-        -command [itcl::code $this AdjustSetting -surfacelighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.edges \
-        -text "Edges" \
-        -variable [itcl::scope _settings(-surfaceedges)] \
-        -command [itcl::code $this AdjustSetting -surfaceedges] \
-        -font "Arial 9"
-
-    checkbutton $inner.outline \
-        -text "Outline" \
-        -variable [itcl::scope _settings(-outline)] \
-        -command [itcl::code $this AdjustSetting -outline] \
-        -font "Arial 9"
-
-    checkbutton $inner.legend \
-        -text "Legend" \
-        -variable [itcl::scope _settings(-legendvisible)] \
-        -command [itcl::code $this AdjustSetting -legendvisible] \
-        -font "Arial 9"
-
-    label $inner.linecolor_l -text "Isolines" -font "Arial 9"
-    itk_component add isolinecolor {
-        Rappture::Combobox $inner.linecolor -width 10 -editable 0
-    }
-    $inner.linecolor choices insert end \
-        "black"              "black"            \
-        "blue"               "blue"             \
-        "cyan"               "cyan"             \
-        "green"              "green"            \
-        "grey"               "grey"             \
-        "magenta"            "magenta"          \
-        "orange"             "orange"           \
-        "red"                "red"              \
-        "white"              "white"            \
-        "none"               "none"
-
-    $itk_component(isolinecolor) value $_settings(-isolinecolor)
-    bind $inner.linecolor <<Value>> \
-        [itcl::code $this AdjustSetting -isolinecolor]
-
-    label $inner.background_l -text "Background" -font "Arial 9"
-    itk_component add background {
-        Rappture::Combobox $inner.background -width 10 -editable 0
-    }
-    $inner.background choices insert end \
-        "black"              "black"            \
-        "white"              "white"            \
-        "grey"               "grey"
-
-    $itk_component(background) value $_settings(-background)
-    bind $inner.background <<Value>> \
-        [itcl::code $this AdjustSetting -background]
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-surfaceopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -surfaceopacity]
-
-    itk_component add field_l {
-        label $inner.field_l -text "Field" -font "Arial 9"
-    } {
-        ignore -font
-    }
-    itk_component add field {
-        Rappture::Combobox $inner.field -width 10 -editable 0
-    }
-    bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting -field]
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9"
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList]
-
-    $itk_component(colormap) value "BCGYR"
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -colormap]
-
-    label $inner.numcontours_l -text "Number of Isolines" -font "Arial 9"
-    itk_component add numcontours {
-        Rappture::Spinint $inner.numcontours \
-            -min 0 -max 50 -font "arial 9"
-    }
-    $itk_component(numcontours) value $_settings(-numcontours)
-    bind $itk_component(numcontours) <<Value>> \
-        [itcl::code $this AdjustSetting -numcontours]
-
-    blt::table $inner \
-        0,0 $inner.field_l      -anchor w -pady 2 \
-        0,1 $inner.field        -anchor w -pady 2 -fill x \
-        1,0 $inner.colormap_l   -anchor w -pady 2 \
-        1,1 $inner.colormap     -anchor w -pady 2 -fill x \
-        2,0 $inner.linecolor_l  -anchor w -pady 2 \
-        2,1 $inner.linecolor    -anchor w -pady 2 -fill x \
-        3,0 $inner.background_l -anchor w -pady 2 \
-        3,1 $inner.background   -anchor w -pady 2 -fill x \
-        4,0 $inner.numcontours_l -anchor w -pady 2 \
-        4,1 $inner.numcontours  -anchor w -pady 2 \
-        5,0 $inner.colormapDiscrete -anchor w -pady 2 -cspan 2 \
-        6,0 $inner.isolines     -anchor w -pady 2 -cspan 2 \
-        7,0 $inner.wireframe    -anchor w -pady 2 -cspan 2 \
-        8,0 $inner.lighting     -anchor w -pady 2 -cspan 2 \
-        9,0 $inner.edges        -anchor w -pady 2 -cspan 2 \
-        10,0 $inner.outline     -anchor w -pady 2 -cspan 2 \
-        11,0 $inner.legend      -anchor w -pady 2 \
-        12,0 $inner.opacity_l   -anchor w -pady 2 \
-        12,1 $inner.opacity     -fill x   -pady 2 -fill x \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r13 c1 -resize expand
-}
-
-itcl::body Rappture::VtkSurfaceViewer::BuildAxisTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font "Arial 9"
-
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _settings(-axislabels)] \
-        -command [itcl::code $this AdjustSetting -axislabels] \
-        -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9"
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _settings(-xgrid)] \
-        -command [itcl::code $this AdjustSetting -xgrid] \
-        -font "Arial 9"
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _settings(-ygrid)] \
-        -command [itcl::code $this AdjustSetting -ygrid] \
-        -font "Arial 9"
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _settings(-zgrid)] \
-        -command [itcl::code $this AdjustSetting -zgrid] \
-        -font "Arial 9"
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _settings(-axisminorticks)] \
-        -command [itcl::code $this AdjustSetting -axisminorticks] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-
-    itk_component add axisMode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axisMode) value $_settings(-axismode)
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
-
-    blt::table $inner \
-        0,0 $inner.visible    -anchor w -cspan 4 \
-        1,0 $inner.labels     -anchor w -cspan 4 \
-        2,0 $inner.minorticks -anchor w -cspan 4 \
-        4,0 $inner.grid_l     -anchor w \
-        4,1 $inner.xgrid      -anchor w \
-        4,2 $inner.ygrid      -anchor w \
-        4,3 $inner.zgrid      -anchor w \
-        5,0 $inner.mode_l     -anchor w -padx { 2 0 } \
-        5,1 $inner.mode       -fill x   -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-itcl::body Rappture::VtkSurfaceViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set labels { qx qy qz qw xpan ypan zoom }
-    set row 1
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this camera set -ortho] \
-        -font "Arial 9"
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkSurfaceViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkSurfaceViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        foreach cname [$dataobj components] {
-            set tag $dataobj-$cname
-            set contents [$dataobj vtkdata $cname]
-            append bytes "$contents\n"
-        }
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkSurfaceViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkSurfaceViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::VtkSurfaceViewer::SetObjectStyle { dataobj comp } {
-    # Parse style string.
-    set tag $dataobj-$comp
-    array set style {
-        -color           BCGYR
-        -constcolor      white
-        -edgecolor       black
-        -edges           0
-        -isolinecolor    white
-        -isolinesvisible 0
-        -levels          10
-        -lighting        1
-        -linewidth       1.0
-        -opacity         1.0
-        -outline         0
-        -ptsize          1.0
-        -surfacevisible  1
-        -wireframe       0
-    }
-    set style(-constcolor) $itk_option(-plotforeground)
-    array set style [$dataobj style $comp]
-
-    # This is too complicated.  We want to set the colormap, number of
-    # isolines and opacity for the dataset.  They can be the default values,
-    # the style hints loaded with the dataset, or set by user controls.  As
-    # datasets get loaded, they first use the defaults that are overidden
-    # by the style hints.  If the user changes the global controls, then that
-    # overrides everything else.  I don't know what it means when global
-    # controls are specified as style hints by each dataset.  It complicates
-    # the code to handle aberrant cases.
-
-    if { $_changed(-surfaceedges) } {
-        set style(-edges) $_settings(-surfaceedges)
-    }
-    if { $_changed(-surfacelighting) } {
-        set style(-lighting) $_settings(-surfacelighting)
-    }
-    if { $_changed(-surfaceopacity) } {
-        set style(-opacity) [expr $_settings(-surfaceopacity) * 0.01]
-    }
-    if { $_changed(-surfacewireframe) } {
-        set style(-wireframe) $_settings(-surfacewireframe)
-    }
-    if { $_changed(-numcontours) } {
-        set style(-levels) $_settings(-numcontours)
-    }
-    if { $_changed(-colormap) } {
-        set style(-color) $_settings(-colormap)
-    }
-    if { $_currentColormap == "" } {
-        SetCurrentColormap $style(-color)
-        $itk_component(colormap) value $style(-color)
-    }
-    if { $_currentNumContours != $style(-levels) } {
-        set _currentNumContours $style(-levels)
-        set _settings(-numcontours) $_currentNumContours
-        $itk_component(numcontours) value $_currentNumContours
-        UpdateContourList
-        DrawLegend
-    }
-    foreach setting {-outline -isolinesvisible -surfacevisible -isolinecolor} {
-        if {$_changed($setting)} {
-            # User-modified UI setting overrides style
-            set style($setting) $_settings($setting)
-        } else {
-            # Set UI control to style setting (tool provided or default)
-            set _settings($setting) $style($setting)
-        }
-    }
-
-    SendCmd "outline add $tag"
-    SendCmd "outline color [Color2RGB $style(-constcolor)] $tag"
-    SendCmd "outline visible $style(-outline) $tag"
-
-    SendCmd "polydata add $tag"
-    if { $_curFldName != "" } {
-        SendCmd [list polydata colormode $_colorMode $_curFldName $tag]
-    }
-    SendCmd "polydata edges $style(-edges) $tag"
-    set _settings(-surfaceedges) $style(-edges)
-    SendCmd "polydata color [Color2RGB $style(-constcolor)] $tag"
-    SendCmd "polydata lighting $style(-lighting) $tag"
-    set _settings(-surfacelighting) $style(-lighting)
-    SendCmd "polydata linecolor [Color2RGB $style(-edgecolor)] $tag"
-    SendCmd "polydata linewidth $style(-linewidth) $tag"
-    SendCmd "polydata ptsize $style(-ptsize) $tag"
-    SendCmd "polydata opacity $style(-opacity) $tag"
-    set _settings(-surfaceopacity) [expr $style(-opacity) * 100.0]
-    SetCurrentColormap $style(-color)
-    SendCmd "polydata wireframe $style(-wireframe) $tag"
-    set _settings(-surfacewireframe) $style(-wireframe)
-
-    SendCmd [list contour2d add contourlist $_contourList $tag]
-    SendCmd "contour2d colormode constant {} $tag"
-    SendCmd "contour2d color [Color2RGB $style(-isolinecolor)] $tag"
-}
-
-itcl::body Rappture::VtkSurfaceViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-#
-# EnterLegend --
-#
-itcl::body Rappture::VtkSurfaceViewer::EnterLegend { x y } {
-    SetLegendTip $x $y
-}
-
-#
-# MotionLegend --
-#
-itcl::body Rappture::VtkSurfaceViewer::MotionLegend { x y } {
-    Rappture::Tooltip::tooltip cancel
-    set c $itk_component(view)
-    set cw [winfo width $c]
-    set ch [winfo height $c]
-    if { $x >= 0 && $x < $cw && $y >= 0 && $y < $ch } {
-        SetLegendTip $x $y
-    }
-}
-
-#
-# LeaveLegend --
-#
-itcl::body Rappture::VtkSurfaceViewer::LeaveLegend { } {
-    Rappture::Tooltip::tooltip cancel
-    .rappturetooltip configure -icon ""
-}
-
-#
-# SetLegendTip --
-#
-itcl::body Rappture::VtkSurfaceViewer::SetLegendTip { x y } {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set ih [image height $_image(legend)]
-    set iy [expr $y - ($lineht + 2)]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    # If there's a legend title, increase the offset by the line height.
-    if { $title != "" } {
-        incr iy -$lineht
-    }
-    # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
-        return
-    }
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    set color [eval format "\#%02x%02x%02x" $pixel]
-    $_image(swatch) put black  -to 0 0 23 23
-    $_image(swatch) put $color -to 1 1 22 22
-    .rappturetooltip configure -icon $_image(swatch)
-
-    # Compute the value of the point
-    if { [info exists _limits($_curFldName)] } {
-        foreach { vmin vmax } $_limits($_curFldName) break
-        set t [expr 1.0 - (double($iy) / double($ih-1))]
-        set value [expr $t * ($vmax - $vmin) + $vmin]
-    } else {
-        set value 0.0
-    }
-    set tx [expr $x + 15]
-    set ty [expr $y - 5]
-    if { [info exists _isolines($y)] } {
-        Rappture::Tooltip::text $c [format "$title %g (isoline)" $_isolines($y)]
-    } else {
-        Rappture::Tooltip::text $c [format "$title %g" $value]
-    }
-    Rappture::Tooltip::tooltip show $c +$tx,+$ty
-}
-
-#
-# ReceiveLegend --
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-#
-itcl::body Rappture::VtkSurfaceViewer::ReceiveLegend { colormap title min max size } {
-    DebugTrace "Enter"
-    set _title $title
-    regsub {\(mag\)} $title "" _title
-    if { [IsConnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend)] } {
-            set _image(legend) [image create photo]
-        }
-        $_image(legend) configure -data $bytes
-        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-        if { [catch {DrawLegend} errs] != 0 } {
-            global errorInfo
-            puts stderr "errs=$errs errorInfo=$errorInfo"
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-# Draws the legend on the canvas on the right side of the plot area.
-#
-itcl::body Rappture::VtkSurfaceViewer::DrawLegend {} {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    if { [string match "component*" $fname] } {
-        set title ""
-    } else {
-        if { [info exists _fields($fname)] } {
-            foreach { title units } $_fields($fname) break
-            if { $units != "" } {
-                set title [format "%s (%s)" $title $units]
-            }
-        } else {
-            set title $fname
-        }
-    }
-    set x [expr $w - 2]
-    if { !$_settings(-legendvisible) } {
-        $c delete legend
-        return
-    }
-    if { [$c find withtag "legend"] == "" } {
-        set y 2
-        # If there's a legend title, create a text item for the title.
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "title legend" \
-            -font $font
-        if { $title != "" } {
-            incr y $lineht
-        }
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "vmax legend" \
-            -font $font
-        incr y $lineht
-        $c create image $x $y \
-            -anchor ne \
-            -image $_image(legend) -tags "colormap legend"
-        $c create rectangle $x $y 1 1 \
-            -fill "" -outline "" -tags "sensor legend"
-        $c create text $x [expr {$h-2}] \
-            -anchor se \
-            -fill $itk_option(-plotforeground) -tags "vmin legend" \
-            -font $font
-        $c bind sensor <Enter> [itcl::code $this EnterLegend %x %y]
-        $c bind sensor <Leave> [itcl::code $this LeaveLegend]
-        $c bind sensor <Motion> [itcl::code $this MotionLegend %x %y]
-    }
-    $c delete isoline
-    set x2 $x
-    set iw [image width $_image(legend)]
-    set ih [image height $_image(legend)]
-    set x1 [expr $x2 - ($iw*12)/10]
-    set color $_settings(-isolinecolor)
-    # Draw the isolines on the legend.
-    array unset _isolines
-    if { $color != "none"  && [info exists _limits($_curFldName)] &&
-         $_settings(-isolinesvisible) && $_settings(-numcontours) > 0 } {
-
-        foreach { vmin vmax } $_limits($_curFldName) break
-        set range [expr double($vmax - $vmin)]
-        if { $range <= 0.0 } {
-            set range 1.0;              # Min is greater or equal to max.
-        }
-        set tags "isoline legend"
-        set offset [expr 2 + $lineht]
-        if { $title != "" } {
-            incr offset $lineht
-        }
-        foreach value $_contourList {
-            set norm [expr 1.0 - (($value - $vmin) / $range)]
-            set y1 [expr int(round(($norm * $ih) + $offset))]
-            for { set off 0 } { $off < 3 } { incr off } {
-                set _isolines([expr $y1 + $off]) $value
-                set _isolines([expr $y1 - $off]) $value
-            }
-            $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
-        }
-    }
-
-    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
-    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
-    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
-    # Reset the item coordinates according the current size of the plot.
-    $c itemconfigure title -text $title
-    if { [info exists _limits($_curFldName)] } {
-        foreach { vmin vmax } $_limits($_curFldName) break
-        $c itemconfigure vmin -text [format %g $vmin]
-        $c itemconfigure vmax -text [format %g $vmax]
-    }
-    set y 2
-    # If there's a legend title, move the title to the correct position
-    if { $title != "" } {
-        $c itemconfigure title -text $title
-        $c coords title $x $y
-        incr y $lineht
-        $c raise title
-    }
-    $c coords vmax $x $y
-    incr y $lineht
-    $c coords colormap $x $y
-    $c coords sensor [expr $x - $iw] $y $x [expr $y + $ih]
-    $c raise sensor
-    $c coords vmin $x [expr {$h - 2}]
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendTitleAction post
-# USAGE: LegendTitleAction enter
-# USAGE: LegendTitleAction leave
-# USAGE: LegendTitleAction save
-#
-# Used internally to handle the dropdown list for the fields menu combobox.
-# The post option is invoked when the field title is pressed to launch the
-# dropdown.  The enter option is invoked when the user mouses over the field
-# title. The leave option is invoked when the user moves the mouse away
-# from the field title.  The save option is invoked whenever there is a
-# selection from the list, to alert the visualization server.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkSurfaceViewer::LegendTitleAction {option} {
-    set c $itk_component(view)
-    switch -- $option {
-        post {
-            foreach { x1 y1 x2 y2 } [$c bbox title] break
-            set cw [winfo width $itk_component(view)]
-            set mw [winfo reqwidth $itk_component(fieldmenu)]
-            set x1 [expr $cw - $mw]
-            set x [expr $x1 + [winfo rootx $itk_component(view)]]
-            set y [expr $y2 + [winfo rooty $itk_component(view)]]
-            tk_popup $itk_component(fieldmenu) $x $y
-        }
-        enter {
-            $c itemconfigure title -fill red
-        }
-        leave {
-            $c itemconfigure title -fill $itk_option(-plotforeground)
-        }
-        save {
-            $itk_component(field) value $_curFldLabel
-            AdjustSetting -field
-        }
-        default {
-            error "bad option \"$option\": should be post, enter, leave or save"
-        }
-    }
-}
-
-#
-# SetCurrentColormap --
-#
-itcl::body Rappture::VtkSurfaceViewer::SetCurrentColormap { name } {
-    # Keep track of the colormaps that we build.
-    if { $name != "none" && ![info exists _colormaps($name)] } {
-        BuildColormap $name
-        set _colormaps($name) 1
-    }
-    set _currentColormap $name
-    SendCmd "contour2d colormap $_currentColormap"
-    SendCmd "polydata colormap $_currentColormap"
-}
-
-#
-# BuildColormap --
-#
-# Build the designated colormap on the server.
-#
-itcl::body Rappture::VtkSurfaceViewer::BuildColormap { name } {
-    set cmap [ColorsToColormap $name]
-    if { [llength $cmap] == 0 } {
-        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
-    }
-    set amap "0.0 1.0 1.0 1.0"
-    SendCmd "colormap add $name { $cmap } { $amap }"
-}
-
-itcl::body Rappture::VtkSurfaceViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
-
-itcl::body Rappture::VtkSurfaceViewer::UpdateContourList {} {
-    if { ![info exists _limits($_curFldName)] } {
-        return
-    }
-    if { $_currentNumContours < 1 } {
-        set _contourList ""
-        return
-    }
-    foreach { vmin vmax } $_limits($_curFldName) break
-    set v [blt::vector create \#auto]
-    $v seq $vmin $vmax [expr $_currentNumContours+2]
-    $v delete end 0
-    set _contourList [$v range 0 end]
-    blt::vector destroy $v
-}
-
-itcl::body Rappture::VtkSurfaceViewer::SetCurrentFieldName { dataobj } {
-    set _first $dataobj
-    $itk_component(field) choices delete 0 end
-    $itk_component(fieldmenu) delete 0 end
-    array unset _fields
-    set _curFldName ""
-    foreach cname [$_first components] {
-        foreach fname [$_first fieldnames $cname] {
-            if { [info exists _fields($fname)] } {
-                continue
-            }
-            foreach { label units components } \
-                [$_first fieldinfo $fname] break
-            $itk_component(field) choices insert end "$fname" "$label"
-            $itk_component(fieldmenu) add radiobutton -label "$label" \
-                -value $label -variable [itcl::scope _curFldLabel] \
-                -selectcolor red \
-                -activebackground $itk_option(-plotbackground) \
-                -activeforeground $itk_option(-plotforeground) \
-                -font "Arial 8" \
-                -command [itcl::code $this LegendTitleAction save]
-            set _fields($fname) [list $label $units $components]
-            if { $_curFldName == "" } {
-                set _curFldName $fname
-                set _curFldLabel $label
-            }
-        }
-    }
-    $itk_component(field) value $_curFldLabel
-}
Index: trunk/gui/scripts/vtkviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,3096 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtkviewer - Vtk drawing object viewer
-#
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *VtkViewer.width 4i widgetDefault
-option add *VtkViewer*cursor crosshair widgetDefault
-option add *VtkViewer.height 4i widgetDefault
-option add *VtkViewer.foreground black widgetDefault
-option add *VtkViewer.controlBackground gray widgetDefault
-option add *VtkViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkViewer.plotBackground black widgetDefault
-option add *VtkViewer.plotForeground white widgetDefault
-option add *VtkViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkViewer::SetServerList
-}
-
-itcl::class Rappture::VtkViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method limits { dataobj }
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildColormap { name }
-    private method BuildCutawayTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildGlyphsTab {}
-    private method BuildMoleculeTab {}
-    private method BuildPolydataTab {}
-    private method ChangeColormap { dataobj comp color }
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method DrawLegend {}
-    private method EnterLegend { x y }
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method EventuallySetAtomScale { args }
-    private method EventuallySetBondScale { args }
-    private method EventuallySetGlyphsOpacity { args }
-    private method EventuallySetMoleculeOpacity { args }
-    private method EventuallySetMoleculeQuality { args }
-    private method EventuallySetPolydataOpacity { args }
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method LeaveLegend {}
-    private method MotionLegend { x y }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { colormap title min max size }
-    private method RequestLegend {}
-    private method Rotate {option x y}
-    private method SetAtomScale {}
-    private method SetBondScale {}
-    private method SetColormap { dataobj comp }
-    private method SetGlyphsOpacity {}
-    private method SetLegendTip { x y }
-    private method SetMoleculeOpacity {}
-    private method SetMoleculeQuality {}
-    private method SetObjectStyle { dataobj comp }
-    private method SetOpacity { dataset }
-    private method SetOrientation { side }
-    private method SetPolydataOpacity {}
-    private method Slice {option args}
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _colormaps;        # contains all the colormaps
-                                        # in the server.
-    private variable _dataset2style;    # maps dataobj-component to transfunc
-    private variable _click;            # info used for rotate operations
-    private variable _limits;           # autoscale min/max for all axes
-    private variable _fieldlimits;      # maps dataobj-comp to field limits
-    private variable _fieldComponents;  # maps dataobj-comp-fname to number of
-                                        # components
-    private variable _view;             # view params for 3D view
-    private variable _settings
-    private variable _style;            # Array of current component styles.
-    private variable _initialStyle;     # Array of initial component styles.
-    private variable _axis
-    private variable _reset 1;          # Connection to server has been reset.
-    private variable _haveGlyphs 0
-    private variable _haveMolecules 0
-    private variable _havePolydata 0
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _start 0
-    private variable _title ""
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _rotatePending 0
-    private variable _atomScalePending 0
-    private variable _bondScalePending 0
-    private variable _moleculeOpacityPending 0
-    private variable _moleculeQualityPending 0
-    private variable _polydataOpacityPending 0
-    private variable _glyphsOpacityPending 0
-    private variable _rotateDelay 150
-    private variable _scaleDelay 100
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::constructor {args} {
-    package require vtk
-    set _serverType "vtkvis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    # Atom scale event
-    $_dispatcher register !atomscale
-    $_dispatcher dispatch $this !atomscale \
-        "[itcl::code $this SetAtomScale]; list"
-
-    # Bond scale event
-    $_dispatcher register !bondscale
-    $_dispatcher dispatch $this !bondscale \
-        "[itcl::code $this SetBondScale]; list"
-
-    # Molecule opacity event
-    $_dispatcher register !moleculeOpacity
-    $_dispatcher dispatch $this !moleculeOpacity \
-        "[itcl::code $this SetMoleculeOpacity]; list"
-
-    # Molecule quality event
-    $_dispatcher register !moleculeQuality
-    $_dispatcher dispatch $this !moleculeQuality \
-        "[itcl::code $this SetMoleculeQuality]; list"
-
-    # Polydata opacity event
-    $_dispatcher register !polydataOpacity
-    $_dispatcher dispatch $this !polydataOpacity \
-        "[itcl::code $this SetPolydataOpacity]; list"
-
-    # Glyphs opacity event
-    $_dispatcher register !glyphsOpacity
-    $_dispatcher dispatch $this !glyphsOpacity \
-        "[itcl::code $this SetGlyphsOpacity]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _axis [subst {
-        labels          1
-        minorticks      1
-        visible         1
-        xgrid           0
-        ygrid           0
-        zgrid           0
-        xcutaway        0
-        ycutaway        0
-        zcutaway        0
-        xposition       0
-        yposition       0
-        zposition       0
-        xdirection      -1
-        ydirection      -1
-        zdirection      -1
-    }]
-    array set _settings [subst {
-        glyphs-colormap            BCGYR
-        glyphs-edges               0
-        glyphs-lighting            1
-        glyphs-opacity             100
-        glyphs-outline             0
-        glyphs-visible             1
-        glyphs-wireframe           0
-        legend                     1
-        molecule-atoms-visible     1
-        molecule-atomscale         0.3
-        molecule-bonds-visible     1
-        molecule-bondscale         0.075
-        molecule-bondstyle         "cylinder"
-        molecule-colorfield        "element"
-        molecule-colormap          elementDefault
-        molecule-colormode         "by_elements"
-        molecule-edges             0
-        molecule-labels            0
-        molecule-lighting          1
-        molecule-opacity           100
-        molecule-outline           0
-        molecule-quality           1.0
-        molecule-representation    "Ball and Stick"
-        molecule-rscale            "covalent"
-        molecule-visible           1
-        molecule-wireframe         0
-        polydata-colormap          BCGYR
-        polydata-edges             0
-        polydata-lighting          1
-        polydata-opacity           100
-        polydata-outline           0
-        polydata-visible           1
-        polydata-wireframe         0
-    }]
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fix the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    if { [catch {
-        BuildAxisTab
-        #BuildCutawayTab
-        BuildCameraTab
-    } errs] != 0 } {
-        puts stderr errs=$errs
-    }
-
-    # Legend
-    set _image(legend) [image create photo]
-    itk_component add legend {
-        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -plotbackground plotBackground Background
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::destructor {} {
-    Disconnect
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size $_width $_height"
-
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 200 !resize
-    }
-}
-
-itcl::body Rappture::VtkViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after $_rotateDelay !rotate
-    }
-}
-
-itcl::body Rappture::VtkViewer::SetAtomScale {} {
-    SendCmd "molecule ascale $_settings(molecule-atomscale)"
-    set _atomScalePending 0
-}
-
-itcl::body Rappture::VtkViewer::SetBondScale {} {
-    SendCmd "molecule bscale $_settings(molecule-bondscale)"
-    set _bondScalePending 0
-}
-
-itcl::body Rappture::VtkViewer::SetMoleculeOpacity {} {
-    set _moleculeOpacityPending 0
-    foreach dataset [CurrentDatasets -visible $_first] {
-        foreach { dataobj comp } [split $dataset -] break
-        if { [$dataobj type $comp] == "molecule" } {
-            SetOpacity $dataset
-        }
-    }
-}
-
-itcl::body Rappture::VtkViewer::SetMoleculeQuality {} {
-    SendCmd [subst {molecule aquality $_settings(molecule-quality)
-molecule bquality $_settings(molecule-quality)}]
-    set _moleculeQualityPending 0
-}
-
-itcl::body Rappture::VtkViewer::SetGlyphsOpacity {} {
-    set _glyphsOpacityPending 0
-    foreach dataset [CurrentDatasets -visible $_first] {
-        foreach { dataobj comp } [split $dataset -] break
-        if { [$dataobj type $comp] == "glyphs" } {
-            SetOpacity $dataset
-        }
-    }
-}
-
-itcl::body Rappture::VtkViewer::SetPolydataOpacity {} {
-    set _polydataOpacityPending 0
-    foreach dataset [CurrentDatasets -visible $_first] {
-        foreach { dataobj comp } [split $dataset -] break
-        if { [$dataobj type $comp] == "polydata" } {
-            SetOpacity $dataset
-        }
-    }
-}
-
-itcl::body Rappture::VtkViewer::EventuallySetAtomScale { args } {
-    if { !$_atomScalePending } {
-        set _atomScalePending 1
-        $_dispatcher event -after $_scaleDelay !atomscale
-    }
-}
-
-itcl::body Rappture::VtkViewer::EventuallySetBondScale { args } {
-    if { !$_bondScalePending } {
-        set _bondScalePending 1
-        $_dispatcher event -after $_scaleDelay !bondscale
-    }
-}
-
-itcl::body Rappture::VtkViewer::EventuallySetMoleculeOpacity { args } {
-    if { !$_moleculeOpacityPending } {
-        set _moleculeOpacityPending 1
-        $_dispatcher event -after $_scaleDelay !moleculeOpacity
-    }
-}
-
-itcl::body Rappture::VtkViewer::EventuallySetMoleculeQuality { args } {
-    if { !$_moleculeQualityPending } {
-        set _moleculeQualityPending 1
-        $_dispatcher event -after $_scaleDelay !moleculeQuality
-    }
-}
-
-itcl::body Rappture::VtkViewer::EventuallySetPolydataOpacity { args } {
-    if { !$_polydataOpacityPending } {
-        set _polydataOpacityPending 1
-        $_dispatcher event -after $_scaleDelay !polydataOpacity
-    }
-}
-
-itcl::body Rappture::VtkViewer::EventuallySetGlyphsOpacity { args } {
-    if { !$_glyphsOpacityPending } {
-        set _glyphsOpacityPending 1
-        $_dispatcher event -after $_scaleDelay !glyphsOpacity
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::add {dataobj {settings ""}} {
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::delete {args} {
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::scale {args} {
-    foreach dataobj $args {
-        foreach comp [$dataobj components] {
-            set type [$dataobj type $comp]
-            switch -- $type {
-                "polydata" {
-                    set _havePolydata 1
-                }
-                "glyphs" {
-                    set _haveGlyphs 1
-                }
-                "molecule" {
-                    set _haveMolecules 1
-                }
-            }
-        }
-        array set bounds [limits $dataobj]
-        if {[info exists bounds(xmin)] && (![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin))} {
-            set _limits(xmin) $bounds(xmin)
-        }
-        if {[info exists bounds(xmax)] && (![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax))} {
-            set _limits(xmax) $bounds(xmax)
-        }
-
-        if {[info exists bounds(ymin)] && (![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin))} {
-            set _limits(ymin) $bounds(ymin)
-        }
-        if {[info exists bounds(ymax)] && (![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax))} {
-            set _limits(ymax) $bounds(ymax)
-        }
-
-        if {[info exists bounds(zmin)] && (![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin))} {
-            set _limits(zmin) $bounds(zmin)
-        }
-        if {[info exists bounds(zmax)] && (![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax))} {
-            set _limits(zmax) $bounds(zmax)
-        }
-    }
-    if { $_haveGlyphs } {
-        if { ![$itk_component(main) exists "Glyph Settings"] } {
-            if { [catch { BuildGlyphsTab } errs ]  != 0 } {
-                global errorInfo
-                puts stderr "errs=$errs\nerrorInfo=$errorInfo"
-            }
-        }
-    }
-    if { $_havePolydata } {
-        if { ![$itk_component(main) exists "Mesh Settings"] } {
-            if { [catch { BuildPolydataTab } errs ]  != 0 } {
-                global errorInfo
-                puts stderr "errs=$errs\nerrorInfo=$errorInfo"
-            }
-        }
-    }
-    if { $_haveMolecules } {
-        if { ![$itk_component(main) exists "Molecule Settings"]} {
-            if { [catch { BuildMoleculeTab } errs ]  != 0 } {
-                global errorInfo
-                puts stderr "errs=$errs\nerrorInfo=$errorInfo"
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::Connect {} {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtkviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    array unset _colormaps
-    array unset _dataset2style
-
-    global readyForNextFrame
-    set readyForNextFrame 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::ReceiveImage { args } {
-    global readyForNextFrame
-    set readyForNextFrame 1
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        set time [clock seconds]
-        set date [clock format $time]
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-        InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
-            axis-visible axis-labels axis-minorticks
-
-        StopBufferingCommands
-        SendCmd "imgflush"
-        StartBufferingCommands
-    }
-
-    set _first ""
-    SendCmd "dataset visible 0"
-    set count 0
-    eval scale $_dlist
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-        }
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { ![info exists _datasets($tag)] } {
-                set bytes [$dataobj data $comp]
-                if { $bytes == "" } {
-                    continue
-                }
-                if 0 {
-                    set f [open /tmp/vtkviewer.vtk "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $bytes
-                    close $f
-                }
-                set length [string length $bytes]
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $length
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "dataset add $tag data follows $length"
-                SendData $bytes
-                set _datasets($tag) 1
-                SetObjectStyle $dataobj $comp
-            }
-            set type [$dataobj type $comp]
-            if { [info exists _obj2ovride($dataobj-raise)] } {
-                SendCmd "$type visible 1 $tag"
-                SetOpacity $tag
-            }
-        }
-    }
-    if {"" != $_first} {
-        foreach axis { x y z } {
-            set label [$_first hints ${axis}label]
-            if { $label != "" } {
-                SendCmd [list axis name $axis $label]
-            }
-            set units [$_first hints ${axis}units]
-            if { $units != "" } {
-                SendCmd [list axis units $axis $units]
-            }
-        }
-    }
-    if { $_haveGlyphs } {
-        InitSettings glyphs-outline
-    }
-    if { $_haveMolecules } {
-        InitSettings molecule-outline
-    }
-    if { $_havePolydata } {
-        InitSettings polydata-outline
-    }
-    if { $_reset } {
-        if { $_haveGlyphs } {
-            InitSettings glyphs-edges glyphs-lighting glyphs-opacity \
-                glyphs-visible glyphs-wireframe
-        }
-        if { $_havePolydata } {
-            InitSettings polydata-edges polydata-lighting polydata-opacity \
-                polydata-visible polydata-wireframe
-        }
-        if { $_haveMolecules } {
-            InitSettings molecule-edges molecule-lighting molecule-opacity \
-                molecule-visible molecule-wireframe molecule-labels
-        }
-
-        $_arcball quaternion [ViewToQuaternion]
-        SendCmd "camera reset"
-        if { $_view(-ortho)} {
-            SendCmd "camera mode ortho"
-        } else {
-            SendCmd "camera mode persp"
-        }
-        DoRotate
-        PanCamera
-        Zoom reset
-    }
-
-    if { $_haveMolecules } {
-        #InitSettings molecule-representation
-    }
-    set _reset 0
-    global readyForNextFrame
-    set readyForNextFrame 0;            # Don't advance to the next frame
-                                        # until we get an image.
-
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _datasets($tag)] && $_datasets($tag) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            $_arcball quaternion [ViewToQuaternion]
-            DoRotate
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::InitSettings { args } {
-    foreach setting $args {
-        AdjustSetting $setting
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkViewer::AdjustSetting {what {value ""}} {
-    if { ![isconnected] } {
-        return
-    }
-    switch -- $what {
-        "glyphs-opacity" {
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                if { [$dataobj type $comp] == "glyphs" } {
-                    SetOpacity $dataset
-                }
-            }
-        }
-        "glyphs-outline" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "glyphs" } {
-                    SendCmd "outline visible $bool $dataset"
-                }
-            }
-        }
-        "glyphs-wireframe" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "glyphs" } {
-                    SendCmd "$type wireframe $bool $dataset"
-                }
-            }
-        }
-        "glyphs-visible" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "glyphs" } {
-                    SendCmd "$type visible $bool $dataset"
-                }
-            }
-        }
-        "glyphs-lighting" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "glyphs" } {
-                    SendCmd "$type lighting $bool $dataset"
-                }
-            }
-        }
-        "glyphs-edges" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "glyphs" } {
-                    SendCmd "$type edges $bool $dataset"
-                }
-            }
-        }
-        "glyphs-colormap" {
-            set colormap [$itk_component(glyphscolormap) value]
-            set colormap [$itk_component(glyphscolormap) translate $colormap]
-            set _settings($what) $colormap
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach {dataobj comp} [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "glyphs" } {
-                    ChangeColormap $dataobj $comp $colormap
-                    # FIXME: fill in current selected fieldname
-                    #SendCmd "glyphs colormode scalar {} $dataset"
-                }
-            }
-            set _legendPending 1
-        }
-        "polydata-opacity" {
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                if { [$dataobj type $comp] == "polydata" } {
-                    SetOpacity $dataset
-                }
-            }
-        }
-        "polydata-outline" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "polydata" } {
-                    SendCmd "outline visible $bool $dataset"
-                }
-            }
-        }
-        "polydata-wireframe" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "polydata" } {
-                    SendCmd "$type wireframe $bool $dataset"
-                }
-            }
-        }
-        "polydata-visible" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "polydata" } {
-                    SendCmd "$type visible $bool $dataset"
-                }
-            }
-        }
-        "polydata-lighting" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "polydata" } {
-                    SendCmd "$type lighting $bool $dataset"
-                }
-            }
-        }
-        "polydata-edges" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "polydata" } {
-                    SendCmd "$type edges $bool $dataset"
-                }
-            }
-        }
-        "polydata-colormap" {
-            set colormap [$itk_component(polydatacolormap) value]
-            set colormap [$itk_component(polydatacolormap) translate $colormap]
-            set _settings($what) $colormap
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach {dataobj comp} [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "polydata" } {
-                    ChangeColormap $dataobj $comp $colormap
-                    # FIXME: fill in current selected fieldname
-                    #SendCmd "polydata colormode scalar {} $dataset"
-                }
-            }
-            set _legendPending 1
-        }
-        "molecule-opacity" {
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                if { [$dataobj type $comp] == "molecule" } {
-                    SetOpacity $dataset
-                }
-            }
-        }
-        "molecule-outline" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "molecule" } {
-                    SendCmd "outline visible $bool $dataset"
-                }
-            }
-        }
-        "molecule-wireframe" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "molecule" } {
-                    SendCmd "molecule wireframe $bool $dataset"
-                }
-            }
-        }
-        "molecule-visible" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "molecule" } {
-                    SendCmd "molecule visible $bool $dataset"
-                }
-            }
-        }
-        "molecule-lighting" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "molecule" } {
-                    SendCmd "molecule lighting $bool $dataset"
-                }
-            }
-        }
-        "molecule-edges" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach { dataobj comp } [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "molecule" } {
-                    SendCmd "molecule edges $bool $dataset"
-                }
-            }
-        }
-        "molecule-colormap" {
-            set colormap [$itk_component(moleculecolormap) value]
-            set colormap [$itk_component(moleculecolormap) translate $colormap]
-            set _settings($what) $colormap
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach {dataobj comp} [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "molecule" } {
-                    ChangeColormap $dataobj $comp $colormap
-                    if { $colormap == "elementDefault" } {
-                        SendCmd [list molecule colormode by_elements element $dataset]
-                    } else {
-                        # FIXME: Set the chosen scalar field name here
-                        set _settings(molecule-colormode) scalar
-                        set _settings(molecule-colorfield) ""
-                        SendCmd [list molecule colormode $_settings(molecule-colormode) $_settings(molecule-colorfield) $dataset]
-                    }
-                }
-            }
-            set _legendPending 1
-        }
-        "molecule-representation" {
-            set value [$itk_component(representation) value]
-            set value [$itk_component(representation) translate $value]
-            switch -- $value {
-                "ballandstick" {
-                    set _settings(molecule-rscale) covalent
-                    set _settings(molecule-atoms-visible) 1
-                    set _settings(molecule-bonds-visible) 1
-                    set _settings(molecule-bondstyle) cylinder
-                    set _settings(molecule-atomscale) 0.3
-                    set _settings(molecule-bondscale) 0.075
-                }
-                "balls" - "spheres" {
-                    set _settings(molecule-rscale) covalent
-                    set _settings(molecule-atoms-visible) 1
-                    set _settings(molecule-bonds-visible) 0
-                    set _settings(molecule-bondstyle) cylinder
-                    set _settings(molecule-atomscale) 0.3
-                    set _settings(molecule-bondscale) 0.075
-                }
-                "sticks" {
-                    set _settings(molecule-rscale) none
-                    set _settings(molecule-atoms-visible) 1
-                    set _settings(molecule-bonds-visible) 1
-                    set _settings(molecule-bondstyle) cylinder
-                    set _settings(molecule-atomscale) 0.075
-                    set _settings(molecule-bondscale) 0.075
-                }
-                "spacefilling" {
-                    set _settings(molecule-rscale) van_der_waals
-                    set _settings(molecule-atoms-visible) 1
-                    set _settings(molecule-bonds-visible) 0
-                    set _settings(molecule-bondstyle) cylinder
-                    set _settings(molecule-atomscale) 1.0
-                    set _settings(molecule-bondscale) 0.075
-                }
-                "rods"  {
-                    set _settings(molecule-rscale) none
-                    set _settings(molecule-atoms-visible) 1
-                    set _settings(molecule-bonds-visible) 1
-                    set _settings(molecule-bondstyle) cylinder
-                    set _settings(molecule-atomscale) 0.1
-                    set _settings(molecule-bondscale) 0.1
-                }
-                "wireframe" - "lines" {
-                    set _settings(molecule-rscale) none
-                    set _settings(molecule-atoms-visible) 0
-                    set _settings(molecule-bonds-visible) 1
-                    set _settings(molecule-bondstyle) line
-                    set _settings(molecule-atomscale) 1.0
-                    set _settings(molecule-bondscale) 1.0
-                }
-                default {
-                    error "unknown representation $value"
-                }
-            }
-            $itk_component(rscale) value [$itk_component(rscale) label $_settings(molecule-rscale)]
-            switch -- $value {
-                "ballandstick" - "balls" - "spheres" {
-                    $itk_component(rscale) configure -state normal
-                }
-                default {
-                    $itk_component(rscale) configure -state disabled
-                }
-            }
-            foreach dataset [CurrentDatasets -all] {
-                foreach {dataobj comp} [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "molecule" } {
-                    StartBufferingCommands
-                    SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset}]
-                    SendCmd [subst {molecule ascale $_settings(molecule-atomscale) $dataset}]
-                    SendCmd [subst {molecule bscale $_settings(molecule-bondscale) $dataset}]
-                    SendCmd [subst {molecule bstyle $_settings(molecule-bondstyle) $dataset}]
-                    SendCmd [subst {molecule atoms $_settings(molecule-atoms-visible) $dataset}]
-                    SendCmd [subst {molecule bonds $_settings(molecule-bonds-visible) $dataset}]
-                    StopBufferingCommands
-                }
-            }
-        }
-        "molecule-rscale" {
-            set value [$itk_component(rscale) value]
-            set value [$itk_component(rscale) translate $value]
-            set _settings($what) $value
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach {dataobj comp} [split $dataset -] break
-                set type [$dataobj type $comp]
-                if { $type == "molecule" } {
-                    SendCmd [subst {molecule rscale $_settings($what) $dataset}]
-                }
-            }
-        }
-        "molecule-labels" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible $_first] {
-               foreach { dataobj comp } [split $dataset -] break
-               set type [$dataobj type $comp]
-               if { $type == "molecule" } {
-                   SendCmd "molecule labels $bool $dataset"
-               }
-            }
-        }
-        "axis-visible" {
-            set bool $_axis(visible)
-            SendCmd "axis visible all $bool"
-        }
-        "axis-labels" {
-            set bool $_axis(labels)
-            SendCmd "axis labels all $bool"
-        }
-        "axis-minorticks" {
-            set bool $_axis(minorticks)
-            SendCmd "axis minticks all $bool"
-        }
-        "axis-xgrid" {
-            set bool $_axis(xgrid)
-            SendCmd "axis grid x $bool"
-        }
-        "axis-ygrid" {
-            set bool $_axis(ygrid)
-            SendCmd "axis grid y $bool"
-        }
-        "axis-zgrid" {
-            set bool $_axis(zgrid)
-            SendCmd "axis grid z $bool"
-        }
-        "axis-mode" {
-            set mode [$itk_component(axismode) value]
-            set mode [$itk_component(axismode) translate $mode]
-            SendCmd "axis flymode $mode"
-        }
-        "axis-xcutaway" - "axis-ycutaway" - "axis-zcutaway" {
-            set axis [string range $what 5 5]
-            set bool $_axis(${axis}cutaway)
-            if { $bool } {
-                set pos [expr $_axis(${axis}position) * 0.01]
-                set dir $_axis(${axis}direction)
-                $itk_component(${axis}CutScale) configure -state normal \
-                    -troughcolor white
-                SendCmd "renderer clipplane $axis $pos $dir"
-            } else {
-                $itk_component(${axis}CutScale) configure -state disabled \
-                    -troughcolor grey82
-                SendCmd "renderer clipplane $axis 1 -1"
-            }
-        }
-        "axis-xposition" - "axis-yposition" - "axis-zposition" -
-        "axis-xdirection" - "axis-ydirection" - "axis-zdirection" {
-            set axis [string range $what 5 5]
-            #set dir $_axis(${axis}direction)
-            set pos [expr $_axis(${axis}position) * 0.01]
-            SendCmd "renderer clipplane ${axis} $pos -1"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-#
-# RequestLegend --
-#
-# Request a new legend from the server.  The size of the legend
-# is determined from the height of the canvas.  It will be rotated
-# to be vertical when drawn.
-#
-itcl::body Rappture::VtkViewer::RequestLegend {} {
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-    set w 12
-    set h [expr {$_height - 2 * ($lineht + 2)}]
-    if { $h < 1 } {
-        return
-    }
-    # Set the legend on the first dataset.
-    foreach dataset [CurrentDatasets -visible] {
-        foreach {dataobj comp} [split $dataset -] break
-        if { [info exists _dataset2style($dataset)] } {
-            #SendCmd "legend $_dataset2style($dataset) vmag {} {} $w $h 0"
-            SendCmd "legend2 $_dataset2style($dataset) $w $h"
-            break;
-        }
-    }
-}
-
-#
-# ChangeColormap --
-#
-itcl::body Rappture::VtkViewer::ChangeColormap {dataobj comp color} {
-    set tag $dataobj-$comp
-    if { ![info exist _style($tag)] } {
-        error "no initial colormap"
-    }
-    array set style $_style($tag)
-    set style(-color) $color
-    set _style($tag) [array get style]
-    SetColormap $dataobj $comp
-}
-
-#
-# SetColormap --
-#
-itcl::body Rappture::VtkViewer::SetColormap { dataobj comp } {
-    array set style {
-        -color BCGYR
-    }
-    if {[$dataobj type $comp] == "molecule"} {
-        set style(-color) elementDefault
-    }
-    set tag $dataobj-$comp
-    if { ![info exists _initialStyle($tag)] } {
-        # Save the initial component style.
-        set _initialStyle($tag) [$dataobj style $comp]
-    }
-
-    # Override defaults with initial style defined in xml.
-    array set style $_initialStyle($tag)
-
-    if { ![info exists _style($tag)] } {
-        set _style($tag) [array get style]
-    }
-    # Override initial style with current style.
-    array set style $_style($tag)
-
-    set name "$style(-color)"
-    if { $name != "none" && ![info exists _colormaps($name)] } {
-        BuildColormap $name
-        set _colormaps($name) 1
-    }
-    if { ![info exists _dataset2style($tag)] ||
-         $_dataset2style($tag) != $name } {
-        set _dataset2style($tag) $name
-        if { $name != "none" } {
-            switch -- [$dataobj type $comp] {
-                "polydata" {
-                    SendCmd "polydata colormap $name $tag"
-                }
-                "glyphs" {
-                    SendCmd "glyphs colormap $name $tag"
-                }
-                "molecule" {
-                    SendCmd "molecule colormap $name $tag"
-                }
-            }
-        }
-    }
-}
-
-#
-# BuildColormap --
-#
-itcl::body Rappture::VtkViewer::BuildColormap { name } {
-    if { $name == "elementDefault" } {
-        return
-    }
-    set cmap [ColorsToColormap $name]
-    if { [llength $cmap] == 0 } {
-        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
-    }
-    set amap "0.0 1.0 1.0 1.0"
-    SendCmd "colormap add $name { $cmap } { $amap }"
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkViewer::plotbackground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotbackground)]
-        SendCmd "screen bgcolor $rgb"
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkViewer::plotforeground {
-    if { [isconnected] } {
-        set rgb [Color2RGB $itk_option(-plotforeground)]
-        SendCmd "axis color all $rgb"
-        SendCmd "outline color $rgb"
-    }
-}
-
-itcl::body Rappture::VtkViewer::limits { dataobj } {
-    foreach cname [$dataobj components] {
-        set tag $dataobj-$cname
-        if { ![info exists _limits($tag)] } {
-            set data [$dataobj data $cname]
-            if { $data == "" } {
-                continue
-            }
-            set tmpfile file[pid].vtk
-            set f [open "$tmpfile" "w"]
-            fconfigure $f -translation binary -encoding binary
-            puts $f $data
-            close $f
-            set reader [vtkDataSetReader $tag-xvtkDataSetReader]
-            $reader SetFileName $tmpfile
-            $reader ReadAllNormalsOn
-            $reader ReadAllTCoordsOn
-            $reader ReadAllScalarsOn
-            $reader ReadAllColorScalarsOn
-            $reader ReadAllVectorsOn
-            $reader ReadAllTensorsOn
-            $reader ReadAllFieldsOn
-            $reader Update
-            file delete $tmpfile
-            set dataset [$reader GetOutput]
-            if { $dataset == "" } {
-                # Invalid VTK file -- loader failed to parse
-                continue
-            }
-            set _limits($tag) [$dataset GetBounds]
-            set dataAttrs [$dataset GetPointData]
-            if { $dataAttrs != ""} {
-                set numArrays [$dataAttrs GetNumberOfArrays]
-                for {set i 0} {$i < $numArrays} {incr i} {
-                    set array [$dataAttrs GetArray $i]
-                    set fname [$dataAttrs GetArrayName $i]
-                    foreach {min max} [$array GetRange -1] break
-                    lappend _fieldlimits($tag) $fname pointdata [list $min $max]
-                    set _fieldComponents($tag-$fname) [$array GetNumberOfComponents]
-                }
-            }
-            set dataAttrs [$dataset GetCellData]
-            if { $dataAttrs != ""} {
-                set numArrays [$dataAttrs GetNumberOfArrays]
-                for {set i 0} {$i < $numArrays} {incr i} {
-                    set array [$dataAttrs GetArray $i]
-                    set fname [$dataAttrs GetArrayName $i]
-                    foreach {min max} [$array GetRange -1] break
-                    lappend _fieldlimits($tag) $fname celldata [list $min $max]
-                    set _fieldComponents($tag-$fname) [$array GetNumberOfComponents]
-                }
-            }
-            set dataAttrs [$dataset GetFieldData]
-            if { $dataAttrs != ""} {
-                set numArrays [$dataAttrs GetNumberOfArrays]
-                for {set i 0} {$i < $numArrays} {incr i} {
-                    set array [$dataAttrs GetArray $i]
-                    set fname [$dataAttrs GetArrayName $i]
-                    foreach {min max} [$array GetRange -1] break
-                    lappend _fieldlimits($tag) $fname fielddata [list $min $max]
-                    set _fieldComponents($tag-$fname) [$array GetNumberOfComponents]
-                }
-            }
-            rename $dataset ""
-            rename $reader ""
-        }
-        foreach {xMin xMax yMin yMax zMin zMax} $_limits($tag) break
-        if {![info exists limits(xmin)] || $limits(xmin) > $xMin} {
-            set limits(xmin) $xMin
-        }
-        if {![info exists limits(xmax)] || $limits(xmax) < $xMax} {
-            set limits(xmax) $xMax
-        }
-        if {![info exists limits(ymin)] || $limits(ymin) > $yMin} {
-            set limits(ymin) $xMin
-        }
-        if {![info exists limits(ymax)] || $limits(ymax) < $yMax} {
-            set limits(ymax) $yMax
-        }
-        if {![info exists limits(zmin)] || $limits(zmin) > $zMin} {
-            set limits(zmin) $zMin
-        }
-        if {![info exists limits(zmax)] || $limits(zmax) < $zMax} {
-            set limits(zmax) $zMax
-        }
-    }
-    return [array get limits]
-}
-
-itcl::body Rappture::VtkViewer::BuildGlyphsTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert 0 \
-        -title "Glyph Settings" \
-        -icon [Rappture::icon volume-on]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.glyphs \
-        -text "Show Glyphs" \
-        -variable [itcl::scope _settings(glyphs-visible)] \
-        -command [itcl::code $this AdjustSetting glyphs-visible] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.outline \
-        -text "Show Outline" \
-        -variable [itcl::scope _settings(glyphs-outline)] \
-        -command [itcl::code $this AdjustSetting glyphs-outline] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.wireframe \
-        -text "Show Wireframe" \
-        -variable [itcl::scope _settings(glyphs-wireframe)] \
-        -command [itcl::code $this AdjustSetting glyphs-wireframe] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(glyphs-lighting)] \
-        -command [itcl::code $this AdjustSetting glyphs-lighting] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.edges \
-        -text "Show Edges" \
-        -variable [itcl::scope _settings(glyphs-edges)] \
-        -command [itcl::code $this AdjustSetting glyphs-edges] \
-        -font "Arial 9" -anchor w
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9" -anchor w
-    itk_component add glyphscolormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList]
-    $itk_component(glyphscolormap) value [$itk_component(glyphscolormap) label $_settings(glyphs-colormap)]
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting glyphs-colormap]
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(glyphs-opacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this EventuallySetGlyphsOpacity]
-    $inner.opacity set $_settings(glyphs-opacity)
-
-    blt::table $inner \
-        0,0 $inner.glyphs     -cspan 2  -anchor w -pady 2 \
-        1,0 $inner.outline    -cspan 2  -anchor w -pady 2 \
-        2,0 $inner.wireframe  -cspan 2  -anchor w -pady 2 \
-        3,0 $inner.lighting   -cspan 2  -anchor w -pady 2 \
-        4,0 $inner.edges      -cspan 2  -anchor w -pady 2 \
-        5,0 $inner.opacity_l  -anchor w -pady 2 \
-        5,1 $inner.opacity    -fill x   -pady 2 \
-        6,0 $inner.colormap_l -anchor w -pady 2 \
-        6,1 $inner.colormap   -fill x   -pady 2
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r8 c1 -resize expand
-}
-
-itcl::body Rappture::VtkViewer::BuildPolydataTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert 0 \
-        -title "Mesh Settings" \
-        -icon [Rappture::icon mesh]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.mesh \
-        -text "Show Mesh" \
-        -variable [itcl::scope _settings(polydata-visible)] \
-        -command [itcl::code $this AdjustSetting polydata-visible] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.outline \
-        -text "Show Outline" \
-        -variable [itcl::scope _settings(polydata-outline)] \
-        -command [itcl::code $this AdjustSetting polydata-outline] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.wireframe \
-        -text "Show Wireframe" \
-        -variable [itcl::scope _settings(polydata-wireframe)] \
-        -command [itcl::code $this AdjustSetting polydata-wireframe] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(polydata-lighting)] \
-        -command [itcl::code $this AdjustSetting polydata-lighting] \
-        -font "Arial 9" -anchor w
-
-    checkbutton $inner.edges \
-        -text "Show Edges" \
-        -variable [itcl::scope _settings(polydata-edges)] \
-        -command [itcl::code $this AdjustSetting polydata-edges] \
-        -font "Arial 9" -anchor w
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9" -anchor w
-    itk_component add polydatacolormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList]
-    $itk_component(polydatacolormap) value [$itk_component(polydatacolormap) label $_settings(polydata-colormap)]
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting polydata-colormap]
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(polydata-opacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this EventuallySetPolydataOpacity]
-    $inner.opacity set $_settings(polydata-opacity)
-
-    blt::table $inner \
-        0,0 $inner.mesh       -cspan 2  -anchor w -pady 2 \
-        1,0 $inner.outline    -cspan 2  -anchor w -pady 2 \
-        2,0 $inner.wireframe  -cspan 2  -anchor w -pady 2 \
-        3,0 $inner.lighting   -cspan 2  -anchor w -pady 2 \
-        4,0 $inner.edges      -cspan 2  -anchor w -pady 2 \
-        5,0 $inner.opacity_l  -anchor w -pady 2 \
-        5,1 $inner.opacity    -fill x   -pady 2 \
-        6,0 $inner.colormap_l -anchor w -pady 2 \
-        6,1 $inner.colormap   -fill x   -pady 2
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r8 c1 -resize expand
-}
-
-itcl::body Rappture::VtkViewer::BuildAxisTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-    #set bfg [option get $itk_component(hull) boldFont Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _axis(visible)] \
-        -command [itcl::code $this AdjustSetting axis-visible] \
-        -font "Arial 9"
-
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _axis(labels)] \
-        -command [itcl::code $this AdjustSetting axis-labels] \
-        -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9"
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _axis(xgrid)] \
-        -command [itcl::code $this AdjustSetting axis-xgrid] \
-        -font "Arial 9"
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _axis(ygrid)] \
-        -command [itcl::code $this AdjustSetting axis-ygrid] \
-        -font "Arial 9"
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _axis(zgrid)] \
-        -command [itcl::code $this AdjustSetting axis-zgrid] \
-        -font "Arial 9"
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _axis(minorticks)] \
-        -command [itcl::code $this AdjustSetting axis-minorticks] \
-        -font "Arial 9"
-
-    label $inner.mode_l -text "Mode" -font "Arial 9"
-
-    itk_component add axismode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axismode) value "static"
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]
-
-    blt::table $inner \
-        0,0 $inner.visible -anchor w -cspan 4 \
-        1,0 $inner.labels  -anchor w -cspan 4 \
-        2,0 $inner.minorticks  -anchor w -cspan 4 \
-        4,0 $inner.grid_l  -anchor w \
-        4,1 $inner.xgrid   -anchor w \
-        4,2 $inner.ygrid   -anchor w \
-        4,3 $inner.zgrid   -anchor w \
-        5,0 $inner.mode_l  -anchor w -padx { 2 0 } \
-        5,1 $inner.mode    -fill x   -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-itcl::body Rappture::VtkViewer::BuildCameraTab {} {
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font "Arial 9"
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set labels { qx qy qz qw xpan ypan zoom }
-    set row 1
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font "Arial 9"
-        entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this camera set -ortho] \
-        -font "Arial 9"
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c* -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-itcl::body Rappture::VtkViewer::BuildCutawayTab {} {
-
-    set fg [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Cutaway Along Axis" \
-        -icon [Rappture::icon cutbutton]]
-
-    $inner configure -borderwidth 4
-
-    # X-value slicer...
-    itk_component add xCutButton {
-        Rappture::PushButton $inner.xbutton \
-            -onimage [Rappture::icon x-cutplane] \
-            -offimage [Rappture::icon x-cutplane] \
-            -command [itcl::code $this AdjustSetting axis-xcutaway] \
-            -variable [itcl::scope _axis(xcutaway)]
-    }
-    Rappture::Tooltip::for $itk_component(xCutButton) \
-        "Toggle the X-axis cutaway on/off"
-
-    itk_component add xCutScale {
-        ::scale $inner.xval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move x] \
-            -variable [itcl::scope _axis(xposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    # Set the default cutaway value before disabling the scale.
-    $itk_component(xCutScale) set 100
-    $itk_component(xCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(xCutScale) \
-        "@[itcl::code $this Slice tooltip x]"
-
-    itk_component add xDirButton {
-        Rappture::PushButton $inner.xdir \
-            -onimage [Rappture::icon arrow-down] \
-            -onvalue -1 \
-            -offimage [Rappture::icon arrow-up] \
-            -offvalue 1 \
-            -command [itcl::code $this AdjustSetting axis-xdirection] \
-            -variable [itcl::scope _axis(xdirection)]
-    }
-    set _axis(xdirection) -1
-    Rappture::Tooltip::for $itk_component(xDirButton) \
-        "Toggle the direction of the X-axis cutaway"
-
-    # Y-value slicer...
-    itk_component add yCutButton {
-        Rappture::PushButton $inner.ybutton \
-            -onimage [Rappture::icon y-cutplane] \
-            -offimage [Rappture::icon y-cutplane] \
-            -command [itcl::code $this AdjustSetting axis-ycutaway] \
-            -variable [itcl::scope _axis(ycutaway)]
-    }
-    Rappture::Tooltip::for $itk_component(yCutButton) \
-        "Toggle the Y-axis cutaway on/off"
-
-    itk_component add yCutScale {
-        ::scale $inner.yval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move y] \
-            -variable [itcl::scope _axis(yposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    Rappture::Tooltip::for $itk_component(yCutScale) \
-        "@[itcl::code $this Slice tooltip y]"
-    # Set the default cutaway value before disabling the scale.
-    $itk_component(yCutScale) set 100
-    $itk_component(yCutScale) configure -state disabled
-
-    itk_component add yDirButton {
-        Rappture::PushButton $inner.ydir \
-            -onimage [Rappture::icon arrow-down] \
-            -onvalue -1 \
-            -offimage [Rappture::icon arrow-up] \
-            -offvalue 1 \
-            -command [itcl::code $this AdjustSetting axis-ydirection] \
-            -variable [itcl::scope _axis(ydirection)]
-    }
-    Rappture::Tooltip::for $itk_component(yDirButton) \
-        "Toggle the direction of the Y-axis cutaway"
-    set _axis(ydirection) -1
-
-    # Z-value slicer...
-    itk_component add zCutButton {
-        Rappture::PushButton $inner.zbutton \
-            -onimage [Rappture::icon z-cutplane] \
-            -offimage [Rappture::icon z-cutplane] \
-            -command [itcl::code $this AdjustSetting axis-zcutaway] \
-            -variable [itcl::scope _axis(zcutaway)]
-    }
-    Rappture::Tooltip::for $itk_component(zCutButton) \
-        "Toggle the Z-axis cutaway on/off"
-
-    itk_component add zCutScale {
-        ::scale $inner.zval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this Slice move z] \
-            -variable [itcl::scope _axis(zposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    $itk_component(zCutScale) set 100
-    $itk_component(zCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(zCutScale) \
-        "@[itcl::code $this Slice tooltip z]"
-
-    itk_component add zDirButton {
-        Rappture::PushButton $inner.zdir \
-            -onimage [Rappture::icon arrow-down] \
-            -onvalue -1 \
-            -offimage [Rappture::icon arrow-up] \
-            -offvalue 1 \
-            -command [itcl::code $this AdjustSetting axis-zdirection] \
-            -variable [itcl::scope _axis(zdirection)]
-    }
-    set _axis(zdirection) -1
-    Rappture::Tooltip::for $itk_component(zDirButton) \
-        "Toggle the direction of the Z-axis cutaway"
-
-    blt::table $inner \
-        0,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
-        1,0 $itk_component(xCutScale)   -fill y \
-        0,1 $itk_component(yCutButton)  -anchor e -padx 2 -pady 2 \
-        1,1 $itk_component(yCutScale)   -fill y \
-        0,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
-        1,2 $itk_component(zCutScale)   -fill y \
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r1 c3 -resize expand
-}
-
-itcl::body Rappture::VtkViewer::BuildMoleculeTab {} {
-    set fg [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert 0 \
-        -title "Molecule Settings" \
-        -icon [Rappture::icon molecule]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.molecule \
-        -text "Show Molecule" \
-        -variable [itcl::scope _settings(molecule-visible)] \
-        -command [itcl::code $this AdjustSetting molecule-visible] \
-        -font "Arial 9"
-
-    checkbutton $inner.outline \
-        -text "Show Outline" \
-        -variable [itcl::scope _settings(molecule-outline)] \
-        -command [itcl::code $this AdjustSetting molecule-outline] \
-        -font "Arial 9"
-
-    checkbutton $inner.label \
-        -text "Show Atom Labels" \
-        -variable [itcl::scope _settings(molecule-labels)] \
-        -command [itcl::code $this AdjustSetting molecule-labels] \
-        -font "Arial 9"
-
-    checkbutton $inner.wireframe \
-        -text "Show Wireframe" \
-        -variable [itcl::scope _settings(molecule-wireframe)] \
-        -command [itcl::code $this AdjustSetting molecule-wireframe] \
-        -font "Arial 9"
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(molecule-lighting)] \
-        -command [itcl::code $this AdjustSetting molecule-lighting] \
-        -font "Arial 9"
-
-    checkbutton $inner.edges \
-        -text "Show Edges" \
-        -variable [itcl::scope _settings(molecule-edges)] \
-        -command [itcl::code $this AdjustSetting molecule-edges] \
-        -font "Arial 9"
-
-    label $inner.rep_l -text "Molecule Representation" \
-        -font "Arial 9"
-
-    itk_component add representation {
-        Rappture::Combobox $inner.rep -width 20 -editable 0
-    }
-    $inner.rep choices insert end \
-        "ballandstick"  "Ball and Stick" \
-        "spheres"       "Spheres"        \
-        "sticks"        "Sticks"         \
-        "rods"          "Rods"           \
-        "wireframe"     "Wireframe"      \
-        "spacefilling"  "Space Filling"
-
-    bind $inner.rep <<Value>> \
-        [itcl::code $this AdjustSetting molecule-representation]
-    $inner.rep value "Ball and Stick"
-
-    label $inner.rscale_l -text "Atom Radii" \
-        -font "Arial 9"
-
-    itk_component add rscale {
-        Rappture::Combobox $inner.rscale -width 20 -editable 0
-    }
-    $inner.rscale choices insert end \
-        "atomic"        "Atomic"   \
-        "covalent"      "Covalent" \
-        "van_der_waals" "VDW"      \
-        "none"          "Constant"
-
-    bind $inner.rscale <<Value>> \
-        [itcl::code $this AdjustSetting molecule-rscale]
-    $inner.rscale value "Covalent"
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9"
-    itk_component add moleculecolormap {
-        Rappture::Combobox $inner.colormap -width 10 -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList -includeElementDefault]
-    $itk_component(moleculecolormap) value [$itk_component(moleculecolormap) label $_settings(molecule-colormap)]
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting molecule-colormap]
-
-    label $inner.atomscale_l -text "Atom Scale" -font "Arial 9"
-    ::scale $inner.atomscale -width 15 -font "Arial 7" \
-        -from 0.025 -to 2.0 -resolution 0.025 -label "" \
-        -showvalue true -orient horizontal \
-        -command [itcl::code $this EventuallySetAtomScale] \
-        -variable [itcl::scope _settings(molecule-atomscale)]
-    $inner.atomscale set $_settings(molecule-atomscale)
-    Rappture::Tooltip::for $inner.atomscale \
-        "Adjust relative scale of atoms (spheres or balls)."
-
-    label $inner.bondscale_l -text "Bond Scale" -font "Arial 9"
-    ::scale $inner.bondscale -width 15 -font "Arial 7" \
-        -from 0.005 -to 0.3 -resolution 0.005 -label "" \
-        -showvalue true -orient horizontal \
-        -command [itcl::code $this EventuallySetBondScale] \
-        -variable [itcl::scope _settings(molecule-bondscale)]
-    Rappture::Tooltip::for $inner.bondscale \
-        "Adjust scale of bonds (sticks)."
-    $inner.bondscale set $_settings(molecule-bondscale)
-
-    label $inner.opacity_l -text "Opacity" -font "Arial 9"
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(molecule-opacity)] \
-        -width 15 -font "Arial 7" \
-        -showvalue on \
-        -command [itcl::code $this EventuallySetMoleculeOpacity]
-
-    label $inner.quality_l -text "Quality" -font "Arial 9"
-    ::scale $inner.quality -width 15 -font "Arial 7" \
-        -from 0.0 -to 10.0 -resolution 0.1 -label "" \
-        -showvalue true -orient horizontal \
-        -command [itcl::code $this EventuallySetMoleculeQuality] \
-        -variable [itcl::scope _settings(molecule-quality)]
-    Rappture::Tooltip::for $inner.quality \
-        "Adjust tesselation quality"
-    $inner.quality set $_settings(molecule-quality)
-
-    blt::table $inner \
-        0,0 $inner.molecule     -anchor w -pady {1 0} \
-        1,0 $inner.outline      -anchor w -pady {1 0} \
-        2,0 $inner.label        -anchor w -pady {1 0} \
-        3,0 $inner.edges        -anchor w -pady {1 0} \
-        4,0 $inner.rep_l        -anchor w -pady { 2 0 } \
-        5,0 $inner.rep          -fill x    -pady 2 \
-        6,0 $inner.rscale_l     -anchor w -pady { 2 0 } \
-        7,0 $inner.rscale       -fill x    -pady 2 \
-        8,0 $inner.colormap_l    -anchor w  -pady 0 \
-        9,0 $inner.colormap      -fill x    -padx 2 \
-        10,0 $inner.atomscale_l  -anchor w -pady {3 0} \
-        11,0 $inner.atomscale   -fill x    -padx 2 \
-        12,0 $inner.bondscale_l -anchor w -pady {3 0} \
-        13,0 $inner.bondscale   -fill x   -padx 2 \
-        14,0 $inner.opacity_l   -anchor w -pady {3 0} \
-        15,0 $inner.opacity     -fill x    -padx 2 \
-        16,0 $inner.quality_l   -anchor w -pady {3 0} \
-        17,0 $inner.quality     -fill x    -padx 2
-
-    blt::table configure $inner r* -resize none
-    blt::table configure $inner r18 -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            set contents [$dataobj data $comp]
-            append bytes "$contents\n"
-        }
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::VtkViewer::SetObjectStyle { dataobj comp } {
-    # Parse style string.
-    set tag $dataobj-$comp
-    set type [$dataobj type $comp]
-    switch -- $type {
-        "glyphs" {
-            array set style {
-                -color BCGYR
-                -colormode constant
-                -constcolor white
-                -edgecolor black
-                -edges 0
-                -gscale 1
-                -lighting 1
-                -linewidth 1.0
-                -normscale 0
-                -opacity 1.0
-                -orientglyphs 0
-                -outline 0
-                -ptsize 1.0
-                -quality 1
-                -scalemode "vcomp"
-                -shape "sphere"
-                -visible 1
-                -wireframe 0
-            }
-            array set style [$dataobj style $comp]
-            set shape [$dataobj shape $comp]
-            if {$shape != ""} {
-                set style(-shape) $shape
-            }
-            # Backwards compat with camel case style option
-            if { [info exists style(-orientGlyphs)] } {
-                set style(-orientglyphs) $style(-orientGlyphs)
-                array unset style -orientGlyphs
-            }
-            # Backwards compat with camel case style option
-            if { [info exists style(-scaleMode)] } {
-                set style(-scalemode) $style(-scaleMode)
-                array unset style -scaleMode
-            }
-            SendCmd "outline add $tag"
-            SendCmd "outline color [Color2RGB $style(-constcolor)] $tag"
-            SendCmd "outline visible $style(-outline) $tag"
-            set _settings(glyphs-outline) $style(-outline)
-
-            SendCmd "glyphs add $style(-shape) $tag"
-            SendCmd "glyphs normscale $style(-normscale) $tag"
-            SendCmd "glyphs gscale $style(-gscale) $tag"
-            SendCmd "glyphs wireframe $style(-wireframe) $tag"
-            SendCmd "glyphs color [Color2RGB $style(-constcolor)] $tag"
-            #SendCmd "glyphs colormode $style(-colormode) {} $tag"
-            # Colormap is set by call to SetColormap below
-            set _settings(glyphs-colormap) $style(-color)
-            $itk_component(glyphscolormap) value [$itk_component(glyphscolormap) label $style(-color)]
-            # Omitting field name for gorient and smode commands
-            # defaults to active scalars or vectors depending on mode
-            SendCmd "glyphs gorient $style(-orientglyphs) {} $tag"
-            SendCmd "glyphs smode $style(-scalemode) {} $tag"
-            SendCmd "glyphs edges $style(-edges) $tag"
-            SendCmd "glyphs linecolor [Color2RGB $style(-edgecolor)] $tag"
-            SendCmd "glyphs linewidth $style(-linewidth) $tag"
-            SendCmd "glyphs ptsize $style(-ptsize) $tag"
-            SendCmd "glyphs quality $style(-quality) $tag"
-            SendCmd "glyphs lighting $style(-lighting) $tag"
-            SendCmd "glyphs opacity $style(-opacity) $tag"
-            set _settings(glyphs-opacity) [expr 100.0 * $style(-opacity)]
-            SendCmd "glyphs visible $style(-visible) $tag"
-            set _settings(glyphs-wireframe) $style(-wireframe)
-        }
-        "molecule" {
-            array set style {
-                -atomscale 0.3
-                -atomsvisible 1
-                -bondconstcolor white
-                -bondcolormode "by_elements"
-                -bondscale 0.075
-                -bondstyle "cylinder"
-                -bondsvisible 1
-                -color "elementDefault"
-                -colormode "by_elements"
-                -colorfield "element"
-                -constcolor white
-                -edgecolor black
-                -edges 0
-                -labels 0
-                -lighting 1
-                -linewidth 1.0
-                -opacity 1.0
-                -outline 0
-                -quality 1.0
-                -representation ""
-                -rscale "covalent"
-                -visible 1
-                -wireframe 0
-            }
-            set haveElementArray 0
-            foreach {fname assoc limits} $_fieldlimits($tag) {
-                DebugTrace "$assoc field $fname ([lindex $limits 0],[lindex $limits 1])"
-                if {$assoc == "pointdata" && $fname == "element"} {
-                    set haveElementArray 1
-                    break
-                }
-            }
-            if {!$haveElementArray} {
-                set style(-bondcolormode) constant
-                set style(-colorfield) ""
-                set style(-color) BCGYR
-                set style(-colormode) scalar
-            }
-            array set style [$dataobj style $comp]
-
-            SendCmd "outline add $tag"
-            SendCmd "outline color [Color2RGB $style(-constcolor)] $tag"
-            SendCmd "outline visible $style(-outline) $tag"
-            set _settings(molecule-outline) $style(-outline)
-
-            SendCmd "molecule add $tag"
-            if {$style(-representation) != ""} {
-                switch -- $style(-representation) {
-                    "ballandstick" {
-                        set _settings(molecule-rscale) covalent
-                        set _settings(molecule-atoms-visible) 1
-                        set _settings(molecule-bonds-visible) 1
-                        set _settings(molecule-bondstyle) cylinder
-                        set _settings(molecule-atomscale) 0.3
-                        set _settings(molecule-bondscale) 0.075
-                    }
-                    "balls" - "spheres" {
-                        set _settings(molecule-rscale) covalent
-                        set _settings(molecule-atoms-visible) 1
-                        set _settings(molecule-bonds-visible) 0
-                        set _settings(molecule-bondstyle) cylinder
-                        set _settings(molecule-atomscale) 0.3
-                        set _settings(molecule-bondscale) 0.075
-                    }
-                    "sticks" {
-                        set _settings(molecule-rscale) none
-                        set _settings(molecule-atoms-visible) 1
-                        set _settings(molecule-bonds-visible) 1
-                        set _settings(molecule-bondstyle) cylinder
-                        set _settings(molecule-atomscale) 0.075
-                        set _settings(molecule-bondscale) 0.075
-                    }
-                    "spacefilling" {
-                        set _settings(molecule-rscale) van_der_waals
-                        set _settings(molecule-atoms-visible) 1
-                        set _settings(molecule-bonds-visible) 0
-                        set _settings(molecule-bondstyle) cylinder
-                        set _settings(molecule-atomscale) 1.0
-                        set _settings(molecule-bondscale) 0.075
-                    }
-                    "rods"  {
-                        set _settings(molecule-rscale) none
-                        set _settings(molecule-atoms-visible) 1
-                        set _settings(molecule-bonds-visible) 1
-                        set _settings(molecule-bondstyle) cylinder
-                        set _settings(molecule-atomscale) 0.1
-                        set _settings(molecule-bondscale) 0.1
-                    }
-                    "wireframe" - "lines" {
-                        set _settings(molecule-rscale) none
-                        set _settings(molecule-atoms-visible) 0
-                        set _settings(molecule-bonds-visible) 1
-                        set _settings(molecule-bondstyle) line
-                        set _settings(molecule-atomscale) 1.0
-                        set _settings(molecule-bondscale) 1.0
-                    }
-                    default {
-                        error "unknown representation $value"
-                    }
-                }
-                SendCmd "molecule rscale $_settings(molecule-rscale) $tag"
-                SendCmd "molecule atoms $_settings(molecule-atoms-visible) $tag"
-                SendCmd "molecule bonds $_settings(molecule-bonds-visible) $tag"
-                SendCmd "molecule bstyle $_settings(molecule-bondstyle) $tag"
-                SendCmd "molecule ascale $_settings(molecule-atomscale) $tag"
-                SendCmd "molecule bscale $_settings(molecule-bondscale) $tag"
-                $itk_component(representation) value [$itk_component(representation) label $style(-representation)]
-                $itk_component(rscale) value [$itk_component(rscale) label $_settings(molecule-rscale)]
-                switch -- $style(-representation) {
-                    "ballandstick" - "balls" - "spheres" {
-                        $itk_component(rscale) configure -state normal
-                    }
-                    default {
-                        $itk_component(rscale) configure -state disabled
-                    }
-                }
-            } else {
-                SendCmd "molecule rscale $style(-rscale) $tag"
-                set _settings(molecule-rscale) $style(-rscale)
-                SendCmd "molecule atoms $style(-atomsvisible) $tag"
-                set _settings(molecule-atoms-visible) $style(-atomsvisible)
-                SendCmd "molecule bonds $style(-bondsvisible) $tag"
-                set _settings(molecule-bonds-visible) $style(-bondsvisible)
-                SendCmd "molecule bstyle $style(-bondstyle) $tag"
-                set _settings(molecule-bondstyle) $style(-bondstyle)
-                SendCmd "molecule ascale $style(-atomscale) $tag"
-                set _settings(molecule-atomscale) $style(-atomscale)
-                SendCmd "molecule bscale $style(-bondscale) $tag"
-                set _settings(molecule-bondscale) $style(-bondscale)
-            }
-            SendCmd "molecule labels $style(-labels) $tag"
-            set _settings(molecule-labels) $style(-labels)
-            SendCmd "molecule color [Color2RGB $style(-constcolor)] $tag"
-            SendCmd "molecule bcolor [Color2RGB $style(-bondconstcolor)] $tag"
-            SendCmd [list molecule colormode $style(-colormode) $style(-colorfield) $tag]
-            SendCmd "molecule bcmode $style(-bondcolormode) $tag"
-            set _settings(molecule-colormode) $style(-colormode)
-            set _settings(molecule-colorfield) $style(-colorfield)
-            # Colormap is set by call to SetColormap below
-            set _settings(molecule-colormap) $style(-color)
-            $itk_component(moleculecolormap) value [$itk_component(moleculecolormap) label $style(-color)]
-            SendCmd "molecule linecolor [Color2RGB $style(-edgecolor)] $tag"
-            SendCmd "molecule linewidth $style(-linewidth) $tag"
-            SendCmd "molecule edges $style(-edges) $tag"
-            set _settings(molecule-edges) $style(-edges)
-            SendCmd "molecule lighting $style(-lighting) $tag"
-            set _settings(molecule-lighting) $style(-lighting)
-            SendCmd "molecule aquality $style(-quality) $tag"
-            SendCmd "molecule bquality $style(-quality) $tag"
-            set _settings(molecule-quality) $style(-quality)
-            SendCmd "molecule visible $style(-visible) $tag"
-            set _settings(molecule-visible) $style(-visible)
-            set _haveMolecules 1
-        }
-        "polydata" {
-            array set style {
-                -cloudstyle "mesh"
-                -color BCGYR
-                -colormode constant
-                -constcolor white
-                -edgecolor black
-                -edges 1
-                -lighting 1
-                -linewidth 1.0
-                -opacity 1.0
-                -outline 0
-                -visible 1
-                -wireframe 0
-            }
-            array set style [$dataobj style $comp]
-
-            SendCmd "outline add $tag"
-            SendCmd "outline color [Color2RGB $style(-constcolor)] $tag"
-            SendCmd "outline visible $style(-outline) $tag"
-            set _settings(polydata-outline) $style(-outline)
-
-            SendCmd "polydata add $tag"
-            SendCmd "polydata visible $style(-visible) $tag"
-            set _settings(polydata-visible) $style(-visible)
-            SendCmd "polydata edges $style(-edges) $tag"
-            set _settings(polydata-edges) $style(-edges)
-            SendCmd "polydata cloudstyle $style(-cloudstyle) $tag"
-            SendCmd "polydata color [Color2RGB $style(-constcolor)] $tag"
-            #SendCmd "polydata colormode $style(-colormode) {} $tag"
-            # Colormap is set by call to SetColormap below
-            set _settings(polydata-colormap) $style(-color)
-            $itk_component(polydatacolormap) value [$itk_component(polydatacolormap) label $style(-color)]
-            SendCmd "polydata lighting $style(-lighting) $tag"
-            set _settings(polydata-lighting) $style(-lighting)
-            SendCmd "polydata linecolor [Color2RGB $style(-edgecolor)] $tag"
-            SendCmd "polydata linewidth $style(-linewidth) $tag"
-            SendCmd "polydata opacity $style(-opacity) $tag"
-            set _settings(polydata-opacity) [expr 100.0 * $style(-opacity)]
-            SendCmd "polydata wireframe $style(-wireframe) $tag"
-            set _settings(polydata-wireframe) $style(-wireframe)
-            set havePolyData 1
-        }
-    }
-    SetColormap $dataobj $comp
-}
-
-itcl::body Rappture::VtkViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Drawing} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::ReceiveLegend { colormap title min max size } {
-    set _limits(vmin) $min
-    set _limits(vmax) $max
-    set _title $title
-    if { [IsConnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend)] } {
-            set _image(legend) [image create photo]
-        }
-        $_image(legend) configure -data $bytes
-        DrawLegend
-    }
-}
-
-#
-# DrawLegend --
-#
-# Draws the legend in it's own canvas which resides to the right
-# of the contour plot area.
-#
-itcl::body Rappture::VtkViewer::DrawLegend {} {
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    if { $_settings(legend) } {
-        set x [expr $w - 2]
-        if { [$c find withtag "legend"] == "" } {
-            $c create image $x [expr {$lineht+2}] \
-                -anchor ne \
-                -image $_image(legend) -tags "colormap legend"
-            $c create text $x 2 \
-                -anchor ne \
-                -fill $itk_option(-plotforeground) -tags "vmax legend" \
-                -font $font
-            $c create text $x [expr {$h-2}] \
-                -anchor se \
-                -fill $itk_option(-plotforeground) -tags "vmin legend" \
-                -font $font
-            #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y]
-            $c bind colormap <Leave> [itcl::code $this LeaveLegend]
-            $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
-        }
-        # Reset the item coordinates according the current size of the plot.
-        $c coords colormap $x [expr {$lineht+2}]
-        if { $_limits(vmin) != "" } {
-            $c itemconfigure vmin -text [format %g $_limits(vmin)]
-        }
-        if { $_limits(vmax) != "" } {
-            $c itemconfigure vmax -text [format %g $_limits(vmax)]
-        }
-        $c coords vmin $x [expr {$h-2}]
-        $c coords vmax $x 2
-    }
-}
-
-#
-# EnterLegend --
-#
-itcl::body Rappture::VtkViewer::EnterLegend { x y } {
-    SetLegendTip $x $y
-}
-
-#
-# MotionLegend --
-#
-itcl::body Rappture::VtkViewer::MotionLegend { x y } {
-    Rappture::Tooltip::tooltip cancel
-    set c $itk_component(view)
-    SetLegendTip $x $y
-}
-
-#
-# LeaveLegend --
-#
-itcl::body Rappture::VtkViewer::LeaveLegend { } {
-    Rappture::Tooltip::tooltip cancel
-    .rappturetooltip configure -icon ""
-}
-
-#
-# SetLegendTip --
-#
-itcl::body Rappture::VtkViewer::SetLegendTip { x y } {
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set imgHeight [image height $_image(legend)]
-    set coords [$c coords colormap]
-    set imgX [expr $w - [image width $_image(legend)] - 2]
-    set imgY [expr $y - $lineht - 2]
-
-    # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
-        return
-    }
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    set color [eval format "\#%02x%02x%02x" $pixel]
-    $_image(swatch) put black  -to 0 0 23 23
-    $_image(swatch) put $color -to 1 1 22 22
-    .rappturetooltip configure -icon $_image(swatch)
-
-    # Compute the value of the point
-    set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
-    set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
-    set tipx [expr $x + 15]
-    set tipy [expr $y - 5]
-    Rappture::Tooltip::text $c "$_title $value"
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Slice move x|y|z <newval>
-#
-# Called automatically when the user drags the slider to move the
-# cut plane that slices 3D data.  Gets the current value from the
-# slider and moves the cut plane to the appropriate point in the
-# data set.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::Slice {option args} {
-    switch -- $option {
-        "move" {
-            set axis [lindex $args 0]
-            set newval [lindex $args 1]
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Slice move x|y|z newval\""
-            }
-            set newpos [expr {0.01*$newval}]
-            SendCmd "renderer clipplane $axis $newpos -1"
-        }
-        "tooltip" {
-            set axis [lindex $args 0]
-            set val [$itk_component(${axis}CutScale) get]
-            return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
-        }
-        default {
-            error "bad option \"$option\": should be axis, move, or tooltip"
-        }
-    }
-}
-
-itcl::body Rappture::VtkViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
-
-itcl::body Rappture::VtkViewer::SetOpacity { dataset } {
-    foreach {dataobj comp} [split $dataset -] break
-    set type [$dataobj type $comp]
-    set val $_settings($type-opacity)
-    set sval [expr { 0.01 * double($val) }]
-    if { !$_obj2ovride($dataobj-raise) } {
-        # This is wrong.  Need to figure out why raise isn't set with 1
-        #set sval [expr $sval * .6]
-    }
-    SendCmd "$type opacity $sval $dataset"
-}
Index: trunk/gui/scripts/vtkvolumeviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkvolumeviewer.tcl	(revision 6716)
+++ 	(revision )
@@ -1,2416 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: vtkvolumeviewer - Vtk volume viewer
-#
-#  This widget performs volume rendering on 3D scalar/vector datasets.
-#  It connects to the Vtkvis server running on a rendering farm,
-#  transmits data, and displays the results.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2016  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-#package require Img
-
-option add *VtkVolumeViewer.width 4i widgetDefault
-option add *VtkVolumeViewer*cursor crosshair widgetDefault
-option add *VtkVolumeViewer.height 4i widgetDefault
-option add *VtkVolumeViewer.foreground black widgetDefault
-option add *VtkVolumeViewer.controlBackground gray widgetDefault
-option add *VtkVolumeViewer.controlDarkBackground #999999 widgetDefault
-option add *VtkVolumeViewer.plotBackground black widgetDefault
-option add *VtkVolumeViewer.plotForeground white widgetDefault
-option add *VtkVolumeViewer.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-# must use this name -- plugs into Rappture::resources::load
-proc VtkVolumeViewer_init_resources {} {
-    Rappture::resources::register \
-        vtkvis_server Rappture::VtkVolumeViewer::SetServerList
-}
-
-itcl::class Rappture::VtkVolumeViewer {
-    inherit Rappture::VisViewer
-
-    itk_option define -plotforeground plotForeground Foreground ""
-    itk_option define -plotbackground plotBackground Background ""
-
-    constructor { args } {
-        Rappture::VisViewer::constructor
-    } {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public proc SetServerList { namelist } {
-        Rappture::VisViewer::SetServerList "vtkvis" $namelist
-    }
-    public method add {dataobj {settings ""}}
-    public method camera {option args}
-    public method delete {args}
-    public method disconnect {}
-    public method download {option args}
-    public method get {args}
-    public method isconnected {}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method scale {args}
-
-    # The following methods are only used by this class.
-    private method AdjustSetting {what {value ""}}
-    private method BuildAxisTab {}
-    private method BuildCameraTab {}
-    private method BuildColormap { name colors }
-    private method BuildCutplanesTab {}
-    private method BuildDownloadPopup { widget command }
-    private method BuildViewTab {}
-    private method BuildVolumeTab {}
-    private method ChangeColormap { dataobj comp color }
-    private method Connect {}
-    private method CurrentDatasets {args}
-    private method Disconnect {}
-    private method DoResize {}
-    private method DoRotate {}
-    private method DrawLegend {}
-    private method EnterLegend { x y }
-    private method EventuallyRequestLegend {}
-    private method EventuallyResize { w h }
-    private method EventuallyRotate { q }
-    private method EventuallySetCutplane { axis args }
-    private method GetDatasetsWithComponent { cname }
-    private method GetImage { args }
-    private method GetVtkData { args }
-    private method InitSettings { args }
-    private method IsValidObject { dataobj }
-    private method LeaveLegend {}
-    private method LegendTitleAction { option }
-    private method MotionLegend { x y }
-    private method Pan {option x y}
-    private method PanCamera {}
-    private method Pick {x y}
-    private method QuaternionToView { q } {
-        foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break
-    }
-    private method Rebuild {}
-    private method ReceiveDataset { args }
-    private method ReceiveImage { args }
-    private method ReceiveLegend { colormap title min max size }
-    private method RequestLegend {}
-    private method Rotate {option x y}
-    private method SetColormap { dataobj comp }
-    private method SetCurrentFieldName { dataobj }
-    private method SetLegendTip { x y }
-    private method SetObjectStyle { dataobj cname }
-    private method SetOrientation { side }
-    private method Slice {option args}
-    private method ViewToQuaternion {} {
-        return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]
-    }
-    private method Zoom {option}
-
-    private variable _arcball ""
-    private variable _dlist "";         # list of data objects
-    private variable _obj2ovride;       # maps dataobj => style override
-    private variable _datasets;         # contains all the dataobj-component
-                                        # datasets in the server
-    private variable _colormaps;        # contains all the colormaps
-                                        # in the server.
-    private variable _dataset2style;    # maps dataobj-component to transfunc
-
-    private variable _reset 1;          # Connection to server has been reset.
-    private variable _click;            # Info used for rotate operations.
-    private variable _limits;           # Autoscale min/max for all axes
-    private variable _view;             # View params for 3D view
-    private variable _settings
-    private variable _style;            # Array of current component styles.
-    private variable _initialStyle;     # Array of initial component styles.
-
-    private variable _start 0
-    private variable _title ""
-    private variable _fields
-    private variable _curFldName ""
-    private variable _curFldLabel ""
-    private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar)
-    private variable _cutplaneCmd "imgcutplane"
-    private variable _allowMultiComponent 0
-
-    private variable _first "";         # This is the topmost dataset.
-    private variable _volcomponents;    # Maps component name to list of
-                                        # dataobj-component tags
-    private variable _componentsList;   # List of components found
-
-    private variable _width 0
-    private variable _height 0
-    private variable _resizePending 0
-    private variable _legendPending 0
-    private variable _rotatePending 0
-    private variable _cutplanePending 0
-
-    private common _downloadPopup;      # download options from popup
-    private common _hardcopy
-}
-
-itk::usual VtkVolumeViewer {
-    keep -background -foreground -cursor -font
-    keep -plotbackground -plotforeground
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::constructor {args} {
-    set _serverType "vtkvis"
-
-    #DebugOn
-    EnableWaitDialog 900
-
-    # Rebuild event
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    # Resize event
-    $_dispatcher register !resize
-    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
-
-    # Legend event
-    $_dispatcher register !legend
-    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
-
-    # Rotate event
-    $_dispatcher register !rotate
-    $_dispatcher dispatch $this !rotate "[itcl::code $this DoRotate]; list"
-
-    # X-Cutplane event
-    $_dispatcher register !xcutplane
-    $_dispatcher dispatch $this !xcutplane \
-        "[itcl::code $this AdjustSetting -xcutplaneposition]; list"
-
-    # Y-Cutplane event
-    $_dispatcher register !ycutplane
-    $_dispatcher dispatch $this !ycutplane \
-        "[itcl::code $this AdjustSetting -ycutplaneposition]; list"
-
-    # Z-Cutplane event
-    $_dispatcher register !zcutplane
-    $_dispatcher dispatch $this !zcutplane \
-        "[itcl::code $this AdjustSetting -zcutplaneposition]; list"
-
-    #
-    # Populate parser with commands handle incoming requests
-    #
-    $_parser alias image [itcl::code $this ReceiveImage]
-    $_parser alias legend [itcl::code $this ReceiveLegend]
-    $_parser alias dataset [itcl::code $this ReceiveDataset]
-
-    # Initialize the view to some default parameters.
-    array set _view {
-        -ortho    0
-        -qw       0.853553
-        -qx       -0.353553
-        -qy       0.353553
-        -qz       0.146447
-        -xpan     0
-        -ypan     0
-        -zoom     1.0
-    }
-    set _arcball [blt::arcball create 100 100]
-    $_arcball quaternion [ViewToQuaternion]
-
-    array set _settings {
-        -axesvisible            1
-        -axislabels             1
-        -axisminorticks         1
-        -axismode               "static"
-        -background             black
-        -color                  BCGYR
-        -cutplanelighting       1
-        -cutplaneopacity        100
-        -cutplanesvisible       0
-        -legendvisible          1
-        -volumelighting         1
-        -volumematerial         80
-        -volumeopacity          50
-        -volumeoutline          0
-        -volumequality          80
-        -volumevisible          1
-        -xcutplaneposition      50
-        -xcutplanevisible       1
-        -xgrid                  0
-        -ycutplaneposition      50
-        -ycutplanevisible       1
-        -ygrid                  0
-        -zcutplaneposition      50
-        -zcutplanevisible       1
-        -zgrid                  0
-    }
-
-    itk_component add view {
-        canvas $itk_component(plotarea).view \
-            -highlightthickness 0 -borderwidth 0
-    } {
-        usual
-        ignore -highlightthickness -borderwidth -background
-    }
-
-    itk_component add fieldmenu {
-        menu $itk_component(plotarea).menu -bg black -fg white -relief flat \
-            -tearoff 0
-    } {
-        usual
-        ignore -background -foreground -relief -tearoff
-    }
-    set c $itk_component(view)
-    bind $c <Configure> [itcl::code $this EventuallyResize %w %h]
-    bind $c <Control-F1> [itcl::code $this ToggleConsole]
-
-    # Fixes the scrollregion in case we go off screen
-    $c configure -scrollregion [$c bbox all]
-
-    set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1
-    set _map(cheight) -1
-    set _map(zoom) 1.0
-    set _map(original) ""
-
-    set f [$itk_component(main) component controls]
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(reset) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    itk_component add zoomin {
-        button $f.zin -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-in] \
-            -command [itcl::code $this Zoom in]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomin) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomin) "Zoom in"
-
-    itk_component add zoomout {
-        button $f.zout -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon zoom-out] \
-            -command [itcl::code $this Zoom out]
-    } {
-        usual
-        ignore -highlightthickness
-    }
-    pack $itk_component(zoomout) -side top -padx 2 -pady 2
-    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
-
-    itk_component add volume {
-        Rappture::PushButton $f.volume \
-            -onimage [Rappture::icon volume-on] \
-            -offimage [Rappture::icon volume-off] \
-            -variable [itcl::scope _settings(-volumevisible)] \
-            -command [itcl::code $this AdjustSetting -volumevisible]
-    }
-    $itk_component(volume) select
-    Rappture::Tooltip::for $itk_component(volume) \
-        "Don't display the volume"
-    pack $itk_component(volume) -padx 2 -pady 2
-
-    itk_component add cutplane {
-        Rappture::PushButton $f.cutplane \
-            -onimage [Rappture::icon cutbutton] \
-            -offimage [Rappture::icon cutbutton] \
-            -variable [itcl::scope _settings(-cutplanesvisible)] \
-            -command [itcl::code $this AdjustSetting -cutplanesvisible]
-    }
-    Rappture::Tooltip::for $itk_component(cutplane) \
-        "Show/Hide cutplanes"
-    pack $itk_component(cutplane) -padx 2 -pady 2
-
-    if { [catch {
-        BuildViewTab
-        BuildVolumeTab
-        BuildCutplanesTab
-        BuildAxisTab
-        BuildCameraTab
-    } errs] != 0 } {
-        puts stderr errs=$errs
-    }
-
-    # Legend
-    set _image(legend) [image create photo]
-    itk_component add legend {
-        canvas $itk_component(plotarea).legend -width 50 -highlightthickness 0
-    } {
-        usual
-        ignore -highlightthickness
-        rename -background -plotbackground plotBackground Background
-    }
-
-    # Hack around the Tk panewindow.  The problem is that the requested
-    # size of the 3d view isn't set until an image is retrieved from
-    # the server.  So the panewindow uses the tiny size.
-    set w 10000
-    pack forget $itk_component(view)
-    blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w
-    blt::table configure $itk_component(plotarea) c1 -resize none
-
-    # Bindings for rotation via mouse
-    bind $itk_component(view) <ButtonPress-1> \
-        [itcl::code $this Rotate click %x %y]
-    bind $itk_component(view) <B1-Motion> \
-        [itcl::code $this Rotate drag %x %y]
-    bind $itk_component(view) <ButtonRelease-1> \
-        [itcl::code $this Rotate release %x %y]
-
-    # Bindings for panning via mouse
-    bind $itk_component(view) <ButtonPress-2> \
-        [itcl::code $this Pan click %x %y]
-    bind $itk_component(view) <B2-Motion> \
-        [itcl::code $this Pan drag %x %y]
-    bind $itk_component(view) <ButtonRelease-2> \
-        [itcl::code $this Pan release %x %y]
-
-    #bind $itk_component(view) <ButtonRelease-3> \
-    #    [itcl::code $this Pick %x %y]
-
-    # Bindings for panning via keyboard
-    bind $itk_component(view) <KeyPress-Left> \
-        [itcl::code $this Pan set -10 0]
-    bind $itk_component(view) <KeyPress-Right> \
-        [itcl::code $this Pan set 10 0]
-    bind $itk_component(view) <KeyPress-Up> \
-        [itcl::code $this Pan set 0 -10]
-    bind $itk_component(view) <KeyPress-Down> \
-        [itcl::code $this Pan set 0 10]
-    bind $itk_component(view) <Shift-KeyPress-Left> \
-        [itcl::code $this Pan set -2 0]
-    bind $itk_component(view) <Shift-KeyPress-Right> \
-        [itcl::code $this Pan set 2 0]
-    bind $itk_component(view) <Shift-KeyPress-Up> \
-        [itcl::code $this Pan set 0 -2]
-    bind $itk_component(view) <Shift-KeyPress-Down> \
-        [itcl::code $this Pan set 0 2]
-
-    # Bindings for zoom via keyboard
-    bind $itk_component(view) <KeyPress-Prior> \
-        [itcl::code $this Zoom out]
-    bind $itk_component(view) <KeyPress-Next> \
-        [itcl::code $this Zoom in]
-
-    bind $itk_component(view) <Enter> "focus $itk_component(view)"
-
-    if {[string equal "x11" [tk windowingsystem]]} {
-        # Bindings for zoom via mouse
-        bind $itk_component(view) <4> [itcl::code $this Zoom out]
-        bind $itk_component(view) <5> [itcl::code $this Zoom in]
-    }
-
-    set _image(download) [image create photo]
-
-    eval itk_initialize $args
-    Connect
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::destructor {} {
-    Disconnect
-    image delete $_image(plot)
-    image delete $_image(download)
-    catch { blt::arcball destroy $_arcball }
-}
-
-itcl::body Rappture::VtkVolumeViewer::DoResize {} {
-    if { $_width < 2 } {
-        set _width 500
-    }
-    if { $_height < 2 } {
-        set _height 500
-    }
-    set _start [clock clicks -milliseconds]
-    SendCmd "screen size $_width $_height"
-
-    EventuallyRequestLegend
-    set _resizePending 0
-}
-
-itcl::body Rappture::VtkVolumeViewer::DoRotate {} {
-    SendCmd "camera orient [ViewToQuaternion]"
-    set _rotatePending 0
-}
-
-itcl::body Rappture::VtkVolumeViewer::EventuallyResize { w h } {
-    set _width $w
-    set _height $h
-    $_arcball resize $w $h
-    if { !$_resizePending } {
-        set _resizePending 1
-        $_dispatcher event -after 400 !resize
-    }
-}
-
-itcl::body Rappture::VtkVolumeViewer::EventuallyRequestLegend {} {
-    if { !$_legendPending } {
-        set _legendPending 1
-        $_dispatcher event -idle !legend
-    }
-}
-
-itcl::body Rappture::VtkVolumeViewer::EventuallyRotate { q } {
-    QuaternionToView $q
-    if { !$_rotatePending } {
-        set _rotatePending 1
-        $_dispatcher event -after 100 !rotate
-    }
-}
-
-itcl::body Rappture::VtkVolumeViewer::EventuallySetCutplane { axis args } {
-    if { !$_cutplanePending } {
-        set _cutplanePending 1
-        $_dispatcher event -after 100 !${axis}cutplane
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a data object to the plot.  The optional
-# <settings> are used to configure the plot.  Allowed settings are
-# -color, -brightness, -width, -linestyle, and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::add {dataobj {settings ""}} {
-    DebugTrace "Enter"
-    if { ![IsValidObject $dataobj] } {
-        DebugTrace "Invalid"
-        return;                         # Ignore invalid objects.
-    }
-    array set params {
-        -color auto
-        -width 1
-        -linestyle solid
-        -brightness 0
-        -raise 0
-        -description ""
-        -param ""
-        -type ""
-    }
-    array set params $settings
-
-    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
-        # can't handle -autocolors yet
-        set params(-color) black
-    }
-    set pos [lsearch -exact $_dlist $dataobj]
-    if {$pos < 0} {
-        lappend _dlist $dataobj
-    }
-    set _obj2ovride($dataobj-color) $params(-color)
-    set _obj2ovride($dataobj-width) $params(-width)
-    set _obj2ovride($dataobj-raise) $params(-raise)
-    $_dispatcher event -idle !rebuild
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.  No data objects are
-# deleted.  They are only removed from the display list.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::delete {args} {
-    DebugTrace "Enter"
-    if { [llength $args] == 0} {
-        set args $_dlist
-    }
-    # Delete all specified dataobjs
-    set changed 0
-    foreach dataobj $args {
-        set pos [lsearch -exact $_dlist $dataobj]
-        if { $pos < 0 } {
-            continue;                   # Don't know anything about it.
-        }
-        # Remove it from the dataobj list.
-        set _dlist [lreplace $_dlist $pos $pos]
-        array unset _obj2ovride $dataobj-*
-        set changed 1
-    }
-    # If anything changed, then rebuild the plot
-    if { $changed } {
-        $_dispatcher event -idle !rebuild
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get ?-objects?
-# USAGE: get ?-visible?
-# USAGE: get ?-image view?
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.  The optional "-image"
-# flag can also request the internal images being shown.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::get {args} {
-    if {[llength $args] == 0} {
-        set args "-objects"
-    }
-
-    set op [lindex $args 0]
-    switch -- $op {
-        "-objects" {
-            # put the dataobj list in order according to -raise options
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if {[info exists _obj2ovride($dataobj-raise)] &&
-                    $_obj2ovride($dataobj-raise)} {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-visible" {
-            set dlist {}
-            foreach dataobj $_dlist {
-                if { ![IsValidObject $dataobj] } {
-                    continue
-                }
-                if { ![info exists _obj2ovride($dataobj-raise)] } {
-                    # No setting indicates that the object isn't visible.
-                    continue
-                }
-                # Otherwise use the -raise parameter to put the object to
-                # the front of the list.
-                if { $_obj2ovride($dataobj-raise) } {
-                    set dlist [linsert $dlist 0 $dataobj]
-                } else {
-                    lappend dlist $dataobj
-                }
-            }
-            return $dlist
-        }
-        "-image" {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"get -image view\""
-            }
-            switch -- [lindex $args end] {
-                view {
-                    return $_image(plot)
-                }
-                default {
-                    error "bad image name \"[lindex $args end]\": should be view"
-                }
-            }
-        }
-        default {
-            error "bad option \"$op\": should be -objects, -visible or -image"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<data1> <data2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <data> objects.  This
-# accounts for all objects--even those not showing on the screen.
-# Because of this, the limits are appropriate for all objects as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::scale {args} {
-    DebugTrace "Enter"
-    array unset _limits
-    array unset _volcomponents
-    set _componentsList ""
-
-    foreach dataobj $args {
-        if { ![$dataobj isvalid] } {
-            continue;                     # Object doesn't contain valid data.
-        }
-        # Determine limits for each axis.
-        foreach axis { x y z } {
-            set lim [$dataobj limits $axis]
-            if { ![info exists _limits($axis)] } {
-                set _limits($axis) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {amin amax} $_limits($axis) break
-            if { $amin > $min } {
-                set amin $min
-            }
-            if { $amax < $max } {
-                set amax $max
-            }
-            set _limits($axis) [list $amin $amax]
-        }
-        # Determine limits for each field.
-        foreach { fname lim } [$dataobj fieldlimits] {
-            if { ![info exists _limits($fname)] } {
-                set _limits($fname) $lim
-                continue
-            }
-            foreach {min max} $lim break
-            foreach {fmin fmax} $_limits($fname) break
-            if { $fmin > $min } {
-                set fmin $min
-            }
-            if { $fmax < $max } {
-                set fmax $max
-            }
-            set _limits($fname) [list $fmin $fmax]
-        }
-        # Get limits for each component.
-        foreach cname [$dataobj components] {
-            if { ![info exists _volcomponents($cname)] } {
-                lappend _componentsList $cname
-            }
-            lappend _volcomponents($cname) $dataobj-$cname
-            array unset limits
-            array set limits [$dataobj valueLimits $cname]
-            if { ![info exists _limits($cname)] } {
-                set _limits($cname) $limits(v)
-                continue
-            }
-            foreach {min max} $limits(v) break
-            foreach {vmin vmax} $_limits($cname) break
-            if { $vmin > $min } {
-                set vmin $min
-            }
-            if { $vmax < $max } {
-                set vmax $max
-            }
-            set _limits($cname) [list $vmin $vmax]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::download {option args} {
-    switch $option {
-        coming {
-            if {[catch {
-                blt::winop snap $itk_component(plotarea) $_image(download)
-            }]} {
-                $_image(download) configure -width 1 -height 1
-                $_image(download) put #000000
-            }
-        }
-        controls {
-            set popup .vtkviewerdownload
-            if { ![winfo exists .vtkviewerdownload] } {
-                set inner [BuildDownloadPopup $popup [lindex $args 0]]
-            } else {
-                set inner [$popup component inner]
-            }
-            set _downloadPopup(image_controls) $inner.image_frame
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            set word [Rappture::filexfer::label downloadWord]
-            $inner.summary configure -text "$word $num in the following format:"
-            update idletasks            ;# Fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .vtkviewerdownload
-            if {[winfo exists .vtkviewerdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                "image" {
-                    return [$this GetImage [lindex $args 0]]
-                }
-                "vtk" {
-                    return [$this GetVtkData [lindex $args 0]]
-                }
-            }
-            return ""
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Connect ?<host:port>,<host:port>...?
-#
-# Clients use this method to establish a connection to a new
-# server, or to reestablish a connection to the previous server.
-# Any existing connection is automatically closed.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::Connect {} {
-    set _hosts [GetServerList "vtkvis"]
-    if { "" == $_hosts } {
-        return 0
-    }
-    set _reset 1
-    set result [VisViewer::Connect $_hosts]
-    if { $result } {
-        if { $_reportClientInfo }  {
-            # Tell the server the viewer, hub, user and session.
-            # Do this immediately on connect before buffering any commands
-            global env
-
-            set info {}
-            set user "???"
-            if { [info exists env(USER)] } {
-                set user $env(USER)
-            }
-            set session "???"
-            if { [info exists env(SESSION)] } {
-                set session $env(SESSION)
-            }
-            lappend info "version" "$Rappture::version"
-            lappend info "build" "$Rappture::build"
-            lappend info "svnurl" "$Rappture::svnurl"
-            lappend info "installdir" "$Rappture::installdir"
-            lappend info "hub" [exec hostname]
-            lappend info "client" "vtkvolumeviewer"
-            lappend info "user" $user
-            lappend info "session" $session
-            SendCmd "clientinfo [list $info]"
-        }
-
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-# Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkVolumeViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkVolumeViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-# Clients use this method to disconnect from the current rendering server.
-#
-itcl::body Rappture::VtkVolumeViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    $_dispatcher cancel !rebuild
-    $_dispatcher cancel !resize
-    $_dispatcher cancel !rotate
-    $_dispatcher cancel !xcutplane
-    $_dispatcher cancel !ycutplane
-    $_dispatcher cancel !zcutplane
-    $_dispatcher cancel !legend
-    # disconnected -- no more data sitting on server
-    array unset _datasets
-    array unset _colormaps
-    array unset _dataset2style
-
-    set _resizePending 0
-    set _rotatePending 0
-    set _cutplanePending 0
-    set _legendPending 0
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::ReceiveImage { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    StopWaiting
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"]
-            fconfigure $f -encoding binary
-            puts -nonewline $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        #puts stderr "[clock format [clock seconds]]: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            #puts stderr "round trip time [expr $finish -$_start] milliseconds"
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkVolumeViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::Rebuild {} {
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        update
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # Turn on buffering of commands to the server.  We don't want to
-    # be preempted by a server disconnect/reconnect (which automatically
-    # generates a new call to Rebuild).
-    StartBufferingCommands
-
-    if { $_width != $w || $_height != $h || $_reset } {
-        set _width $w
-        set _height $h
-        $_arcball resize $w $h
-        DoResize
-    }
-    if { $_reset } {
-        #
-        # Reset the camera and other view parameters
-        #
-        $_arcball quaternion [ViewToQuaternion]
-        if {$_view(-ortho)} {
-            SendCmd "camera mode ortho"
-        } else {
-            SendCmd "camera mode persp"
-        }
-        DoRotate
-        PanCamera
-        set _first ""
-        InitSettings -background \
-            -xgrid -ygrid -zgrid -axismode \
-            -axesvisible -axislabels -axisminorticks
-        StopBufferingCommands
-        SendCmd "imgflush"
-        StartBufferingCommands
-    }
-
-    set _first ""
-    # No volumes are active (i.e. in the working set of displayed volumes).
-    # A volume is always invisible if it's not in the working set.  A
-    # volume in the working set may be visible/invisible depending upon the
-    # global visibility value.
-    SendCmd "dataset visible 0"
-    foreach dataobj [get -objects] {
-        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
-            set _first $dataobj
-            SetCurrentFieldName $dataobj
-        }
-        foreach cname [$dataobj components] {
-            set tag $dataobj-$cname
-            if { ![info exists _datasets($tag)] } {
-                set bytes [$dataobj vtkdata $cname]
-                if 0 {
-                    set f [open /tmp/vtkvolume.vtk "w"]
-                    fconfigure $f -translation binary -encoding binary
-                    puts -nonewline $f $bytes
-                    close $f
-                }
-                set length [string length $bytes]
-                if { $_reportClientInfo }  {
-                    set info {}
-                    lappend info "tool_id"       [$dataobj hints toolid]
-                    lappend info "tool_name"     [$dataobj hints toolname]
-                    lappend info "tool_title"    [$dataobj hints tooltitle]
-                    lappend info "tool_command"  [$dataobj hints toolcommand]
-                    lappend info "tool_revision" [$dataobj hints toolrevision]
-                    lappend info "dataset_label" [$dataobj hints label]
-                    lappend info "dataset_size"  $length
-                    lappend info "dataset_tag"   $tag
-                    SendCmd "clientinfo [list $info]"
-                }
-                SendCmd "dataset add $tag data follows $length"
-                SendData $bytes
-                set _datasets($tag) 1
-                SetObjectStyle $dataobj $cname
-            }
-            if { [info exists _obj2ovride($dataobj-raise)] } {
-                SendCmd "volume visible 1 $tag"
-            }
-            break
-        }
-    }
-    if {"" != $_first} {
-        foreach axis { x y z } {
-            set label [$_first hints ${axis}label]
-            if { $label != "" } {
-                SendCmd [list axis name $axis $label]
-            }
-            set units [$_first hints ${axis}units]
-            if { $units != "" } {
-                SendCmd [list axis units $axis $units]
-            }
-        }
-    }
-
-    InitSettings -color \
-        -volumevisible \
-        -volumematerial \
-        -volumelighting -volumeopacity -volumequality -volumeoutline \
-        -cutplanesvisible \
-        -xcutplaneposition -ycutplaneposition -zcutplaneposition \
-        -xcutplanevisible -ycutplanevisible -zcutplanevisible
-
-    if { $_reset } {
-        SendCmd "camera reset"
-        SendCmd "camera zoom $_view(-zoom)"
-        RequestLegend
-        set _reset 0
-    }
-    # Actually write the commands to the server socket.  If it fails, we don't
-    # care.  We're finished here.
-    blt::busy hold $itk_component(hull)
-    StopBufferingCommands
-    blt::busy release $itk_component(hull)
-}
-
-# ----------------------------------------------------------------------
-# USAGE: CurrentDatasets ?-all -visible? ?dataobjs?
-#
-# Returns a list of server IDs for the current datasets being displayed.  This
-# is normally a single ID, but it might be a list of IDs if the current data
-# object has multiple components.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::CurrentDatasets {args} {
-    set flag [lindex $args 0]
-    switch -- $flag {
-        "-all" {
-            if { [llength $args] > 1 } {
-                error "CurrentDatasets: can't specify dataobj after \"-all\""
-            }
-            set dlist [get -objects]
-        }
-        "-visible" {
-            if { [llength $args] > 1 } {
-                set dlist {}
-                set args [lrange $args 1 end]
-                foreach dataobj $args {
-                    if { [info exists _obj2ovride($dataobj-raise)] } {
-                        lappend dlist $dataobj
-                    }
-                }
-            } else {
-                set dlist [get -visible]
-            }
-        }
-        default {
-            set dlist $args
-        }
-    }
-    set rlist ""
-    foreach dataobj $dlist {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _datasets($tag)] && $_datasets($tag) } {
-                lappend rlist $tag
-            }
-        }
-    }
-    return $rlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom in
-# USAGE: Zoom out
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::Zoom {option} {
-    switch -- $option {
-        "in" {
-            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "out" {
-            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
-            SendCmd "camera zoom $_view(-zoom)"
-        }
-        "reset" {
-            array set _view {
-                -qw      0.853553
-                -qx      -0.353553
-                -qy      0.353553
-                -qz      0.146447
-                -xpan    0
-                -ypan    0
-                -zoom    1.0
-            }
-            if { $_first != "" } {
-                set location [$_first hints camera]
-                if { $location != "" } {
-                    array set _view $location
-                }
-            }
-            $_arcball quaternion [ViewToQuaternion]
-            DoRotate
-            SendCmd "camera reset"
-        }
-    }
-}
-
-itcl::body Rappture::VtkVolumeViewer::PanCamera {} {
-    set x $_view(-xpan)
-    set y $_view(-ypan)
-    SendCmd "camera pan $x $y"
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rotate click <x> <y>
-# USAGE: Rotate drag <x> <y>
-# USAGE: Rotate release <x> <y>
-#
-# Called automatically when the user clicks/drags/releases in the
-# plot area.  Moves the plot according to the user's actions.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::Rotate {option x y} {
-    switch -- $option {
-        "click" {
-            $itk_component(view) configure -cursor fleur
-            set _click(x) $x
-            set _click(y) $y
-        }
-        "drag" {
-            if {[array size _click] == 0} {
-                Rotate click $x $y
-            } else {
-                set w [winfo width $itk_component(view)]
-                set h [winfo height $itk_component(view)]
-                if {$w <= 0 || $h <= 0} {
-                    return
-                }
-
-                if {[catch {
-                    # this fails sometimes for no apparent reason
-                    set dx [expr {double($x-$_click(x))/$w}]
-                    set dy [expr {double($y-$_click(y))/$h}]
-                }]} {
-                    return
-                }
-                if { $dx == 0 && $dy == 0 } {
-                    return
-                }
-                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
-                EventuallyRotate $q
-                set _click(x) $x
-                set _click(y) $y
-            }
-        }
-        "release" {
-            Rotate drag $x $y
-            $itk_component(view) configure -cursor ""
-            catch {unset _click}
-        }
-        default {
-            error "bad option \"$option\": should be click, drag, release"
-        }
-    }
-}
-
-itcl::body Rappture::VtkVolumeViewer::Pick {x y} {
-    foreach tag [CurrentDatasets -visible] {
-        SendCmd "dataset getscalar pixel $x $y $tag"
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: $this Pan click x y
-#        $this Pan drag x y
-#        $this Pan release x y
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::Pan {option x y} {
-    switch -- $option {
-        "set" {
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set x [expr $x / double($w)]
-            set y [expr $y / double($h)]
-            set _view(-xpan) [expr $_view(-xpan) + $x]
-            set _view(-ypan) [expr $_view(-ypan) + $y]
-            PanCamera
-            return
-        }
-        "click" {
-            set _click(x) $x
-            set _click(y) $y
-            $itk_component(view) configure -cursor hand1
-        }
-        "drag" {
-            if { ![info exists _click(x)] } {
-                set _click(x) $x
-            }
-            if { ![info exists _click(y)] } {
-                set _click(y) $y
-            }
-            set w [winfo width $itk_component(view)]
-            set h [winfo height $itk_component(view)]
-            set dx [expr ($_click(x) - $x)/double($w)]
-            set dy [expr ($_click(y) - $y)/double($h)]
-            set _click(x) $x
-            set _click(y) $y
-            set _view(-xpan) [expr $_view(-xpan) - $dx]
-            set _view(-ypan) [expr $_view(-ypan) - $dy]
-            PanCamera
-        }
-        "release" {
-            Pan drag $x $y
-            $itk_component(view) configure -cursor ""
-        }
-        default {
-            error "unknown option \"$option\": should set, click, drag, or release"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: InitSettings <what> ?<value>?
-#
-# Used internally to update rendering settings whenever parameters
-# change in the popup settings panel.  Sends the new settings off
-# to the back end.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::InitSettings { args } {
-    foreach spec $args {
-        AdjustSetting $spec
-    }
-}
-
-#
-# AdjustSetting --
-#
-# Changes/updates a specific setting in the widget.  There are
-# usually user-setable option.  Commands are sent to the render
-# server.
-#
-itcl::body Rappture::VtkVolumeViewer::AdjustSetting {what {value ""}} {
-    if { ![isconnected] } {
-        return
-    }
-    switch -- $what {
-        "-axesvisible" {
-            set bool $_settings($what)
-            SendCmd "axis visible all $bool"
-        }
-        "-axislabels" {
-            set bool $_settings($what)
-            SendCmd "axis labels all $bool"
-        }
-        "-axisminorticks" {
-            set bool $_settings($what)
-            SendCmd "axis minticks all $bool"
-        }
-        "-axismode" {
-            set mode [$itk_component(axismode) value]
-            set mode [$itk_component(axismode) translate $mode]
-            set _settings($what) $mode
-            SendCmd "axis flymode $mode"
-        }
-        "-background" {
-            set bgcolor [$itk_component(background) value]
-            set _settings($what) $bgcolor
-            array set fgcolors {
-                "black" "white"
-                "white" "black"
-                "grey"  "black"
-            }
-            configure -plotbackground $bgcolor \
-                -plotforeground $fgcolors($bgcolor)
-            $itk_component(view) delete "legend"
-            DrawLegend
-        }
-        "-color" {
-            set color [$itk_component(colormap) value]
-            set _settings($what) $color
-            foreach dataset [CurrentDatasets -visible $_first] {
-                foreach {dataobj comp} [split $dataset -] break
-                ChangeColormap $dataobj $comp $color
-            }
-            EventuallyRequestLegend
-        }
-        "-cutplanelighting" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible] {
-                if {$_cutplaneCmd != "imgcutplane"} {
-                    SendCmd "$_cutplaneCmd lighting $bool $dataset"
-                } else {
-                    if {$bool} {
-                        set ambient 0.0
-                        set diffuse 1.0
-                    } else {
-                        set ambient 1.0
-                        set diffuse 0.0
-                    }
-                    SendCmd "imgcutplane material $ambient $diffuse $dataset"
-                }
-            }
-        }
-        "-cutplaneopacity" {
-            set val $_settings($what)
-            set sval [expr { 0.01 * double($val) }]
-            foreach dataset [CurrentDatasets -visible] {
-                SendCmd "$_cutplaneCmd opacity $sval $dataset"
-            }
-        }
-        "-cutplanesvisible" {
-            set bool $_settings($what)
-            foreach dataset [CurrentDatasets -visible] {
-                SendCmd "$_cutplaneCmd visible $bool $dataset"
-            }
-        }
-        "-field" {
-            set label [$itk_component(field) value]
-            set fname [$itk_component(field) translate $label]
-            set _settings($what) $fname
-            if { [info exists _fields($fname)] } {
-                foreach { label units components } $_fields($fname) break
-                if { !$_allowMultiComponent && $components > 1 } {
-                    puts stderr "Can't use a vector field in a volume"
-                    return
-                } else {
-                    if { $components > 1 } {
-                        set _colorMode vmag
-                    } else {
-                        set _colorMode scalar
-                    }
-                }
-                set _curFldName $fname
-                set _curFldLabel $label
-            } else {
-                puts stderr "unknown field \"$fname\""
-                return
-            }
-            foreach dataset [CurrentDatasets -visible $_first] {
-                #SendCmd [list $_cutplaneCmd colormode $_colorMode $_curFldName $dataset]
-                SendCmd [list dataset scalar $_curFldName $dataset]
-            }
-            SendCmd "camera reset"
-            DrawLegend
-        }
-        "-legendvisible" {
-            DrawLegend
-        }
-        "-volumematerial" {
-            set val $_settings($what)
-            set diffuse [expr {0.01*$val}]
-            set specular [expr {0.01*$val}]
-            #set power [expr {sqrt(160*$val+1.0)}]
-            set power [expr {$val+1.0}]
-            foreach tag [CurrentDatasets -visible] {
-                SendCmd "volume shading diffuse $diffuse $tag"
-                SendCmd "volume shading specular $specular $power $tag"
-            }
-        }
-        "-volumelighting" {
-            set bool $_settings($what)
-            foreach tag [CurrentDatasets -visible] {
-                SendCmd "volume lighting $bool $tag"
-            }
-        }
-        "-volumeopacity" {
-            set val $_settings($what)
-            set val [expr {0.01*$val}]
-            foreach tag [CurrentDatasets -visible] {
-                SendCmd "volume opacity $val $tag"
-            }
-        }
-        "-volumeoutline" {
-            set bool $_settings($what)
-            SendCmd "outline visible 0"
-            foreach tag [CurrentDatasets -visible] {
-                SendCmd "outline visible $bool $tag"
-            }
-        }
-        "-volumequality" {
-            set val $_settings($what)
-            set val [expr {0.01*$val}]
-            foreach tag [CurrentDatasets -visible] {
-                SendCmd "volume quality $val $tag"
-            }
-        }
-        "-volumevisible" {
-            set bool $_settings($what)
-            foreach tag [CurrentDatasets -visible] {
-                SendCmd "volume visible $bool $tag"
-            }
-            if { $bool } {
-                Rappture::Tooltip::for $itk_component(volume) \
-                    "Hide the volume"
-            } else {
-                Rappture::Tooltip::for $itk_component(volume) \
-                    "Show the volume"
-            }
-        }
-        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
-            set axis [string range $what 1 1]
-            set bool $_settings($what)
-            if { $bool } {
-                $itk_component(${axis}CutScale) configure -state normal \
-                    -troughcolor white
-            } else {
-                $itk_component(${axis}CutScale) configure -state disabled \
-                    -troughcolor grey82
-            }
-            foreach dataset [CurrentDatasets -visible] {
-                SendCmd "$_cutplaneCmd axis $axis $bool $dataset"
-            }
-        }
-        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
-            set axis [string range $what 1 1]
-            set pos [expr $_settings($what) * 0.01]
-            foreach dataset [CurrentDatasets -visible] {
-                SendCmd "$_cutplaneCmd slice ${axis} ${pos} $dataset"
-            }
-            set _cutplanePending 0
-        }
-        "-xgrid" - "-ygrid" - "-zgrid" {
-            set axis [string range $what 1 1]
-            set bool $_settings($what)
-            SendCmd "axis grid $axis $bool"
-        }
-        default {
-            error "don't know how to fix $what"
-        }
-    }
-}
-
-#
-# RequestLegend --
-#
-# Request a new legend from the server.  The size of the legend
-# is determined from the height of the canvas.
-#
-itcl::body Rappture::VtkVolumeViewer::RequestLegend {} {
-    set _legendPending 0
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-    set w 12
-    set h [expr {$_height - 3 * ($lineht + 2)}]
-    if { $h < 1 } {
-        return
-    }
-    # Set the legend on the first dataset.
-    foreach dataset [CurrentDatasets -visible $_first] {
-        foreach {dataobj comp} [split $dataset -] break
-        if { [info exists _dataset2style($dataset)] } {
-            #SendCmd [list legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0]
-            SendCmd "legend2 $_dataset2style($dataset) $w $h"
-            break;
-        }
-    }
-}
-
-#
-# ChangeColormap --
-#
-itcl::body Rappture::VtkVolumeViewer::ChangeColormap {dataobj comp color} {
-    set tag $dataobj-$comp
-    if { ![info exist _style($tag)] } {
-        error "no initial colormap"
-    }
-    array set style $_style($tag)
-    set style(-color) $color
-    set _style($tag) [array get style]
-    SetColormap $dataobj $comp
-}
-
-#
-# SetColormap --
-#
-itcl::body Rappture::VtkVolumeViewer::SetColormap { dataobj comp } {
-    array set style {
-        -color BCGYR
-        -levels 6
-    }
-    set tag $dataobj-$comp
-    if { ![info exists _initialStyle($tag)] } {
-        # Save the initial component style.
-        set _initialStyle($tag) [$dataobj style $comp]
-    }
-
-    # Override defaults with initial style defined in xml.
-    array set style $_initialStyle($tag)
-
-    if { ![info exists _style($tag)] } {
-        set _style($tag) [array get style]
-    }
-    # Override initial style with current style.
-    array set style $_style($tag)
-
-    set name "$style(-color):$style(-levels)"
-    if { ![info exists _colormaps($name)] } {
-        BuildColormap $name [array get style]
-        set _colormaps($name) 1
-    }
-    if { ![info exists _dataset2style($tag)] ||
-         $_dataset2style($tag) != $name } {
-        SendCmd "volume colormap $name $tag"
-        SendCmd "$_cutplaneCmd colormap $name-opaque $tag"
-        set _dataset2style($tag) $name
-    }
-}
-
-#
-# BuildColormap --
-#
-# Alpha map is in the format: normalized_value opacity midpoint sharpness
-#
-itcl::body Rappture::VtkVolumeViewer::BuildColormap { name styles } {
-    array set style $styles
-    set cmap [ColorsToColormap $style(-color)]
-    if { [llength $cmap] == 0 } {
-        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
-    }
-
-    set amap "0.0 0.0 0.5 0.0 1.0 1.0 0.5 0.0"
-    set opaqueAmap "0.0 1.0 1.0 1.0"
-    SendCmd [list colormap define $name $cmap -spline $amap]
-    SendCmd [list colormap define $name-opaque $cmap $opaqueAmap]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotbackground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkVolumeViewer::plotbackground {
-    if { [isconnected] } {
-        set color $itk_option(-plotbackground)
-        set rgb [Color2RGB $color]
-        SendCmd "screen bgcolor $rgb"
-        $itk_component(legend) configure -background $color
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -plotforeground
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::VtkVolumeViewer::plotforeground {
-    if { [isconnected] } {
-        set color $itk_option(-plotforeground)
-        set rgb [Color2RGB $color]
-        SendCmd "axis color all $rgb"
-        SendCmd "outline color $rgb"
-        SendCmd "$_cutplaneCmd color $rgb"
-        $itk_component(legend) itemconfigure labels -fill $color
-        $itk_component(legend) itemconfigure limits -fill $color
-    }
-}
-
-itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} {
-    set font [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "View Settings" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.axes \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font $font
-
-    checkbutton $inner.outline \
-        -text "Outline" \
-        -variable [itcl::scope _settings(-volumeoutline)] \
-        -command [itcl::code $this AdjustSetting -volumeoutline] \
-        -font $font
-
-    checkbutton $inner.legend \
-        -text "Legend" \
-        -variable [itcl::scope _settings(-legendvisible)] \
-        -command [itcl::code $this AdjustSetting -legendvisible] \
-        -font $font
-
-    checkbutton $inner.volume \
-        -text "Volume" \
-        -variable [itcl::scope _settings(-volumevisible)] \
-        -command [itcl::code $this AdjustSetting -volumevisible] \
-        -font $font
-
-    label $inner.background_l -text "Background" -font $font
-    itk_component add background {
-        Rappture::Combobox $inner.background -width 10 -editable 0
-    }
-    $inner.background choices insert end \
-        "black" "black" \
-        "white" "white" \
-        "grey"  "grey"
-
-    $itk_component(background) value $_settings(-background)
-    bind $inner.background <<Value>> \
-        [itcl::code $this AdjustSetting -background]
-
-    blt::table $inner \
-        0,0 $inner.axes -cspan 2 -anchor w \
-        1,0 $inner.outline -cspan 2 -anchor w \
-        2,0 $inner.volume -cspan 2 -anchor w \
-        3,0 $inner.legend -cspan 2 -anchor w \
-        4,0 $inner.background_l -anchor e -pady 2 \
-        4,1 $inner.background -fill x
-
-    blt::table configure $inner r* -resize none
-    blt::table configure $inner r5 -resize expand
-}
-
-itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} {
-    set font [option get $itk_component(hull) font Font]
-    #set bfont [option get $itk_component(hull) boldFont Font]
-    set bfont "Arial 9 bold"
-
-    set inner [$itk_component(main) insert end \
-        -title "Volume Settings" \
-        -icon [Rappture::icon volume-on]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visibility \
-        -text "Visible" \
-        -font $font \
-        -variable [itcl::scope _settings(-volumevisible)] \
-        -command [itcl::code $this AdjustSetting -volumevisible]
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -font $font \
-        -variable [itcl::scope _settings(-volumelighting)] \
-        -command [itcl::code $this AdjustSetting -volumelighting]
-
-    label $inner.dim_l -text "Dim" -font $font
-    ::scale $inner.material -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-volumematerial)] \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -volumematerial]
-    label $inner.bright_l -text "Bright" -font $font
-
-    label $inner.opacity_l -text "Opacity" -font $font
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-volumeopacity)] \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -volumeopacity]
-
-    label $inner.quality_l -text "Quality" -font $font
-    ::scale $inner.quality -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-volumequality)] \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -volumequality]
-
-    label $inner.field_l -text "Field" -font $font
-    itk_component add field {
-        Rappture::Combobox $inner.field -editable 0
-    }
-    bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting -field]
-
-    label $inner.colormap_l -text "Colormap" -font $font
-    itk_component add colormap {
-        Rappture::Combobox $inner.colormap -editable 0
-    }
-    $inner.colormap choices insert end [GetColormapList]
-    bind $inner.colormap <<Value>> \
-        [itcl::code $this AdjustSetting -color]
-    $itk_component(colormap) value $_settings(-color)
-
-    blt::table $inner \
-        0,0 $inner.field_l -anchor w -pady 2 \
-        0,1 $inner.field -fill x -pady 2 -cspan 3 \
-        1,0 $inner.visibility -anchor w -pady 2 -cspan 4 \
-        2,0 $inner.lighting -anchor w -pady 2 -cspan 4 \
-        3,0 $inner.dim_l -anchor e -pady 2 \
-        3,1 $inner.material -fill x -pady 2 -cspan 2 \
-        3,3 $inner.bright_l -anchor w -pady 2 \
-        4,0 $inner.opacity_l -anchor w -pady 2 -cspan 4 \
-        5,0 $inner.opacity -fill x -pady 2 -cspan 4 \
-        6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \
-        7,0 $inner.quality -fill x -pady 2 -cspan 4 \
-        8,0 $inner.colormap_l -anchor w -pady 2 \
-        8,1 $inner.colormap -fill x -pady 2 -cspan 3
-
-    blt::table configure $inner r* c0 c1 c3 -resize none
-    blt::table configure $inner r9 c2 -resize expand
-}
-
-itcl::body Rappture::VtkVolumeViewer::BuildAxisTab {} {
-    set font [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Axis Settings" \
-        -icon [Rappture::icon axis2]]
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Axes" \
-        -variable [itcl::scope _settings(-axesvisible)] \
-        -command [itcl::code $this AdjustSetting -axesvisible] \
-        -font $font
-
-    checkbutton $inner.labels \
-        -text "Axis Labels" \
-        -variable [itcl::scope _settings(-axislabels)] \
-        -command [itcl::code $this AdjustSetting -axislabels] \
-        -font $font
-    label $inner.grid_l -text "Grid" -font $font
-    checkbutton $inner.xgrid \
-        -text "X" \
-        -variable [itcl::scope _settings(-xgrid)] \
-        -command [itcl::code $this AdjustSetting -xgrid] \
-        -font $font
-    checkbutton $inner.ygrid \
-        -text "Y" \
-        -variable [itcl::scope _settings(-ygrid)] \
-        -command [itcl::code $this AdjustSetting -ygrid] \
-        -font $font
-    checkbutton $inner.zgrid \
-        -text "Z" \
-        -variable [itcl::scope _settings(-zgrid)] \
-        -command [itcl::code $this AdjustSetting -zgrid] \
-        -font $font
-    checkbutton $inner.minorticks \
-        -text "Minor Ticks" \
-        -variable [itcl::scope _settings(-axisminorticks)] \
-        -command [itcl::code $this AdjustSetting -axisminorticks] \
-        -font $font
-
-    label $inner.mode_l -text "Mode" -font $font
-
-    itk_component add axismode {
-        Rappture::Combobox $inner.mode -width 10 -editable 0
-    }
-    $inner.mode choices insert end \
-        "static_triad"    "static" \
-        "closest_triad"   "closest" \
-        "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"
-    $itk_component(axismode) value $_settings(-axismode)
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
-
-    blt::table $inner \
-        0,0 $inner.visible -anchor w -cspan 4 \
-        1,0 $inner.labels -anchor w -cspan 4 \
-        2,0 $inner.minorticks -anchor w -cspan 4 \
-        4,0 $inner.grid_l -anchor w \
-        4,1 $inner.xgrid -anchor w \
-        4,2 $inner.ygrid -anchor w \
-        4,3 $inner.zgrid -anchor w \
-        5,0 $inner.mode_l -anchor w -padx { 2 0 } \
-        5,1 $inner.mode -fill x -cspan 3
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r7 c6 -resize expand
-    blt::table configure $inner r3 -height 0.125i
-}
-
-itcl::body Rappture::VtkVolumeViewer::BuildCameraTab {} {
-    set font [option get $itk_component(hull) font Font]
-    set inner [$itk_component(main) insert end \
-        -title "Camera Settings" \
-        -icon [Rappture::icon camera]]
-    $inner configure -borderwidth 4
-
-    label $inner.view_l -text "view" -font $font
-    set f [frame $inner.view]
-    foreach side { front back left right top bottom } {
-        button $f.$side  -image [Rappture::icon view$side] \
-            -command [itcl::code $this SetOrientation $side]
-        Rappture::Tooltip::for $f.$side "Change the view to $side"
-        pack $f.$side -side left
-    }
-    blt::table $inner \
-        0,0 $inner.view_l -anchor e -pady 2 \
-        0,1 $inner.view -anchor w -pady 2
-    blt::table configure $inner r0 -resize none
-
-    set row 1
-    set labels { qx qy qz qw xpan ypan zoom }
-    foreach tag $labels {
-        label $inner.${tag}label -text $tag -font $font
-        entry $inner.${tag} -font $font  -bg white \
-            -textvariable [itcl::scope _view(-$tag)]
-        bind $inner.${tag} <Return> \
-            [itcl::code $this camera set -${tag}]
-        bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set -${tag}]
-        blt::table $inner \
-            $row,0 $inner.${tag}label -anchor e -pady 2 \
-            $row,1 $inner.${tag} -anchor w -pady 2
-        blt::table configure $inner r$row -resize none
-        incr row
-    }
-    checkbutton $inner.ortho \
-        -text "Orthographic Projection" \
-        -variable [itcl::scope _view(-ortho)] \
-        -command [itcl::code $this camera set -ortho] \
-        -font $font
-    blt::table $inner \
-            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
-    blt::table configure $inner r$row -resize none
-    incr row
-
-    blt::table configure $inner c0 c1 -resize none
-    blt::table configure $inner c2 -resize expand
-    blt::table configure $inner r$row -resize expand
-}
-
-itcl::body Rappture::VtkVolumeViewer::BuildCutplanesTab {} {
-    set font [option get $itk_component(hull) font Font]
-
-    set inner [$itk_component(main) insert end \
-        -title "Cutplane Settings" \
-        -icon [Rappture::icon cutbutton]]
-
-    $inner configure -borderwidth 4
-
-    checkbutton $inner.visible \
-        -text "Show Cutplanes" \
-        -variable [itcl::scope _settings(-cutplanesvisible)] \
-        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
-        -font $font
-
-    checkbutton $inner.lighting \
-        -text "Enable Lighting" \
-        -variable [itcl::scope _settings(-cutplanelighting)] \
-        -command [itcl::code $this AdjustSetting -cutplanelighting] \
-        -font $font
-
-    label $inner.opacity_l -text "Opacity" -font $font
-    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(-cutplaneopacity)] \
-        -width 10 \
-        -showvalue off \
-        -command [itcl::code $this AdjustSetting -cutplaneopacity]
-    $inner.opacity set $_settings(-cutplaneopacity)
-
-    # X-value slicer...
-    itk_component add xCutButton {
-        Rappture::PushButton $inner.xbutton \
-            -onimage [Rappture::icon x-cutplane] \
-            -offimage [Rappture::icon x-cutplane] \
-            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
-            -variable [itcl::scope _settings(-xcutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(xCutButton) \
-        "Toggle the X-axis cutplane on/off"
-    $itk_component(xCutButton) select
-
-    itk_component add xCutScale {
-        ::scale $inner.xval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane x] \
-            -variable [itcl::scope _settings(-xcutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(xCutScale) set 50
-    $itk_component(xCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(xCutScale) \
-        "@[itcl::code $this Slice tooltip x]"
-
-    # Y-value slicer...
-    itk_component add yCutButton {
-        Rappture::PushButton $inner.ybutton \
-            -onimage [Rappture::icon y-cutplane] \
-            -offimage [Rappture::icon y-cutplane] \
-            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
-            -variable [itcl::scope _settings(-ycutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(yCutButton) \
-        "Toggle the Y-axis cutplane on/off"
-    $itk_component(yCutButton) select
-
-    itk_component add yCutScale {
-        ::scale $inner.yval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane y] \
-            -variable [itcl::scope _settings(-ycutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    Rappture::Tooltip::for $itk_component(yCutScale) \
-        "@[itcl::code $this Slice tooltip y]"
-    # Set the default cutplane value before disabling the scale.
-    $itk_component(yCutScale) set 50
-    $itk_component(yCutScale) configure -state disabled
-
-    # Z-value slicer...
-    itk_component add zCutButton {
-        Rappture::PushButton $inner.zbutton \
-            -onimage [Rappture::icon z-cutplane] \
-            -offimage [Rappture::icon z-cutplane] \
-            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
-            -variable [itcl::scope _settings(-zcutplanevisible)]
-    }
-    Rappture::Tooltip::for $itk_component(zCutButton) \
-        "Toggle the Z-axis cutplane on/off"
-    $itk_component(zCutButton) select
-
-    itk_component add zCutScale {
-        ::scale $inner.zval -from 100 -to 0 \
-            -width 10 -orient vertical -showvalue 1 \
-            -borderwidth 1 -highlightthickness 0 \
-            -command [itcl::code $this EventuallySetCutplane z] \
-            -variable [itcl::scope _settings(-zcutplaneposition)]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    $itk_component(zCutScale) set 50
-    $itk_component(zCutScale) configure -state disabled
-    Rappture::Tooltip::for $itk_component(zCutScale) \
-        "@[itcl::code $this Slice tooltip z]"
-
-    blt::table $inner \
-        0,0 $inner.visible              -anchor w -pady 2 -cspan 4 \
-        1,0 $inner.lighting             -anchor w -pady 2 -cspan 4 \
-        2,0 $inner.opacity_l            -anchor w -pady 2 -cspan 3 \
-        3,0 $inner.opacity              -fill x   -pady 2 -cspan 3 \
-        4,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
-        5,0 $itk_component(xCutScale)   -fill y \
-        4,1 $itk_component(yCutButton)  -anchor e -padx 2 -pady 2 \
-        5,1 $itk_component(yCutScale)   -fill y \
-        4,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
-        5,2 $itk_component(zCutScale)   -fill y
-
-    blt::table configure $inner r* c* -resize none
-    blt::table configure $inner r5 c3 -resize expand
-}
-
-#
-# camera --
-#
-itcl::body Rappture::VtkVolumeViewer::camera {option args} {
-    switch -- $option {
-        "show" {
-            puts [array get _view]
-        }
-        "set" {
-            set what [lindex $args 0]
-            set x $_view($what)
-            set code [catch { string is double $x } result]
-            if { $code != 0 || !$result } {
-                return
-            }
-            switch -- $what {
-                "-ortho" {
-                    if {$_view($what)} {
-                        SendCmd "camera mode ortho"
-                    } else {
-                        SendCmd "camera mode persp"
-                    }
-                }
-                "-xpan" - "-ypan" {
-                    PanCamera
-                }
-                "-qx" - "-qy" - "-qz" - "-qw" {
-                    set q [ViewToQuaternion]
-                    $_arcball quaternion $q
-                    EventuallyRotate $q
-                }
-                "-zoom" {
-                    SendCmd "camera zoom $_view($what)"
-                }
-            }
-        }
-    }
-}
-
-itcl::body Rappture::VtkVolumeViewer::GetVtkData { args } {
-    set bytes ""
-    foreach dataobj [get] {
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            set contents [$dataobj vtkdata $comp]
-            append bytes "$contents\n"
-        }
-    }
-    return [list .vtk $bytes]
-}
-
-itcl::body Rappture::VtkVolumeViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 &&
-         [image height $_image(download)] > 0 } {
-        set bytes [$_image(download) data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        return [list .jpg $bytes]
-    }
-    return ""
-}
-
-itcl::body Rappture::VtkVolumeViewer::BuildDownloadPopup { popup command } {
-    Rappture::Balloon $popup \
-        -title "[Rappture::filexfer::label downloadWord] as..."
-    set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w
-    radiobutton $inner.vtk_button -text "VTK data file" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -font "Arial 9" \
-        -value vtk
-    Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file."
-    radiobutton $inner.image_button -text "Image File" \
-        -variable [itcl::scope _downloadPopup(format)] \
-        -value image
-    Rappture::Tooltip::for $inner.image_button \
-        "Save as digital image."
-
-    button $inner.ok -text "Save" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command $command \
-        -compound left \
-        -image [Rappture::icon download]
-
-    button $inner.cancel -text "Cancel" \
-        -highlightthickness 0 -pady 2 -padx 3 \
-        -command [list $popup deactivate] \
-        -compound left \
-        -image [Rappture::icon cancel]
-
-    blt::table $inner \
-        0,0 $inner.summary -cspan 2  \
-        1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \
-        2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \
-        4,1 $inner.cancel -width .9i -fill y \
-        4,0 $inner.ok -padx 2 -width .9i -fill y
-    blt::table configure $inner r3 -height 4
-    blt::table configure $inner r4 -pady 4
-    raise $inner.image_button
-    $inner.vtk_button invoke
-    return $inner
-}
-
-itcl::body Rappture::VtkVolumeViewer::SetObjectStyle { dataobj cname } {
-    # Parse style string.
-    set tag $dataobj-$cname
-    array set style {
-        -color      BCGYR
-        -lighting   1
-        -opacity    0.5
-        -outline    0
-        -visible    1
-    }
-    array set style [$dataobj style $cname]
-    set _settings(-volumelighting) $style(-lighting)
-    set _settings(-volumeopacity) [expr $style(-opacity) * 100.0]
-    set _settings(-volumeoutline) $style(-outline)
-    set _settings(-volumevisible) $style(-visible)
-
-    $itk_component(colormap) value $style(-color)
-
-    SendCmd "outline add $tag"
-    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
-    SendCmd "outline visible $style(-outline) $tag"
-
-    SendCmd "$_cutplaneCmd add $tag"
-    SendCmd "$_cutplaneCmd color [Color2RGB $itk_option(-plotforeground)] $tag"
-    SendCmd "$_cutplaneCmd visible 0 $tag"
-
-    SendCmd "volume add $tag"
-    SendCmd "volume lighting $style(-lighting) $tag"
-    SendCmd "volume opacity $style(-opacity) $tag"
-    SendCmd "volume visible $style(-visible) $tag"
-    SetColormap $dataobj $cname
-}
-
-itcl::body Rappture::VtkVolumeViewer::IsValidObject { dataobj } {
-    if {[catch {$dataobj isa Rappture::Field} valid] != 0 || !$valid} {
-        return 0
-    }
-    return 1
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveLegend <colormap> <title> <min> <max> <size>
-#
-# Invoked automatically whenever the "legend" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::ReceiveLegend { colormap title min max size } {
-    if { [isconnected] } {
-        set bytes [ReceiveBytes $size]
-        if { ![info exists _image(legend)] } {
-            set _image(legend) [image create photo]
-        }
-        $_image(legend) configure -data $bytes
-        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
-        if { [catch {DrawLegend} errs] != 0 } {
-            puts stderr errs=$errs
-        }
-    }
-}
-
-#
-# DrawLegend --
-#
-itcl::body Rappture::VtkVolumeViewer::DrawLegend {} {
-    set fname $_curFldName
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    if { !$_settings(-legendvisible) } {
-        $c delete legend
-        return
-    }
-
-    if { [info exists _fields($fname)] } {
-        foreach { title units } $_fields($fname) break
-        if { $units != "" } {
-            set title [format "%s (%s)" $title $units]
-        }
-    } else {
-        set title $fname
-    }
-
-    set x [expr $w - 2]
-    if { [$c find withtag "legend"] == "" } {
-        set y 2
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "title legend" \
-            -font $font
-        incr y $lineht
-        $c create text $x $y \
-            -anchor ne \
-            -fill $itk_option(-plotforeground) -tags "vmax legend" \
-            -font $font
-        incr y $lineht
-        $c create image $x $y \
-            -anchor ne \
-            -image $_image(legend) -tags "colormap legend"
-        $c create text $x [expr {$h-2}] \
-            -anchor se \
-            -fill $itk_option(-plotforeground) -tags "vmin legend" \
-            -font $font
-        #$c bind colormap <Enter> [itcl::code $this EnterLegend %x %y]
-        $c bind colormap <Leave> [itcl::code $this LeaveLegend]
-        $c bind colormap <Motion> [itcl::code $this MotionLegend %x %y]
-    }
-    $c bind title <ButtonPress> [itcl::code $this LegendTitleAction post]
-    $c bind title <Enter> [itcl::code $this LegendTitleAction enter]
-    $c bind title <Leave> [itcl::code $this LegendTitleAction leave]
-    # Reset the item coordinates according the current size of the plot.
-    $c itemconfigure title -text $title
-    if { [info exists _limits($_curFldName)] } {
-        foreach { vmin vmax } $_limits($_curFldName) break
-        $c itemconfigure vmin -text [format %g $vmin]
-        $c itemconfigure vmax -text [format %g $vmax]
-    }
-    set y 2
-    $c coords title $x $y
-    incr y $lineht
-    $c coords vmax $x $y
-    incr y $lineht
-    $c coords colormap $x $y
-    $c coords vmin $x [expr {$h - 2}]
-}
-
-#
-# EnterLegend --
-#
-itcl::body Rappture::VtkVolumeViewer::EnterLegend { x y } {
-    SetLegendTip $x $y
-}
-
-#
-# MotionLegend --
-#
-itcl::body Rappture::VtkVolumeViewer::MotionLegend { x y } {
-    Rappture::Tooltip::tooltip cancel
-    set c $itk_component(view)
-    SetLegendTip $x $y
-}
-
-#
-# LeaveLegend --
-#
-itcl::body Rappture::VtkVolumeViewer::LeaveLegend { } {
-    Rappture::Tooltip::tooltip cancel
-    .rappturetooltip configure -icon ""
-}
-
-#
-# SetLegendTip --
-#
-itcl::body Rappture::VtkVolumeViewer::SetLegendTip { x y } {
-    set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-
-    set imgHeight [image height $_image(legend)]
-    set coords [$c coords colormap]
-    set imgX [expr $w - [image width $_image(legend)] - 2]
-    set imgY [expr $y - 2 * ($lineht + 2)]
-
-    if { [info exists _fields($_title)] } {
-        foreach { title units } $_fields($_title) break
-        if { $units != "" } {
-            set title [format "%s (%s)" $title $units]
-        }
-    } else {
-        set title $_title
-    }
-    # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
-        #puts stderr "out of range: $imgY"
-        return
-    }
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    set color [eval format "\#%02x%02x%02x" $pixel]
-    $_image(swatch) put black  -to 0 0 23 23
-    $_image(swatch) put $color -to 1 1 22 22
-    .rappturetooltip configure -icon $_image(swatch)
-
-    # Compute the value of the point
-    if { [info exists _limits($_curFldName)] } {
-        foreach { vmin vmax } $_limits($_curFldName) break
-        set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
-        set value [expr $t * ($vmax - $vmin) + $vmin]
-    } else {
-        set value 0.0
-    }
-    set tipx [expr $x + 15]
-    set tipy [expr $y - 5]
-    Rappture::Tooltip::text $c "$title $value"
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Slice move x|y|z <newval>
-#
-# Called automatically when the user drags the slider to move the
-# cut plane that slices 3D data.  Gets the current value from the
-# slider and moves the cut plane to the appropriate point in the
-# data set.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::Slice {option args} {
-    switch -- $option {
-        "move" {
-            set axis [lindex $args 0]
-            set newval [lindex $args 1]
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Slice move x|y|z newval\""
-            }
-            set newpos [expr {0.01*$newval}]
-            SendCmd "$_cutplaneCmd slice $axis $newpos"
-        }
-        "tooltip" {
-            set axis [lindex $args 0]
-            set val [$itk_component(${axis}CutScale) get]
-            return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
-        }
-        default {
-            error "bad option \"$option\": should be axis, move, or tooltip"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: LegendTitleAction post
-# USAGE: LegendTitleAction enter
-# USAGE: LegendTitleAction leave
-# USAGE: LegendTitleAction save
-#
-# Used internally to handle the dropdown list for the fields menu combobox.
-# The post option is invoked when the field title is pressed to launch the
-# dropdown.  The enter option is invoked when the user mouses over the field
-# title. The leave option is invoked when the user moves the mouse away
-# from the field title.  The save option is invoked whenever there is a
-# selection from the list, to alert the visualization server.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkVolumeViewer::LegendTitleAction {option} {
-    set c $itk_component(view)
-    switch -- $option {
-        post {
-            foreach { x1 y1 x2 y2 } [$c bbox title] break
-            set x1 [expr [winfo width $itk_component(view)] - [winfo reqwidth $itk_component(fieldmenu)]]
-            set x [expr $x1 + [winfo rootx $itk_component(view)]]
-            set y [expr $y2 + [winfo rooty $itk_component(view)]]
-            tk_popup $itk_component(fieldmenu) $x $y
-        }
-        enter {
-            $c itemconfigure title -fill red
-        }
-        leave {
-            $c itemconfigure title -fill $itk_option(-plotforeground)
-        }
-        save {
-            $itk_component(field) value $_curFldLabel
-            AdjustSetting -field
-        }
-        default {
-            error "bad option \"$option\": should be post, enter, leave or save"
-        }
-    }
-}
-
-itcl::body Rappture::VtkVolumeViewer::SetOrientation { side } {
-    array set positions {
-        front "1 0 0 0"
-        back  "0 0 1 0"
-        left  "0.707107 0 -0.707107 0"
-        right "0.707107 0 0.707107 0"
-        top   "0.707107 -0.707107 0 0"
-        bottom "0.707107 0.707107 0 0"
-    }
-    foreach name { -qw -qx -qy -qz } value $positions($side) {
-        set _view($name) $value
-    }
-    set q [ViewToQuaternion]
-    $_arcball quaternion $q
-    SendCmd "camera orient $q"
-    SendCmd "camera reset"
-    set _view(-xpan) 0
-    set _view(-ypan) 0
-    set _view(-zoom) 1.0
-}
-
-#
-# GetDatasetsWithComponent --
-#
-# Returns a list of all the datasets (known by the combination of
-# their data object and component name) that match the given
-# component name.  For example, this is used where we want to change
-# the settings of volumes that have the current component.
-#
-itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } {
-    if { ![info exists _volcomponents($cname)] } {
-        return ""
-    }
-    return $_volcomponents($cname)
-}
-
-itcl::body Rappture::VtkVolumeViewer::SetCurrentFieldName { dataobj } {
-    set _first $dataobj
-    $itk_component(field) choices delete 0 end
-    $itk_component(fieldmenu) delete 0 end
-    array unset _fields
-    set _curFldName ""
-    foreach cname [$_first components] {
-        foreach fname [$_first fieldnames $cname] {
-            if { [info exists _fields($fname)] } {
-                continue
-            }
-            foreach { label units components } \
-                [$_first fieldinfo $fname] break
-            # Only scalar fields are valid
-            if {$_allowMultiComponent || $components == 1} {
-                $itk_component(field) choices insert end "$fname" "$label"
-                $itk_component(fieldmenu) add radiobutton -label "$label" \
-                    -value $label -variable [itcl::scope _curFldLabel] \
-                    -selectcolor red \
-                    -activebackground $itk_option(-plotbackground) \
-                    -activeforeground $itk_option(-plotforeground) \
-                    -font "Arial 8" \
-                    -command [itcl::code $this LegendTitleAction save]
-                set _fields($fname) [list $label $units $components]
-                if { $_curFldName == "" } {
-                    set _curFldName $fname
-                    set _curFldLabel $label
-                }
-            }
-        }
-    }
-    $itk_component(field) value $_curFldLabel
-}
Index: trunk/gui/scripts/xylegend.tcl
===================================================================
--- trunk/gui/scripts/xylegend.tcl	(revision 6716)
+++ 	(revision )
@@ -1,634 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: xylegend - X/Y plot legend.
-#
-#  This widget is a legend for an X/Y plot, meant to view line graphs produced
-#  as output from the run of a Rappture tool.  Use the "add" and
-#  "delete" methods to control the curves showing on the plot.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *Xylegend.font \
-    -*-helvetica-medium-r-normal-*-8-* widgetDefault
-
-option add *Xylegend.Button.font \
-    -*-helvetica-medium-r-normal-*-9-* widgetDefault
-
-itcl::class ::Rappture::XyLegend {
-    inherit itk::Widget
-
-    private variable _autocolors {
-        #0000cd
-        #cd0000
-        #00cd00
-        #3a5fcd
-        #cdcd00
-        #cd1076
-        #009acd
-        #00c5cd
-        #a2b5cd
-        #7ac5cd
-        #66cdaa
-        #a2cd5a
-        #cd9b9b
-        #cdba96
-        #cd3333
-        #cd6600
-        #cd8c95
-        #cd00cd
-        #9a32cd
-        #6ca6cd
-        #9ac0cd
-        #9bcd9b
-        #00cd66
-        #cdc673
-        #cdad00
-        #cd5555
-        #cd853f
-        #cd7054
-        #cd5b45
-        #cd6889
-        #cd69c9
-        #551a8b
-    }
-    private variable _lastColorIndex ""
-    private variable _dispatcher "" ;# dispatcher for !events
-    private variable _graph     ""
-    private variable _tree      ""
-    private variable _diff      "";     # Polygon marker used for difference.
-    private variable _rename    "";     # Node selected to be renamed.
-    private variable _diffelements
-    private variable _unmapHidden 0
-
-    constructor {graph args} {}
-    destructor {}
-
-    public method reset { list }
-
-    private method Add { elem label {flags ""}}
-    private method Average {}
-    private method BuildPopup { popup }
-    private method Check {}
-    private method Delete { args }
-    private method Difference {}
-    private method Editor { option args }
-    private method GetData { elem what }
-    private method Hide { args }
-    private method Lower { args }
-    private method Raise { args }
-    private method Recolor {}
-    private method PopupMenu { x y }
-    private method Rename {}
-    private method SelectAll {}
-    private method Show { args }
-    private method Toggle { args }
-    private method UnmapHidden {}
-}
-
-itk::usual XyLegend {
-    keep -background -foreground -cursor
-}
-
-itk::usual TreeView {
-    keep -background -foreground -cursor
-}
-
-blt::bitmap define dot1 {
-#define dot1_width 8
-#define dot1_height 8
-static unsigned char dot1_bits[] = {
-   0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa, 0x55, 0xaa};
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyLegend::constructor { graph args } {
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-    itk_component add scrollbars {
-        Rappture::Scroller $itk_interior.scrl \
-            -xscrollmode auto -yscrollmode auto \
-            -width 200 -height 100
-    }
-    set _tree [blt::tree create]
-    itk_component add legend {
-        blt::treeview $itk_component(scrollbars).legend -linewidth 0 \
-            -bg white -selectmode multiple \
-            -highlightthickness 0 \
-            -tree $_tree \
-            -font "Arial 9" \
-            -flat yes -separator /
-    }
-    $itk_component(scrollbars) contents $itk_component(legend)
-    $itk_component(legend) column insert 0 "show" \
-        -text "" -weight 0.0 -pad 0 -borderwidth 0
-    $itk_component(legend) style checkbox "check" -showvalue no \
-        -onvalue 0 -offvalue 1 \
-        -boxcolor grey50 -checkcolor black -activebackground grey90
-    $itk_component(legend) column configure "treeView" -justify left \
-        -weight 1.0 -text "" -pad 0 -borderwidth 0 -edit no
-    $itk_component(legend) column configure "show" -style "check" -pad {0 0} \
-        -edit yes
-    itk_component add controls {
-        frame $itk_component(hull).controls -width 100 -relief sunken -bd 2
-    }
-    set controls $itk_component(controls)
-    grid $itk_component(controls) -column 0 -row 1 -sticky nsew
-    grid columnconfigure $itk_component(hull) 0 -weight 1
-    grid rowconfigure $itk_component(hull) 1 \
-        -minsize [winfo reqheight $itk_component(scrollbars)]
-    grid rowconfigure $itk_component(hull) 0 -weight 1
-    grid $itk_component(scrollbars) -column 0 -row 0 -sticky nsew
-    set commands {
-        hide    ""
-        show    ""
-        toggle  ""
-        raise        findup
-        lower   finddn
-        average ""
-        difference ""
-        delete ""
-        rename ""
-        recolor ""
-    }
-    foreach { but icon} $commands {
-        set title [string totitle $but]
-        button $controls.$but -text $title \
-            -relief flat -pady 0 -padx 0  -font "Arial 9" \
-            -command [itcl::code $this $title]  -overrelief flat \
-            -activebackground grey90
-    }
-    grid $controls.hide       -column 0 -row 0 -sticky w
-    grid $controls.show       -column 0 -row 1 -sticky w
-    grid $controls.toggle     -column 0 -row 2 -sticky w
-    grid $controls.raise      -column 0 -row 3 -sticky w
-    grid $controls.lower      -column 0 -row 4 -sticky w
-    grid $controls.difference -column 1 -row 0 -sticky w
-    grid $controls.average    -column 1 -row 1 -sticky w
-    grid $controls.rename     -column 1 -row 2 -sticky w
-    grid $controls.recolor    -column 1 -row 3 -sticky w
-    grid $controls.delete     -column 1 -row 4 -sticky w
-
-    grid columnconfigure $controls 0  -weight 1
-    grid columnconfigure $controls 1 -weight 1
-
-    set _graph $graph
-    set cmd [itcl::code $this Toggle current]
-    $itk_component(legend) bind CheckBoxStyle <ButtonRelease-1> \
-        [itcl::code [subst -nocommands {
-            if { [%W edit -root -test %X %Y] } {
-                %W edit -root %X %Y
-                $this Toggle [%W nearest -root %X %Y]
-                break
-            }
-        }]]
-    bind $itk_component(legend) <Enter> { focus %W }
-    $itk_component(legend) bind Entry <Control-KeyRelease-a> \
-        [itcl::code $this SelectAll]
-    $itk_component(legend) bind Entry <KeyRelease-Return> \
-        +[itcl::code $this Toggle focus]
-    $itk_component(legend) bind Entry <Escape> \
-        "$itk_component(legend) selection clearall"
-    $itk_component(legend) configure -selectcommand \
-        [itcl::code $this Check]
-
-    itk_component add editor {
-        Rappture::Editor $itk_interior.editor \
-            -activatecommand [itcl::code $this Editor activate] \
-            -validatecommand [itcl::code $this Editor validate] \
-            -applycommand [itcl::code $this Editor apply]
-    }
-    set _lastColorIndex [llength $_autocolors]
-    Check
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyLegend::destructor {} {
-    foreach node [$_tree children root] {
-        $_tree delete $node
-    }
-    if { $_diff != "" } {
-        catch { $_graph marker delete $_diff }
-    }
-}
-
-itcl::body Rappture::XyLegend::Add { elem label {flags ""} } {
-    set hide [$_graph element cget $elem -hide]
-    set im [image create photo]
-    $_graph legend icon $elem $im
-    set data(show) $hide
-    set data(delete) [expr { $flags == "-delete" }]
-    set node [$_tree insert root -at 0 -label $elem -data [array get data]]
-    $itk_component(legend) entry configure $node -label $label -icon $im \
-        -activeicon $im
-    update idletasks
-    return $node
-}
-
-# ----------------------------------------------------------------------
-# USAGE: reset
-#
-# Clients use this to add a curve to the plot.  The optional <settings>
-# are used to configure the plot.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyLegend::reset { list } {
-    foreach node [$_tree children root] {
-        $_tree delete $node
-    }
-    foreach elem $list {
-        if {[catch {$_graph element cget $elem -label} label] == 0} {
-            if {$label eq ""} {
-                set label $elem
-            }
-            Add $elem $label
-        }
-    }
-    $itk_component(legend) open -recurse root
-    Check
-}
-
-itcl::body Rappture::XyLegend::Hide { args } {
-    if { $args == "" } {
-        set nodes [$itk_component(legend) curselection]
-    } else {
-        set nodes $args
-    }
-    foreach node $nodes {
-        set elem [$_tree label $node]
-        if { ![$_graph element exists $elem] } {
-            continue
-        }
-        $_graph element configure $elem -hide yes
-        $_tree set $node "show" 1
-    }
-}
-
-itcl::body Rappture::XyLegend::Show { args } {
-    if { $args == "" } {
-        set nodes [$itk_component(legend) curselection]
-    } else {
-        set nodes $args
-    }
-    foreach node $nodes {
-        set elem [$_tree label $node]
-        if { ![$_graph element exists $elem] } {
-            continue
-        }
-        $_graph element configure $elem -hide no
-        $_tree set $node "show" 0
-    }
-}
-
-itcl::body Rappture::XyLegend::Toggle { args } {
-    if { $args == "" } {
-        set nodes [$itk_component(legend) curselection]
-    } else {
-        set nodes $args
-    }
-    foreach node $nodes {
-        set elem [$_tree label $node]
-        if { ![$_graph element exists $elem] } {
-            continue
-        }
-        set hide [$_graph element cget $elem -hide]
-        set hide [expr $hide==0]
-        $_tree set $node "show" $hide
-        $_graph element configure $elem -hide $hide
-    }
-}
-
-itcl::body Rappture::XyLegend::Raise { args } {
-    if { $args == "" } {
-        set nodes [$itk_component(legend) curselection]
-    } else {
-        set nodes $args
-    }
-    set elements {}
-    foreach node $nodes {
-        set elem [$_tree label $node]
-        set found($elem) 1
-        set elements [linsert $elements 0 $elem]
-    }
-    foreach elem $elements {
-        $_tree move [$_tree index $elem] 0 -at 0
-    }
-    set list {}
-    foreach elem [$_graph element show] {
-        if { [info exists found($elem)] }  {
-            continue
-        }
-        lappend list $elem
-    }
-    $_graph element show [concat $list $elements]
-}
-
-itcl::body Rappture::XyLegend::Lower { args } {
-    if { $args == "" } {
-        set nodes [$itk_component(legend) curselection]
-    } else {
-        set nodes $args
-    }
-    set elements {}
-    foreach node $nodes {
-        set elem [$_tree label $node]
-        set found($elem) 1
-        set elements [linsert $elements 0 $elem]
-    }
-    set pos [$_tree degree 0]
-
-    foreach elem $elements {
-        incr pos -1
-        $_tree move [$_tree index $elem] 0 -at $pos
-    }
-
-    set list {}
-    foreach elem [$_graph element show] {
-        if { [info exists found($elem)] }  {
-            continue
-        }
-        lappend list $elem
-    }
-    $_graph element show [concat $elements $list]
-}
-
-itcl::body Rappture::XyLegend::Delete { args } {
-    if { $args == "" } {
-        set nodes [$itk_component(legend) curselection]
-    } else {
-        set nodes $args
-    }
-    set elements {}
-    set delnodes {}
-    foreach node $nodes {
-        if { ![$_tree get $node "delete" 0] } {
-            continue
-        }
-        set elem [$_tree label $node]
-        lappend elements $elem
-        lappend delnodes $node
-        if { $_diff != "" && [info exists _diffelements($elem)] } {
-            $_graph marker delete $_diff
-            array unset _diffelements
-            set _diff ""
-        }
-    }
-    if { [llength $delnodes] > 0 } {
-        eval $_tree delete $delnodes
-    }
-    $itk_component(legend) selection clearall
-    eval $_graph element delete $elements
-}
-
-itcl::body Rappture::XyLegend::Check {} {
-    set nodes [$itk_component(legend) curselection]
-    foreach n { hide show toggle raise lower
-        rename average difference delete recolor } {
-        $itk_component(controls).$n configure -state disabled
-    }
-    foreach node $nodes {
-        if { [$_tree get $node "delete" 0] } {
-            $itk_component(controls).delete configure -state normal
-            break
-        }
-    }
-    if { [$_tree degree 0] > 1  && [llength $nodes] > 0 } {
-        foreach n { raise lower } {
-            $itk_component(controls).$n configure -state normal
-        }
-    }
-    switch -- [llength $nodes] {
-        0 {
-        }
-        1 {
-            foreach n { hide show toggle rename recolor } {
-                $itk_component(controls).$n configure -state normal
-            }
-        }
-        2 {
-            foreach n { hide show toggle difference average recolor } {
-                $itk_component(controls).$n configure -state normal
-            }
-        }
-        default {
-            foreach n { hide show toggle average recolor } {
-                $itk_component(controls).$n configure -state normal
-            }
-        }
-    }
-}
-
-itcl::body Rappture::XyLegend::GetData { elem what } {
-    set y [$_graph element cget $elem $what]
-    if { [blt::vector names $y] == $y } {
-        set y [$y range 0 end]
-    }
-    return $y
-}
-
-itcl::body Rappture::XyLegend::Average {} {
-    set nodes [$itk_component(legend) curselection]
-    if { $nodes == "" } {
-        return
-    }
-    set elements {}
-    set sum [blt::vector create \#auto -command ""]
-
-    set xcoords [blt::vector create \#auto -command ""]
-    set ycoords [blt::vector create \#auto -command ""]
-
-    blt::busy hold $itk_component(hull)
-    update
-    # Step 1. Get the x-values for each curve, then sort them to get the
-    #         unique values.
-
-    set labels {}
-    foreach node $nodes {
-        set elem [$_tree label $node]
-        set label [$_graph element cget $elem -label]
-        $xcoords append [GetData $elem -x]
-        set elements [linsert $elements 0 $elem]
-        set labels [linsert $labels 0 $label]
-    }
-    # Sort the abscissas keeping unique values.
-    $xcoords sort -uniq
-
-    # Step 2. Now for each curve, generate a cubic spline of that curve
-    #         and interpolate to get the corresponding y-values for each
-    #         abscissa.  Normally the abscissa are the same, so we're
-    #         interpolation the knots.
-
-    set x [blt::vector create \#auto -command ""]
-    set y [blt::vector create \#auto -command ""]
-    $sum length [$xcoords length]
-
-    foreach node $nodes {
-        set elem [$_tree label $node]
-        $x set [GetData $elem -x]
-        $y set [GetData $elem -y]
-        blt::spline natural $x $y $xcoords $ycoords
-
-        # Sum the interpolated y-coordinate values.
-        $sum expr "$sum + $ycoords"
-    }
-    blt::vector destroy $x $y
-
-    # Get the average
-    $sum expr "$sum / [llength $elements]"
-
-    # Step 3.  Create a new curve which is the average. Append it to the
-    #          the end.
-
-    set count 0
-    while {[$_graph element exists avg$count] } {
-        incr count
-    }
-    set labels [lsort -dictionary $labels]
-    set name "avg$count"
-    set label "Avg. [join $labels ,]"
-
-    # Don't use the vector because we don't know when it will be cleaned up.
-
-    if { $_lastColorIndex == 0 } {
-        set _lastColorIndex [llength $_autocolors]
-    }
-    incr _lastColorIndex -1
-    set color [lindex $_autocolors $_lastColorIndex]
-    $_graph element create $name -label $label -x [$xcoords range 0 end]\
-        -y [$sum range 0 end] -symbol scross -pixels 3 -color $color
-    blt::vector destroy $xcoords $ycoords $sum
-    set node [Add $name $label -delete]
-    Raise $node
-    blt::busy forget $itk_component(hull)
-}
-
-itcl::body Rappture::XyLegend::Difference {} {
-
-    if { $_diff != "" } {
-        $_graph marker delete $_diff
-        set _diff ""
-    }
-    set nodes [$itk_component(legend) curselection]
-    set elem1 [$_tree label [lindex $nodes 0]]
-    set elem2 [$_tree label [lindex $nodes 1]]
-    if { [info exists _diffelements($elem1)] &&
-         [info exists _diffelements($elem2)] } {
-        array unset _diffelements;      # Toggle the difference.
-        return;
-    }
-    array unset _diffelements
-    set x [blt::vector create \#auto -command ""]
-    set y [blt::vector create \#auto -command ""]
-    set m [blt::vector create \#auto -command ""]
-
-    $x append [GetData $elem1 -x]
-    $y append [GetData $elem1 -y]
-    $x sort -reverse $y
-    $x append [GetData $elem2 -x]
-    $y append [GetData $elem2 -y]
-    $m merge $x $y
-    set _diff [$_graph marker create polygon \
-                   -coords [$m range 0 end] \
-                   -element $elem1 \
-                   -stipple dot1 \
-                   -outline "" -fill "#cd69c9"]
-    blt::vector destroy $m $x $y
-    set _diffelements($elem1) 1
-    set _diffelements($elem2) 1
-}
-
-
-itcl::body Rappture::XyLegend::UnmapHidden {} {
-    $_graph configure -unmaphiddenelements $_unmapHidden
-}
-
-itcl::body Rappture::XyLegend::SelectAll { } {
-    foreach node [$_tree children 0] {
-        $itk_component(legend) selection set $node
-    }
-}
-
-itcl::body Rappture::XyLegend::Rename {} {
-    Editor popup
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Editor popup
-# USAGE: Editor activate
-# USAGE: Editor validate <value>
-# USAGE: Editor apply <value>
-# USAGE: Editor menu <rootx> <rooty>
-#
-# Used internally to handle the various functions of the pop-up
-# editor for the value of this gauge.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyLegend::Editor {option args} {
-    switch -- $option {
-        popup {
-            $itk_component(editor) activate
-        }
-        activate {
-            set _rename [$itk_component(legend) curselection]
-            if { $_rename == "" } {
-                return;
-            }
-            set label [$itk_component(legend) entry cget $_rename -label]
-            foreach { l r w h } [$itk_component(legend) bbox $_rename] break
-            set info(text) $label
-            set info(x) [expr $l + [winfo rootx $itk_component(legend)]]
-            set info(y) [expr $r + [winfo rooty $itk_component(legend)]]
-            set info(w) $w
-            set info(h) $h
-            return [array get info]
-        }
-        validate {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"editor validate value\""
-            }
-        }
-        apply {
-            if {[llength $args] != 1} {
-                error "wrong # args: should be \"editor apply value\""
-            }
-            set label [lindex $args 0]
-            $itk_component(legend) entry configure $_rename -label $label
-            set elem [$_tree label $_rename]
-            $_graph element configure $elem -label $label
-        }
-        menu {
-            eval tk_popup $itk_component(emenu) $args
-        }
-        default {
-            error "bad option \"$option\": should be popup, activate, validate, apply, and menu"
-        }
-    }
-}
-
-itcl::body Rappture::XyLegend::Recolor {} {
-    set nodes [$itk_component(legend) curselection]
-    if { $nodes == "" } {
-        return
-    }
-    foreach node $nodes {
-        set elem [$_tree label $node]
-        if { $_lastColorIndex == 0 } {
-            set _lastColorIndex [llength $_autocolors]
-        }
-        incr _lastColorIndex -1
-        set color [lindex $_autocolors $_lastColorIndex]
-        $_graph element configure $elem -color $color
-        set im [$itk_component(legend) entry cget $node -icon]
-        $_graph legend icon $elem $im
-    }
-}
Index: trunk/gui/scripts/xyplot.tcl
===================================================================
--- trunk/gui/scripts/xyplot.tcl	(revision 1)
+++ trunk/gui/scripts/xyplot.tcl	(revision 1)
@@ -0,0 +1,240 @@
+# ----------------------------------------------------------------------
+#  COMPONENT: xyplot - X/Y plot for analyzing results
+#
+#  This widget is an X/Y plot, meant to view line graphs produced
+#  as output from the run of a Rappture tool.  It takes a -layout
+#  object describing what should be plotted, and a -run object
+#  containing the data.  This widget puts it all together, and lets
+#  the user explore the results.
+# ======================================================================
+#  AUTHOR:  Michael McLennan, Purdue University
+#  Copyright (c) 2004  Purdue Research Foundation, West Lafayette, IN
+# ======================================================================
+package require Itk
+package require BLT
+
+option add *Xyplot.width 4i widgetDefault
+option add *Xyplot.height 4i widgetDefault
+option add *Xyplot.font \
+    -*-helvetica-medium-r-normal-*-*-120-* widgetDefault
+
+itcl::class Rappture::Xyplot {
+    inherit itk::Widget
+
+    itk_option define -layout layout Layout ""
+    itk_option define -run run Run ""
+
+    constructor {args} { # defined below }
+    destructor { # defined below }
+
+    protected method _rebuild {}
+
+    private variable _device ""  ;# device contained in -run
+    private variable _path2obj   ;# maps field/curve name => object
+}
+                                                                                
+itk::usual Xyplot {
+    keep -background -foreground -cursor -font
+}
+
+# ----------------------------------------------------------------------
+# CONSTRUCTOR
+# ----------------------------------------------------------------------
+itcl::body Rappture::Xyplot::constructor {args} {
+    option add hull.width hull.height
+    pack propagate $itk_component(hull) no
+
+    itk_component add plot {
+        blt::graph $itk_interior.plot \
+            -highlightthickness 0 -plotpadx 0 -plotpady 0 \
+            -rightmargin 10
+    } {
+        keep -background -foreground -cursor -font
+    }
+    pack $itk_component(plot) -expand yes -fill both
+
+    Blt_ZoomStack $itk_component(plot)
+    $itk_component(plot) legend configure -hide yes
+
+    eval itk_initialize $args
+}
+
+# ----------------------------------------------------------------------
+# DESTRUCTOR
+# ----------------------------------------------------------------------
+itcl::body Rappture::Xyplot::destructor {} {
+    foreach name [array names _path2obj] {
+        itcl::delete object $_path2obj($name)
+    }
+    if {$_device != ""} {
+        itcl::delete object $_device
+    }
+}
+
+# ----------------------------------------------------------------------
+# USAGE: _rebuild
+#
+# Called automatically whenever something changes that affects the
+# data in the widget.  Clears any existing data and rebuilds the
+# widget to display new data.
+# ----------------------------------------------------------------------
+itcl::body Rappture::Xyplot::_rebuild {} {
+    set g $itk_component(plot)
+    set layout $itk_option(-layout)
+    set run $itk_option(-run)
+
+    # first clear out the widget
+    eval $g element delete [$g element names]
+    $g axis configure y -min "" -max ""
+
+    foreach name [array names _path2obj] {
+        itcl::delete object $_path2obj($name)
+    }
+    catch {unset _path2obj}
+
+    # now extract any new data and plot it
+    if {$layout != "" && $run != ""} {
+        set count 0
+        foreach item [$layout get -children] {
+          switch -glob -- $item {
+            title {
+                $g configure -title [$layout get title]
+            }
+            legend {
+                set where [$layout get legend]
+                if {$where == "off"} {
+                    $itk_component(plot) legend configure -hide yes
+                } else {
+                    $itk_component(plot) legend configure -hide no \
+                        -position plotarea -anchor $where -borderwidth 0
+                }
+            }
+            xaxis {
+                $g xaxis configure -title [$layout get xaxis]
+            }
+            yaxis {
+                $g yaxis configure -title [$layout get yaxis]
+            }
+            field* {
+              set name [$layout get $item]
+              if {[$run get -exists output.$name]} {
+                  set fobj [Rappture::Field ::#auto $_device $run output.$name]
+                  set _path2obj($name) $fobj
+                  foreach {xv yv} [$fobj vectors component0] { break }
+
+                  set elem "elem[incr count]"
+                  set label [$fobj hints label]
+                  $g element create $elem -x $xv -y $yv \
+                      -symbol "" -linewidth 2 -label $label
+
+                  set color [$fobj hints color]
+                  if {$color != ""} {
+                      $g element configure $elem -color $color
+                  }
+
+                  set style [$layout get $item.style]
+                  if {$style == ""} {
+                      set style [$fobj hints style]
+                  }
+                  if {$style != ""} {
+                      eval $g element configure $elem $style
+                  }
+               }
+            }
+            curve* {
+              set name [$layout get $item]
+              if {[$run get -exists output.$name]} {
+                  set cobj [Rappture::Curve ::#auto $run output.$name]
+                  set _path2obj($name) $cobj
+                  foreach {xv yv} [$cobj vectors component0] { break }
+
+                  set elem "elem[incr count]"
+                  set label [$cobj hints label]
+                  $g element create $elem -x $xv -y $yv \
+                      -symbol "" -linewidth 2 -label $label
+
+                  set color [$cobj hints color]
+                  if {$color != ""} {
+                      $g element configure $elem -color $color
+                  }
+
+                  set style [$layout get $item.style]
+                  if {$style == ""} {
+                      set style [$fobj hints style]
+                  }
+                  if {$style != ""} {
+                      eval $g element configure $elem $style
+                  }
+               }
+            }
+          }
+        }
+
+        #
+        # HACK ALERT!
+        # Use this code to fix up the y-axis limits for the BLT graph.
+        # The auto-limits don't always work well.  We want them to be
+        # set to a "nice" number slightly above or below the min/max
+        # limits.
+        #
+        set log [$g axis cget y -logscale]
+        foreach {min max} [$g axis limits y] { break }
+        if {$log} {
+            if {$min == $max} {
+                set min [expr {0.9*$min}]
+                set max [expr {1.1*$max}]
+            }
+            set min [expr {pow(10.0,floor(log10($min)))}]
+            set max [expr {pow(10.0,ceil(log10($max)))}]
+        } else {
+            if {$min > 0} {
+                set min [expr {0.95*$min}]
+            } else {
+                set min [expr {1.05*$min}]
+            }
+            if {$max > 0} {
+                set max [expr {1.05*$max}]
+            } else {
+                set max [expr {0.95*$max}]
+            }
+        }
+        $g axis configure y -min $min -max $max
+    }
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -layout
+#
+# Set to the Rappture::Library object representing the layout being
+# displayed in the plot.
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Xyplot::layout {
+    if {$itk_option(-layout) != ""} {
+        if {![Rappture::Library::valid $itk_option(-layout)]} {
+            error "bad value \"$itk_option(-layout)\": should be Rappture::Library"
+        }
+    }
+    after cancel [itcl::code $this _rebuild]
+    after idle [itcl::code $this _rebuild]
+}
+
+# ----------------------------------------------------------------------
+# CONFIGURATION OPTION: -run
+#
+# Set to the Rappture::Library object representing the data being
+# displayed in the plot.
+# ----------------------------------------------------------------------
+itcl::configbody Rappture::Xyplot::run {
+    if {$_device != ""} {
+        itcl::delete object $_device
+        set _device ""
+    }
+    if {$itk_option(-run) != ""} {
+        if {![Rappture::Library::valid $itk_option(-run)]} {
+            error "bad value \"$itk_option(-run)\": should be Rappture::Library"
+        }
+        set _device [$itk_option(-run) get -object device]
+    }
+    after cancel [itcl::code $this _rebuild]
+    after idle [itcl::code $this _rebuild]
+}
Index: trunk/gui/scripts/xyprint.tcl
===================================================================
--- trunk/gui/scripts/xyprint.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1471 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: xyprint - Print X-Y plot.
-#
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-#option add *XyPrint.width 3i widgetDefault
-#option add *XyPrint.height 3i widgetDefault
-option add *XyPrint.gridColor #d9d9d9 widgetDefault
-option add *XyPrint.activeColor blue widgetDefault
-option add *XyPrint.dimColor gray widgetDefault
-option add *XyPrint.controlBackground gray widgetDefault
-option add *XyPrint*Font "Arial 9" widgetDefault
-option add *XyPrint*Entry*width "6" widgetDefault
-option add *XyPrint*Entry*background "white" widgetDefault
-
-itcl::class Rappture::XyPrint {
-    inherit itk::Widget
-
-    constructor {args} {}
-    destructor {}
-
-    private variable _graph "";         # Original graph.
-    private variable _clone "";         # Cloned graph.
-    private variable _preview "";       # Preview image.
-    private variable _savedSettings;    # Array of settings.
-
-    private common _oldSettingsFile "~/.rpsettings"
-    private common _settingsFile "~/.rp_settings"
-
-    public method print { graph toolName plotName }
-    public method reset {}
-
-    private method CopyOptions { cmd orig clone {exclude {}}}
-    private method CloneGraph { orig }
-
-    private method BuildGeneralTab {}
-    private method BuildLayoutTab {}
-    private method BuildLegendTab {}
-    private method BuildAxisTab {}
-    private method SetOption { opt }
-    private method SetComponentOption { comp opt }
-    private method SetNamedComponentOption { comp name opt }
-    private method GetAxis {}
-    private method GetElement { args }
-    private method RegeneratePreview {}
-    private method InitClone {}
-    private method Pixels2Inches { pixels }
-    private method Inches2Pixels { inches {defValue ""}}
-    private method Color2RGB { color }
-
-    private method ApplyGeneralSettings {}
-    private method ApplyLegendSettings {}
-    private method ApplyAxisSettings {}
-    private method ApplyElementSettings {}
-    private method ApplyLayoutSettings {}
-    private method InitializeSettings {}
-    private method CreateSettings { toolName plotName }
-    private method RestoreSettings { toolName plotName }
-    private method SaveSettings { toolName plotName }
-    private method DestroySettings {}
-    private method ResetSettings { }
-    private method GetOutput {}
-    private method SetWaitVariable { state }
-    private method SetLayoutOption { option }
-    private method GetAxisType { axis }
-    private method restore { toolName plotName data }
-
-    # Same dialog may be used for different graphs
-    private common _settings
-    private common _wait
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyPrint::constructor { args } {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    set w [winfo pixels . 2.5i]
-    set h [winfo pixels . 2i]
-    set _preview [image create photo -width $w -height $h]
-    itk_component add tabs {
-        blt::tabset $itk_interior.tabs \
-            -highlightthickness 0 -tearoff 0 -side top \
-            -bd 0 -gap 0 -tabborderwidth 1 \
-            -outerpad 1 -background grey
-    } {
-        keep -cursor
-        ignore -highlightthickness -borderwidth -background
-    }
-    set inner [frame $itk_interior.frame -bg grey]
-    itk_component add preview {
-        label $inner.preview \
-            -highlightthickness 0 -bd 0 -image $_preview -width 2.5i \
-                -height 2.5i -background grey
-    } {
-        ignore -background
-    }
-    itk_component add ok {
-        button $itk_interior.ok -text "Save" \
-            -highlightthickness 0 -pady 2 -padx 0 \
-            -command [itcl::code $this SetWaitVariable 1] \
-            -compound left \
-            -image [Rappture::icon download]
-    }
-    itk_component add cancel {
-        button $itk_interior.cancel -text "Cancel" \
-            -highlightthickness 0 -pady 2 -padx 0 \
-            -command [itcl::code $this SetWaitVariable 0] \
-            -compound left \
-            -image [Rappture::icon cancel]
-    }
-    blt::table $itk_interior \
-        0,0 $inner -fill both \
-        0,1 $itk_component(tabs) -fill both -cspan 2 \
-        1,2 $itk_component(cancel) -padx 2 -pady 2 -width .9i -fill y \
-        1,1 $itk_component(ok) -padx 2 -pady 2 -width .9i -fill y
-    blt::table $inner \
-        0,0 $itk_component(preview) -fill both -padx 10 -pady 10
-
-    #blt::table configure $itk_interior c1 c2 -resize none
-    blt::table configure $itk_interior c0 -resize both
-    BuildGeneralTab
-    BuildAxisTab
-    BuildLegendTab
-    BuildLayoutTab
-    eval itk_initialize $args
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyPrint::destructor {} {
-    destroy $_clone
-    image delete $_preview
-    array unset _settings $this-*
-}
-
-itcl::body Rappture::XyPrint::DestroySettings {} {
-    destroy $_clone
-    set _clone ""
-    set _graph ""
-}
-
-itcl::body Rappture::XyPrint::reset {} {
-    SetWaitVariable 0
-}
-
-itcl::body Rappture::XyPrint::SetWaitVariable { state } {
-    set _wait($this) $state
-}
-
-itcl::body Rappture::XyPrint::print { graph toolName plotName } {
-    set _graph $graph
-    CloneGraph $graph
-    InitClone
-    RestoreSettings $toolName $plotName
-    InitializeSettings
-    SetWaitVariable 0
-    tkwait variable [itcl::scope _wait($this)]
-    SaveSettings $toolName $plotName
-    set output ""
-    if { $_wait($this) } {
-        set output [GetOutput]
-    }
-    DestroySettings
-    return $output
-}
-
-itcl::body Rappture::XyPrint::GetOutput {} {
-    # Get the selected format of the download.
-    set page $itk_component(graph_page)
-    set format [$page.format current]
-
-    if { $format == "jpg" } {
-        set img [image create photo]
-        $_clone snap $img
-        set bytes [$img data -format "jpeg -quality 100"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        image delete $img
-        return [list .jpg $bytes]
-    } elseif { $format == "png" } {
-        set img [image create photo]
-        $_clone snap $img
-        set bytes [$img data -format "png"]
-        set bytes [Rappture::encoding::decode -as b64 $bytes]
-        image delete $img
-        return [list .png $bytes]
-    }
-
-    # Handle encapsulated postscript or portable document format.
-
-    # Append an "i" for the graph postscript component.
-    set w $_settings($this-layout-width)i
-    set h $_settings($this-layout-height)i
-
-    $_clone postscript configure \
-        -maxpect false \
-        -decoration yes \
-        -center yes \
-        -width $w -height $h
-
-    set psdata [$_clone postscript output]
-
-    if 0 {
-        set f [open "junk.raw" "w"]
-        puts -nonewline $f $psdata
-        close $f
-    }
-    if { $format == "eps" } {
-        return [list .$format $psdata]
-    }
-
-    set cmd ""
-    # | eps2eps << $psdata
-    lappend cmd "|" "/usr/bin/gs" \
-        "-q" "-sDEVICE=epswrite" "-sstdout=%stderr" \
-        "-sOutputFile=-" "-dNOPAUSE" "-dBATCH" "-dSAFER" \
-        "-dDEVICEWIDTH=250000" "-dDEVICEHEIGHT=250000" "-" "<<" "$psdata"
-    if { $format == "pdf" } {
-        # | eps2eps << $psdata | ps2pdf
-        lappend cmd "|" "/usr/bin/gs" \
-            "-q" "-sDEVICE=pdfwrite" "-sstdout=%stderr" \
-            "-sOutputFile=-" "-dNOPAUSE" "-dBATCH" "-dSAFER" \
-            "-dCompatibilityLevel=1.4" "-c" ".setpdfwrite" "-f" "-"
-    }
-    if { [catch {
-        set f [open $cmd "r"]
-        fconfigure $f -translation binary -encoding binary
-        set output [read $f]
-        close $f
-    } err ] != 0 } {
-        global errorInfo
-        puts stderr "failed to generate file: $err\n$errorInfo"
-        return ""
-    }
-    if 0 {
-        set f [open "junk.$format" "w"]
-        fconfigure $f -translation binary -encoding binary
-        puts -nonewline $f $output
-        close $f
-    }
-    return [list .$format $output]
-}
-
-itcl::body Rappture::XyPrint::CopyOptions { cmd orig clone {exclude {}} } {
-    set all [eval $orig $cmd]
-    set configLine $clone
-    foreach name $exclude {
-        set ignore($name) 1
-    }
-    foreach arg $cmd {
-        lappend configLine $arg
-    }
-    foreach option $all {
-        if { [llength $option] != 5 } {
-            continue
-        }
-        set switch [lindex $option 0]
-        set initial [lindex $option 3]
-        set current [lindex $option 4]
-        if { [info exists ignore($switch)] } {
-            continue
-        }
-        if { [string compare $initial $current] == 0 } {
-            continue
-        }
-        lappend configLine $switch $current
-    }
-    eval $configLine
-}
-
-itcl::body Rappture::XyPrint::CloneGraph { orig } {
-    set top $itk_interior
-    if { [winfo exists $top.graph] } {
-        destroy $top.graph
-    }
-    set _clone [blt::graph $top.graph]
-    CopyOptions "configure" $orig $_clone
-    # Axis component
-    foreach axis [$orig axis names] {
-        if { $axis == "z" } {
-            continue
-        }
-        if { [$orig axis cget $axis -hide] } {
-            continue
-        }
-        if { [$_clone axis name $axis] == "" } {
-            $_clone axis create $axis
-        }
-        CopyOptions [list axis configure $axis] $orig $_clone
-    }
-    foreach axis { x y x2 y2 } {
-        $_clone ${axis}axis use [$orig ${axis}axis use]
-    }
-    # Pen component
-    foreach pen [$orig pen names] {
-        if { [$_clone pen name $pen] == "" } {
-            $_clone pen create $pen
-        }
-        CopyOptions [list pen configure $pen] $orig $_clone
-    }
-    # Marker component
-    foreach marker [$orig marker names] {
-        $_clone marker create [$orig marker type $marker] -name $marker
-        CopyOptions [list marker configure $marker] $orig $_clone -name
-    }
-    # Element component
-    foreach elem [$orig element names] {
-        set oper [$orig element type $elem]
-        $_clone $oper create $elem
-        CopyOptions [list $oper configure $elem] $orig $_clone -data
-        if { [$_clone $oper cget $elem -hide] } {
-            $_clone $oper configure $elem -label ""
-        }
-    }
-    # Fix element display list
-    $_clone element show [$orig element show]
-    # Legend component
-    CopyOptions {legend configure} $orig $_clone
-    # Postscript component
-    CopyOptions {postscript configure} $orig $_clone
-    # Crosshairs component
-    CopyOptions {crosshairs configure} $orig $_clone
-    # Grid component
-    CopyOptions {grid configure} $orig $_clone
-
-    # Create markers representing lines at zero for the x and y axis.
-    $_clone marker create line -name x-zero \
-        -coords "0 -Inf 0 Inf" -dashes 1 -hide yes
-    $_clone marker create line -name y-zero \
-        -coords "-Inf 0 Inf 0" -dashes 1 -hide yes
-}
-
-itcl::body Rappture::XyPrint::InitClone {} {
-
-    $_clone configure -width 3.4i -height 3.4i -background white \
-        -borderwidth 0 \
-        -leftmargin 0 \
-        -rightmargin 0 \
-        -topmargin 0 \
-        -bottommargin 0
-
-    # Kill the title and create a border around the plot
-    $_clone configure \
-        -title "" \
-        -plotborderwidth 1 -plotrelief solid  \
-        -plotbackground white -plotpadx 0 -plotpady 0
-
-    set _settings($this-layout-width) [Pixels2Inches [$_clone cget -width]]
-    set _settings($this-layout-height) [Pixels2Inches [$_clone cget -height]]
-
-    set _settings($this-legend-fontfamily) helvetica
-    set _settings($this-legend-fontsize)   10
-    set _settings($this-legend-fontweight) normal
-    set _settings($this-legend-fontslant)  roman
-    set font "helvetica 10 normal roman"
-    $_clone legend configure \
-        -position right \
-        -font $font \
-        -hide yes -borderwidth 0 -background white -relief solid \
-        -anchor nw -activeborderwidth 0
-    #
-    set _settings($this-axis-ticks-fontfamily) helvetica
-    set _settings($this-axis-ticks-fontsize)   10
-    set _settings($this-axis-ticks-fontweight) normal
-    set _settings($this-axis-ticks-fontslant)  roman
-    set _settings($this-axis-title-fontfamily) helvetica
-    set _settings($this-axis-title-fontsize)   10
-    set _settings($this-axis-title-fontweight) normal
-    set _settings($this-axis-title-fontslant)  roman
-    foreach axis [$_clone axis names] {
-        if { $axis == "z" } {
-            continue
-        }
-        if { [$_clone axis cget $axis -hide] } {
-            continue
-        }
-        set _settings($this-$axis-ticks-fontfamily) helvetica
-        set _settings($this-$axis-ticks-fontsize)   10
-        set _settings($this-$axis-ticks-fontweight) normal
-        set _settings($this-$axis-ticks-fontslant)  roman
-        set _settings($this-$axis-title-fontfamily) helvetica
-        set _settings($this-$axis-title-fontsize)   10
-        set _settings($this-$axis-title-fontweight) normal
-        set _settings($this-$axis-title-fontslant)  roman
-        set tickfont "helvetica 10 normal roman"
-        set titlefont "helvetica 10 normal roman"
-        $_clone axis configure $axis -ticklength 5  \
-            -majorticks {} -minorticks {}
-        $_clone axis configure $axis \
-            -tickfont $tickfont \
-            -titlefont $titlefont
-    }
-    set count 0
-    foreach elem [$_clone element names] {
-        if { [$_clone element type $elem] == "bar" } {
-            continue
-        }
-        incr count
-        if { [$_clone element cget $elem -linewidth] > 1 } {
-            $_clone element configure $elem -linewidth 1 -pixels 3
-        }
-    }
-    if { $count == 0 } {
-        # There are no "line" elements in the graph.
-        # Remove the symbol and dashes controls.
-        set page $itk_component(legend_page)
-        # May have already been forgotten.
-        catch {
-            blt::table forget $page.symbol_l
-            blt::table forget $page.symbol
-            blt::table forget $page.dashes_l
-            blt::table forget $page.dashes
-        }
-    }
-}
-
-itcl::body Rappture::XyPrint::SetOption { opt } {
-    set new $_settings($this$opt)
-    set old [$_clone cget $opt]
-    set code [catch [list $_clone configure $opt $new] err]
-    if { $code != 0 } {
-        bell
-        global errorInfo
-        puts stderr "$err: $errorInfo"
-        set _settings($this$opt) $old
-        $_clone configure $opt $old
-    }
-}
-
-itcl::body Rappture::XyPrint::SetComponentOption { comp opt } {
-    set new $_settings($this-$comp$opt)
-    set old [$_clone $comp cget $opt]
-    set code [catch [list $_clone $comp configure $opt $new] err]
-    if { $code != 0 } {
-        bell
-        global errorInfo
-        puts stderr "$err: $errorInfo"
-        set _settings($this-$comp$opt) $old
-        $_clone $comp configure $opt $old
-    }
-}
-
-itcl::body Rappture::XyPrint::SetNamedComponentOption { comp name opt } {
-    set new $_settings($this-$comp$opt)
-    set old [$_clone $comp cget $name $opt]
-    set code [catch [list $_clone $comp configure $name $opt $new] err]
-    if { $code != 0 } {
-        bell
-        global errorInfo
-        puts stderr "$err: $errorInfo"
-        set _settings($this-$comp$opt) $old
-        $_clone $comp configure $name $opt $old
-    }
-}
-
-itcl::body Rappture::XyPrint::RegeneratePreview {} {
-    update
-    set img [image create photo]
-    set w [Inches2Pixels $_settings($this-layout-width) 3.4]
-    set h [Inches2Pixels $_settings($this-layout-height) 3.4]
-    $_clone snap $img -width $w -height $h
-
-    set pixelsPerInch [winfo pixels . 1i]
-    set cw [winfo width $itk_component(preview)]
-    set ch [winfo height $itk_component(preview)]
-    set rw [expr 2.5*$pixelsPerInch]
-    set rh [expr 2.5*$pixelsPerInch]
-    set maxwidth $rw
-    set maxheight $rh
-    if { $maxwidth > $cw } {
-        set maxwidth $cw
-    }
-    if { $maxheight > $ch } {
-        set maxheight $ch
-    }
-    set sx [expr double($maxwidth)/$w]
-    set sy [expr double($maxheight)/$h]
-    set s [expr min($sx,$sy)]
-
-    set pw [expr int(round($s * $w))]
-    set ph [expr int(round($s * $h))]
-    $_preview configure -width $pw -height $ph
-    blt::winop resample $img $_preview box
-    image delete $img
-}
-
-itcl::body Rappture::XyPrint::Pixels2Inches { pixels } {
-    if { [llength $pixels] == 2 } {
-        set pixels [lindex $pixels 0]
-    }
-    set pixelsPerInch [winfo pixels . 1i]
-    set inches [expr { double($pixels) / $pixelsPerInch }]
-    return [format %.3g ${inches}]
-}
-
-itcl::body Rappture::XyPrint::Inches2Pixels { inches {defValue ""}} {
-    set n [scan $inches %g dummy]
-    if { $n != 1  && $defValue != "" } {
-        set inches $defValue
-    }
-    return  [winfo pixels . ${inches}i]
-}
-
-itcl::body Rappture::XyPrint::Color2RGB { color } {
-    foreach { r g b } [winfo rgb $_clone $color] {
-        set r [expr round($r / 257.0)]
-        set g [expr round($g / 257.0)]
-        set b [expr round($b / 257.0)]
-    }
-    return [format "\#%02x%02x%02x" $r $g $b]
-}
-
-itcl::body Rappture::XyPrint::GetAxisType { axis } {
-    foreach type { x y x2 y2 } {
-        set axes [$_clone ${type}axis use]
-        if { [lsearch $axes $axis] >= 0 } {
-            return [string range $type 0 0]
-        }
-    }
-    return ""
-}
-
-itcl::body Rappture::XyPrint::GetAxis {} {
-    set axis [$itk_component(axis_combo) current]
-    foreach option { -min -max -loose -title -stepsize -subdivisions } {
-        set _settings($this-axis$option) [$_clone axis cget $axis $option]
-    }
-    foreach attr { fontfamily fontsize fontweight fontslant } {
-        set specific $this-$axis-ticks
-        set general $this-axis-ticks
-        set _settings(${general}-${attr}) $_settings(${specific}-${attr})
-        set specific $this-$axis-title
-        set general $this-axis-title
-        set _settings(${general}-${attr}) $_settings(${specific}-${attr})
-    }
-    set type [GetAxisType $axis]
-    if { [$_clone grid cget -map${type}] == $axis } {
-        set _settings($this-axis-grid) 1
-    }  else {
-        set _settings($this-axis-grid) 0
-    }
-    set _settings($this-axis-plotpad${type}) \
-        [Pixels2Inches [$_clone cget -plotpad${type}]]
-    set _settings($this-axis-zero) [$_clone marker cget ${type}-zero -hide]
-}
-
-itcl::body Rappture::XyPrint::GetElement { args } {
-    set index 1
-    array unset _settings $this-element-*
-    foreach elem [$_clone element show] {
-        set _settings($this-element-$index) $elem
-        incr index
-    }
-    set index [$itk_component(element_slider) get]
-    set elem $_settings($this-element-$index)
-    set _settings($this-element-label) [$_clone element cget $elem -label]
-    set _settings($this-element-color) [$_clone element cget $elem -color]
-    if { [$_clone element type $elem] != "bar" } {
-        set _settings($this-element-symbol) [$_clone element cget $elem -symbol]
-        set _settings($this-element-dashes) [$_clone element cget $elem -dashes]
-    }
-    set page $itk_component(legend_page)
-    set color [$page.color label $_settings($this-element-color)]
-    if { $color == "" } {
-        set color [Color2RGB $_settings($this-element-color)]
-        $page.color choices insert end $color $color
-        $page.color value $color
-    } else {
-        $page.color value [$page.color label $_settings($this-element-color)]
-    }
-    if { [$_clone element type $elem] != "bar" } {
-        $page.symbol value [$page.symbol label $_settings($this-element-symbol)]
-        $page.dashes value [$page.dashes label $_settings($this-element-dashes)]
-    }
-    #FixElement
-}
-
-itcl::body Rappture::XyPrint::BuildLayoutTab {} {
-    itk_component add layout_page {
-        frame $itk_component(tabs).layout_page
-    }
-    set page $itk_component(layout_page)
-    $itk_component(tabs) insert end "layout" \
-        -text "Layout" -padx 2 -pady 2 -window $page -fill both
-
-    label $page.width_l -text "width"
-    entry $page.width -width 6 \
-        -textvariable [itcl::scope _settings($this-layout-width)]
-    bind  $page.width <KeyPress-Return> [itcl::code $this ApplyLayoutSettings]
-    Rappture::Tooltip::for $page.width \
-        "Set the width (inches) of the output image. Must be a positive number."
-
-    label $page.height_l -text "height"
-    entry $page.height -width 6 \
-        -textvariable [itcl::scope _settings($this-layout-height)]
-    bind  $page.height <KeyPress-Return> [itcl::code $this ApplyLayoutSettings]
-    Rappture::Tooltip::for $page.height \
-        "Set the height (inches) of the output image. Must be a positive number"
-
-    label $page.margin_l -text "Margins"
-
-    label $page.left_l -text "left"
-    entry $page.left -width 6 \
-        -textvariable [itcl::scope _settings($this-layout-leftmargin)]
-    bind  $page.left <KeyPress-Return> [itcl::code $this ApplyLayoutSettings]
-    Rappture::Tooltip::for $page.left \
-        "Set the size (inches) of the left margin. If zero, the size is automatically determined."
-
-    label $page.right_l -text "right"
-    entry $page.right -width 6 \
-        -textvariable [itcl::scope _settings($this-layout-rightmargin)]
-    bind  $page.right <KeyPress-Return> [itcl::code $this ApplyLayoutSettings]
-    Rappture::Tooltip::for $page.right \
-        "Set the size (inches) of the right margin. If zero, the size is automatically determined."
-
-
-    label $page.top_l -text "top"
-    entry $page.top -width 6 \
-        -textvariable [itcl::scope _settings($this-layout-topmargin)]
-    bind  $page.top <KeyPress-Return> [itcl::code $this ApplyLayoutSettings]
-    Rappture::Tooltip::for $page.top \
-        "Set the size (inches) of the top margin. If zero, the size is automatically determined."
-
-    label $page.bottom_l -text "bottom"
-    entry $page.bottom -width 6 \
-        -textvariable [itcl::scope _settings($this-layout-bottommargin)]
-    bind  $page.bottom <KeyPress-Return> [itcl::code $this ApplyLayoutSettings]
-    Rappture::Tooltip::for $page.bottom \
-        "Set the size (inches) of the bottom margin. If zero, the size is automatically determined."
-
-
-    label $page.map -image [Rappture::icon graphmargins]
-    blt::table $page \
-        0,0 $page.width_l -anchor e \
-        0,1 $page.width -fill x  \
-        1,0 $page.height_l -anchor e \
-        1,1 $page.height -fill x \
-        3,0 $page.left_l -anchor e \
-        3,1 $page.left -fill x  \
-        4,0 $page.right_l -anchor e \
-        4,1 $page.right -fill x \
-        5,0 $page.top_l -anchor e \
-        5,1 $page.top -fill x \
-        6,0 $page.bottom_l -anchor e \
-        6,1 $page.bottom -fill x  \
-        0,2 $page.map -fill both -rspan 7 -padx 2
-
-    blt::table configure $page c0 r* -resize none
-    blt::table configure $page c1 r2 -resize both
-}
-
-
-itcl::body Rappture::XyPrint::BuildGeneralTab {} {
-    itk_component add graph_page {
-        frame $itk_component(tabs).graph_page
-    }
-    set page $itk_component(graph_page)
-    $itk_component(tabs) insert end "graph" \
-        -text "General" -padx 2 -pady 2 -window $page -fill both
-
-    label $page.format_l -text "format"
-    Rappture::Combobox $page.format -width 30 -editable no
-    $page.format choices insert end \
-        "pdf" "PDF Portable Document Format" \
-        "ps"  "PS PostScript Format"  \
-        "eps" "EPS Encapsulated PostScript"  \
-        "jpg" "JPEG Joint Photographic Experts Group Format" \
-        "png" "PNG Portable Network Graphics Format"
-
-    bind $page.format <<Value>> [itcl::code $this ApplyGeneralSettings]
-    Rappture::Tooltip::for $page.format \
-        "Set the format of the image."
-
-    label $page.style_l -text "style"
-    Rappture::Combobox $page.style -width 20 -editable no
-    $page.style choices insert end \
-        "ieee" "IEEE Journal"  \
-        "gekco" "G Klimeck"
-    bind $page.style <<Value>> [itcl::code $this ApplyGeneralSettings]
-    Rappture::Tooltip::for $page.format \
-        "Set the style template."
-
-    checkbutton $page.remember -text "remember settings" \
-        -variable [itcl::scope _settings($this-general-remember)]
-    Rappture::Tooltip::for $page.remember \
-        "Remember the settings. They will be override the default settings."
-
-    button $page.revert -text "revert" -image [Rappture::icon revert] \
-        -compound left -padx 3 -pady 1 -overrelief raised -relief flat \
-        -command [itcl::code $this ResetSettings]
-    Rappture::Tooltip::for $page.revert \
-        "Revert to the default settings."
-
-    blt::table $page \
-        2,0 $page.format_l -anchor e \
-        2,1 $page.format -fill x -cspan 2 \
-        3,0 $page.style_l -anchor e \
-        3,1 $page.style -fill x -cspan 2 \
-        5,0 $page.remember -cspan 2 -anchor w \
-        5,2 $page.revert -anchor e
-    blt::table configure $page r* -resize none  -pady { 0 2 }
-    blt::table configure $page r4 -resize both
-
-}
-
-itcl::body Rappture::XyPrint::ApplyLegendSettings {} {
-    set page $itk_component(legend_page)
-    set _settings($this-legend-anchor)    [$page.anchor current]
-    if { $_clone != "" } {
-        lappend font $_settings($this-legend-fontfamily)
-        lappend font $_settings($this-legend-fontsize)
-        lappend font $_settings($this-legend-fontweight)
-        lappend font $_settings($this-legend-fontslant)
-        foreach option { -hide -position -anchor -borderwidth } {
-            SetComponentOption legend $option
-        }
-        $_clone legend configure -font fixed -font $font
-    }
-    ApplyElementSettings
-}
-
-itcl::body Rappture::XyPrint::BuildLegendTab {} {
-    itk_component add legend_page {
-        frame $itk_component(tabs).legend_page
-    }
-    set page $itk_component(legend_page)
-    $itk_component(tabs) insert end "legend" \
-        -text "Legend" -padx 2 -pady 2 -window $page -fill both
-
-    checkbutton $page.show -text "show legend" \
-        -offvalue 1 -onvalue 0 \
-        -variable [itcl::scope _settings($this-legend-hide)]  \
-        -command [itcl::code $this ApplyLegendSettings]
-    Rappture::Tooltip::for $page.show \
-        "Display the legend."
-
-    label $page.position_l -text "position"
-    Rappture::Combobox $page.position -width 15 -editable no
-    $page.position choices insert end \
-        "leftmargin" "left margin"  \
-        "rightmargin" "right margin"  \
-        "bottommargin" "bottom margin"  \
-        "topmargin" "top margin"  \
-        "plotarea" "inside plot"
-    bind $page.position <<Value>> [itcl::code $this ApplyLegendSettings]
-    Rappture::Tooltip::for $page.position \
-        "Set the position of the legend.  This option and the anchor determine the legend's location."
-
-    Rappture::Combobox $page.anchor -width 10 -editable no
-    $page.anchor choices insert end \
-        "nw" "northwest"  \
-        "n" "north"  \
-        "ne" "northeast"  \
-        "sw" "southwest"  \
-        "s" "south"  \
-        "se" "southeast"  \
-        "c" "center"  \
-        "e" "east"  \
-        "w" "west"
-    bind $page.anchor <<Value>> [itcl::code $this ApplyLegendSettings]
-    Rappture::Tooltip::for $page.anchor \
-        "Set the anchor of the legend.  This option and the anchor determine the legend's location."
-
-    checkbutton $page.border -text "border" \
-        -variable [itcl::scope _settings($this-legend-borderwidth)] \
-        -onvalue 1 -offvalue 0 \
-        -command [itcl::code $this ApplyLegendSettings]
-    Rappture::Tooltip::for $page.border \
-        "Display a solid border around the legend."
-
-    label $page.slider_l -text "legend\nentry"  -justify right
-    itk_component add element_slider {
-        ::scale $page.slider -from 1 -to 1 \
-            -orient horizontal -width 12 \
-            -command [itcl::code $this GetElement]
-    }
-    Rappture::Tooltip::for $page.slider \
-        "Select the current entry."
-
-    label $page.label_l -text "label"
-    entry $page.label \
-        -background white \
-        -textvariable [itcl::scope _settings($this-element-label)]
-    bind  $page.label <KeyPress-Return> [itcl::code $this ApplyElementSettings]
-    Rappture::Tooltip::for $page.label \
-        "Set the label of the current entry in the legend."
-
-    label $page.color_l -text "color "
-    Rappture::Combobox $page.color -width 15 -editable no
-    $page.color choices insert end \
-        "#000000" "black" \
-        "#ffffff" "white" \
-        "#0000cd" "blue" \
-        "#cd0000" "red" \
-        "#00cd00" "green" \
-        "#3a5fcd" "royal blue" \
-        "#cdcd00" "yellow" \
-        "#cd1076" "deep pink" \
-        "#009acd" "deep sky blue" \
-        "#00c5cd" "torquise" \
-        "#a2b5cd" "light steel blue" \
-        "#7ac5cd" "cadet blue" \
-        "#66cdaa" "aquamarine" \
-        "#a2cd5a" "dark olive green" \
-        "#cd9b9b" "rosy brown" \
-        "#0000ff" "blue1" \
-        "#ff0000" "red1" \
-        "#00ff00" "green1"
-    bind $page.color <<Value>> [itcl::code $this ApplyElementSettings]
-    Rappture::Tooltip::for $page.color \
-        "Set the color of the current entry."
-
-    label $page.dashes_l -text "line style"
-    Rappture::Combobox $page.dashes -width 15 -editable no
-    $page.dashes choices insert end \
-        "" "solid"  \
-        "1" "dot" \
-        "5 2" "dash" \
-        "2 4 2" "dashdot" \
-        "2 4 2 2" "dashdotdot"
-    bind $page.dashes <<Value>> [itcl::code $this ApplyElementSettings]
-    Rappture::Tooltip::for $page.dashes \
-        "Set the line style of the current entry."
-
-    label $page.symbol_l -text "symbol"
-    Rappture::Combobox $page.symbol -editable no
-    $page.symbol choices insert end \
-        "none" "none"  \
-        "square" "square" \
-        "circle" "circle" \
-        "diamond" "diamond" \
-        "plus" "plus" \
-        "cross" "cross" \
-        "splus" "skinny plus"  \
-        "scross" "skinny cross" \
-        "triangle" "triangle"
-    bind $page.symbol <<Value>> [itcl::code $this ApplyElementSettings]
-    Rappture::Tooltip::for $page.symbol \
-        "Set the symbol of the current entry. \"none\" display no symbols."
-
-    label $page.font_l -text "font"
-    Rappture::Combobox $page.fontfamily -width 10 -editable no
-    $page.fontfamily choices insert end \
-        "courier" "courier" \
-        "helvetica" "helvetica"  \
-        "new*century*schoolbook"  "new century schoolbook" \
-        "symbol"  "symbol" \
-        "times"  "times"
-    bind $page.fontfamily <<Value>> [itcl::code $this ApplyLegendSettings]
-    Rappture::Tooltip::for $page.fontfamily \
-        "Set the font of entries in the legend."
-
-    Rappture::Combobox $page.fontsize -width 4 -editable no
-    $page.fontsize choices insert end \
-        "8" "8" \
-        "9" "9" \
-        "10" "10" \
-        "11" "11" \
-        "12" "12" \
-        "14" "14" \
-        "17" "17" \
-        "18" "18" \
-        "20" "20"
-    bind  $page.fontsize <<Value>> [itcl::code $this ApplyLegendSettings]
-    Rappture::Tooltip::for $page.fontsize \
-        "Set the size (points) of the font."
-
-    Rappture::PushButton $page.fontweight \
-        -onimage [Rappture::icon font-bold] \
-        -offimage [Rappture::icon font-bold] \
-        -onvalue "bold" -offvalue "normal" \
-        -command [itcl::code $this ApplyLegendSettings] \
-        -variable [itcl::scope _settings($this-legend-fontweight)]
-    Rappture::Tooltip::for $page.fontweight \
-        "Use the bold version of the font."
-
-    Rappture::PushButton $page.fontslant \
-        -onimage [Rappture::icon font-italic] \
-        -offimage [Rappture::icon font-italic] \
-        -onvalue "italic" -offvalue "roman" \
-        -command [itcl::code $this ApplyLegendSettings] \
-        -variable [itcl::scope _settings($this-legend-fontslant)]
-    Rappture::Tooltip::for $page.fontslant \
-        "Use the italic version of the font."
-
-    blt::table $page \
-        1,0 $page.show -cspan 2 -anchor w \
-        1,2 $page.border -cspan 2 -anchor w \
-        2,0 $page.position_l -anchor e \
-        2,1 $page.position -fill x \
-        2,2 $page.anchor -fill x  -cspan 3 \
-        3,0 $page.font_l -anchor e \
-        3,1 $page.fontfamily -fill x \
-        3,2 $page.fontsize -fill x \
-        3,3 $page.fontweight -anchor e \
-        3,4 $page.fontslant -anchor e \
-        4,0 $page.slider_l -anchor e \
-        4,1 $page.slider -fill x -cspan 5 \
-        5,0 $page.label_l -anchor e \
-        5,1 $page.label -fill x -cspan 5 \
-        6,0 $page.color_l -anchor e \
-        6,1 $page.color -fill x \
-        6,2 $page.symbol_l -anchor e \
-        6,3 $page.symbol -fill both -cspan 3 \
-        7,0 $page.dashes_l -anchor e \
-        7,1 $page.dashes -fill x \
-
-    blt::table configure $page r* -resize none -pady { 0 2 }
-    blt::table configure $page c3 c4 -resize none
-    blt::table configure $page r8 -resize both
-
-}
-
-itcl::body Rappture::XyPrint::BuildAxisTab {} {
-    itk_component add axis_page {
-        frame $itk_component(tabs).axis_page
-    }
-    set page $itk_component(axis_page)
-    $itk_component(tabs) insert end "axis" \
-        -text "Axis" -padx 2 -pady 2 -window $page -fill both
-
-    label $page.axis_l -text "axis"
-    itk_component add axis_combo {
-        Rappture::Combobox $page.axis -width 20 -editable no
-    }
-    bind $itk_component(axis_combo) <<Value>> [itcl::code $this GetAxis]
-    Rappture::Tooltip::for $page.axis \
-        "Select the current axis."
-
-    label $page.title_l -text "title"
-    entry $page.title \
-        -textvariable [itcl::scope _settings($this-axis-title)]
-    bind  $page.title <KeyPress-Return> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.title \
-        "Set the title of the current axis."
-
-    label $page.min_l -text "min"
-    entry $page.min -width 10 \
-        -textvariable [itcl::scope _settings($this-axis-min)]
-    bind  $page.min <KeyPress-Return> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.min \
-        "Set the minimum limit for the current axis. If empty, the minimum is automatically determined."
-
-    label $page.max_l -text "max"
-    entry $page.max -width 10 \
-        -textvariable [itcl::scope _settings($this-axis-max)]
-    bind  $page.max <KeyPress-Return> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.max \
-        "Set the maximum limit for the current axis. If empty, the maximum is automatically determined."
-
-    label $page.subdivisions_l -text "subdivisions"
-    entry $page.subdivisions \
-        -textvariable [itcl::scope _settings($this-axis-subdivisions)]
-    bind  $page.subdivisions <KeyPress-Return> \
-        [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.subdivisions \
-        "Set the number of subdivisions (minor ticks) for the current axis."
-
-    label $page.stepsize_l -text "step size"
-    entry $page.stepsize \
-        -textvariable [itcl::scope _settings($this-axis-stepsize)]
-    bind  $page.stepsize <KeyPress-Return> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.stepsize \
-        "Set the interval between major ticks for the current axis. If zero, the interval is automatically determined."
-
-    checkbutton $page.loose -text "loose limits" \
-        -onvalue "always" -offvalue "0" \
-        -variable [itcl::scope _settings($this-axis-loose)] \
-        -command [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.loose \
-        "Set major ticks outside of the limits for the current axis."
-
-    label $page.plotpad_l -text "pad"
-    entry $page.plotpad -width 6 \
-        -textvariable [itcl::scope _settings($this-axis-plotpad)]
-    bind  $page.plotpad <KeyPress-Return> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.plotpad \
-        "Set padding (points) between the current axis and the plot."
-
-    checkbutton $page.grid -text "show grid lines" \
-        -variable [itcl::scope _settings($this-axis-grid)] \
-        -command [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.grid \
-        "Display grid lines for the current axis."
-
-    checkbutton $page.zero -text "mark zero" \
-        -offvalue 1 -onvalue 0 \
-        -variable [itcl::scope _settings($this-axis-zero)] \
-        -command [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.zero \
-        "Display a line at zero for the current axis."
-
-    label $page.tickfont_l -text "tick font"
-    Rappture::Combobox $page.tickfontfamily -width 10 -editable no
-    $page.tickfontfamily choices insert end \
-        "courier" "courier" \
-        "helvetica" "helvetica"  \
-        "new*century*schoolbook"  "new century schoolbook" \
-        "symbol"  "symbol" \
-        "times"  "times"
-    bind $page.tickfontfamily <<Value>> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.tickfontfamily \
-        "Set the font of the ticks for the current axis."
-
-    Rappture::Combobox $page.tickfontsize -width 4 -editable no
-    $page.tickfontsize choices insert end \
-        "8" "8" \
-        "9" "9" \
-        "10" "10" \
-        "11" "11" \
-        "12" "12" \
-        "14" "14" \
-        "17" "17" \
-        "18" "18" \
-        "20" "20"
-    bind $page.tickfontsize <<Value>> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.tickfontsize \
-        "Set the size (points) of the tick font."
-
-    Rappture::PushButton $page.tickfontweight \
-        -onimage [Rappture::icon font-bold] \
-        -offimage [Rappture::icon font-bold] \
-        -onvalue "bold" -offvalue "normal" \
-        -command [itcl::code $this ApplyAxisSettings] \
-        -variable [itcl::scope _settings($this-axis-ticks-fontweight)]
-    Rappture::Tooltip::for $page.tickfontweight \
-        "Use the bold version of the tick font."
-
-    Rappture::PushButton $page.tickfontslant \
-        -onimage [Rappture::icon font-italic] \
-        -offimage [Rappture::icon font-italic] \
-        -onvalue "italic" -offvalue "roman" \
-        -command [itcl::code $this ApplyAxisSettings] \
-        -variable [itcl::scope _settings($this-axis-ticks-fontslant)]
-    Rappture::Tooltip::for $page.tickfontslant \
-        "Use the italic version of the tick font."
-
-    label $page.titlefont_l -text "title font"
-    Rappture::Combobox $page.titlefontfamily -width 10 -editable no
-    $page.titlefontfamily choices insert end \
-        "courier" "courier" \
-        "helvetica" "helvetica"  \
-        "new*century*schoolbook"  "new century schoolbook" \
-        "symbol"  "symbol" \
-        "times"  "times"
-    bind $page.titlefontfamily <<Value>> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.titlefontfamily \
-        "Set the font of the title for the current axis."
-
-    Rappture::Combobox $page.titlefontsize -width 4 -editable no
-    $page.titlefontsize choices insert end \
-        "8" "8" \
-        "9" "9" \
-        "10" "10" \
-        "11" "11" \
-        "12" "12" \
-        "14" "14" \
-        "17" "17" \
-        "18" "18" \
-        "20" "20"
-    bind $page.titlefontsize <<Value>> [itcl::code $this ApplyAxisSettings]
-    Rappture::Tooltip::for $page.titlefontsize \
-        "Set the size (point) of the title font."
-
-    Rappture::PushButton $page.titlefontweight \
-        -onimage [Rappture::icon font-bold] \
-        -offimage [Rappture::icon font-bold] \
-        -onvalue "bold" -offvalue "normal" \
-        -command [itcl::code $this ApplyAxisSettings] \
-        -variable [itcl::scope _settings($this-axis-title-fontweight)]
-    Rappture::Tooltip::for $page.titlefontweight \
-        "Use the bold version of the title font."
-
-    Rappture::PushButton $page.titlefontslant \
-        -onimage [Rappture::icon font-italic] \
-        -offimage [Rappture::icon font-italic] \
-        -onvalue "italic" -offvalue "roman" \
-        -command [itcl::code $this ApplyAxisSettings] \
-        -variable [itcl::scope _settings($this-axis-title-fontslant)]
-    Rappture::Tooltip::for $page.titlefontslant \
-        "Use the italic version of the title font."
-
-    blt::table $page \
-        1,1 $page.axis_l -anchor e  -pady 6 \
-        1,2 $page.axis -fill x -cspan 6 \
-        2,1 $page.title_l -anchor e \
-        2,2 $page.title -fill x -cspan 5 \
-        3,1 $page.min_l -anchor e \
-        3,2 $page.min -fill x \
-        3,3 $page.stepsize_l -anchor e \
-        3,4 $page.stepsize -fill both -cspan 3 \
-        4,1 $page.max_l -anchor e \
-        4,2 $page.max -fill both \
-        4,3 $page.subdivisions_l -anchor e \
-        4,4 $page.subdivisions -fill both -cspan 3  \
-        5,1 $page.titlefont_l -anchor e \
-        5,2 $page.titlefontfamily -fill x -cspan 2 \
-        5,4 $page.titlefontsize -fill x \
-        5,5 $page.titlefontweight -anchor e \
-        5,6 $page.titlefontslant -anchor e \
-        6,1 $page.tickfont_l -anchor e \
-        6,2 $page.tickfontfamily -fill x -cspan 2 \
-        6,4 $page.tickfontsize -fill x \
-        6,5 $page.tickfontweight -anchor e \
-        6,6 $page.tickfontslant -anchor e \
-        7,1 $page.loose -cspan 2 -anchor w \
-        7,3 $page.grid -anchor w -cspan 2 \
-        8,1 $page.zero -cspan 2 -anchor w \
-        8,3 $page.plotpad_l -anchor e \
-        8,4 $page.plotpad -fill both -cspan 3
-
-    blt::table configure $page  c0 c4 c5 c6 c7 c8 -resize none
-}
-
-itcl::body Rappture::XyPrint::ApplyGeneralSettings {} {
-    RegeneratePreview
-}
-
-itcl::body Rappture::XyPrint::ApplyLegendSettings {} {
-    set page $itk_component(legend_page)
-    set _settings($this-legend-position)  [$page.position current]
-    set _settings($this-legend-anchor)    [$page.anchor current]
-
-    foreach option { -hide -position -anchor -borderwidth } {
-        SetComponentOption legend $option
-    }
-    set _settings($this-legend-fontfamily)  [$page.fontfamily value]
-    set _settings($this-legend-fontsize)    [$page.fontsize value]
-    lappend font $_settings($this-legend-fontfamily)
-    lappend font $_settings($this-legend-fontsize)
-    lappend font $_settings($this-legend-fontweight)
-    lappend font $_settings($this-legend-fontslant)
-    $_clone legend configure -font fixed -font $font
-    ApplyElementSettings
-}
-
-itcl::body Rappture::XyPrint::ApplyAxisSettings {} {
-    set axis [$itk_component(axis_combo) current]
-    set type [GetAxisType $axis]
-    set page $itk_component(axis_page)
-    if { $_settings($this-axis-grid) } {
-        $_clone grid configure -hide no -map${type} ${axis}
-    } else {
-        $_clone grid configure -hide no -map${type} ""
-    }
-    $_clone configure -plotpad${type} $_settings($this-axis-plotpad)
-    foreach option { -min -max -loose -title -stepsize -subdivisions } {
-        SetNamedComponentOption axis $axis $option
-    }
-    set _settings($this-axis-ticks-fontfamily)  [$page.tickfontfamily value]
-    set _settings($this-axis-ticks-fontsize)    [$page.tickfontsize value]
-    set _settings($this-axis-title-fontfamily)  [$page.titlefontfamily value]
-    set _settings($this-axis-title-fontsize)    [$page.titlefontsize value]
-
-    set tickfont {}
-    set titlefont {}
-
-    foreach attr { fontfamily fontsize fontweight fontslant } {
-        set specific $this-$axis-ticks
-        set general  $this-axis-ticks
-        set _settings(${specific}-${attr}) $_settings(${general}-${attr})
-        lappend tickfont $_settings(${general}-${attr})
-        set specific $this-$axis-title
-        set general  $this-axis-title
-        set _settings(${specific}-${attr}) $_settings(${general}-${attr})
-        lappend titlefont $_settings(${general}-${attr})
-    }
-    $_clone axis configure $axis -tickfont $tickfont -titlefont $titlefont
-    $_clone marker configure ${type}-zero -hide $_settings($this-axis-zero)
-    GetAxis
-    RegeneratePreview
-}
-
-itcl::body Rappture::XyPrint::ApplyElementSettings {} {
-    set index [$itk_component(element_slider) get]
-    set page $itk_component(legend_page)
-    set _settings($this-element-color)  [$page.color current]
-    if { $_clone != "" } {
-        set elem $_settings($this-element-$index)
-        if { [$_clone element type $elem] != "bar" } {
-            set _settings($this-element-symbol) [$page.symbol current]
-            set _settings($this-element-dashes) [$page.dashes current]
-            foreach option { -symbol -dashes } {
-                SetNamedComponentOption element $elem $option
-            }
-        }
-        foreach option { -color -label } {
-            SetNamedComponentOption element $elem $option
-        }
-        RegeneratePreview
-    }
-}
-
-itcl::body Rappture::XyPrint::SetLayoutOption { opt } {
-    set new [Inches2Pixels $_settings($this-layout$opt)]
-    $_clone configure $opt $new
-}
-
-itcl::body Rappture::XyPrint::ApplyLayoutSettings {} {
-    foreach opt { -width -height -leftmargin -rightmargin -topmargin
-        -bottommargin } {
-        set old [$_clone cget $opt]
-        set code [catch { SetLayoutOption $opt } err]
-        if { $code != 0 } {
-            bell
-            global errorInfo
-            puts stderr "$err: $errorInfo"
-            set _settings($this-layout$opt) [Pixels2Inches $old]
-            $_clone configure $opt [Pixels2Inches $old]
-        }
-    }
-    RegeneratePreview
-}
-
-
-itcl::body Rappture::XyPrint::InitializeSettings {} {
-    # General settings
-
-    # Always set to "ps" "ieee"
-    set _settings($this-general-format) ps
-    set _settings($this-general-style) ieee
-    set _settings($this-general-remember) 0
-    set page $itk_component(graph_page)
-    $page.format value [$page.format label $_settings($this-general-format)]
-    $page.style value [$page.style label $_settings($this-general-style)]
-
-    # Layout settings
-    set _settings($this-layout-width) [Pixels2Inches [$_clone cget -width]]
-    set _settings($this-layout-height) [Pixels2Inches [$_clone cget -height]]
-    set _settings($this-layout-leftmargin) \
-        [Pixels2Inches [$_clone cget -leftmargin]]
-    set _settings($this-layout-rightmargin) \
-        [Pixels2Inches [$_clone cget -rightmargin]]
-    set _settings($this-layout-topmargin) \
-        [Pixels2Inches [$_clone cget -topmargin]]
-    set _settings($this-layout-bottommargin) \
-        [Pixels2Inches [$_clone cget -bottommargin]]
-
-    # Legend settings
-    set page $itk_component(legend_page)
-
-    set names [$_clone element show]
-    $itk_component(element_slider) configure -from 1 -to [llength $names]
-    set state [expr  { ([llength $names] < 2) ? "disabled" : "normal" } ]
-    $page.slider configure -state $state
-    $page.slider_l configure -state $state
-    # Always initialize the slider to the first entry in the element list.
-    $itk_component(element_slider) set 1
-    # Always set the borderwidth to be not displayed
-    set _settings($this-legend-borderwidth) 0
-
-    $page.fontfamily value $_settings($this-legend-fontfamily)
-    $page.fontsize value $_settings($this-legend-fontsize)
-    if { $_settings($this-legend-fontweight) == "bold" } {
-        set _settings($this-legend-font-bold) 1
-    }
-    set _settings($this-legend-hide) [$_clone legend cget -hide]
-    set _settings($this-legend-position) [$_clone legend cget -position]
-    set _settings($this-legend-anchor) [$_clone legend cget -anchor]
-    $page.position value \
-        [$page.position label $_settings($this-legend-position)]
-    $page.anchor value [$page.anchor label $_settings($this-legend-anchor)]
-    GetElement
-
-    # Axis settings
-    set page $itk_component(axis_page)
-    set names [lsort [$_clone axis names]]
-    $itk_component(axis_combo) choices delete 0 end
-    foreach axis $names {
-        if { $axis == "z" } {
-            continue
-        }
-        if { ![$_clone axis cget $axis -hide] } {
-            $itk_component(axis_combo) choices insert end $axis $axis
-        }
-        lappend axisnames $axis
-    }
-    set axis [lindex $names 0]
-
-    $page.titlefontfamily value $_settings($this-$axis-title-fontfamily)
-    $page.titlefontsize value   $_settings($this-$axis-title-fontsize)
-    $page.tickfontfamily value  $_settings($this-$axis-ticks-fontfamily)
-    $page.tickfontsize value    $_settings($this-$axis-ticks-fontsize)
-
-    # Always hide the zero line.
-    set _settings($this-axis-zero) 1
-    set _settings($this-axis-plotpad) [Pixels2Inches [$_clone cget -plotpadx]]
-    # Pick the first axis to initially display
-    set axis [lindex $axisnames 0]
-    $itk_component(axis_combo) value $axis
-    GetAxis
-    RegeneratePreview
-}
-
-
-itcl::body Rappture::XyPrint::restore { toolName plotName data } {
-    set key [list $toolName $plotName]
-    set _savedSettings($key) $data
-}
-
-itcl::body Rappture::XyPrint::RestoreSettings { toolName plotName } {
-    if { ![file readable $_settingsFile] } {
-        return;                         # No file or not readable
-    }
-    if { [file exists $_oldSettingsFile] } {
-        file delete $_oldSettingsFile
-    }
-    # Read the file by sourcing it into a safe interpreter The only commands
-    # executed will be "xyprint" which will simply add the data into an array
-    # _savedSettings.
-    set parser [interp create -safe]
-    $parser alias xyprint [itcl::code $this restore]
-    set f [open $_settingsFile "r"]
-    set code [read $f]
-    close $f
-    if { [catch { $parser eval $code }] != 0 } {
-        file delete $_settingsFile
-    }
-    # Now see if there's an entry for this tool/plot combination.  The data
-    # associated with the variable is itself code to update the graph (clone).
-    set key [list $toolName $plotName]
-    if { [info exists _savedSettings($key)] }  {
-        $parser alias "preview" $_clone
-        $parser eval $_savedSettings($key)
-    }
-    # Restore settings to this instance
-    foreach {name value} [$parser eval "array get settings"] {
-        set _settings($this-$name) $value
-    }
-    interp delete $parser
-}
-
-itcl::body Rappture::XyPrint::ResetSettings {} {
-    set graph $_graph
-    DestroySettings
-    set _graph $graph
-    CloneGraph $graph
-    InitClone
-    InitializeSettings
-}
-
-itcl::body Rappture::XyPrint::SaveSettings { toolName plotName } {
-    if { !$_settings($this-general-remember) } {
-        return
-    }
-    if { [catch { open $_settingsFile "w" 0600 } f ] != 0 } {
-        puts stderr "$_settingsFile isn't writable: $f"
-        bell
-        return
-    }
-    set key [list $toolName $plotName]
-    set _savedSettings($key) [CreateSettings $toolName $plotName]
-    # Write the settings out
-    foreach key [lsort [array names _savedSettings]] {
-        set tool [lindex $key 0]
-        set plot [lindex $key 1]
-        puts $f "xyprint \"$tool\" \"$plot\" \{"
-        set settings [string trim $_savedSettings($key) \n]
-        puts $f "$settings"
-        puts $f "\}\n"
-    }
-    close $f
-}
-
-itcl::body Rappture::XyPrint::CreateSettings { toolName plotName } {
-    # Create stanza associated with tool and plot title.
-    # General settings
-    set length [string length "${this}-"]
-    append out "    array set settings {\n"
-    foreach item [array names _settings ${this}-*] {
-        set field [string range $item $length end]
-        if { [regexp {^element-[0-9]+$} $field] } {
-            continue
-        }
-        set value $_settings($item)
-        append out "        [list $field] [list $value]\n"
-    }
-    append out "    }\n"
-    # Legend font
-    lappend legendfont $_settings($this-legend-fontfamily)
-    lappend legendfont $_settings($this-legend-fontsize)
-    lappend legendfont $_settings($this-legend-fontweight)
-    lappend legendfont $_settings($this-legend-fontslant)
-    # Axis tick font
-    lappend axistickfont $_settings($this-axis-ticks-fontfamily)
-    lappend axistickfont $_settings($this-axis-ticks-fontsize)
-    lappend axistickfont $_settings($this-axis-ticks-fontweight)
-    lappend axistickfont $_settings($this-axis-ticks-fontslant)
-    # Axis title font
-    lappend axistitlefont $_settings($this-axis-title-fontfamily)
-    lappend axistitlefont $_settings($this-axis-title-fontsize)
-    lappend axistitlefont $_settings($this-axis-title-fontweight)
-    lappend axistitlefont $_settings($this-axis-title-fontslant)
-    append out "\n"
-
-    # Layout settings
-    append out "    preview configure"
-    foreach opt { -width -height -leftmargin -rightmargin -topmargin
-        -bottommargin -plotpadx -plotpady } {
-        set value [$_clone cget $opt]
-        append out " $opt [list $value]"
-    }
-    append out "\n"
-
-    # Legend settings
-    append out "    preview legend configure"
-    foreach opt { -position -anchor -borderwidth -hide } {
-        set value [$_clone legend cget $opt]
-        append out " $opt [list $value]"
-    }
-    append out " -font [list $legendfont]\n"
-
-    # Element settings
-    foreach elem [$_clone element show] {
-        set label [$_clone element cget $elem -label]
-        if { $label == "" } {
-            continue
-        }
-        set label [list $label]
-        append out "    if \{ \[preview element exists $label] \} \{\n"
-        append out "        preview element configure $label"
-        if { [$_clone element type $elem] != "bar" } {
-            set options { -symbol -color -dashes -label }
-        } else {
-            set options { -color -label }
-        }
-        foreach opt $options {
-            set value [$_clone element cget $elem $opt]
-            append out " $opt [list $value]"
-        }
-        append out "    \}\n"
-    }
-
-    # Axis settings
-    foreach axis [$_clone axis names] {
-        if { [$_clone axis cget $axis -hide] } {
-            continue
-        }
-        set axis [list $axis]
-        append out "    if \{ \[llength \[preview axis names $axis\]\] == 1 \} \{\n"
-        append out "        preview axis configure $axis"
-        foreach opt { -hide -min -max -loose -title -stepsize -subdivisions } {
-            set value [$_clone axis cget $axis $opt]
-            append out " $opt [list $value]"
-        }
-        append out " -tickfont [list $axistickfont]"
-        append out " -titlefont [list $axistitlefont]\n"
-        set hide [$_clone marker cget ${axis}-zero -hide]
-        append out "        preview marker configure ${axis}-zero -hide $hide\n"
-        append out "    \}\n"
-    }
-
-    append out "    preview grid configure"
-    append out " -hide \"[$_clone grid cget -hide]\""
-    append out " -mapx \"[$_clone grid cget -mapx]\""
-    append out " -mapy \"[$_clone grid cget -mapy]\""
-    return $out
-}
Index: trunk/gui/scripts/xyresult.tcl
===================================================================
--- trunk/gui/scripts/xyresult.tcl	(revision 6716)
+++ 	(revision )
@@ -1,1682 +1,0 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*-
-# ----------------------------------------------------------------------
-#  COMPONENT: xyresult - X/Y plot in a ResultSet
-#
-#  This widget is an X/Y plot, meant to view line graphs produced
-#  as output from the run of a Rappture tool.  Use the "add" and
-#  "delete" methods to control the data objects showing on the plot.
-# ======================================================================
-#  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
-#
-#  See the file "license.terms" for information on usage and
-#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-# ======================================================================
-package require Itk
-package require BLT
-
-option add *XyResult.width 3i widgetDefault
-option add *XyResult.height 3i widgetDefault
-option add *XyResult.gridColor #d9d9d9 widgetDefault
-option add *XyResult.activeColor blue widgetDefault
-option add *XyResult.dimColor gray widgetDefault
-option add *XyResult.controlBackground gray widgetDefault
-option add *XyResult.font \
-    -*-helvetica-medium-r-normal-*-12-* widgetDefault
-
-set autocolors {
-    #0000cd
-    #cd0000
-    #00cd00
-    #3a5fcd
-    #cdcd00
-    #cd1076
-    #009acd
-    #00c5cd
-    #a2b5cd
-    #7ac5cd
-    #66cdaa
-    #a2cd5a
-    #cd9b9b
-    #cdba96
-    #cd3333
-    #cd6600
-    #cd8c95
-    #cd00cd
-    #9a32cd
-    #6ca6cd
-    #9ac0cd
-    #9bcd9b
-    #00cd66
-    #cdc673
-    #cdad00
-    #cd5555
-    #cd853f
-    #cd7054
-    #cd5b45
-    #cd6889
-    #cd69c9
-    #551a8b
-}
-
-option add *XyResult.autoColors $autocolors widgetDefault
-option add *XyResult*Balloon*Entry.background white widgetDefault
-
-itcl::class Rappture::XyResult {
-    inherit itk::Widget
-
-    itk_option define -gridcolor gridColor GridColor ""
-    itk_option define -activecolor activeColor ActiveColor ""
-    itk_option define -dimcolor dimColor DimColor ""
-    itk_option define -autocolors autoColors AutoColors ""
-
-    private variable _viewable "";      # Display list for widget.
-    private variable _dispatcher "";    # Dispatcher for !events
-    private variable _dlist "";         # List of dataobj objects
-    private variable _dataobj2raise;    # Maps dataobj => raise flag 0/1
-    private variable _dataobj2desc;     # Maps dataobj => description of data
-    private variable _dataobj2sim;      # Maps dataobj => type of graph element
-    private variable _elem2comp;        # Maps graph element => dataobj
-    private variable _comp2elem;        # Maps graph element => dataobj
-    private variable _label2axis;       # Maps axis label => axis ID
-    private variable _limits;           # Axis limits:  x-min, x-max, etc.
-    private variable _nextColorIndex 0; # Index for next "-color auto"
-    private variable _hilite;           # Info for element currently highlighted
-    private variable _axis;             # Info for axis manipulations
-    private variable _axisPopup;        # Info for axis being edited in popup
-    common _downloadPopup;              # Download options from popup
-    private variable _markers
-    private variable _nextElement 0
-
-    constructor {args} {
-        # defined below
-    }
-    destructor {
-        # defined below
-    }
-    public method add {dataobj {settings ""}}
-    public method get {}
-    public method delete {args}
-    public method scale {args}
-    public method parameters {title args} {
-        # do nothing
-    }
-    public method download {option args}
-
-    protected method Rebuild {}
-    protected method ResetLimits {}
-    protected method ResetLegend {}
-    protected method Zoom {option args}
-    protected method Hilite {state x y}
-    protected method Axis {option args}
-    protected method GetAxes {dataobj}
-    protected method GetLineMarkerOptions { style }
-    protected method GetTextMarkerOptions { style }
-    protected method EnterMarker { g name x y text }
-    protected method LeaveMarker { g name }
-
-
-    private method BuildGraph { dlist }
-    private method BuildMarkers { dataobj elem }
-    private method FormatAxis { axis w value }
-    private method GetFormattedValue { axis g value }
-    private method BuildAxisPopup { popup }
-    private method ShowAxisPopup { axis }
-    private method SetAxis { setting }
-    private method SetElements { dataobj {settings ""} }
-    private method SetAxisRangeState { axis }
-}
-
-itk::usual XyResult {
-    keep -background -foreground -cursor -font
-}
-
-itk::usual Panedwindow {
-    keep -background -cursor
-}
-
-# ----------------------------------------------------------------------
-# CONSTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::constructor {args} {
-    Rappture::dispatcher _dispatcher
-    $_dispatcher register !rebuild
-    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
-
-    array set _downloadPopup {
-        format csv
-    }
-
-    option add hull.width hull.height
-    pack propagate $itk_component(hull) no
-
-    itk_component add main {
-        Rappture::SidebarFrame $itk_interior.main
-    }
-    pack $itk_component(main) -expand yes -fill both
-    set f [$itk_component(main) component controls]
-
-    itk_component add reset {
-        button $f.reset -borderwidth 1 -padx 1 -pady 1 \
-            -highlightthickness 0 \
-            -image [Rappture::icon reset-view] \
-            -command [itcl::code $this Zoom reset]
-    } {
-        usual
-        ignore -borderwidth -highlightthickness
-    }
-    pack $itk_component(reset) -padx 4 -pady 2 -anchor e
-    Rappture::Tooltip::for $itk_component(reset) \
-        "Reset the view to the default zoom level"
-
-    set f [$itk_component(main) component frame]
-    itk_component add plot {
-        blt::graph $f.plot \
-            -highlightthickness 0 -plotpadx 0 -plotpady 4
-    } {
-        keep -background -foreground -cursor -font
-    }
-    pack $itk_component(plot) -expand yes -fill both
-
-    $itk_component(plot) pen configure activeLine \
-        -symbol square -pixels 3 -linewidth 2 \
-        -outline black -fill red -color black
-
-    # Add bindings so you can mouse over points to see values:
-    #
-    $itk_component(plot) element bind all <Enter> \
-        [itcl::code $this Hilite at %x %y]
-    $itk_component(plot) element bind all <Motion> \
-        [itcl::code $this Hilite at %x %y]
-    $itk_component(plot) element bind all <Leave> \
-        [itcl::code $this Hilite off %x %y]
-
-    $itk_component(plot) legend configure -hide yes
-
-    #
-    # Add legend for editing hidden/elements:
-    #
-    set inner [$itk_component(main) insert end \
-        -title "Legend" \
-        -icon [Rappture::icon wrench]]
-    $inner configure -borderwidth 4
-
-    itk_component add legend {
-        Rappture::XyLegend $inner.legend $itk_component(plot)
-    }
-    pack $itk_component(legend) -expand yes -fill both
-    after idle [itcl::code $this ResetLegend]
-
-    # quick-and-dirty zoom functionality, for now...
-    Blt_ZoomStack $itk_component(plot)
-    eval itk_initialize $args
-
-    set _hilite(elem) ""
-}
-
-# ----------------------------------------------------------------------
-# DESTRUCTOR
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::destructor {} {
-}
-
-# ----------------------------------------------------------------------
-# USAGE: add <dataobj> ?<settings>?
-#
-# Clients use this to add a dataobj to the plot.  The optional <settings>
-# are used to configure the plot.  Allowed settings are -color,
-# -brightness, -width, -linestyle and -raise.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::add {dataobj {settings ""}} {
-    set g $itk_component(plot)
-    SetElements $dataobj $settings
-
-    array set attrs $settings
-
-    # Colors have to be set/reset here because of "-brightness" and "auto".
-    # Colors can't be overriden by the user.
-
-    # If the color is "auto", then select a color from -autocolors
-    if { ![info exists attrs(-color)] } {
-        set color "auto"
-    } else {
-        set color $attrs(-color)
-    }
-    if { ![info exists attrs(-width)] } {
-        set linewidth 1
-    } else {
-        set linewidth $attrs(-width)
-    }
-    if { $color == "auto" || $color == "autoreset" } {
-        if { $color == "autoreset" } {
-            set _nextColorIndex 0
-        }
-        set color [lindex $itk_option(-autocolors) $_nextColorIndex]
-        if { "" == $color} {
-            set color black
-        }
-        # Set up for next auto color
-        incr _nextColorIndex
-        if { $_nextColorIndex >= [llength $itk_option(-autocolors)] } {
-            set _nextColorIndex 0
-        }
-    }
-    # If -brightness is set, then update the color.
-    if { [info exists attrs(-brightness)] } {
-        set brightness $attrs(-brightness)
-        set color [Rappture::color::brightness $color $brightness]
-        set bg [$itk_component(plot) cget -plotbackground]
-        foreach {h s v} [Rappture::color::RGBtoHSV $bg] break
-        if {$v > 0.5} {
-            set color [Rappture::color::brightness_max $color 0.8]
-        } else {
-            set color [Rappture::color::brightness_min $color 0.2]
-        }
-    }
-    set type [$dataobj hints type]
-
-    set elem ""
-    foreach cname [$dataobj components] {
-        set tag $dataobj-$cname
-        set elem $_comp2elem($tag)
-        switch -- $type {
-            "bar" {
-                $g bar configure $elem -foreground $color -background $color \
-                    -hide no
-            }
-            "scatter" {
-                $g line configure $elem -color $color -hide no
-            }
-            default {
-                $g line configure $elem -color $color -hide no \
-                    -linewidth $linewidth
-            }
-        }
-        if { [lsearch $_viewable $elem] < 0 } {
-            lappend _viewable $elem
-        }
-    }
-    if { [$dataobj info class] == "::Rappture::Curve" } {
-        BuildMarkers $dataobj $elem
-    }
-    $_dispatcher event -idle !rebuild
-}
-
-# ----------------------------------------------------------------------
-# USAGE: get
-#
-# Clients use this to query the list of objects being plotted, in
-# order from bottom to top of this result.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::get {} {
-    # put the dataobj list in order according to -raise options
-    set bottom {}
-    set top {}
-    foreach obj $_dlist {
-        if {[info exists _dataobj2raise($obj)] && $_dataobj2raise($obj)} {
-            lappend top $obj
-        } else {
-            lappend bottom $obj
-        }
-    }
-    set _dlist [concat $bottom $top]
-    return $_dlist
-}
-
-# ----------------------------------------------------------------------
-# USAGE: delete ?<dataobj1> <dataobj2> ...?
-#
-# Clients use this to delete a dataobj from the plot.  If no dataobjs
-# are specified, then all dataobjs are deleted.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::delete {args} {
-    set g $itk_component(plot)
-
-    # First try to create list of elements from the dataobjs specified
-    set elemlist {}
-    foreach dataobj $args {
-        foreach cname [$dataobj components] {
-            set tag $dataobj-$cname
-            if { [info exists _comp2elem($tag)] } {
-                lappend elemlist $_comp2elem($tag)
-            }
-        }
-    }
-    # If no dataobjs were specified then hide all elements.
-    if { [llength $elemlist] == 0 } {
-        set elemlist [$g element names]
-    }
-    # Hide all elements specified by their dataobjs
-    foreach elem $elemlist {
-        $g element configure $elem -hide yes
-        set i [lsearch $_viewable $elem]
-        if { $i >= 0 } {
-            set _viewable [lreplace $_viewable $i $i]
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: scale ?<dataobj1> <dataobj2> ...?
-#
-# Sets the default limits for the overall plot according to the
-# limits of the data for all of the given <dataobj> objects.  This
-# accounts for all dataobjs--even those not showing on the screen.
-# Because of this, the limits are appropriate for all dataobjs as
-# the user scans through data in the ResultSet viewer.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::scale {args} {
-    set _dlist $args
-    BuildGraph $args
-}
-
-# ----------------------------------------------------------------------
-# USAGE: download coming
-# USAGE: download controls <downloadCommand>
-# USAGE: download now
-#
-# Clients use this method to create a downloadable representation
-# of the plot.  Returns a list of the form {ext string}, where
-# "ext" is the file extension (indicating the type of data) and
-# "string" is the data itself.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::download {option args} {
-    switch $option {
-        coming {
-            # nothing to do
-        }
-        controls {
-            set popup .xyresultdownload
-            if {![winfo exists .xyresultdownload]} {
-                # if we haven't created the popup yet, do it now
-                Rappture::Balloon $popup \
-                    -title "[Rappture::filexfer::label downloadWord] as..."
-                set inner [$popup component inner]
-                label $inner.summary -text "" -anchor w
-                pack $inner.summary -side top
-                radiobutton $inner.csv -text "Data as Comma-Separated Values" \
-                    -variable Rappture::XyResult::_downloadPopup(format) \
-                    -value csv
-                pack $inner.csv -anchor w
-                radiobutton $inner.image -text "Image (PS/PDF/PNG/JPEG)" \
-                    -variable Rappture::XyResult::_downloadPopup(format) \
-                    -value image
-                pack $inner.image -anchor w
-                button $inner.go -text [Rappture::filexfer::label download] \
-                    -command [lindex $args 0]
-                pack $inner.go -side bottom -pady 4
-            } else {
-                set inner [$popup component inner]
-            }
-            set num [llength [get]]
-            set num [expr {($num == 1) ? "1 result" : "$num results"}]
-            $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:"
-            update idletasks ;# fix initial sizes
-            return $popup
-        }
-        now {
-            set popup .xyresultdownload
-            if {[winfo exists .xyresultdownload]} {
-                $popup deactivate
-            }
-            switch -- $_downloadPopup(format) {
-                csv {
-                    set dlist ""
-                    set g $itk_component(plot)
-
-                    # Build up a list of download-able dataobjs. Add
-                    # objects that are currently viewable (selected by the
-                    # simulation selector) and visible in the graph
-                    # (selected by the legend).
-                    foreach elem $_viewable {
-                        foreach {dataobj cname} \
-                            [split $_elem2comp($elem) -] break
-
-                        # Build a lookup table of graph elements associated
-                        # with each label. There will be more than one
-                        # element for each entry if there is more than one
-                        # simulation currently being downloaded.
-
-                        set label [$dataobj hints label]
-                        lappend label2elem($label) $elem
-
-                        # Ignore hidden graph elements.
-                        if { [$g element cget $elem -hide] } {
-                            continue
-                        }
-                        lappend dlist $dataobj
-
-                    }
-
-                    # Generate the comma-separated value data for these
-                    # objects.
-                    set csvdata ""
-                    foreach dataobj $dlist {
-                        append csvdata "[string repeat - 60]\n"
-                        append csvdata " [$dataobj hints label]\n"
-                        if { [info exists _dataobj2desc($dataobj)] } {
-                            set indent "for:"
-                            foreach line [split $_dataobj2desc($dataobj) \n] {
-                                append csvdata " $indent $line\n"
-                                set indent "    "
-                            }
-                        }
-                        append csvdata "[string repeat - 60]\n"
-                        set sim $_dataobj2sim($dataobj)
-                        set xlabel [$dataobj hints xlabel]
-                        set ylabel [$dataobj hints ylabel]
-                        set label [$dataobj hints label]
-                        if { [llength $label2elem($label)] > 1 } {
-                            set xlabel [format "%s (\#%d)" $xlabel $sim]
-                            set ylabel [format "%s (\#%d)" $ylabel $sim]
-                        }
-                        append csvdata "$xlabel, $ylabel\n"
-                        set first 1
-                        foreach comp [$dataobj components] {
-                            if {!$first} {
-                                # blank line between components
-                                append csvdata "\n"
-                            }
-                            set xv [$dataobj mesh $comp]
-                            set yv [$dataobj values $comp]
-                            foreach x [$xv range 0 end] y [$yv range 0 end] {
-                                append csvdata [format "%20.15g, %20.15g\n" $x $y]
-                            }
-                            set first 0
-                        }
-                        append csvdata "\n"
-                    }
-                    return [list .txt $csvdata]
-                }
-                image {
-                    set popup .xyprintdownload
-                    if { ![winfo exists $popup] } {
-                        # Create a popup for the print dialog
-                        Rappture::Balloon $popup -title "Save as image..."
-                        set inner [$popup component inner]
-                        # Create the print dialog widget and add it to the
-                        # balloon popup.
-                        Rappture::XyPrint $inner.print
-                        $popup configure \
-                            -deactivatecommand [list $inner.print reset]
-                        blt::table $inner 0,0 $inner.print -fill both
-                    }
-                    update
-                    # Activate the popup and call for the output.
-                    foreach { widget toolName plotName } $args break
-                    $popup activate $widget left
-                    set inner [$popup component inner]
-                    set output [$inner.print print $itk_component(plot) \
-                                    $toolName $plotName]
-                    $popup deactivate
-                    return $output
-                }
-            }
-        }
-        default {
-            error "bad option \"$option\": should be coming, controls, now"
-        }
-    }
-}
-
-itcl::body Rappture::XyResult::BuildMarkers { dataobj elem } {
-    set g $itk_component(plot)
-
-    set ymin -Inf
-    set ymax Inf
-    set xmax Inf
-    set xmin -Inf
-    foreach m [$dataobj xmarkers] {
-        foreach {at label style} $m break
-        set id [$g marker create line -coords [list $at $ymin $at $ymax]]
-        $g marker bind $id <Enter> \
-            [itcl::code $this EnterMarker $g x-$label $at $ymin $at]
-        $g marker bind $id <Leave> \
-            [itcl::code $this LeaveMarker $g x-$label]
-        set options [GetLineMarkerOptions $style]
-        $g marker configure $id -element $elem
-        if { $options != "" } {
-            eval $g marker configure $id $options
-        }
-        if { $label != "" } {
-            set id [$g marker create text -anchor nw \
-                        -text $label -coords [list $at $ymax]]
-            $g marker configure $id -element $elem
-            set options [GetTextMarkerOptions $style]
-            if { $options != "" } {
-                eval $g marker configure $id $options
-            }
-        }
-    }
-    foreach m [$dataobj ymarkers] {
-        foreach {at label style} $m break
-        set id [$g marker create line -coords [list $xmin $at $xmax $at]]
-        $g marker configure $id -element $elem
-        $g marker bind $id <Enter> \
-            [itcl::code $this EnterMarker $g $label $at $xmin $at]
-        $g marker bind $id <Leave> \
-            [itcl::code $this LeaveMarker $g $label]
-        set options [GetLineMarkerOptions $style]
-        if { $options != "" } {
-            eval $g marker configure $id $options
-        }
-        if { $label != "" } {
-            set id [$g marker create text -anchor se \
-                        -text $label -coords [list $xmax $at]]
-            $g marker configure $id -element $elem
-            set options [GetTextMarkerOptions $style]
-            if { $options != "" } {
-                eval $g marker configure $id $options
-            }
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-#       Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::Rebuild {} {
-    ResetLegend
-    # Fix raise/lower elements
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ResetLimits
-#
-# Used internally to apply automatic limits to the axes for the
-# current plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::ResetLimits {} {
-    set g $itk_component(plot)
-
-    foreach axis [$g axis names] {
-        $g axis configure $axis -min "" -max ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ResetLegend
-#
-# Used internally to apply automatic limits to the axes for the
-# current plot.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::ResetLegend {} {
-    update idletasks
-
-    set g $itk_component(plot)
-    # Fix duplicate labels by appending the simulation number
-    # Collect the labels from all the viewable elements.
-    set above {}
-    set below {}
-    foreach elem $_viewable {
-        foreach {dataobj cname} [split $_elem2comp($elem) -] break
-        set label [$dataobj hints label]
-        lappend label2elem($label) $elem
-        if { $_dataobj2raise($dataobj) } {
-            lappend $g element raise $elem
-        }
-    }
-    # Then relabel elements with the same label, using the simulation number.
-    foreach label [array names label2elem] {
-        foreach elem $label2elem($label) {
-            if { [llength $label2elem($label)] == 1 } {
-                $g element configure $elem -label $label
-                continue
-            }
-            foreach {dataobj cname} [split $_elem2comp($elem) -] break
-            set sim $_dataobj2sim($dataobj)
-            set elabel [format "%s (\#%d)" $label $sim]
-            $g element configure $elem -label $elabel
-        }
-    }
-    $itk_component(legend) reset $_viewable
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: Zoom reset
-#
-# Called automatically when the user clicks on one of the zoom
-# controls for this widget.  Changes the zoom for the current view.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::Zoom {option args} {
-    switch -- $option {
-        reset {
-            ResetLimits
-            Rappture::Logger::log curve zoom -reset
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Hilite <state> <x> <y>
-#
-# Called automatically when the user brushes one of the elements
-# on the plot.  Causes the element to highlight and a tooltip to
-# pop up with element info.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::Hilite {state x y} {
-    set g $itk_component(plot)
-    set elem ""
-
-    # Peek inside of Blt_ZoomStack package to see if we're currently in the
-    # middle of a zoom selection.
-    if {[info exists ::zoomInfo($g,corner)] && $::zoomInfo($g,corner) == "B" } {
-        return;
-    }
-    set tip ""
-    if {$state == "at"} {
-        if {[$g element closest $x $y info -interpolate yes]} {
-            # for dealing with xy line plots
-            set elem $info(name)
-
-            set mapx [$g element cget $elem -mapx]
-            set mapy [$g element cget $elem -mapy]
-
-            # search again for an exact point -- this time don't interpolate
-            set tip ""
-            array unset info
-            if {[$g element closest $x $y info -interpolate no]
-                  && $info(name) == $elem} {
-
-                set x [$g axis transform $mapx $info(x)]
-                set y [$g axis transform $mapy $info(y)]
-                if {[info exists _elem2comp($elem)]} {
-                    foreach {dataobj cname} [split $_elem2comp($elem) -] break
-                    set yunits [$dataobj hints yunits]
-                    set xunits [$dataobj hints xunits]
-                } else {
-                    set xunits ""
-                    set yunits ""
-                }
-                set tip [$g element cget $elem -label]
-                set yval [GetFormattedValue y $g $info(y)]
-                append tip "\n$yval$yunits"
-                set xval [GetFormattedValue x $g $info(x)]
-                append tip " @ $xval$xunits"
-                set tip [string trim $tip]
-            }
-            set state 1
-        } elseif {[$g element closest $x $y info -interpolate no]} {
-            # for dealing with xy scatter plot
-            set elem $info(name)
-
-            set mapx [$g element cget $elem -mapx]
-            set mapy [$g element cget $elem -mapy]
-
-            set tip ""
-            set x [$g axis transform $mapx $info(x)]
-            set y [$g axis transform $mapy $info(y)]
-
-            if {[info exists _elem2comp($elem)]} {
-                foreach {dataobj cname} [split $_elem2comp($elem) -] break
-                set yunits [$dataobj hints yunits]
-                set xunits [$dataobj hints xunits]
-            } else {
-                set xunits ""
-                set yunits ""
-            }
-            set tip [$g element cget $elem -label]
-            set yval [GetFormattedValue y $g $info(y)]
-            append tip "\n$yval$yunits"
-            set xval [GetFormattedValue x $g $info(x)]
-            append tip " @ $xval$xunits"
-            set tip [string trim $tip]
-            set state 1
-        } else {
-            set state 0
-        }
-    }
-
-    if {$state} {
-        #
-        # Highlight ON:
-        # - activate trace
-        # - multiple axes? dim other axes
-        # - pop up tooltip about data
-        #
-        if { [$g element exists $_hilite(elem)] && $_hilite(elem) != $elem } {
-            $g element deactivate $_hilite(elem)
-            $g crosshairs configure -hide yes
-            Rappture::Tooltip::tooltip cancel
-        }
-        $g element activate $elem
-        set _hilite(elem) $elem
-
-        set mapx [$g element cget $elem -mapx]
-        set mapy [$g element cget $elem -mapy]
-        if {[info exists _elem2comp($elem)]} {
-            foreach {dataobj cname} [split $_elem2comp($elem) -] break
-            foreach {mapx mapy} [GetAxes $dataobj] break
-        }
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;           # fix main x-axis too
-            foreach axis $allx {
-                if {$axis == $mapx} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;           # fix main y-axis too
-            foreach axis $ally {
-                if {$axis == $mapy} {
-                    $g axis configure $axis -color $itk_option(-foreground) \
-                        -titlecolor $itk_option(-foreground)
-                } else {
-                    $g axis configure $axis -color $itk_option(-dimcolor) \
-                        -titlecolor $itk_option(-dimcolor)
-                }
-            }
-        }
-        if {"" != $tip} {
-            $g crosshairs configure -hide no -position @$x,$y
-
-            if {$x > 0.5*[winfo width $g]} {
-                if {$x < 4} {
-                    set tipx "-0"
-                } else {
-                    set tipx "-[expr {$x-20}]"  ;# move tooltip to the left
-                }
-            } else {
-                if {$x < -4} {
-                    set tipx "+0"
-                } else {
-                    set tipx "+[expr {$x+20}]"  ;# move tooltip to the right
-                }
-            }
-            if {$y > 0.5*[winfo height $g]} {
-                if {$y < 4} {
-                    set tipy "-0"
-                } else {
-                    set tipy "-[expr {$y-20}]"  ;# move tooltip to the top
-                }
-            } else {
-                if {$y < -4} {
-                    set tipy "+0"
-                } else {
-                    set tipy "+[expr {$y+20}]"  ;# move tooltip to the bottom
-                }
-            }
-            Rappture::Tooltip::text $g $tip
-            Rappture::Tooltip::tooltip show $g $tipx,$tipy
-            Rappture::Logger::log tooltip -for "curve probe -- [string map [list \n " // "] $tip]"
-        }
-    } else {
-        #
-        # Highlight OFF:
-        # - deactivate (color back to normal)
-        # - put all axes back to normal color
-        # - take down tooltip
-        #
-        if { [$g element exists $_hilite(elem)] } {
-            $g element deactivate $_hilite(elem)
-        }
-        set allx [$g x2axis use]
-        if {[llength $allx] > 0} {
-            lappend allx x  ;# fix main x-axis too
-            foreach axis $allx {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        set ally [$g y2axis use]
-        if {[llength $ally] > 0} {
-            lappend ally y  ;# fix main y-axis too
-            foreach axis $ally {
-                $g axis configure $axis -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-            }
-        }
-
-        $g crosshairs configure -hide yes
-
-        # only cancel in plotting area or we'll mess up axes
-        if {[$g inside $x $y]} {
-            Rappture::Tooltip::tooltip cancel
-        }
-
-        # There is no currently highlighted element
-        set _hilite(elem) ""
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Axis hilite <axis> <state>
-#
-# USAGE: Axis click <axis> <x> <y>
-# USAGE: Axis drag <axis> <x> <y>
-# USAGE: Axis release <axis> <x> <y>
-#
-# Used internally to handle editing of the x/y axes.  The hilite
-# operation causes the axis to light up.  The edit operation pops
-# up a panel with editing options.  The changed operation applies
-# changes from the panel.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::Axis {option args} {
-    switch -- $option {
-        hilite {
-            if {[llength $args] != 2} {
-                error "wrong # args: should be \"Axis hilite axis state\""
-            }
-            set g $itk_component(plot)
-            set axis [lindex $args 0]
-            set state [lindex $args 1]
-
-            if {$state} {
-                $g axis configure $axis \
-                    -color $itk_option(-activecolor) \
-                    -titlecolor $itk_option(-activecolor)
-
-                set x [expr {[winfo pointerx $g]+4}]
-                set y [expr {[winfo pointery $g]+4}]
-                Rappture::Tooltip::tooltip pending $g-$axis @$x,$y
-            } else {
-                $g axis configure $axis \
-                    -color $itk_option(-foreground) \
-                    -titlecolor $itk_option(-foreground)
-                Rappture::Tooltip::tooltip cancel
-            }
-        }
-        click {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis click axis x y\""
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            set g $itk_component(plot)
-
-            set _axis(moved) 0
-            set _axis(click-x) $x
-            set _axis(click-y) $y
-            foreach {min max} [$g axis limits $axis] break
-            set _axis(min0) $min
-            set _axis(max0) $max
-            Rappture::Tooltip::tooltip cancel
-        }
-        drag {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis drag axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-            set g $itk_component(plot)
-
-            if {[info exists _axis(click-x)] && [info exists _axis(click-y)]} {
-                foreach {x0 y0 pw ph} [$g extents plotarea] break
-                switch -glob $axis {
-                  x* {
-                    set pix $x
-                    set pix0 $_axis(click-x)
-                    set pixmin $x0
-                    set pixmax [expr {$x0+$pw}]
-                  }
-                  y* {
-                    set pix $y
-                    set pix0 $_axis(click-y)
-                    set pixmin [expr {$y0+$ph}]
-                    set pixmax $y0
-                  }
-                }
-                set log [$g axis cget $axis -logscale]
-                set min $_axis(min0)
-                set max $_axis(max0)
-                set dpix [expr {abs($pix-$pix0)}]
-                set v0 [$g axis invtransform $axis $pixmin]
-                set v1 [$g axis invtransform $axis [expr {$pixmin+$dpix}]]
-                if {$log} {
-                    set v0 [expr {log10($v0)}]
-                    set v1 [expr {log10($v1)}]
-                    set min [expr {log10($min)}]
-                    set max [expr {log10($max)}]
-                }
-
-                if {$pix > $pix0} {
-                    set delta [expr {$v1-$v0}]
-                } else {
-                    set delta [expr {$v0-$v1}]
-                }
-                set min [expr {$min-$delta}]
-                set max [expr {$max-$delta}]
-                if {$log} {
-                    set min [expr {pow(10.0,$min)}]
-                    set max [expr {pow(10.0,$max)}]
-                }
-                $g axis configure $axis -min $min -max $max
-
-                # move axis, don't edit on release
-                set _axis(move) 1
-            }
-        }
-        release {
-            if {[llength $args] != 3} {
-                error "wrong # args: should be \"Axis release axis x y\""
-            }
-            if {![info exists _axis(moved)]} {
-                return  ;# must have skipped click event -- ignore
-            }
-            set axis [lindex $args 0]
-            set x [lindex $args 1]
-            set y [lindex $args 2]
-
-            if {!$_axis(moved)} {
-                # small movement? then treat as click -- pop up axis editor
-                set dx [expr {abs($x-$_axis(click-x))}]
-                set dy [expr {abs($y-$_axis(click-y))}]
-                if {$dx < 2 && $dy < 2} {
-                    ShowAxisPopup $axis
-                    return
-                }
-            }
-            # one last movement
-            Axis drag $axis $x $y
-
-            # log this change
-            Rappture::Logger::log curve axis $axis \
-                -drag [$itk_component(plot) axis limits $axis]
-
-            catch {unset _axis}
-        }
-        default {
-            error "bad option \"$option\": should be hilite"
-        }
-    }
-}
-
-
-# ----------------------------------------------------------------------
-# USAGE: GetLineMarkerOptions <style>
-#
-# Used internally to create a list of configuration options specific to the
-# axis line marker.  The input is a list of name value pairs.  Options that
-# are not recognized are ignored.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::GetLineMarkerOptions {style} {
-    array set lineOptions {
-        "-color"  "-outline"
-        "-dashes" "-dashes"
-        "-linecolor" "-outline"
-        "-linewidth" "-linewidth"
-    }
-    set options {}
-    foreach {name value} $style {
-        if { [info exists lineOptions($name)] } {
-            lappend options $lineOptions($name) $value
-        }
-    }
-    return $options
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetTextMarkerOptions <style>
-#
-# Used internally to create a list of configuration options specific to the
-# axis text marker.  The input is a list of name value pairs.  Options that
-# are not recognized are ignored.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::GetTextMarkerOptions {style} {
-    array set textOptions {
-        "-color"        "-outline"
-        "-textcolor"    "-outline"
-        "-font"         "-font"
-        "-xoffset"      "-xoffset"
-        "-yoffset"      "-yoffset"
-        "-anchor"       "-anchor"
-        "-rotate"       "-rotate"
-    }
-    set options {}
-    foreach {name value} $style {
-        if { [info exists textOptions($name)] } {
-            lappend options $textOptions($name) $value
-        }
-    }
-    return $options
-}
-
-# ----------------------------------------------------------------------
-# USAGE: GetAxes <dataobj>
-#
-# Used internally to figure out the axes used to plot the given
-# <dataobj>.  Returns a list of the form {x y}, where x is the
-# x-axis name (x, x2, x3, etc.), and y is the y-axis name.
-# ----------------------------------------------------------------------
-itcl::body Rappture::XyResult::GetAxes {dataobj} {
-    set xlabel [$dataobj hints xlabel]
-    if {[info exists _label2axis($xlabel)]} {
-        set mapx $_label2axis($xlabel)
-    } else {
-        set mapx "x"
-    }
-
-    set ylabel [$dataobj hints ylabel]
-    if {[info exists _label2axis($ylabel)]} {
-        set mapy $_label2axis($ylabel)
-    } else {
-        set mapy "y"
-    }
-    return [list $mapx $mapy]
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -gridcolor
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::XyResult::gridcolor {
-    if {"" == $itk_option(-gridcolor)} {
-        $itk_component(plot) grid off
-    } else {
-        $itk_component(plot) grid configure -color $itk_option(-gridcolor)
-        $itk_component(plot) grid on
-    }
-}
-
-# ----------------------------------------------------------------------
-# CONFIGURATION OPTION: -autocolors
-# ----------------------------------------------------------------------
-itcl::configbody Rappture::XyResult::autocolors {
-    foreach c $itk_option(-autocolors) {
-        if {[catch {winfo rgb $itk_component(hull) $c}]} {
-            error "bad color \"$c\""
-        }
-    }
-        incr _nextColorIndex
-    if {$_nextColorIndex >= [llength $itk_option(-autocolors)]} {
-        set _nextColorIndex 0
-    }
-}
-
-itcl::body Rappture::XyResult::EnterMarker { g name x y text } {
-    LeaveMarker $g $name
-    set id [$g marker create text \
-                -coords [list $x $y] \
-                -yoffset -1 \
-                -anchor s \
-                -text $text]
-    set _markers($name) $id
-}
-
-itcl::body Rappture::XyResult::LeaveMarker { g name } {
-    if { [info exists _markers($name)] } {
-        set id $_markers($name)
-        $g marker delete $id
-        unset _markers($name)
-    }
-}
-
-#
-# SetAxis --
-#
-#       Configures the graph axis with the designated setting using
-#       the currently stored value.  User-configurable axis settings
-#       are stored in the _axisPopup variable or in the widgets. This
-#       routine syncs the graph with that setting.
-#
-itcl::body Rappture::XyResult::SetAxis { setting } {
-    set g $itk_component(plot)
-    set axis $_axisPopup(axis)
-    switch -- $setting {
-        "logscale" {
-            set bool $_axisPopup(logscale)
-            $g axis configure $axis -logscale $bool
-        }
-        "loose" {
-            set bool $_axisPopup(loose)
-            $g axis configure $axis -loose $bool
-        }
-        "range" {
-            set auto $_axisPopup(auto)
-            set _axisPopup($axis-auto) $auto
-            if { $auto } {
-                # Set the axis range automatically
-                $g axis configure $axis -min "" -max ""
-            } else {
-                # Set the axis range from the entry values.
-                set label $_axisPopup(label)
-                set min $_axisPopup(${label}-min)
-                set max $_axisPopup(${label}-max)
-                $g axis configure $axis -min $min -max $max
-            }
-            SetAxisRangeState $axis
-        }
-        "format" {
-            set inner [$itk_component(hull).axes component inner]
-            set format [$inner.format translate [$inner.format value]]
-            set _axisPopup($axis-format) $format
-
-            # Force the graph to reformat the ticks
-            set min [$itk_component(plot) axis cget $axis -min]
-            $g axis configure $axis -min $min
-        }
-        "label" {
-            set label $_axisPopup(label)
-            $g axis configure $axis -title $label
-        }
-        "min" {
-            set min $_axisPopup(min)
-            if { [catch { $g axis configure $axis -min $min } msg] != 0 } {
-                set inner [$itk_component(hull).axes component inner]
-                Rappture::Tooltip::cue $inner.max $msg
-                bell
-                return
-            }
-            set label $_axisPopup(label)
-            set _axisPopup(${label}-min) $min
-        }
-        "max" {
-            set max $_axisPopup(max)
-            if { [catch { $g axis configure $axis -max $max } msg] != 0 } {
-                set inner [$itk_component(hull).axes component inner]
-                Rappture::Tooltip::cue $inner.max $msg
-                bell
-                return
-            }
-            set label $_axisPopup(label)
-            set _axisPopup(${label}-max) $max
-        }
-    }
-}
-
-#
-# SetAxisRangeState --
-#
-#       Sets the state of widgets controlling the axis range based
-#       upon whether the automatic or manual setting.  If the
-#       axis is configure to be automatic, the manual setting widgets
-#       are disabled.  And vesa-versa the automatic setting widgets
-#       are dsiabled if the axis is manual.
-#
-itcl::body Rappture::XyResult::SetAxisRangeState { axis } {
-    set inner [$itk_component(hull).axes component inner]
-    set g $itk_component(plot)
-
-    if { $_axisPopup(auto) } {
-        foreach {min max} [$g axis limits $axis] break
-        $inner.minl configure -state disabled
-        $inner.min configure -state disabled
-        $inner.maxl configure -state disabled
-        $inner.max configure -state disabled
-        $inner.loose configure -state normal
-        $inner.tight configure -state normal
-    } else {
-        foreach {min max} [$g axis limits $axis] break
-        $inner.minl configure -state normal
-        $inner.min configure -state normal
-        set _axisPopup(min) [$g axis cget $axis -min]
-        $inner.maxl configure -state normal
-        $inner.max configure -state normal
-        set _axisPopup(max) [$g axis cget $axis -max]
-        $inner.loose configure -state disabled
-        $inner.tight configure -state disabled
-    }
-}
-
-#
-# BuildAxisPopup --
-#
-#       Creates the popup balloon dialog for axes. This routine is
-#       called only once the first time the user clicks to bring up
-#       an axis dialog.  It is reused for all other axes.
-#
-itcl::body Rappture::XyResult::BuildAxisPopup { popup } {
-    Rappture::Balloon $popup -title "Axis Options"
-    set inner [$itk_component(hull).axes component inner]
-
-    label $inner.labell -text "Label:"
-    entry $inner.label \
-        -width 15 -highlightbackground $itk_option(-background) \
-        -textvariable [itcl::scope _axisPopup(label)]
-
-    bind $inner.label <Return>   [itcl::code $this SetAxis label]
-    bind $inner.label <KP_Enter> [itcl::code $this SetAxis label]
-    bind $inner.label <FocusOut> [itcl::code $this SetAxis label]
-
-    label $inner.formatl -text "Format:"
-    Rappture::Combobox $inner.format -width 15 -editable no
-    $inner.format choices insert end \
-        "%.6g"  "Auto"         \
-        "%.0f"  "X"          \
-        "%.1f"  "X.X"          \
-        "%.2f"  "X.XX"         \
-        "%.3f"  "X.XXX"        \
-        "%.6f"  "X.XXXXXX"     \
-        "%.1e"  "X.Xe+XX"      \
-        "%.2e"  "X.XXe+XX"     \
-        "%.3e"  "X.XXXe+XX"    \
-        "%.6e"  "X.XXXXXXe+XX"
-
-    bind $inner.format <<Value>> [itcl::code $this SetAxis format]
-
-    label $inner.rangel -text "Axis Range:"
-    radiobutton $inner.auto -text "Automatic" \
-        -variable [itcl::scope _axisPopup(auto)] -value 1 \
-        -command [itcl::code $this SetAxis range]
-    radiobutton $inner.manual -text "Manual" \
-        -variable [itcl::scope _axisPopup(auto)] -value 0 \
-        -command [itcl::code $this SetAxis range]
-
-    radiobutton $inner.loose -text "loose" \
-        -variable [itcl::scope _axisPopup(loose)] -value 1 \
-        -command [itcl::code $this SetAxis loose]
-    radiobutton $inner.tight -text "tight" \
-        -variable [itcl::scope _axisPopup(loose)] -value 0 \
-        -command [itcl::code $this SetAxis loose]
-
-    label $inner.minl -text "min"
-    entry $inner.min \
-        -width 15 -highlightbackground $itk_option(-background) \
-        -textvariable [itcl::scope _axisPopup(min)]
-    bind $inner.min <Return> [itcl::code $this SetAxis min]
-    bind $inner.min <KP_Enter> [itcl::code $this SetAxis min]
-    bind $inner.min <FocusOut> [itcl::code $this SetAxis min]
-
-    label $inner.maxl -text "max"
-    entry $inner.max \
-        -width 15 -highlightbackground $itk_option(-background) \
-        -textvariable [itcl::scope _axisPopup(max)]
-    bind $inner.max <Return> [itcl::code $this SetAxis max]
-    bind $inner.max <KP_Enter> [itcl::code $this SetAxis max]
-    bind $inner.max <FocusOut> [itcl::code $this SetAxis max]
-
-
-    label $inner.scalel -text "Scale:"
-    radiobutton $inner.linear -text "linear" \
-        -variable [itcl::scope _axisPopup(logscale)] -value 0 \
-        -command [itcl::code $this SetAxis logscale]
-    radiobutton $inner.log -text "logarithmic" \
-        -variable [itcl::scope _axisPopup(logscale)] -value 1 \
-        -command [itcl::code $this SetAxis logscale]
-
-    blt::table $inner \
-        0,0 $inner.labell -anchor w \
-        0,1 $inner.label -anchor w -fill x  -cspan 3 \
-        1,0 $inner.formatl -anchor w \
-        1,1 $inner.format -anchor w -fill x  -cspan 3 \
-        2,0 $inner.scalel -anchor w \
-        2,2 $inner.linear -anchor w \
-        2,3 $inner.log -anchor w \
-        3,0 $inner.rangel -anchor w \
-        4,0 $inner.manual -anchor w -padx 4 \
-        4,2 $inner.minl -anchor e \
-        4,3 $inner.min -anchor w \
-        5,2 $inner.maxl -anchor e \
-        5,3 $inner.max -anchor w \
-        6,0 $inner.auto -anchor w -padx 4 \
-        6,2 $inner.tight -anchor w \
-        6,3 $inner.loose -anchor w \
-
-
-    blt::table configure $inner r2 -pady 4
-    blt::table configure $inner c1 -width 20
-    update
-}
-
-#
-# ShowAxisPopup --
-#
-#       Displays the axis dialog for an axis.  It initializes the
-#       _axisInfo variables for that axis if necessary.
-#
-itcl::body Rappture::XyResult::ShowAxisPopup { axis } {
-    set g $itk_component(plot)
-    set popup $itk_component(hull).axes
-
-    if { ![winfo exists $popup] } {
-        BuildAxisPopup $popup
-    }
-    set _axisPopup(axis)     $axis
-    set _axisPopup(label)    [$g axis cget $axis -title]
-    set _axisPopup(logscale) [$g axis cget $axis -logscale]
-    set _axisPopup(loose)    [$g axis cget $axis -loose]
-    if { ![info exists _axisPopup($axis-format)] } {
-        set inner [$itk_component(hull).axes component inner]
-        set _axisPopup($axis-format) "%.6g"
-        set fmts [$inner.format choices get -value]
-        set i [lsearch -exact $fmts $_axisPopup($axis-format)]
-        if {$i < 0} { set i 0 }  ;# use Auto choice
-        $inner.format value [$inner.format choices get -label $i]
-    }
-    foreach {min max} [$g axis limits $axis] break
-    if { $_axisPopup(logscale) } {
-        set type "log"
-    } else {
-        set type "lin"
-    }
-    set amin ""
-    set label $_axisPopup(label)
-    if { [info exists _limits(${label}-min)] } {
-        set amin $_limits(${label}-min)
-    }
-    set amax ""
-    if { [info exists _limits(${label}-max)] } {
-        set amax $_limits(${label}-max)
-    }
-    set auto 1
-    if { $amin != "" || $amax != "" } {
-        set auto 0
-    }
-    if { ![info exists _axisPopup($axis-auto)] } {
-        set _axisPopup($axis-auto) $auto;# Defaults to automatic
-    }
-    set _axisPopup(auto)  $_axisPopup($axis-auto)
-    SetAxisRangeState $axis
-    if { ![info exists _axisPopup(${label}-min)] } {
-        if { $amin != "" } {
-            set _axisPopup(${label}-min) $amin
-            set _axisPopup(min)   $_axisPopup(${label}-min)
-            SetAxis min
-        } else {
-            set _axisPopup(${label}-min) $min
-        }
-    }
-    if { ![info exists _axisPopup(${label}-max)] } {
-        if { $amax != "" } {
-            set _axisPopup(${label}-max) $amax
-            set _axisPopup(max)   $_axisPopup(${label}-max)
-            SetAxis max
-        } else {
-            set _axisPopup(${label}-max) $max
-        }
-    }
-    set _axisPopup(min)  $_axisPopup(${label}-min)
-    set _axisPopup(max)  $_axisPopup(${label}-max)
-    set _axisPopup(axis) $axis
-
-    #
-    # Figure out where the window should pop up.
-    #
-    set x [winfo rootx $g]
-    set y [winfo rooty $g]
-    set w [winfo width $g]
-    set h [winfo height $g]
-    foreach {x0 y0 pw ph} [$g extents plotarea] break
-    switch -glob -- $axis {
-        x {
-            set x [expr {round($x + $x0+0.5*$pw)}]
-            set y [expr {round($y + $y0+$ph + 0.5*($h-$y0-$ph))}]
-            set dir "above"
-        }
-        x* {
-            set x [expr {round($x + $x0+0.5*$pw)}]
-            set dir "below"
-            set allx [$itk_component(plot) x2axis use]
-            set max [llength $allx]
-            set i [lsearch -exact $allx $axis]
-            set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-        }
-        y {
-            set x [expr {round($x + 0.5*$x0)}]
-            set y [expr {round($y + $y0+0.5*$ph)}]
-            set dir "right"
-        }
-        y* {
-            set y [expr {round($y + $y0+0.5*$ph)}]
-            set dir "left"
-            set ally [$g y2axis use]
-            set max [llength $ally]
-            set i [lsearch -exact $ally $axis]
-            set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
-            set x [expr {round($x+$x0+$pw + ($i+0.5)*($w-$x0-$pw)/double($max))}]
-        }
-    }
-    $popup activate @$x,$y $dir
-}
-
-#
-# GetFormattedValue --
-#
-#       Callback routine for the axis format procedure.  It formats the
-#       axis tick label according to the selected format.  This routine
-#       is also used to format tooltip values.
-#
-itcl::body Rappture::XyResult::GetFormattedValue { axis g value } {
-    if { [$g axis cget $axis -logscale] ||
-         ![info exists _axisPopup($axis-format)] } {
-        set fmt "%.6g"
-    } else {
-        set fmt $_axisPopup($axis-format)
-    }
-    return [format $fmt $value]
-}
-
-
-#
-# BuildGraph --
-#
-#       This procedure loads each data objects specified into the
-#       graph.  The data object may already be loaded (from the "add"
-#       method which gets called first).   The graph elements that
-#       are created, are hidden.  This allows the graph to account
-#       for all datasets, even those not currently being displayed.
-#
-itcl::body Rappture::XyResult::BuildGraph { dlist } {
-    set g $itk_component(plot)
-
-    foreach label [array names _label2axis] {
-        set axis $_label2axis($label)
-        switch -- $axis {
-            "x" - "x2" - "y" - "y2" {
-                $g axis configure $axis -hide yes -checklimits no
-            }
-            default {
-                $g axis delete $axis
-            }
-        }
-    }
-    array unset _label2axis
-    array unset _limits
-
-    # Scan through all objects and create a list of all axes.
-    # The first x-axis gets mapped to "x".  The second, to "x2".
-    # Beyond that, we must create new axes "x3", "x4", etc.
-    # We do the same for y.
-
-    set anum(x) 0
-    set anum(y) 0
-    foreach dataobj $dlist {
-        foreach axis {x y} {
-            set label [$dataobj hints ${axis}label]
-            if { $label == "" } {
-                continue
-            }
-            # Collect the limits (if set for the axis)
-            set min [$dataobj hints ${axis}min]
-            set max [$dataobj hints ${axis}max]
-            set tag ${label}-min
-            if { $min != "" && ( ![info exists _limits($tag)] ||
-                                   $_limits($tag) > $min ) } {
-                set _limits($tag) $min
-            }
-            set tag ${label}-max
-            if { $max != "" && (![info exists _limits($tag)] ||
-                                  $_limits($tag) < $max) } {
-                set _limits($tag) $max
-            }
-            if  { [$dataobj hints ${axis}scale] == "log" } {
-                set tag ${label}-log
-                set _limits($tag) 1
-            }
-            if { ![info exists _label2axis($label)] } {
-                switch [incr anum($axis)] {
-                    1 { set axisName $axis }
-                    2 { set axisName ${axis}2 }
-                    default {
-                        set axis $axis$anum($axis)
-                        catch {$g axis create $axisName}
-                    }
-                }
-                $g axis configure $axisName -title $label -hide no \
-                    -checklimits no -showticks yes
-                set _label2axis($label) $axisName
-
-                # If this axis has a description, add it as a tooltip
-                set desc [string trim [$dataobj hints ${axis}desc]]
-                Rappture::Tooltip::text $g-$axisName $desc
-            }
-        }
-    }
-    # Next, set the axes based on what we've found.
-    foreach label [array names _label2axis] {
-        set logscale [info exists _limits(${label}-log)]
-        set amin ""
-        if { [info exists _limits(${label}-min)] } {
-            set amin $_limits(${label}-min)
-        }
-        set amax ""
-        if { [info exists _limits(${label}-max)] } {
-            set amax $_limits(${label}-max)
-        }
-        set axis $_label2axis($label)
-        $g axis configure $axis \
-            -hide no -checklimits no \
-            -command [itcl::code $this GetFormattedValue $axis] \
-            -min $amin -max $amax -logscale $logscale
-        $g axis bind $axis <Enter> \
-            [itcl::code $this Axis hilite $axis on]
-        $g axis bind $axis <Leave> \
-            [itcl::code $this Axis hilite $axis off]
-        $g axis bind $axis <ButtonPress-1> \
-            [itcl::code $this Axis click $axis %x %y]
-        $g axis bind $axis <B1-Motion> \
-            [itcl::code $this Axis drag $axis %x %y]
-        $g axis bind $axis <ButtonRelease-1> \
-            [itcl::code $this Axis release $axis %x %y]
-        $g axis bind $axis <KeyPress> \
-            [list ::Rappture::Tooltip::tooltip cancel]
-    }
-
-    foreach dataobj $dlist {
-        SetElements $dataobj
-    }
-    ResetLegend
-}
-
-#
-# SetElements --
-#
-#       This procedure loads each data objects specified into the
-#       graph.  The data object may already be loaded (from the "add"
-#       method which gets called first).   The graph elements that
-#       are created, are hidden.  This allows the graph to account
-#       for all datasets, even those not currently being displayed.
-#
-itcl::body Rappture::XyResult::SetElements { dataobj {settings ""} } {
-    set g $itk_component(plot)
-
-    array set attrs [$dataobj hints style]
-    array set attrs $settings
-    set type [$dataobj hints type]
-    if { $type == "" } {
-        set type "line"
-    }
-
-    # Now fix attributes to a more usable form for the graph.
-
-    # Convert -linestyle to BLT -dashes
-    if { ![info exists attrs(-linestyle)] } {
-        set dashes {}
-    } else {
-        switch -- $attrs(-linestyle) {
-            dashed  { set dashes {4 4} }
-            dotted  { set dashes {2 4} }
-            default { set dashes {}    }
-        }
-    }
-    if { ![info exists attrs(-barwidth)] } {
-        set barwidth 1.0
-    } else {
-        set barwidth $attrs(-barwidth)
-    }
-    if { ![info exists attrs(-width)] } {
-        set linewidth 1
-    } else {
-        set linewidth $attrs(-width)
-    }
-    set _dataobj2raise($dataobj) [info exists attrs(-raise)]
-    if { ![info exists attrs(-simulation)] } {
-        set sim 0
-    } else {
-        set sim $attrs(-simulation)
-    }
-    set _dataobj2sim($dataobj) $sim
-
-    foreach {mapx mapy} [GetAxes $dataobj] break
-    set label [$dataobj hints label]
-
-    foreach cname [$dataobj components] {
-        set tag $dataobj-$cname
-        set xv [$dataobj mesh $cname]
-        set yv [$dataobj values $cname]
-        set xev [$dataobj xErrorValues $cname]
-        set yev [$dataobj yErrorValues $cname]
-        if {([$xv length] <= 1) || ($linewidth == 0)} {
-            set sym square
-            set pixels 2
-        } else {
-            set sym ""
-            set pixels 6
-        }
-        if { ![info exists _comp2elem($tag)] } {
-            set elem "$type[incr _nextElement]"
-            set _elem2comp($elem) $tag
-            set _comp2elem($tag) $elem
-            set found($_comp2elem($tag)) 1
-            lappend label2elem($label) $elem
-            switch -- $type {
-                "line" {
-                    $g line create $elem \
-                        -x $xv -y $yv \
-                        -symbol $sym \
-                        -pixels $pixels \
-                        -linewidth $linewidth \
-                        -label $label \
-                        -dashes $dashes \
-                        -mapx $mapx \
-                        -mapy $mapy \
-                        -hide yes \
-                        -xerror $xev -yerror $yev
-                }
-                "scatter" {
-                    $g line create $elem \
-                        -x $xv -y $yv \
-                        -symbol square \
-                        -pixels 2 \
-                        -linewidth 0 \
-                        -label $label \
-                        -dashes $dashes \
-                        -mapx $mapx \
-                        -mapy $mapy \
-                        -hide yes \
-                        -xerror $xev -yerror $yev
-                }
-                "bar" {
-                    $g bar create $elem \
-                        -x $xv -y $yv \
-                        -barwidth $barwidth \
-                        -label $label \
-                        -mapx $mapx \
-                        -mapy $mapy \
-                        -hide yes \
-                        -xerror $xev -yerror $yev
-                }
-            }
-        } else {
-            $g element configure $_comp2elem($tag) -mapx $mapx -mapy $mapy
-        }
-    }
-}
-
