Index: /branches/1.3/gui/scripts/barchartresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/barchartresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/barchartresult.tcl	(revision 3800)
@@ -290,11 +290,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
-
+    array set params $settings
     # if the color is "auto", then select a color from -autocolors
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
Index: /branches/1.3/gui/scripts/contourresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/contourresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/contourresult.tcl	(revision 3800)
@@ -346,10 +346,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/datatableresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/datatableresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/datatableresult.tcl	(revision 3800)
@@ -139,10 +139,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
     if { $params(-raise) } {
         set _raised $dataobj
Index: /branches/1.3/gui/scripts/deviceViewer1D.tcl
===================================================================
--- /branches/1.3/gui/scripts/deviceViewer1D.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/deviceViewer1D.tcl	(revision 3800)
@@ -167,10 +167,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
  
     set pos [lsearch -exact $dataobj $_dlist]
Index: /branches/1.3/gui/scripts/deviceresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/deviceresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/deviceresult.tcl	(revision 3800)
@@ -73,10 +73,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
 
     eval $itk_component(viewer) add $dataobj [list $settings]
Index: /branches/1.3/gui/scripts/energyLevels.tcl
===================================================================
--- /branches/1.3/gui/scripts/energyLevels.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/energyLevels.tcl	(revision 3800)
@@ -274,10 +274,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
 
     # convert -linestyle to BLT -dashes
Index: /branches/1.3/gui/scripts/flowvisviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/flowvisviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/flowvisviewer.tcl	(revision 3800)
@@ -588,10 +588,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/histogramresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/histogramresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/histogramresult.tcl	(revision 3800)
@@ -286,10 +286,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
 
     # if the color is "auto", then select a color from -autocolors
Index: /branches/1.3/gui/scripts/imageresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/imageresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/imageresult.tcl	(revision 3800)
@@ -189,10 +189,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
 
     if {$params(-raise)} {
Index: /branches/1.3/gui/scripts/meshresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/meshresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/meshresult.tcl	(revision 3800)
@@ -136,10 +136,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/moleculeViewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/moleculeViewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/moleculeViewer.tcl	(revision 3800)
@@ -235,10 +235,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
  
     set pos [lsearch -exact $dataobj $_dlist]
Index: /branches/1.3/gui/scripts/molvisviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/molvisviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/molvisviewer.tcl	(revision 3800)
@@ -450,11 +450,5 @@
         -param          ""
     }
-
-    foreach {opt val} $options {
-        if {![info exists params($opt)]} {
-            error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
 
     set pos [lsearch -exact $dataobj $_dlist]
Index: /branches/1.3/gui/scripts/nanovisviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/nanovisviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/nanovisviewer.tcl	(revision 3800)
@@ -410,10 +410,6 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
+
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/numberresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/numberresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/numberresult.tcl	(revision 3800)
@@ -276,10 +276,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
 
     # if type is set to "scatter", then override the width
Index: /branches/1.3/gui/scripts/resultviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/resultviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/resultviewer.tcl	(revision 3800)
@@ -195,4 +195,5 @@
 
                 set index [_cleanIndex $index]
+                lappend opts "-simulation" [expr $index + 1]
                 set reset "-color autoreset"
                 set slot [lindex $_dataslots $index]
Index: /branches/1.3/gui/scripts/sequenceresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/sequenceresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/sequenceresult.tcl	(revision 3800)
@@ -212,10 +212,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
 
     if {$params(-raise) && "" == $_topmost} {
Index: /branches/1.3/gui/scripts/textresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/textresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/textresult.tcl	(revision 3800)
@@ -186,10 +186,5 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
 
     set replace 0
Index: /branches/1.3/gui/scripts/valueresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/valueresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/valueresult.tcl	(revision 3800)
@@ -84,10 +84,6 @@
         -param ""
     }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
+
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/vtkglyphviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/vtkglyphviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/vtkglyphviewer.tcl	(revision 3800)
@@ -526,10 +526,6 @@
     set params(-description) ""
     set params(-param) ""
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
+
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/vtkheightmapviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/vtkheightmapviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/vtkheightmapviewer.tcl	(revision 3800)
@@ -88,5 +88,4 @@
     private method BuildDownloadPopup { widget command } 
     private method Combo { option }
-    private method ConvertToVtkData { dataobj comp } 
     private method DrawLegend {}
     private method EnterLegend { x y } 
@@ -389,5 +388,4 @@
 
     set _image(download) [image create photo]
-    puts stderr "args=$args"
     eval itk_initialize $args
     Connect
@@ -484,10 +482,6 @@
     set params(-description) ""
     set params(-param) ""
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
+
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
@@ -2172,7 +2166,6 @@
         foreach comp [$dataobj components] {
             set tag $dataobj-$comp
-            #set contents [ConvertToVtkData $dataobj $comp]
             set contents [$dataobj vtkdata $comp]
-            append bytes "$contents\n\n"
+            append bytes "$contents\n"
         }
     }
Index: /branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl	(revision 3800)
@@ -533,10 +533,6 @@
     set params(-description) ""
     set params(-param) ""
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
+
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl	(revision 3800)
@@ -561,10 +561,6 @@
     set params(-description) ""
     set params(-param) ""
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
+
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/vtkviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/vtkviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/vtkviewer.tcl	(revision 3800)
@@ -94,4 +94,5 @@
     private method EventuallySetBondScale { args } 
     private method EventuallySetMoleculeOpacity { args } 
+    private method EventuallySetMoleculeQuality { args } 
     private method EventuallySetPolydataOpacity { args } 
     private method EventuallyResize { w h } 
@@ -109,4 +110,5 @@
     private method SetLegendTip { x y }
     private method SetMoleculeOpacity {}
+    private method SetMoleculeQuality {}
     private method SetObjectStyle { dataobj comp } 
     private method SetOpacity { dataset }
@@ -152,4 +154,5 @@
     private variable _bondScalePending 0
     private variable _moleculeOpacityPending 0
+    private variable _moleculeQualityPending 0
     private variable _polydataOpacityPending 0
     private variable _glyphsOpacityPending 0
@@ -203,4 +206,9 @@
     $_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
@@ -259,12 +267,14 @@
     array set _settings [subst {
         legend                  1
+        glyphs-opacity          100
+        glyphs-wireframe        0
         polydata-edges          0
         polydata-lighting       1
-        polydata-opacity        40
+        polydata-opacity        100
         polydata-palette        rainbow
         polydata-visible        1
         polydata-wireframe      0
-        molecule-atomscale      1.0
-        molecule-bondscale      1.0
+        molecule-atomscale      0.3
+        molecule-bondscale      0.075
         molecule-atoms-visible  1
         molecule-bonds-visible  1
@@ -274,5 +284,7 @@
         molecule-opacity        100
         molecule-palette        elementDefault
+        molecule-quality        1.0
         molecule-representation "Ball and Stick"
+        molecule-rscale         "covalent"
         molecule-visible        1
         molecule-wireframe      0
@@ -497,4 +509,10 @@
 }
 
+itcl::body Rappture::VtkViewer::SetMoleculeQuality {} {
+    SendCmd [subst {molecule aquality $_settings(molecule-quality)
+molecule bquality $_settings(molecule-quality)}]
+    set _moleculeQualityPending 0
+}
+
 itcl::body Rappture::VtkViewer::SetPolydataOpacity {} {
     set _polydataOpacityPending 0
@@ -525,4 +543,11 @@
         set _moleculeOpacityPending 1
         $_dispatcher event -after $_scaleDelay !moleculeOpacity
+    }
+}
+
+itcl::body Rappture::VtkViewer::EventuallySetMoleculeQuality { args } {
+    if { !$_moleculeQualityPending } {
+        set _moleculeQualityPending 1
+        $_dispatcher event -after $_scaleDelay !moleculeQuality
     }
 }
@@ -556,10 +581,6 @@
     set params(-description) ""
     set params(-param) ""
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
+
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
@@ -1368,4 +1389,5 @@
                 if { $type == "polydata" } {
                     ChangeColormap $dataobj $comp $palette
+                    #SendCmd "polydata colormode scalar {} $dataset"
                 }
             }
@@ -1445,5 +1467,5 @@
             switch -- $value {
                 "ballandstick" {
-                    set rscale covalent
+                    set _settings(molecule-rscale) covalent
                     set _settings(molecule-atoms-visible) 1
                     set _settings(molecule-bonds-visible) 1
@@ -1453,5 +1475,5 @@
                 }
                 "balls" - "spheres" {
-                    set rscale covalent
+                    set _settings(molecule-rscale) covalent
                     set _settings(molecule-atoms-visible) 1
                     set _settings(molecule-bonds-visible) 0
@@ -1461,5 +1483,5 @@
                 }
                 "sticks" {
-                    set rscale none
+                    set _settings(molecule-rscale) none
                     set _settings(molecule-atoms-visible) 1
                     set _settings(molecule-bonds-visible) 1
@@ -1469,5 +1491,5 @@
                 }
                 "spacefilling" {
-                    set rscale van_der_waals
+                    set _settings(molecule-rscale) van_der_waals
                     set _settings(molecule-atoms-visible) 1
                     set _settings(molecule-bonds-visible) 0
@@ -1477,5 +1499,5 @@
                 }
                 "rods"  {
-                    set rscale none
+                    set _settings(molecule-rscale) none
                     set _settings(molecule-atoms-visible) 1
                     set _settings(molecule-bonds-visible) 1
@@ -1485,5 +1507,5 @@
                 }
                 "wireframe" - "lines" {
-                    set rscale none
+                    set _settings(molecule-rscale) none
                     set _settings(molecule-atoms-visible) 0
                     set _settings(molecule-bonds-visible) 1
@@ -1496,9 +1518,18 @@
                 }
             }
+            $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 -visible $_first] {
                 foreach {dataobj comp} [split $dataset -] break
                 set type [$dataobj type $comp]
                 if { $type == "molecule" } {
-                    SendCmd [subst {molecule rscale $rscale $dataset
+                    SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset
 molecule ascale $_settings(molecule-atomscale) $dataset
 molecule bscale $_settings(molecule-bondscale) $dataset
@@ -1506,4 +1537,16 @@
 molecule atoms $_settings(molecule-atoms-visible) $dataset
 molecule bonds $_settings(molecule-bonds-visible) $dataset}]
+                }
+            }
+        }
+        "molecule-rscale" {
+            set value [$itk_component(rscale) value]
+            set value [$itk_component(rscale) translate $value]
+            set _settings(molecule-rscale) $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(molecule-rscale) $dataset}]
                 }
             }
@@ -1864,4 +1907,5 @@
         -showvalue off \
         -command [itcl::code $this AdjustSetting polydata-opacity]
+    $inner.opacity set $_settings(polydata-opacity)
 
     blt::table $inner \
@@ -2188,4 +2232,20 @@
         [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 no
+    }
+    $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.palette_l -text "Palette" -font "Arial 9" 
@@ -2235,17 +2295,17 @@
     label $inner.atomscale_l -text "Atom Scale" -font "Arial 9"
     ::scale $inner.atomscale -width 15 -font "Arial 7" \
-        -from 0.0 -to 2.0 -resolution 0.05 -label "" \
+        -from 0.025 -to 2.0 -resolution 0.025 -label "" \
         -showvalue true -orient horizontal \
-        -command [itcl::code $this EventuallyAtomScale] \
+        -command [itcl::code $this EventuallySetAtomScale] \
         -variable [itcl::scope _settings(molecule-atomscale)]
     $inner.atomscale set $_settings(molecule-atomscale)
     Rappture::Tooltip::for $inner.atomscale \
-        "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."
+        "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.0 -to 1.0 -resolution 0.025 -label "" \
+        -from 0.005 -to 0.3 -resolution 0.005 -label "" \
         -showvalue true -orient horizontal \
-        -command [itcl::code $this EventuallyBondScale] \
+        -command [itcl::code $this EventuallySetBondScale] \
         -variable [itcl::scope _settings(molecule-bondscale)]
     Rappture::Tooltip::for $inner.bondscale \
@@ -2258,23 +2318,37 @@
         -width 15 -font "Arial 7" \
         -showvalue on \
-        -command [itcl::code $this EventuallyMoleculeOpacity]
+        -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.label       -anchor w -pady {1 0} \
-        2,0 $inner.edges       -anchor w -pady {1 0} \
-        3,0 $inner.rep_l       -anchor w -pady { 2 0 } \
-        4,0 $inner.rep         -fill x    -pady 2 \
-        5,0 $inner.palette_l   -anchor w  -pady 0 \
-        6,0 $inner.palette     -fill x    -padx 2 \
-        7,0 $inner.atomscale_l -anchor w -pady {3 0} \
-        8,0 $inner.atomscale   -fill x    -padx 2 \
-        9,0 $inner.bondscale_l -anchor w -pady {3 0} \
-        10,0 $inner.bondscale  -fill x   -padx 2 \
-        11,0 $inner.opacity_l  -anchor w -pady {3 0} \
-        12,0 $inner.opacity    -fill x    -padx 2 
+        0,0 $inner.molecule     -anchor w -pady {1 0} \
+        1,0 $inner.label        -anchor w -pady {1 0} \
+        2,0 $inner.edges        -anchor w -pady {1 0} \
+        3,0 $inner.rep_l        -anchor w -pady { 2 0 } \
+        4,0 $inner.rep          -fill x    -pady 2 \
+        5,0 $inner.rscale_l     -anchor w -pady { 2 0 } \
+        6,0 $inner.rscale       -fill x    -pady 2 \
+        7,0 $inner.palette_l    -anchor w  -pady 0 \
+        8,0 $inner.palette      -fill x    -padx 2 \
+        9,0 $inner.atomscale_l  -anchor w -pady {3 0} \
+        10,0 $inner.atomscale   -fill x    -padx 2 \
+        11,0 $inner.bondscale_l -anchor w -pady {3 0} \
+        12,0 $inner.bondscale   -fill x   -padx 2 \
+        13,0 $inner.opacity_l   -anchor w -pady {3 0} \
+        14,0 $inner.opacity     -fill x    -padx 2 \
+        15,0 $inner.quality_l   -anchor w -pady {3 0} \
+        16,0 $inner.quality     -fill x    -padx 2
     
     blt::table configure $inner r* -resize none
-    blt::table configure $inner r13 -resize expand
+    blt::table configure $inner r17 -resize expand
 }
 
@@ -2418,10 +2492,9 @@
         "molecule" {
             SendCmd "molecule add $tag"
-            SendCmd "molecule rscale van_der_waals $tag"
             set _haveMolecules 1
         }
         "polydata" {
             array set settings {
-                -color \#6666FF
+                -color \#FFFFFF
                 -edges 1
                 -edgecolor black
@@ -2444,5 +2517,5 @@
             SendCmd "polydata linewidth $settings(-linewidth) $tag"
             SendCmd "polydata opacity $settings(-opacity) $tag"
-            set _settings(polydata-opacity) $settings(-opacity)
+            set _settings(polydata-opacity) [expr 100.0 * $settings(-opacity)]
             SendCmd "polydata wireframe $settings(-wireframe) $tag"
             set _settings(polydata-wireframe) $settings(-wireframe)
Index: /branches/1.3/gui/scripts/vtkvolumeviewer.tcl
===================================================================
--- /branches/1.3/gui/scripts/vtkvolumeviewer.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/vtkvolumeviewer.tcl	(revision 3800)
@@ -531,10 +531,6 @@
     set params(-description) ""
     set params(-param) ""
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
+    array set params $settings
+
     if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
         # can't handle -autocolors yet
Index: /branches/1.3/gui/scripts/xylegend.tcl
===================================================================
--- /branches/1.3/gui/scripts/xylegend.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/xylegend.tcl	(revision 3800)
@@ -86,5 +86,4 @@
     private method Raise { args } 
     private method PopupMenu { x y }
-    private method Recolor {} 
     private method Rename {} 
     private method SelectAll {}
@@ -159,5 +158,4 @@
         delete ""
         rename ""
-        recolor ""
     }
     foreach { but icon} $commands {
@@ -177,5 +175,4 @@
     grid $controls.rename     -column 1 -row 2 -sticky w
     grid $controls.delete     -column 1 -row 3 -sticky w
-    grid $controls.recolor    -column 1 -row 4 -sticky w
 
     grid columnconfigure $controls 0  -weight 1
@@ -396,5 +393,5 @@
     set nodes [$itk_component(legend) curselection]
     foreach n { hide show toggle raise lower 
-        rename average difference delete recolor } {
+        rename average difference delete } {
         $itk_component(controls).$n configure -state disabled
     }
@@ -414,15 +411,15 @@
         }
         1 {
-            foreach n { hide show toggle rename recolor } {
+            foreach n { hide show toggle rename } {
                 $itk_component(controls).$n configure -state normal
             }
         }
         2 {
-            foreach n { hide show toggle difference average recolor } {
+            foreach n { hide show toggle difference average } {
                 $itk_component(controls).$n configure -state normal
             }
         }
         default {
-            foreach n { hide show toggle average recolor } {
+            foreach n { hide show toggle average } {
                 $itk_component(controls).$n configure -state normal
             }
@@ -551,27 +548,4 @@
 
 
-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]
-        if { [$_graph element type $elem] == "bar" } {
-            $_graph element configure $elem -background $color \
-                -foreground $color
-        } else {
-            $_graph element configure $elem -color $color
-        }
-        set im [$itk_component(legend) entry cget $node -icon]
-        $_graph legend icon $elem $im
-    }
-}
-
 itcl::body Rappture::XyLegend::UnmapHidden {} {
     $_graph configure -unmaphiddenelements $_unmapHidden
Index: /branches/1.3/gui/scripts/xyresult.tcl
===================================================================
--- /branches/1.3/gui/scripts/xyresult.tcl	(revision 3799)
+++ /branches/1.3/gui/scripts/xyresult.tcl	(revision 3800)
@@ -71,5 +71,22 @@
     itk_option define -autocolors autoColors AutoColors ""
 
-    private variable _viewable "";          # Display list for widget.
+    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 
@@ -99,26 +116,6 @@
     protected method LeaveMarker { g name }
 
-    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 _dataobj2type   ;# maps dataobj => type of graph element
-    private variable _dataobj2barwidth ;# 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 _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 _nextElement 0
-
-    private method BuildElements { dlist }
+
+    private method BuildGraph { dlist }
     private method BuildMarkers { dataobj elem }
     private method FormatAxis { axis w value }
@@ -127,4 +124,5 @@
     private method ShowAxisPopup { axis }
     private method SetAxis { setting }
+    private method SetElements { dataobj {settings ""} }
     private method SetAxisRangeState { axis }
 }
@@ -232,136 +230,54 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::XyResult::add {dataobj {settings ""}} {
-    #puts stderr "XyResult::add dataobj=$dataobj settings=$settings"
-    array set params {
-        -color auto
-        -brightness 0
-        -width 1
-        -barwidth 1
-        -raise 0
-        -type "line"
-        -linestyle solid
-        -description ""
-        -param ""
-    }
-    # Override the defaults with first the <style> specified and then the
-    # settings list passed into this routoue.
-    array set params [$dataobj hints style]
-    set type [$dataobj hints type]
-    if { $type == "" } {
-        set type "line"
-    }
-    foreach {opt val} $settings {
-        if {![info exists params($opt)]} {
-            error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
-        }
-        set params($opt) $val
-    }
-
-    # if type is set to "scatter", then override the width
-    if { $type == "scatter" } {
-        set params(-width) 0
-    }
-    # 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]
+    #puts stderr "add: dataobj=$dataobj settings=$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 { $color == "auto" || $color == "autoreset" } {
+        if { $color == "autoreset" } {
+            set _nextColorIndex 0
+        }
+	set color [lindex $itk_option(-autocolors) $_nextColorIndex]
         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 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 params(-color) [Rappture::color::brightness_max \
-                $params(-color) 0.8]
+            set color [Rappture::color::brightness_max $color 0.8]
         } else {
-            set params(-color) [Rappture::color::brightness_min \
-                $params(-color) 0.2]
-        }
-    }
-
-    set _dataobj2raise($dataobj) $params(-raise)
-
-    set g $itk_component(plot)
-    set color $params(-color)
-    set lwidth $params(-width)
-    set dashes $params(-linestyle)
-    set raise $params(-raise)
-    set desc $params(-description)
-    set barwidth $params(-barwidth)
-    foreach {mapx mapy} [GetAxes $dataobj] break
-    foreach comp [$dataobj components] {
-        set tag $dataobj-$comp
-        if { [info exists _comp2elem($tag)] } {
-            set elem $_comp2elem($tag)
-            # Ignore -type, it's already been set 
-            switch -- [$g element type $elem] {
-                "line" - "scatter" {
-                    $g line configure $elem \
-                        -linewidth $lwidth \
-                        -dashes $dashes -hide no
-                } "bar" {
-                    $g bar configure $elem \
-                        -barwidth $barwidth \
-                        -hide no
-                }
-            }
+            set color [Rappture::color::brightness_min $color 0.2]
+        }
+    }
+    set type [$dataobj hints type]
+    foreach cname [$dataobj components] {
+        set tag $dataobj-$cname
+        set elem $_comp2elem($tag) 
+        if { $type == "bar" } {
+            $g bar configure $elem -foreground $color -background $color \
+                -hide no
         } else {
-            set elem "$type[incr _nextElement]"
-            set label [$dataobj hints label]
-            set _elem2comp($elem) $tag
-            set _comp2elem($tag) $elem
-            lappend label2elem($label) $elem
-            set xv [$dataobj mesh $comp]
-            set yv [$dataobj values $comp]
-            switch -- $type {
-                "line" {
-                    if {([$xv length] <= 1) || ($lwidth == 0)} {
-                        set sym square
-                        set pixels 2
-                    } else {
-                        set sym ""
-                        set pixels 6
-                    }
-                    $g element create $elem -x $xv -y $yv \
-                        -symbol $sym -pixels $pixels -linewidth $lwidth \
-                        -label $label \
-                        -color $color -dashes $dashes \
-                        -mapx $mapx -mapy $mapy -hide no
-                } 
-                "scatter" {
-                    $g element create $elem -x $xv -y $yv \
-                        -symbol square -pixels 2 -linewidth $lwidth \
-                        -label $label \
-                        -color $color -dashes $dashes \
-                        -mapx $mapx -mapy $mapy -hide no
-                } 
-                "bar" {
-                    $g bar create $elem -x $xv -y $yv \
-                        -barwidth $barwidth \
-                        -label $label \
-                        -color $color \
-                        -mapx $mapx -mapy $mapy
-                }
-            }
+            $g line configure $elem -color $color -hide no
         }
         if { [lsearch $_viewable $elem] < 0 } {
@@ -442,5 +358,5 @@
     #puts stderr "XyResult::scale args=$args"
     set _dlist $args
-    BuildElements $args 
+    BuildGraph $args 
 }
 
@@ -653,4 +569,6 @@
     # 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
@@ -669,7 +587,6 @@
             }
             foreach {dataobj cname} [split $_elem2comp($elem) -] break
-            regexp {^::curve(?:Value)?([0-9]+)$} $dataobj match suffix
-            incr suffix
-            set elabel [format "%s \#%d" $label $suffix]
+            set sim $_dataobj2sim($dataobj)
+            set elabel [format "%s \#%d" $label $sim]
             $g element configure $elem -label $elabel
         }
@@ -1163,6 +1080,6 @@
         }
     }
-    if {$_autoColorI >= [llength $itk_option(-autocolors)]} {
-        set _autoColorI 0
+    if {$_nextColorIndex >= [llength $itk_option(-autocolors)]} {
+        set _nextColorIndex 0
     }
 }
@@ -1519,5 +1436,5 @@
 
 #
-# BuildElements --
+# BuildGraph --
 #
 #       This procedure loads each data objects specified into the
@@ -1527,5 +1444,5 @@
 #       for all datasets, even those not currently being displayed.
 #       
-itcl::body Rappture::XyResult::BuildElements { dlist } {
+itcl::body Rappture::XyResult::BuildGraph { dlist } {
     set g $itk_component(plot)
     
@@ -1622,54 +1539,78 @@
     }
     
-    # Create data elements and markers, but mark them as hidden.
-    # The "add" method will un-hide them.
-    set count 0
     foreach dataobj $dlist {
-        set label [$dataobj hints label]
-        array set params [$dataobj hints style]
-        set type [$dataobj hints type]
-        # Default 
-        if {[info exists params(-color)]} {
-            set color params(-color)
+        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)
+    }
+    if { ![info exists attrs(-raise)] } {
+        set raise 0
+    } else {
+        set raise $attrs(-raise)
+    }
+    if { ![info exists attrs(-simulation)] } {
+        set sim 0
+    } else {
+        set sim $attrs(-simulation)
+    }
+
+    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]
+
+        if {([$xv length] <= 1) || ($linewidth == 0)} {
+            set sym square
+            set pixels 2
         } else {
-            set color black
-        }
-        if { $type == "" } {
-            set type "line"
-        }
-        if {[info exists parmas(-barwidth)]} {
-            set barwidth $params(-barwidth)
-        } else {
-            set barwidth 1.0
-        }
-        if {[info exists params(-width)]} {
-            set lwidth $params(-width)
-        } else {
-            set lwidth 2
-        }
-        if {[info exists params(-linestyle)]} {
-            set dashes $parmas(-linestyle)
-        } else {
-            set dashes ""
-        }
-        foreach {mapx mapy} [GetAxes $dataobj] break
-        foreach comp [$dataobj components] {
-            set tag $dataobj-$comp
-            if { [info exists _comp2elem($tag)] } {
-                set found($_comp2elem($tag)) 1
-                lappend label2elem($label) $_comp2elem($tag)
-                # Element already created for data object/component.
-                continue
-            }
-            set xv [$dataobj mesh $comp]
-            set yv [$dataobj values $comp]
-            
-            if {([$xv length] <= 1) || ($lwidth == 0)} {
-                set sym square
-                set pixels 2
-            } else {
-                set sym ""
-                set pixels 6
-            }
+            set sym ""
+            set pixels 6
+        }
+        if { ![info exists _comp2elem($tag)] } {
             set elem "$type[incr _nextElement]"
             set _elem2comp($elem) $tag
@@ -1678,23 +1619,33 @@
             lappend label2elem($label) $elem
             switch -- $type {
-                "line" - "scatter" {
+                "line" {
                     $g line create $elem \
                         -x $xv -y $yv \
                         -symbol $sym \
                         -pixels $pixels \
-                        -linewidth $lwidth \
+                        -linewidth $linewidth \
                         -label $label \
-                        -color $color \
                         -dashes $dashes \
                         -mapx $mapx \
                         -mapy $mapy \
                         -hide yes 
-                } "bar" {
+                } 
+                "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 
+                } 
+                "bar" {
                     $g bar create $elem \
                         -x $xv -y $yv \
                         -barwidth $barwidth \
                         -label $label \
-                        -foreground $color \
-                        -background $color \
                         -mapx $mapx \
                         -mapy $mapy \
@@ -1702,14 +1653,23 @@
                 }
             }
-            if { [$dataobj info class] == "Rappture::Curve" } {
-                BuildMarkers $dataobj $elem
-            }
-        }
-    }
-    foreach elem [$g element names] {
-        if { ![info exists found($elem)] } {
-            $g element delete $elem
-        }
-    }
-    ResetLegend
-}
+        } else {
+            set elem $_comp2elem($tag)
+            switch -- $type {
+                "line" {
+                    $g line configure $elem \
+                        -symbol $sym \
+                        -pixels $pixels \
+                        -linewidth $linewidth \
+                        -dashes $dashes 
+                } 
+                "bar" {
+                    $g bar configure $elem \
+                        -barwidth $barwidth \
+                        -label $label 
+                }
+            }
+        }
+        set _dataobj2raise($dataobj) $raise
+        set _dataobj2sim($dataobj) $sim
+    }
+}
