Index: branches/1.3/gui/scripts/vtkheightmapviewer.tcl
===================================================================
--- branches/1.3/gui/scripts/vtkheightmapviewer.tcl	(revision 5011)
+++ branches/1.3/gui/scripts/vtkheightmapviewer.tcl	(revision 5012)
@@ -1,3 +1,3 @@
-# -*- mode: tcl; indent-tabs-mode: nil -*- 
+# -*- mode: tcl; indent-tabs-mode: nil -*-
 # ----------------------------------------------------------------------
 #  COMPONENT: vtkheightmapviewer - Vtk heightmap viewer
@@ -7,5 +7,5 @@
 # ======================================================================
 #  AUTHOR:  Michael McLennan, Purdue University
-#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
+#  Copyright (c) 2004-2014  HUBzero Foundation, LLC
 #
 #  See the file "license.terms" for information on usage and
@@ -58,54 +58,57 @@
     public method get {args}
     public method isconnected {}
-    public method limits3 { dataobj }
-    public method parameters {title args} { 
-        # do nothing 
+    public method parameters {title args} {
+        # do nothing
     }
     public method scale {args}
 
-    protected method CameraReset {}
-    protected method Connect {}
-    protected method CurrentDatasets {args}
-    protected method Disconnect {}
-    protected method DoResize {}
-    protected method DoRotate {}
-    protected method AdjustSetting {what {value ""}}
-    protected method AdjustMode {}
-    protected method InitSettings { args  }
-    protected method Pan {option x y}
-    protected method Pick {x y}
-    protected method Rebuild {}
-    protected method ReceiveDataset { args }
-    protected method ReceiveImage { args }
-    protected method ReceiveLegend { colormap title min max size }
-    protected method Rotate {option x y}
-    protected method Zoom {option}
-
     # 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 BuildDownloadPopup { widget command }
+    private method CameraReset {}
     private method Combo { option }
+    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 IsValidObject { dataobj } 
+    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 MotionLegend { x y } 
+    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 SetLegendTip { x y }
-    private method SetObjectStyle { dataobj comp } 
-    private method GetHeightmapScale {} 
-    private method ResetAxes {}
+    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 ""
@@ -113,6 +116,6 @@
     private variable _obj2datasets
     private variable _obj2ovride   ;    # maps dataobj => style override
-    private variable _comp2scale;	# maps dataset to the heightmap scale.
-    private variable _datasets     ;    # contains all the dataobj-component 
+    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
@@ -123,5 +126,4 @@
     private variable _currentColormap ""
     private variable _currentNumIsolines -1
-    private variable _currentOpacity ""
 
     private variable _maxScale 100;     # This is the # of times the x-axis
@@ -131,5 +133,5 @@
 
     private variable _click        ;    # info used for rotate operations
-    private variable _limits       ;    # Holds overall limits for all dataobjs 
+    private variable _limits       ;    # Holds overall limits for all dataobjs
                                         # using the viewer.
     private variable _view         ;    # view params for 3D view
@@ -156,6 +158,6 @@
     private variable _rotatePending 0
     private variable _legendPending 0
-    private variable _fieldNames {} 
-    private variable _fields 
+    private variable _fieldNames {}
+    private variable _fields
     private variable _curFldName ""
     private variable _curFldLabel ""
@@ -203,48 +205,48 @@
     # Initialize the view to some default parameters.
     array set _view {
-        qw	0.36
-        qx	0.25
-        qy	0.50
-        qz	0.70
-        zoom	1.0 
-        xpan	0
-        ypan	0
-        ortho	0
+        -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]
-    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
-    $_arcball quaternion $q
+    $_arcball quaternion [ViewToQuaternion]
 
     array set _settings {
-        axisFlymode		"static"
-        axisMinorTicks		1
-        stretchToFit		0
-        axisLabels              1
-        axisVisible		1
-        axisXGrid		0
-        axisYGrid		0
-        axisZGrid		0
-        colormapVisible         1
-        colormapDiscrete        0
-        edges			0
-        field			"Default"
-        heightmapScale		50
-        isHeightmap		0
-        isolineColor            black
-        isolinesVisible         1
-        legendVisible           1
-        lighting		1
-        saveLighting		1
-        numIsolines		10
-        opacity                 100
-        outline			0
-        wireframe		0
-        saveOpacity		100
-        saveOutline		0
+        -axisflymode            "static"
+        -axislabels             1
+        -axisminorticks         1
+        -axisvisible            1
+        -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 {
-        opacity                 0
-        colormap                0
-        numIsolines             0
+        -colormap               0
+        -numisolines            0
+        -opacity                0
     }
     itk_component add view {
@@ -253,5 +255,5 @@
     } {
         usual
-        ignore -highlightthickness -borderwidth -background 
+        ignore -highlightthickness -borderwidth -background
     }
 
@@ -259,5 +261,5 @@
         menu $itk_component(plotarea).menu \
             -relief flat \
-            -tearoff no 
+            -tearoff no
     } {
         usual
@@ -279,6 +281,6 @@
 
     set _map(id) [$c create image 0 0 -anchor nw -image $_image(plot)]
-    set _map(cwidth) -1 
-    set _map(cheight) -1 
+    set _map(cwidth) -1
+    set _map(cheight) -1
     set _map(zoom) 1.0
     set _map(original) ""
@@ -325,6 +327,6 @@
             -onimage [Rappture::icon surface] \
             -offimage [Rappture::icon surface] \
-            -variable [itcl::scope _settings(isHeightmap)] \
-            -command [itcl::code $this AdjustSetting isHeightmap] \
+            -variable [itcl::scope _settings(-isheightmap)] \
+            -command [itcl::code $this AdjustSetting -isheightmap] \
     }
     Rappture::Tooltip::for $itk_component(mode) \
@@ -336,6 +338,6 @@
             -onimage [Rappture::icon stretchtofit] \
             -offimage [Rappture::icon stretchtofit] \
-            -variable [itcl::scope _settings(stretchToFit)] \
-            -command [itcl::code $this AdjustSetting stretchToFit] \
+            -variable [itcl::scope _settings(-stretchtofit)] \
+            -command [itcl::code $this AdjustSetting -stretchtofit] \
     }
     Rappture::Tooltip::for $itk_component(stretchtofit) \
@@ -348,9 +350,9 @@
         BuildCameraTab
     } errs] != 0 } {
-	global errorInfo
+        global errorInfo
         puts stderr "errs=$errs errorInfo=$errorInfo"
     }
 
-    # Hack around the Tk panewindow.  The problem is that the requested 
+    # 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.
@@ -358,5 +360,5 @@
     pack forget $itk_component(view)
     blt::table $itk_component(plotarea) \
-        0,0 $itk_component(view) -fill both -reqwidth $w 
+        0,0 $itk_component(view) -fill both -reqwidth $w
     blt::table configure $itk_component(plotarea) c1 -resize none
 
@@ -442,6 +444,5 @@
 
 itcl::body Rappture::VtkHeightmapViewer::DoRotate {} {
-    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
-    SendCmd "camera orient $q" 
+    SendCmd "camera orient [ViewToQuaternion]"
     set _rotatePending 0
 }
@@ -467,8 +468,8 @@
 
 itcl::body Rappture::VtkHeightmapViewer::EventuallyRotate { q } {
-    foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break
+    QuaternionToView $q
     if { !$_rotatePending } {
         set _rotatePending 1
-        global rotate_delay 
+        global rotate_delay
         $_dispatcher event -after $rotate_delay !rotate
     }
@@ -569,5 +570,5 @@
                     continue
                 }
-                if {[info exists _obj2ovride($dataobj-raise)] && 
+                if {[info exists _obj2ovride($dataobj-raise)] &&
                     $_obj2ovride($dataobj-raise)} {
                     set dlist [linsert $dlist 0 $dataobj]
@@ -597,5 +598,5 @@
             }
             return $dlist
-        }           
+        }
         -image {
             if {[llength $args] != 2} {
@@ -617,11 +618,11 @@
 }
 
-# 
+#
 # 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 
+#       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.
 #
@@ -666,5 +667,5 @@
     }
     if { [array size found] > 1 } {
-        set _settings(stretchToFit) 1
+        set _settings(-stretchtofit) 1
     } else {
         # Check if the range of the x and y axes requires that we stretch
@@ -675,5 +676,5 @@
         if { (($xmax - $xmin) > (($ymax -$ymin) * $_maxScale)) ||
              ((($xmax - $xmin) * $_maxScale) < ($ymax -$ymin)) } {
-            set _settings(stretchToFit) 1
+            set _settings(-stretchtofit) 1
         }
     }
@@ -815,8 +816,8 @@
     $_dispatcher cancel !legend
     # disconnected -- no more data sitting on server
-    array unset _datasets 
-    array unset _data 
-    array unset _colormaps 
-    array unset _obj2datasets 
+    array unset _datasets
+    array unset _data
+    array unset _colormaps
+    array unset _obj2datasets
     global readyForNextFrame
     set readyForNextFrame 1
@@ -842,6 +843,7 @@
     if { $info(-type) == "image" } {
         if 0 {
-            set f [open "last.ppm" "w"] 
-            puts $f $bytes
+            set f [open "last.ppm" "w"]
+            fconfigure $f -encoding binary
+            puts -nonewline $f $bytes
             close $f
         }
@@ -849,5 +851,5 @@
         set time [clock seconds]
         set date [clock format $time]
-        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"        
+        #puts stderr "$date: received image [image width $_image(plot)]x[image height $_image(plot)] image>"
         if { $_start > 0 } {
             set finish [clock clicks -milliseconds]
@@ -920,31 +922,37 @@
     # 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).   
+    # 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
-	}
+        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
-
-        # Let's see how this goes.  I think it's preferable to overloading the
-        # axis title with the exponent.
-        SendCmd "axis exp 0 0 0 1"
-
-	SendCmd "axis lrot z 90"
-	set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
-	$_arcball quaternion $q 
-        if {$_settings(isHeightmap) } {
-            if { $_view(ortho)} {
+        #
+        # Reset the camera and other view parameters
+        #
+        InitSettings -isheightmap -background
+
+        # 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 lrot z 90"
+        $_arcball quaternion [ViewToQuaternion]
+        if {$_settings(-isheightmap) } {
+            if { $_view(-ortho)} {
                 SendCmd "camera mode ortho"
             } else {
@@ -953,6 +961,6 @@
             DoRotate
             SendCmd "camera reset"
-	}
-	PanCamera
+        }
+        PanCamera
         StopBufferingCommands
         SendCmd "imgflush"
@@ -973,9 +981,10 @@
             if { ![info exists _datasets($tag)] } {
                 set bytes [$dataobj vtkdata $comp]
-		if 0 { 
+                if 0 {
                     set f [open /tmp/vtkheightmap.vtk "w"]
-                    puts $f $bytes
+                    fconfigure $f -translation binary -encoding binary
+                    puts -nonewline $f $bytes
                     close $f
-		}
+                }
                 set length [string length $bytes]
                 if { $_reportClientInfo }  {
@@ -989,5 +998,5 @@
                     lappend info "dataset_size"  $length
                     lappend info "dataset_tag"   $tag
-                    SendCmd [list "clientinfo" $info]
+                    SendCmd "clientinfo [list $info]"
                 }
                 SendCmd "dataset add $tag data follows $length"
@@ -1002,15 +1011,15 @@
                 SendCmd "dataset visible 1 $tag"
             }
-	    if { ![info exists _comp2scale($tag)] || 
-		 $_comp2scale($tag) != $scale } {
-		SendCmd "heightmap heightscale $scale $tag"
-		set _comp2scale($tag) $scale
-	    }
+            if { ![info exists _comp2scale($tag)] ||
+                 $_comp2scale($tag) != $scale } {
+                SendCmd "heightmap heightscale $scale $tag"
+                set _comp2scale($tag) $scale
+            }
         }
     }
     if { $_first != ""  } {
-	$itk_component(field) choices delete 0 end
-	$itk_component(fieldmenu) delete 0 end
-	array unset _fields
+        $itk_component(field) choices delete 0 end
+        $itk_component(fieldmenu) delete 0 end
+        array unset _fields
         set _curFldName ""
         foreach cname [$_first components] {
@@ -1038,13 +1047,11 @@
         $itk_component(field) value $_curFldLabel
     }
-    InitSettings stretchToFit outline
+    InitSettings -stretchtofit -outline
 
     if { $_reset } {
-	SendCmd "axis tickpos outside"
-	foreach axis { x y z } {
-	    SendCmd "axis lformat $axis %g"
-	}
-        
-	foreach axis { x y z } {
+        SendCmd "axis tickpos outside"
+        #SendCmd "axis lformat all %g"
+
+        foreach axis { x y z } {
             if { $axis == "z" } {
                 set label [$_first hints label]
@@ -1052,6 +1059,6 @@
                 set label [$_first hints ${axis}label]
             }
-	    if { $label == "" } {
-		if {$axis == "z"} {
+            if { $label == "" } {
+                if {$axis == "z"} {
                     if { [string match "component*" $_curFldName] } {
                         set label [string toupper $axis]
@@ -1059,29 +1066,31 @@
                         set label $_curFldLabel
                     }
-		} else {
-		    set label [string toupper $axis]
-		}
-	    }
-	    # May be a space in the axis label.
-	    SendCmd [list axis name $axis $label]
-
-	    if {$axis == "z" && [$_first hints ${axis}units] == ""} {
-		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
-	#
-	ResetAxes
-	set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
-	$_arcball quaternion $q 
-        if {$_settings(isHeightmap) } {
-            if { $_view(ortho)} {
+                } else {
+                    set label [string toupper $axis]
+                }
+            }
+            # May be a space in the axis label.
+            SendCmd [list axis name $axis $label]
+
+            set units ""
+            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
+        #
+        ResetAxes
+        $_arcball quaternion [ViewToQuaternion]
+        if {$_settings(-isheightmap) } {
+            if { $_view(-ortho)} {
                 SendCmd "camera mode ortho"
             } else {
@@ -1091,8 +1100,8 @@
             SendCmd "camera reset"
         }
-	PanCamera
-	InitSettings axisXGrid axisYGrid axisZGrid \
-	    axisVisible axisLabels heightmapScale field isHeightmap \
-            numIsolines
+        PanCamera
+        InitSettings -xgrid -ygrid -zgrid \
+            -axisvisible -axislabels -heightmapscale -field -isheightmap \
+            -numisolines
         if { [array size _fields] < 2 } {
             catch {blt::table forget $itk_component(field) $itk_component(field_l)}
@@ -1102,5 +1111,5 @@
     }
     global readyForNextFrame
-    set readyForNextFrame 0;		# Don't advance to the next frame
+    set readyForNextFrame 0;                # Don't advance to the next frame
 
     # Actually write the commands to the server socket.  If it fails, we don't
@@ -1120,5 +1129,5 @@
 itcl::body Rappture::VtkHeightmapViewer::CurrentDatasets {args} {
     set flag [lindex $args 0]
-    switch -- $flag { 
+    switch -- $flag {
         "-all" {
             if { [llength $args] > 1 } {
@@ -1139,5 +1148,5 @@
                 set dlist [get -visible]
             }
-        }           
+        }
         default {
             set dlist $args
@@ -1158,11 +1167,11 @@
 itcl::body Rappture::VtkHeightmapViewer::CameraReset {} {
     array set _view {
-        qw      0.36
-        qx      0.25
-        qy      0.50
-        qz      0.70
-        zoom    1.0
-        xpan    0
-        ypan    0 
+        -qw      0.36
+        -qx      0.25
+        -qy      0.50
+        -qz      0.70
+        -xpan    0
+        -ypan    0
+        -zoom    1.0
     }
     if { $_first != "" } {
@@ -1172,7 +1181,6 @@
         }
     }
-    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
-    $_arcball quaternion $q
-    if {$_settings(isHeightmap) } {
+    $_arcball quaternion [ViewToQuaternion]
+    if {$_settings(-isheightmap) } {
         DoRotate
     }
@@ -1191,16 +1199,16 @@
     switch -- $option {
         "in" {
-            set _view(zoom) [expr {$_view(zoom)*1.25}]
-            SendCmd "camera zoom $_view(zoom)"
+            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)"
+            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
+            SendCmd "camera zoom $_view(-zoom)"
         }
         "reset" {
             array set _view {
-                zoom    1.0
-                xpan    0
-                ypan    0 
+                -xpan    0
+                -ypan    0
+                -zoom    1.0
             }
             SendCmd "camera reset"
@@ -1210,6 +1218,6 @@
 
 itcl::body Rappture::VtkHeightmapViewer::PanCamera {} {
-    set x $_view(xpan)
-    set y $_view(ypan)
+    set x $_view(-xpan)
+    set y $_view(-ypan)
     SendCmd "camera pan $x $y"
 }
@@ -1271,5 +1279,5 @@
     foreach tag [CurrentDatasets -visible] {
         SendCmd "dataset getscalar pixel $x $y $tag"
-    } 
+    }
 }
 
@@ -1289,6 +1297,6 @@
             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]
+            set _view(-xpan) [expr $_view(-xpan) + $x]
+            set _view(-ypan) [expr $_view(-ypan) + $y]
             PanCamera
             return
@@ -1312,6 +1320,6 @@
             set _click(x) $x
             set _click(y) $y
-            set _view(xpan) [expr $_view(xpan) - $dx]
-            set _view(ypan) [expr $_view(ypan) - $dy]
+            set _view(-xpan) [expr $_view(-xpan) - $dx]
+            set _view(-ypan) [expr $_view(-ypan) - $dy]
             PanCamera
         }
@@ -1335,7 +1343,7 @@
 itcl::body Rappture::VtkHeightmapViewer::InitSettings { args } {
     foreach spec $args {
-        if { [info exists _settings($_first-$spec)] } {
+        if { [info exists _settings($_first${spec})] } {
             # Reset global setting with dataobj specific setting
-            set _settings($spec) $_settings($_first-$spec)
+            set _settings($spec) $_settings($_first${spec})
         }
         AdjustSetting $spec
@@ -1355,5 +1363,5 @@
     }
     switch -- $what {
-        "axisFlymode" {
+        "-axisflymode" {
             set mode [$itk_component(axisflymode) value]
             set mode [$itk_component(axisflymode) translate $mode]
@@ -1361,69 +1369,62 @@
             SendCmd "axis flymode $mode"
         }
-        "axisLabels" {
-            set bool $_settings(axisLabels)
+        "-axislabels" {
+            set bool $_settings($what)
             SendCmd "axis labels all $bool"
         }
-        "axisMinorTicks" {
-            set bool $_settings(axisMinorTicks)
-	    foreach axis { x y z } { 
-		SendCmd "axis minticks ${axis} $bool"
-	    }
-        }
-        "axisVisible" {
-            set bool $_settings(axisVisible)
+        "-axisminorticks" {
+            set bool $_settings($what)
+            SendCmd "axis minticks all $bool"
+        }
+        "-axisvisible" {
+            set bool $_settings($what)
             SendCmd "axis visible all $bool"
         }
-        "axisXGrid" - "axisYGrid" - "axisZGrid" {
-            set axis [string tolower [string range $what 4 4]]
-            set bool $_settings($what)
-            SendCmd "axis grid $axis $bool"
-        }
-        "background" {
+        "-background" {
             set bg [$itk_component(background) value]
-	    array set fgcolors {
-		"black" "white"
-		"white" "black"
-		"grey"	"black"
-	    }
+            array set fgcolors {
+                "black" "white"
+                "white" "black"
+                "grey"  "black"
+            }
             set fg $fgcolors($bg)
             configure -plotbackground $bg -plotforeground $fg
-	    $itk_component(view) delete "legend"
+            $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(colormap) 1
+            DrawLegend
+        }
+        "-colormap" {
+            set _changed($what) 1
             StartBufferingCommands
             set color [$itk_component(colormap) value]
-            set _settings(colormap) $color
-	    if { $color == "none" } {
-		if { $_settings(colormapVisible) } {
-		    SendCmd "heightmap surface 0"
-		    set _settings(colormapVisible) 0
-		}
-	    } else {
-		if { !$_settings(colormapVisible) } {
-		    SendCmd "heightmap surface 1"
-		    set _settings(colormapVisible) 1
-		}
-		SetCurrentColormap $color
-                if {$_settings(colormapDiscrete)} {
-                    set numColors [expr $_settings(numIsolines) + 1]
+            set _settings($what) $color
+            if { $color == "none" } {
+                if { $_settings(-colormapvisible) } {
+                    SendCmd "heightmap surface 0"
+                    set _settings(-colormapvisible) 0
+                }
+            } else {
+                if { !$_settings(-colormapvisible) } {
+                    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
-        }
-        "colormapVisible" {
+            EventuallyRequestLegend
+        }
+        "-colormapvisible" {
             set bool $_settings($what)
             SendCmd "heightmap surface $bool"
         }
-        "colormapDiscrete" {
+        "-colormapdiscrete" {
             set bool $_settings($what)
-            set numColors [expr $_settings(numIsolines) + 1]
+            set numColors [expr $_settings(-numisolines) + 1]
             StartBufferingCommands
             if {$bool} {
@@ -1439,12 +1440,12 @@
             EventuallyRequestLegend
         }
-        "edges" {
-            set bool $_settings(edges)
+        "-edges" {
+            set bool $_settings($what)
             SendCmd "heightmap edges $bool"
         }
-        "field" {
+        "-field" {
             set label [$itk_component(field) value]
             set fname [$itk_component(field) translate $label]
-            set _settings(field) $fname
+            set _settings($what) $fname
             if { [info exists _fields($fname)] } {
                 foreach { label units components } $_fields($fname) break
@@ -1460,6 +1461,6 @@
                 return
             }
-	    set label [$_first hints label]
-	    if { $label == "" } {
+            set label [$_first hints label]
+            if { $label == "" } {
                 if { [string match "component*" $_curFldName] } {
                     set label Z
@@ -1467,17 +1468,17 @@
                     set label $_curFldLabel
                 }
-	    }
-	    # May be a space in the axis label.
-	    SendCmd [list axis name z $label]
-
-	    if { [$_first hints zunits] == "" } {
-		set units [lindex $_fields($_curFldName) 1]
-	    } else {
-		set units [$_first hints zunits]
-	    }
-	    if { $units != "" } {
-		# May be a space in the axis units.
-		SendCmd [list axis units z $units]
-	    }
+            }
+            # May be a space in the axis label.
+            SendCmd [list axis name z $label]
+
+            if { [$_first hints zunits] == "" } {
+                set units [lindex $_fields($_curFldName) 1]
+            } else {
+                set units [$_first hints zunits]
+            }
+            if { $units != "" } {
+                # May be a space in the axis units.
+                SendCmd [list axis units z $units]
+            }
             # Get the new limits because the field changed.
             ResetAxes
@@ -1488,37 +1489,35 @@
             DrawLegend
         }
-        "heightmapScale" {
-	    if { $_settings(isHeightmap) } {
-		set scale [GetHeightmapScale]
-                # Have to set the datasets individually because we are 
+        "-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(isHeightmap)
+                    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
+                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)
-            }
-            AdjustSetting lighting
-            AdjustSetting opacity
-            AdjustSetting outline
+                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 
+            # Have to set the datasets individually because we are
             # tracking them in _comp2scale.
             foreach dataset [CurrentDatasets -all] {
@@ -1526,26 +1525,26 @@
                 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)} {
+            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
+            } 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 {$_settings(-stretchtofit)} {
                 if {$scale == 0} {
                     SendCmd "camera aspect window"
@@ -1556,7 +1555,7 @@
             ResetAxes
             if { $bool } {
-                set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
+                set q [ViewToQuaternion]
                 $_arcball quaternion $q
-                SendCmd "camera orient $q" 
+                SendCmd "camera orient $q"
             } else {
                 bind $c <ButtonPress-1> {}
@@ -1565,5 +1564,5 @@
             }
             Zoom reset
-            # Fix the mouse bindings for rotation/panning and the 
+            # Fix the mouse bindings for rotation/panning and the
             # camera mode. Ideally we'd create a bindtag for these.
             if { $bool } {
@@ -1578,48 +1577,48 @@
             StopBufferingCommands
         }
-        "isolineColor" {
+        "-isolinecolor" {
             set color [$itk_component(isolinecolor) value]
-	    if { $color == "none" } {
-		if { $_settings(isolinesVisible) } {
-		    SendCmd "heightmap isolines 0"
-		    set _settings(isolinesVisible) 0
-		}
-	    } else {
-		if { !$_settings(isolinesVisible) } {
-		    SendCmd "heightmap isolines 1"
-		    set _settings(isolinesVisible) 1
-		}
-		SendCmd "heightmap isolinecolor [Color2RGB $color]"
-	    }
-	    DrawLegend
-        }
-        "isolinesVisible" {
-	    set bool $_settings($what)
+            if { $color == "none" } {
+                if { $_settings(-isolinesvisible) } {
+                    SendCmd "heightmap isolines 0"
+                    set _settings(-isolinesvisible) 0
+                }
+            } else {
+                if { !$_settings(-isolinesvisible) } {
+                    SendCmd "heightmap isolines 1"
+                    set _settings(-isolinesvisible) 1
+                }
+                SendCmd "heightmap isolinecolor [Color2RGB $color]"
+            }
+            DrawLegend
+        }
+        "-isolinesvisible" {
+            set bool $_settings($what)
             SendCmd "heightmap isolines $bool"
-	    DrawLegend
-        }
-        "legendVisible" {
+            DrawLegend
+        }
+        "-legendvisible" {
             if { !$_settings($what) } {
-		$itk_component(view) delete legend
-	    }
-	    DrawLegend
-        }
-        "lighting" {
-	    if { $_settings(isHeightmap) } {
-                set _settings(saveLighting) $_settings(lighting)
-		set bool $_settings($what)
-		SendCmd "heightmap lighting $bool"
-	    } else {
-		SendCmd "heightmap lighting 0"
-	    }
-        }
-        "numIsolines" {
-            set _settings(numIsolines) [$itk_component(numisolines) value]
-            set _currentNumIsolines $_settings(numIsolines)
+                $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(numIsolines) 1
+            set _changed($what) 1
             SendCmd "heightmap contourlist [list $_contourList]"
-            if {$_settings(colormapDiscrete)} {
-                set numColors [expr $_settings(numIsolines) + 1]
+            if {$_settings(-colormapdiscrete)} {
+                set numColors [expr $_settings($what) + 1]
                 SendCmd "colormap res $numColors"
                 EventuallyRequestLegend
@@ -1628,43 +1627,47 @@
             }
         }
-        "opacity" {
-            set _changed(opacity) 1
-	    if { $_settings(isHeightmap) } {
-                set _settings(saveOpacity) $_settings(opacity)
-                set val $_settings(opacity)
-                set sval [expr { 0.01 * double($val) }]
-                SendCmd "heightmap opacity $sval"
+        "-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"
-            }
-        }
-        "outline" {
-	    if { $_settings(isHeightmap) } {
-		SendCmd "outline visible 0"
+                SendCmd "heightmap opacity 1.0"
+            }
+        }
+        "-outline" {
+            if { $_settings(-isheightmap) } {
+                SendCmd "outline visible 0"
             } else {
-                set _settings(saveOutline) $_settings(outline)
-                set bool $_settings(outline)
+                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"
-	    }
+        }
+        "-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" {
+        }
+        "-wireframe" {
             set bool $_settings($what)
             SendCmd "heightmap wireframe $bool"
         }
-	default {
+        "-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"
         }
@@ -1676,12 +1679,12 @@
 #
 #       Request a new legend from the server.  The size of the legend
-#       is determined from the height of the canvas.  
+#       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).
+#        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 {} {
@@ -1690,5 +1693,5 @@
     set w 12
     set lineht [font metrics $font -linespace]
-    # color ramp height = (canvas height) - (min and max value lines) - 2 
+    # color ramp height = (canvas height) - (min and max value lines) - 2
     set h [expr {$_height - 2 * ($lineht + 2)}]
     set _legendHeight $h
@@ -1696,18 +1699,18 @@
     set fname $_curFldName
     if { [string match "component*" $fname] } {
-	set title ""
+        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 { [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, substract one more line
     if { $title != "" } {
-        incr h -$lineht 
+        incr h -$lineht
     }
     if { $h < 1 } {
@@ -1716,6 +1719,7 @@
     # Set the legend on the first heightmap dataset.
     if { $_currentColormap != ""  } {
-	set cmap $_currentColormap
-	SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
+        set cmap $_currentColormap
+        #SendCmd "legend $cmap scalar $_curFldName {} $w $h 0"
+        SendCmd "legend2 $cmap $w $h"
     }
 }
@@ -1770,5 +1774,5 @@
     # Keep track of the colormaps that we build.
     if { $name != "none" && ![info exists _colormaps($name)] } {
-        BuildColormap $name 
+        BuildColormap $name
         set _colormaps($name) 1
     }
@@ -1776,5 +1780,4 @@
     SendCmd "heightmap colormap $_currentColormap"
 }
-
 
 #
@@ -1797,16 +1800,16 @@
 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)\""
-	}
+        "heightmap" {
+            set _settings(-isheightmap) 1
+        }
+        "contour" {
+            set _settings(-isheightmap) 0
+        }
+        default {
+            error "unknown mode settings \"$itk_option(-mode)\""
+        }
     }
     if { !$_reset } {
-        AdjustSetting isHeightmap
+        AdjustSetting -isheightmap
     }
 }
@@ -1821,5 +1824,5 @@
             SendCmd "screen bgcolor $rgb"
         }
-	$itk_component(view) configure -background $itk_option(-plotbackground)
+        $itk_component(view) configure -background $itk_option(-plotbackground)
     }
 }
@@ -1832,18 +1835,8 @@
         set rgb [Color2RGB $itk_option(-plotforeground)]
         if { !$_reset } {
+            SendCmd "axis color all $rgb"
             SendCmd "outline color $rgb"
-            SendCmd "axis color all $rgb"
-        }
-    }
-}
-
-itcl::body Rappture::VtkHeightmapViewer::limits3 { dataobj } {
-    lappend limits x [$dataobj limits x]
-    lappend limits y [$dataobj limits y] 
-    if { [catch { $dataobj limits $_curFldName } vlim] != 0 } {
-        set vlim [$dataobj limits v] 
-    }
-    lappend limits v $vlim
-    return $limits
+        }
+    }
 }
 
@@ -1860,27 +1853,27 @@
     checkbutton $inner.legend \
         -text "Legend" \
-        -variable [itcl::scope _settings(legendVisible)] \
-        -command [itcl::code $this AdjustSetting legendVisible] \
+        -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] \
+        -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"
+        checkbutton $inner.lighting \
+            -text "Enable Lighting" \
+            -variable [itcl::scope _settings(-lighting)] \
+            -command [itcl::code $this AdjustSetting -lighting] \
+            -font "Arial 9"
     } {
-	ignore -font
+        ignore -font
     }
     checkbutton $inner.edges \
         -text "Edges" \
-        -variable [itcl::scope _settings(edges)] \
-        -command [itcl::code $this AdjustSetting edges] \
+        -variable [itcl::scope _settings(-edges)] \
+        -command [itcl::code $this AdjustSetting -edges] \
         -font "Arial 9"
 
@@ -1888,6 +1881,6 @@
         checkbutton $inner.outline \
             -text "Outline" \
-            -variable [itcl::scope _settings(outline)] \
-            -command [itcl::code $this AdjustSetting outline] \
+            -variable [itcl::scope _settings(-outline)] \
+            -command [itcl::code $this AdjustSetting -outline] \
             -font "Arial 9"
     } {
@@ -1896,22 +1889,22 @@
     checkbutton $inner.stretch \
         -text "Stretch to fit" \
-        -variable [itcl::scope _settings(stretchToFit)] \
-        -command [itcl::code $this AdjustSetting stretchToFit] \
+        -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] \
+        -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] \
+        -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" 
+        label $inner.field_l -text "Field" -font "Arial 9"
     } {
         ignore -font
@@ -1921,34 +1914,16 @@
     }
     bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting field]
-
-    label $inner.colormap_l -text "Colormap" -font "Arial 9" 
+        [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 no
     }
-    $inner.colormap choices insert end \
-        "BCGYR"              "BCGYR"            \
-        "BGYOR"              "BGYOR"            \
-        "blue"               "blue"             \
-        "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"            \
-        "brown-to-blue"      "brown-to-blue"    \
-        "grey-to-blue"       "grey-to-blue"     \
-        "orange-to-blue"     "orange-to-blue"   \
-	"none"		     "none"
-
-    $itk_component(colormap) value "BCGYR"
+    $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" 
+        [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 no
@@ -1964,11 +1939,11 @@
         "red"                "red"              \
         "white"              "white"            \
-	"none"		     "none"
-
-    $itk_component(isolinecolor) value "black"
+        "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" 
+        [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 no
@@ -1977,8 +1952,9 @@
         "black"              "black"            \
         "white"              "white"            \
-        "grey"               "grey"             
+        "grey"               "grey"
 
     $itk_component(background) value "white"
-    bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
+    bind $inner.background <<Value>> \
+        [itcl::code $this AdjustSetting -background]
 
     itk_component add opacity_l {
@@ -1989,7 +1965,7 @@
     itk_component add opacity {
         ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-            -variable [itcl::scope _settings(opacity)] \
+            -variable [itcl::scope _settings(-opacity)] \
             -showvalue off \
-            -command [itcl::code $this AdjustSetting opacity]
+            -command [itcl::code $this AdjustSetting -opacity]
     }
     itk_component add scale_l {
@@ -2000,7 +1976,7 @@
     itk_component add scale {
         ::scale $inner.scale -from 0 -to 100 -orient horizontal \
-            -variable [itcl::scope _settings(heightmapScale)] \
+            -variable [itcl::scope _settings(-heightmapscale)] \
             -showvalue off \
-            -command [itcl::code $this AdjustSetting heightmapScale]
+            -command [itcl::code $this AdjustSetting -heightmapscale]
     }
     label $inner.numisolines_l -text "Number of Isolines" -font "Arial 9"
@@ -2009,7 +1985,7 @@
             -min 0 -max 50 -font "arial 9"
     }
-    $itk_component(numisolines) value $_settings(numIsolines)
+    $itk_component(numisolines) value $_settings(-numisolines)
     bind $itk_component(numisolines) <<Value>> \
-        [itcl::code $this AdjustSetting numIsolines]
+        [itcl::code $this AdjustSetting -numisolines]
 
     frame $inner.separator1 -height 2 -relief sunken -bd 1
@@ -2023,6 +1999,6 @@
         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 \
+        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 \
@@ -2058,36 +2034,35 @@
     checkbutton $inner.visible \
         -text "Axes" \
-        -variable [itcl::scope _settings(axisVisible)] \
-        -command [itcl::code $this AdjustSetting axisVisible] \
+        -variable [itcl::scope _settings(-axisvisible)] \
+        -command [itcl::code $this AdjustSetting -axisvisible] \
         -font "Arial 9"
     checkbutton $inner.labels \
         -text "Axis Labels" \
-        -variable [itcl::scope _settings(axisLabels)] \
-        -command [itcl::code $this AdjustSetting axisLabels] \
+        -variable [itcl::scope _settings(-axislabels)] \
+        -command [itcl::code $this AdjustSetting -axislabels] \
         -font "Arial 9"
-    label $inner.grid_l -text "Grid" -font "Arial 9" 
+    label $inner.grid_l -text "Grid" -font "Arial 9"
     checkbutton $inner.xgrid \
         -text "X" \
-        -variable [itcl::scope _settings(axisXGrid)] \
-        -command [itcl::code $this AdjustSetting axisXGrid] \
+        -variable [itcl::scope _settings(-xgrid)] \
+        -command [itcl::code $this AdjustSetting -xgrid] \
         -font "Arial 9"
     checkbutton $inner.ygrid \
         -text "Y" \
-        -variable [itcl::scope _settings(axisYGrid)] \
-        -command [itcl::code $this AdjustSetting axisYGrid] \
+        -variable [itcl::scope _settings(-ygrid)] \
+        -command [itcl::code $this AdjustSetting -ygrid] \
         -font "Arial 9"
     checkbutton $inner.zgrid \
         -text "Z" \
-        -variable [itcl::scope _settings(axisZGrid)] \
-        -command [itcl::code $this AdjustSetting axisZGrid] \
+        -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] \
+        -variable [itcl::scope _settings(-axisminorticks)] \
+        -command [itcl::code $this AdjustSetting -axisminorticks] \
         -font "Arial 9"
 
-
-    label $inner.mode_l -text "Mode" -font "Arial 9" 
+    label $inner.mode_l -text "Mode" -font "Arial 9"
 
     itk_component add axisflymode {
@@ -2098,7 +2073,7 @@
         "closest_triad"   "closest" \
         "furthest_triad"  "farthest" \
-        "outer_edges"     "outer"         
-    $itk_component(axisflymode) value "static"
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlymode]
+        "outer_edges"     "outer"
+    $itk_component(axisflymode) value $_settings(-axisflymode)
+    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axisflymode]
 
     blt::table $inner \
@@ -2106,10 +2081,10 @@
         1,0 $inner.labels  -anchor w -cspan 4 \
         2,0 $inner.minorticks  -anchor w -cspan 4 \
-	4,0 $inner.grid_l  -anchor w \
+        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 
+        5,1 $inner.mode    -fill x -cspan 3
 
     blt::table configure $inner r* c* -resize none
@@ -2117,5 +2092,4 @@
     blt::table configure $inner r3 -height 0.125i
 }
-
 
 itcl::body Rappture::VtkHeightmapViewer::BuildCameraTab {} {
@@ -2137,4 +2111,5 @@
         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 }
@@ -2143,9 +2118,9 @@
         label $inner.${tag}label -text $tag -font "Arial 9"
         entry $inner.${tag} -font "Arial 9"  -bg white \
-            -textvariable [itcl::scope _view($tag)]
+            -textvariable [itcl::scope _view(-$tag)]
         bind $inner.${tag} <Return> \
-            [itcl::code $this camera set ${tag}]
+            [itcl::code $this camera set -${tag}]
         bind $inner.${tag} <KP_Enter> \
-            [itcl::code $this camera set ${tag}]
+            [itcl::code $this camera set -${tag}]
         blt::table $inner \
             $row,0 $inner.${tag}label -anchor e -pady 2 \
@@ -2156,6 +2131,6 @@
     checkbutton $inner.ortho \
         -text "Orthographic Projection" \
-        -variable [itcl::scope _view(ortho)] \
-        -command [itcl::code $this camera set ortho] \
+        -variable [itcl::scope _view(-ortho)] \
+        -command [itcl::code $this camera set -ortho] \
         -font "Arial 9"
     blt::table $inner \
@@ -2164,5 +2139,5 @@
     incr row
 
-    blt::table configure $inner c* r* -resize none
+    blt::table configure $inner c* -resize none
     blt::table configure $inner c2 -resize expand
     blt::table configure $inner r$row -resize expand
@@ -2170,21 +2145,21 @@
 
 #
-#  camera -- 
+#  camera --
 #
 itcl::body Rappture::VtkHeightmapViewer::camera {option args} {
-    switch -- $option { 
+    switch -- $option {
         "show" {
             puts [array get _view]
         }
         "set" {
-            set who [lindex $args 0]
-            set x $_view($who)
+            set what [lindex $args 0]
+            set x $_view($what)
             set code [catch { string is double $x } result]
             if { $code != 0 || !$result } {
                 return
             }
-            switch -- $who {
-                "ortho" {
-                    if {$_view(ortho)} {
+            switch -- $what {
+                "-ortho" {
+                    if {$_view($what)} {
                         SendCmd "camera mode ortho"
                     } else {
@@ -2192,14 +2167,14 @@
                     }
                 }
-                "xpan" - "ypan" {
+                "-xpan" - "-ypan" {
                     PanCamera
                 }
-                "qx" - "qy" - "qz" - "qw" {
-                    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
+                "-qx" - "-qy" - "-qz" - "-qw" {
+                    set q [ViewToQuaternion]
                     $_arcball quaternion $q
                     EventuallyRotate $q
                 }
-                "zoom" {
-                    SendCmd "camera zoom $_view(zoom)"
+                "-zoom" {
+                    SendCmd "camera zoom $_view($what)"
                 }
             }
@@ -2221,5 +2196,5 @@
 
 itcl::body Rappture::VtkHeightmapViewer::GetImage { args } {
-    if { [image width $_image(download)] > 0 && 
+    if { [image width $_image(download)] > 0 &&
          [image height $_image(download)] > 0 } {
         set bytes [$_image(download) data -format "jpeg -quality 100"]
@@ -2234,14 +2209,14 @@
         -title "[Rappture::filexfer::label downloadWord] as..."
     set inner [$popup component inner]
-    label $inner.summary -text "" -anchor w 
+    label $inner.summary -text "" -anchor w
     radiobutton $inner.vtk_button -text "VTK data file" \
         -variable [itcl::scope _downloadPopup(format)] \
         -font "Arial 9 " \
-        -value vtk  
+        -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 
+        -value image
     Rappture::Tooltip::for $inner.image_button \
         "Save as digital image."
@@ -2264,5 +2239,5 @@
         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 
+        4,0 $inner.ok -padx 2 -width .9i -fill y
     blt::table configure $inner r3 -height 4
     blt::table configure $inner r4 -pady 4
@@ -2275,5 +2250,5 @@
 # SetObjectStyle --
 #
-#       Set the style of the heightmap/contour object.  This gets calls 
+#       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.
@@ -2285,6 +2260,6 @@
     array set style {
         -color BCGYR
-        -opacity 100
         -levels 10
+        -opacity 1.0
     }
     set stylelist [$dataobj style $comp]
@@ -2301,12 +2276,12 @@
     # the code to handle aberrant cases.
 
-    if { $_changed(opacity) } {
-        set style(-opacity) $_settings(opacity)
-    }
-    if { $_changed(numIsolines) } {
-        set style(-levels) $_settings(numIsolines)
-    }
-    if { $_changed(colormap) } {
-        set style(-color) $_settings(colormap)
+    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 == "" } {
@@ -2314,11 +2289,10 @@
     }
     if { [info exists style(-stretchtofit)] } {
-        set _settings(stretchToFit) $style(-stretchtofit)
-        AdjustSetting stretchToFit
-    }
-    set _currentOpacity $style(-opacity)
+        set _settings(-stretchtofit) $style(-stretchtofit)
+        AdjustSetting -stretchtofit
+    }
     if { $_currentNumIsolines != $style(-levels) } {
         set _currentNumIsolines $style(-levels)
-        set _settings(numIsolines) $_currentNumIsolines
+        set _settings(-numisolines) $_currentNumIsolines
         $itk_component(numisolines) value $_currentNumIsolines
         UpdateContourList
@@ -2327,16 +2301,18 @@
     SendCmd "outline add $tag"
     SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
-    SendCmd "outline visible $_settings(outline) $tag"
+    SendCmd "outline visible $_settings(-outline) $tag"
     set scale [GetHeightmapScale]
     SendCmd "[list heightmap add contourlist $_contourList $scale $tag]"
-    set _comp2scale($tag) $_settings(heightmapScale)
-    SendCmd "heightmap edges $_settings(edges) $tag"
-    SendCmd "heightmap wireframe $_settings(wireframe) $tag"
-    SetCurrentColormap $style(-color) 
+    set _comp2scale($tag) $_settings(-heightmapscale)
+    SendCmd "heightmap edges $_settings(-edges) $tag"
+    SendCmd "heightmap wireframe $_settings(-wireframe) $tag"
+    SetCurrentColormap $style(-color)
     set color [$itk_component(isolinecolor) value]
     SendCmd "heightmap isolinecolor [Color2RGB $color] $tag"
-    SendCmd "heightmap lighting $_settings(isHeightmap) $tag"
-    SendCmd "heightmap isolines $_settings(isolinesVisible) $tag"
-    SendCmd "heightmap surface $_settings(colormapVisible) $tag"
+    SendCmd "heightmap lighting $_settings(-isheightmap) $tag"
+    SendCmd "heightmap isolines $_settings(-isolinesvisible) $tag"
+    SendCmd "heightmap surface $_settings(-colormapvisible) $tag"
+    SendCmd "heightmap opacity $style(-opacity) $tag"
+    set _settings(-opacity) [expr $style(-opacity) * 100.0]
 }
 
@@ -2365,6 +2341,6 @@
         #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"
+            global errorInfo
+            puts stderr "errs=$errs errorInfo=$errorInfo"
         }
     }
@@ -2383,46 +2359,49 @@
     set font "Arial 8"
     set lineht [font metrics $font -linespace]
-    
+
     if { [string match "component*" $fname] } {
-	set title ""
+        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 { [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 { !$_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.
+        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 
-	$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]
+            -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
@@ -2435,6 +2414,6 @@
     # Draw the isolines on the legend.
     array unset _isolines
-    if { $color != "none"  && [info exists _limits($_curFldName)] && 
-         $_settings(isolinesVisible) && $_currentNumIsolines > 0 } {
+    if { $color != "none"  && [info exists _limits($_curFldName)] &&
+         $_settings(-isolinesvisible) && $_currentNumIsolines > 0 } {
 
         foreach { vmin vmax } $_limits($_curFldName) break
@@ -2444,8 +2423,8 @@
         }
         set tags "isoline legend"
-	set offset [expr 2 + $lineht]
-	if { $title != "" } {
-	    incr offset $lineht
-	}
+        set offset [expr 2 + $lineht]
+        if { $title != "" } {
+            incr offset $lineht
+        }
         foreach value $_contourList {
             set norm [expr 1.0 - (($value - $vmin) / $range)]
@@ -2455,6 +2434,6 @@
                 set _isolines([expr $y1 - $off]) $value
             }
-	    $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
-	}
+            $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
+        }
     }
 
@@ -2465,6 +2444,6 @@
     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]
+        $c itemconfigure vmin -text [format %g $vmin]
+        $c itemconfigure vmax -text [format %g $vmax]
     }
     set y 2
@@ -2472,6 +2451,6 @@
     if { $title != "" } {
         $c itemconfigure title -text $title
-	$c coords title $x $y
-	incr y $lineht
+        $c coords title $x $y
+        incr y $lineht
     }
     $c coords vmax $x $y
@@ -2521,5 +2500,5 @@
     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
@@ -2527,14 +2506,14 @@
 
     if { [string match "component*" $fname] } {
-	set title ""
+        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 { [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.
@@ -2552,6 +2531,6 @@
     }
     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 
+    $_image(swatch) put black  -to 0 0 23 23
+    $_image(swatch) put $color -to 1 1 22 22
 
     # Compute the value of the point
@@ -2563,5 +2542,5 @@
         set value 0.0
     }
-    set tipx [expr $x + 15] 
+    set tipx [expr $x + 15]
     set tipy [expr $y - 5]
     .rappturetooltip configure -icon $_image(swatch)
@@ -2571,5 +2550,5 @@
         Rappture::Tooltip::text $c [format "$title %g" $value]
     }
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy    
+    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy
 }
 
@@ -2586,5 +2565,5 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::VtkHeightmapViewer::Combo {option} {
-    set c $itk_component(view) 
+    set c $itk_component(view)
     switch -- $option {
         post {
@@ -2599,9 +2578,9 @@
         }
         deactivate {
-            $c itemconfigure title -fill $itk_option(-plotforeground) 
+            $c itemconfigure title -fill $itk_option(-plotforeground)
         }
         invoke {
             $itk_component(field) value $_curFldLabel
-            AdjustSetting field
+            AdjustSetting -field
         }
         default {
@@ -2612,13 +2591,13 @@
 
 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 } { 
+    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"
@@ -2629,17 +2608,17 @@
         bottom "0 1 0 0"
     }
-    foreach name { qw qx qy qz } value $positions($side) {
+    foreach name { -qw -qx -qy -qz } value $positions($side) {
         set _view($name) $value
-    } 
-    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
+    }
+    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 {} { 
+    set _view(-xpan) 0
+    set _view(-ypan) 0
+    set _view(-zoom) 1.0
+}
+
+itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} {
     if {$_currentNumIsolines == 0} {
         set _contourList ""
