Index: branches/1.3/gui/scripts/vtkmeshviewer.tcl
===================================================================
--- branches/1.3/gui/scripts/vtkmeshviewer.tcl	(revision 4504)
+++ branches/1.3/gui/scripts/vtkmeshviewer.tcl	(revision 4507)
@@ -92,5 +92,4 @@
     private method PanCamera {}
     private method SetObjectStyle { dataobj } 
-    private method SetOpacity { dataset }
     private method SetOrientation { side }
     private method SetPolydataOpacity {}
@@ -114,13 +113,12 @@
     private variable _style;            # Array of current component styles.
     private variable _initialStyle;     # Array of initial component styles.
-    private variable _axis
     private variable _reset 1;          # Indicates that server was reset and
                                         # needs to be reinitialized.
 
-    private variable _first ""     ;# This is the topmost dataset.
+    private variable _first "";         # This is the topmost dataset.
     private variable _start 0
     private variable _title ""
 
-    common _downloadPopup          ;# download options from popup
+    common _downloadPopup;              # download options from popup
     private common _hardcopy
     private variable _width 0
@@ -184,28 +182,26 @@
     set _limits(zmax) 1.0
 
-    array set _axis [subst {
-        xgrid           0
-        ygrid           0
-        zgrid           0
-        xcutaway        0
-        ycutaway        0
-        zcutaway        0
-        xposition       0
-        yposition       0
-        zposition       0
-        xdirection      -1
-        ydirection      -1
-        zdirection      -1
-        visible         1
-        labels          1
-    }]
-    array set _settings [subst {
-        outline                 0
-        polydata-edges          0
-        polydata-lighting       1
-        polydata-opacity        100
-        polydata-visible        1
-        polydata-wireframe      0
-    }]
+    array set _settings {
+        -axesvisible            1
+        -axislabels             1
+        -outline                0
+        -polydataedges          0
+        -polydatalighting       1
+        -polydataopacity        100
+        -polydatavisible        1
+        -polydatawireframe      0
+        -xcutaway               0
+        -xdirection             -1
+        -xgrid                  0
+        -xposition              0
+        -ycutaway               0
+        -ydirection             -1
+        -ygrid                  0
+        -yposition              0
+        -zcutaway               0
+        -zdirection             -1
+        -zgrid                  0
+        -zposition              0
+    }
     itk_component add view {
         canvas $itk_component(plotarea).view \
@@ -407,10 +403,11 @@
 itcl::body Rappture::VtkMeshViewer::SetPolydataOpacity {} {
     set _polydataOpacityPending 0
-    foreach dataset [CurrentDatasets -visible $_first] {
-        SetOpacity $dataset
-    }
-}
-
-itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity { args } {
+    set val $_settings(-polydataopacity)
+    set sval [expr { 0.01 * double($val) }]
+    SendCmd "polydata opacity $sval"
+}
+
+itcl::body Rappture::VtkMeshViewer::EventuallySetPolydataOpacity { val } {
+    set _settings(-polydataopacity) $val
     if { !$_polydataOpacityPending } {
         set _polydataOpacityPending 1
@@ -478,5 +475,4 @@
         set _dlist [lreplace $_dlist $pos $pos]
         array unset _obj2ovride $dataobj-*
-        array unset _settings $dataobj-*
         set changed 1
     }
@@ -832,7 +828,5 @@
         $_arcball resize $w $h
         DoResize
-        InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
-            axis-visible axis-labels
- 
+        InitSettings -xgrid -ygrid -zgrid -axismode -axesvisible -axislabels
         StopBufferingCommands
         SendCmd "imgflush"
@@ -874,5 +868,6 @@
         }
         lappend _obj2datasets($dataobj) $tag
-        if { [info exists _obj2ovride($dataobj-raise)] } {
+        if { [info exists _obj2ovride($dataobj-raise)] && 
+             $_obj2ovride($dataobj-raise) } {
             SendCmd "dataset visible 1 $tag"
             SetOpacity $tag
@@ -896,9 +891,9 @@
         }
     }
-    InitSettings outline
+    InitSettings -outline
     if { $_reset } {
         # These are settings that rely on a dataset being loaded.
-        InitSettings polydata-edges polydata-lighting polydata-opacity \
-            polydata-visible polydata-wireframe
+        InitSettings -polydataedges -polydatalighting -polydataopacity \
+            -polydatavisible -polydatawireframe
  
         set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
@@ -1152,70 +1147,65 @@
     }
     switch -- $what {
-        "outline" {
-            set bool $_settings(outline)
-            foreach dataset [CurrentDatasets -visible $_first] {
+        "-outline" {
+            set bool $_settings($what)
+            # Only display a outline for the currently visible sets.
+            SendCmd "outline visible 0"
+            foreach dataset [CurrentDatasets -visible] {
                 SendCmd "outline visible $bool $dataset"
             }
         }
-        "polydata-opacity" {
-            foreach dataset [CurrentDatasets -visible $_first] {
-                SetOpacity $dataset
-            }
-        }
-        "polydata-wireframe" {
-            set bool $_settings(polydata-wireframe)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                SendCmd "polydata wireframe $bool $dataset"
-            }
-        }
-        "polydata-visible" {
-            set bool $_settings(polydata-visible)
-            foreach dataset [CurrentDatasets -visible $_first] {
+        "-polydataopacity" {
+            EventuallySetPolydataOpacity
+        }
+        "-polydatawireframe" {
+            set bool $_settings($what)
+            SendCmd "polydata wireframe $bool"
+        }
+        "-polydatavisible" {
+            set bool $_settings($what)
+            # Only change visibility of data sets marked "visible".
+            foreach dataset [CurrentDatasets -visible] {
                 SendCmd "polydata visible $bool $dataset"
             }
         }
-        "polydata-lighting" {
-            set bool $_settings(polydata-lighting)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                SendCmd "polydata lighting $bool $dataset"
-            }
-        }
-        "polydata-edges" {
-            set bool $_settings(polydata-edges)
-            foreach dataset [CurrentDatasets -visible $_first] {
-                SendCmd "polydata edges $bool $dataset"
-            }
-        }
-        "axis-visible" {
-            set bool $_axis(visible)
+        "-polydatalighting" {
+            set bool $_settings($what)
+            SendCmd "polydata lighting $bool"
+        }
+        "-polydataedges" {
+            set bool $_settings($what)
+            SendCmd "polydata edges $bool"
+        }
+        "-axesvisible" {
+            set bool $_settings($what)
             SendCmd "axis visible all $bool"
         }
-        "axis-labels" {
-            set bool $_axis(labels)
+        "-axislabels" {
+            set bool $_settings($what)
             SendCmd "axis labels all $bool"
         }
-        "axis-xgrid" {
-            set bool $_axis(xgrid)
+        "-xgrid" {
+            set bool $_settings($what)
             SendCmd "axis grid x $bool"
         }
-        "axis-ygrid" {
-            set bool $_axis(ygrid)
+        "-ygrid" {
+            set bool $_settings($what)
             SendCmd "axis grid y $bool"
         }
-        "axis-zgrid" {
-            set bool $_axis(zgrid)
+        "-zgrid" {
+            set bool $_settings($what)
             SendCmd "axis grid z $bool"
         }
-        "axis-mode" {
+        "-axismode" {
             set mode [$itk_component(axismode) value]
             set mode [$itk_component(axismode) translate $mode]
             SendCmd "axis flymode $mode"
         }
-        "axis-xcutaway" - "axis-ycutaway" - "axis-zcutaway" {
-            set axis [string range $what 5 5]
-            set bool $_axis(${axis}cutaway)
+        "-xcutaway" - "-ycutaway" - "-zcutaway" {
+            set axis [string range $what 1 1]
+            set bool $_settings($what)
             if { $bool } {
-                set pos [expr $_axis(${axis}position) * 0.01]
-                set dir $_axis(${axis}direction)
+                set pos [expr $_settings(-${axis}position) * 0.01]
+                set dir $_settings(-${axis}direction)
                 $itk_component(${axis}CutScale) configure -state normal \
                     -troughcolor white
@@ -1227,10 +1217,12 @@
             }
         }
-        "axis-xposition" - "axis-yposition" - "axis-zposition" - 
-        "axis-xdirection" - "axis-ydirection" - "axis-zdirection" {
-            set axis [string range $what 5 5]
-            #set dir $_axis(${axis}direction)
-            set pos [expr $_axis(${axis}position) * 0.01]
+        "-xposition" - "-yposition" - "-zposition" {
+            set axis [string range $what 1 1]
+            set pos [expr $_settings($what) * 0.01]
             SendCmd "renderer clipplane ${axis} $pos -1"
+        }
+        "-xdirection" - "-ydirection" - "-zdirection" {
+            set axis [string range $what 1 1]
+            puts stderr "direction not implemented"
         }
         default {
@@ -1317,30 +1309,30 @@
     checkbutton $inner.mesh \
         -text "Show Mesh" \
-        -variable [itcl::scope _settings(polydata-visible)] \
-        -command [itcl::code $this AdjustSetting polydata-visible] \
+        -variable [itcl::scope _settings(-polydatavisible)] \
+        -command [itcl::code $this AdjustSetting -polydatavisible] \
         -font "Arial 9" -anchor w 
 
     checkbutton $inner.outline \
         -text "Show Outline" \
-        -variable [itcl::scope _settings(outline)] \
-        -command [itcl::code $this AdjustSetting outline] \
+        -variable [itcl::scope _settings(-outline)] \
+        -command [itcl::code $this AdjustSetting -outline] \
         -font "Arial 9" -anchor w 
 
     checkbutton $inner.wireframe \
         -text "Show Wireframe" \
-        -variable [itcl::scope _settings(polydata-wireframe)] \
-        -command [itcl::code $this AdjustSetting polydata-wireframe] \
+        -variable [itcl::scope _settings(-polydatawireframe)] \
+        -command [itcl::code $this AdjustSetting -polydatawireframe] \
         -font "Arial 9" -anchor w 
 
     checkbutton $inner.lighting \
         -text "Enable Lighting" \
-        -variable [itcl::scope _settings(polydata-lighting)] \
-        -command [itcl::code $this AdjustSetting polydata-lighting] \
+        -variable [itcl::scope _settings(-polydatalighting)] \
+        -command [itcl::code $this AdjustSetting -polydatalighting] \
         -font "Arial 9" -anchor w
 
     checkbutton $inner.edges \
         -text "Show Edges" \
-        -variable [itcl::scope _settings(polydata-edges)] \
-        -command [itcl::code $this AdjustSetting polydata-edges] \
+        -variable [itcl::scope _settings(-polydataedges)] \
+        -command [itcl::code $this AdjustSetting -polydataedges] \
         -font "Arial 9" -anchor w
 
@@ -1354,13 +1346,13 @@
     }
     bind $inner.field <<Value>> \
-        [itcl::code $this AdjustSetting field]
+        [itcl::code $this AdjustSetting -field]
 
     label $inner.opacity_l -text "Opacity" -font "Arial 9" -anchor w 
     ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
-        -variable [itcl::scope _settings(polydata-opacity)] \
+        -variable [itcl::scope _settings(-polydataopacity)] \
         -width 10 \
         -showvalue off \
-        -command [itcl::code $this AdjustSetting polydata-opacity]
-    $inner.opacity set $_settings(polydata-opacity)
+        -command [itcl::code $this AdjustSetting -polydataopacity]
+    $inner.opacity set $_settings(-polydataopacity)
 
     blt::table $inner \
@@ -1389,28 +1381,28 @@
     checkbutton $inner.visible \
         -text "Show Axes" \
-        -variable [itcl::scope _axis(visible)] \
-        -command [itcl::code $this AdjustSetting axis-visible] \
+        -variable [itcl::scope _settings(-axesvisible)] \
+        -command [itcl::code $this AdjustSetting -axesvisible] \
         -font "Arial 9"
 
     checkbutton $inner.labels \
         -text "Show Axis Labels" \
-        -variable [itcl::scope _axis(labels)] \
-        -command [itcl::code $this AdjustSetting axis-labels] \
+        -variable [itcl::scope _settings(-axislabels)] \
+        -command [itcl::code $this AdjustSetting -axislabels] \
         -font "Arial 9"
 
     checkbutton $inner.gridx \
         -text "Show X Grid" \
-        -variable [itcl::scope _axis(xgrid)] \
-        -command [itcl::code $this AdjustSetting axis-xgrid] \
+        -variable [itcl::scope _settings(-xgrid)] \
+        -command [itcl::code $this AdjustSetting -xgrid] \
         -font "Arial 9"
     checkbutton $inner.gridy \
         -text "Show Y Grid" \
-        -variable [itcl::scope _axis(ygrid)] \
-        -command [itcl::code $this AdjustSetting axis-ygrid] \
+        -variable [itcl::scope _settings(-ygrid)] \
+        -command [itcl::code $this AdjustSetting -ygrid] \
         -font "Arial 9"
     checkbutton $inner.gridz \
         -text "Show Z Grid" \
-        -variable [itcl::scope _axis(zgrid)] \
-        -command [itcl::code $this AdjustSetting axis-zgrid] \
+        -variable [itcl::scope _settings(-zgrid)] \
+        -command [itcl::code $this AdjustSetting -zgrid] \
         -font "Arial 9"
 
@@ -1426,5 +1418,5 @@
         "outer_edges"     "outer"         
     $itk_component(axismode) value "static"
-    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]
+    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting -axismode]
 
     blt::table $inner \
@@ -1504,6 +1496,6 @@
             -onimage [Rappture::icon x-cutplane] \
             -offimage [Rappture::icon x-cutplane] \
-            -command [itcl::code $this AdjustSetting axis-xcutaway] \
-            -variable [itcl::scope _axis(xcutaway)]
+            -command [itcl::code $this AdjustSetting -xcutaway] \
+            -variable [itcl::scope _settings(-xcutaway)]
     }
     Rappture::Tooltip::for $itk_component(xCutButton) \
@@ -1515,5 +1507,5 @@
             -borderwidth 1 -highlightthickness 0 \
             -command [itcl::code $this Slice move x] \
-            -variable [itcl::scope _axis(xposition)]
+            -variable [itcl::scope _settings(-xposition)]
     } {
         usual
@@ -1532,8 +1524,8 @@
             -offimage [Rappture::icon arrow-up] \
             -offvalue 1 \
-            -command [itcl::code $this AdjustSetting axis-xdirection] \
-            -variable [itcl::scope _axis(xdirection)]
-    }
-    set _axis(xdirection) -1 
+            -command [itcl::code $this AdjustSetting -xdirection] \
+            -variable [itcl::scope _settings(-xdirection)]
+    }
+    set _settings(-xdirection) -1 
     Rappture::Tooltip::for $itk_component(xDirButton) \
         "Toggle the direction of the X-axis cutaway"
@@ -1544,6 +1536,6 @@
             -onimage [Rappture::icon y-cutplane] \
             -offimage [Rappture::icon y-cutplane] \
-            -command [itcl::code $this AdjustSetting axis-ycutaway] \
-            -variable [itcl::scope _axis(ycutaway)]
+            -command [itcl::code $this AdjustSetting -ycutaway] \
+            -variable [itcl::scope _settings(-ycutaway)]
     }
     Rappture::Tooltip::for $itk_component(yCutButton) \
@@ -1555,5 +1547,5 @@
             -borderwidth 1 -highlightthickness 0 \
             -command [itcl::code $this Slice move y] \
-            -variable [itcl::scope _axis(yposition)]
+            -variable [itcl::scope _settings(-yposition)]
     } {
         usual
@@ -1572,10 +1564,10 @@
             -offimage [Rappture::icon arrow-up] \
             -offvalue 1 \
-            -command [itcl::code $this AdjustSetting axis-ydirection] \
-            -variable [itcl::scope _axis(ydirection)]
+            -command [itcl::code $this AdjustSetting -ydirection] \
+            -variable [itcl::scope _settings(-ydirection)]
     }
     Rappture::Tooltip::for $itk_component(yDirButton) \
         "Toggle the direction of the Y-axis cutaway"
-    set _axis(ydirection) -1 
+    set _settings(-ydirection) -1 
 
     # Z-value slicer...
@@ -1584,6 +1576,6 @@
             -onimage [Rappture::icon z-cutplane] \
             -offimage [Rappture::icon z-cutplane] \
-            -command [itcl::code $this AdjustSetting axis-zcutaway] \
-            -variable [itcl::scope _axis(zcutaway)]
+            -command [itcl::code $this AdjustSetting -zcutaway] \
+            -variable [itcl::scope _settings(-zcutaway)]
     }
     Rappture::Tooltip::for $itk_component(zCutButton) \
@@ -1595,5 +1587,5 @@
             -borderwidth 1 -highlightthickness 0 \
             -command [itcl::code $this Slice move z] \
-            -variable [itcl::scope _axis(zposition)]
+            -variable [itcl::scope _settings(-zposition)]
     } {
         usual
@@ -1611,8 +1603,8 @@
             -offimage [Rappture::icon arrow-up] \
             -offvalue 1 \
-            -command [itcl::code $this AdjustSetting axis-zdirection] \
-            -variable [itcl::scope _axis(zdirection)]
-    }
-    set _axis(zdirection) -1 
+            -command [itcl::code $this AdjustSetting -zdirection] \
+            -variable [itcl::scope _settings(-zdirection)]
+    }
+    set _settings(-zdirection) -1 
     Rappture::Tooltip::for $itk_component(zDirButton) \
         "Toggle the direction of the Z-axis cutaway"
@@ -1736,5 +1728,5 @@
     set style [$dataobj hints style]
     if { $dataobj != $_first } {
-        set settings(-wireframe) 1
+        set settings(-polydatawireframe) 1
     }
 
@@ -1743,15 +1735,15 @@
         -color white
         -edgecolor black
-        -edges 1
         -lighting 1
         -linewidth 1.0
-        -opacity 1.0
         -outline 0
-        -visible 1
-        -wireframe 0
+        -polydataedges 1
+        -polydataopacity 1.0
+        -polydatavisible 1
+        -polydatawireframe 0
     }
     if {$type == "cloud"} {
         set settings(-cloudstyle) points
-        set settings(-edges) 0
+        set settings(-polydataedges) 0
         set settings(-edgecolor) white
     }
@@ -1763,22 +1755,22 @@
     SendCmd "outline color [Color2RGB $settings(-color)] $tag"
     SendCmd "outline visible $settings(-outline) $tag"
-    set _settings(outline) $settings(-outline)
+    set _settings(-outline) $settings(-outline)
 
     SendCmd "polydata add $tag"
-    SendCmd "polydata visible $settings(-visible) $tag"
+    SendCmd "polydata visible $settings(-polydatavisible) $tag"
     SendCmd "polydata cloudstyle $settings(-cloudstyle) $tag"
-    set _settings(polydata-visible) $settings(-visible)
-    SendCmd "polydata edges $settings(-edges) $tag"
-    set _settings(polydata-edges) $settings(-edges)
+    set _settings(-polydatavisible) $settings(-polydatavisible)
+    SendCmd "polydata edges $settings(-polydataedges) $tag"
+    set _settings(-polydataedges) $settings(-polydataedges)
     SendCmd "polydata color [Color2RGB $settings(-color)] $tag"
-    #SendCmd "polydata colormode constant {} $tag"
-    SendCmd "polydata lighting $settings(-lighting) $tag"
-    set _settings(polydata-lighting) $settings(-lighting)
+
+    SendCmd "polydata lighting $settings(-polydatalighting) $tag"
+    set _settings(-polydatalighting) $settings(-polydatalighting)
     SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag"
     SendCmd "polydata linewidth $settings(-linewidth) $tag"
-    SendCmd "polydata opacity $settings(-opacity) $tag"
-    set _settings(polydata-opacity) [expr 100.0 * $settings(-opacity)]
-    SendCmd "polydata wireframe $settings(-wireframe) $tag"
-    set _settings(polydata-wireframe) $settings(-wireframe)
+    SendCmd "polydata opacity $settings(-polydataopacity) $tag"
+    set _settings(-polydataopacity) [expr 100.0 * $settings(-polydataopacity)]
+    SendCmd "polydata wireframe $settings(-polydatawireframe) $tag"
+    set _settings(-polydatawireframe) $settings(-polydatawireframe)
     set havePolyData 1
 }
@@ -1842,11 +1834,2 @@
 }
 
-itcl::body Rappture::VtkMeshViewer::SetOpacity { dataset } { 
-    set val $_settings(polydata-opacity)
-    set sval [expr { 0.01 * double($val) }]
-    if { !$_obj2ovride($dataset-raise) } {
-        # This is wrong.  Need to figure out why raise isn't set with 1
-        #set sval [expr $sval * .6]
-    }
-    SendCmd "polydata opacity $sval $dataset"
-}
