Index: trunk/gui/scripts/nanovisviewer.tcl
===================================================================
--- trunk/gui/scripts/nanovisviewer.tcl	(revision 974)
+++ trunk/gui/scripts/nanovisviewer.tcl	(revision 975)
@@ -99,5 +99,5 @@
     # The following methods are only used by this class. 
     private method _DefineTransferFunction { ivol }
-    private method _AddIsoMarker { ivol x y }
+    private method _AddIsoMarker { x y }
     private method _InitIsoMarkers { ivol }
     private method _HideIsoMarkers { ivol }
@@ -126,5 +126,8 @@
     private variable _styles
     private common   _settings
-    private variable _currentVolId ""
+    private variable _activeVol "" ;# The currently active volume.  This 
+				    # indicates which isomarkers and transfer
+				    # function to use when changing markers,
+				    # opacity, or thickness.
 }
 
@@ -817,9 +820,8 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::NanovisViewer::_send_transfunc {} {
-    if { ![_DefineTransferFunction $_currentVolId] } {
+    if { ![_DefineTransferFunction $_activeVol] } {
 	return
     }
     _fixLegend
-    $_dispatcher event -idle !legend
 }
 
@@ -831,6 +833,9 @@
 # specified <size> will follow.
 # ----------------------------------------------------------------------
+set counter 0
 itcl::body Rappture::NanovisViewer::_ReceiveImage {option size} {
     if { [isconnected] } {
+	global counter
+	incr counter
         set bytes [ReceiveBytes $size]
         $_image(plot) configure -data $bytes
@@ -864,6 +869,6 @@
                  -fill $itk_option(-plotforeground) -tags vmax
             $c lower transfunc
-            $c bind transfunc <ButtonRelease-1> \
-                [itcl::code $this _AddIsoMarker $ivol %x %y]
+	    $c bind transfunc <ButtonRelease-1> \
+		[itcl::code $this _AddIsoMarker %x %y]
         }
         $c itemconfigure vmin -text $_limits($ivol-min)
@@ -917,4 +922,6 @@
 	    return
 	}
+    }
+    if { [array size _receiveids] == 0 } {
 	_fixLegend
     }
@@ -1294,40 +1301,22 @@
         }
         opacity {
-            if {[isconnected]} {
-                set dataobj [lindex [get] 0]
-                if {$dataobj != 0} {
-		    set val [$inner.scales.opacity get]
-		    set sval [expr { 0.01 * double($val) }]
-		    # FIXME: This will change when we can select the current 
-		    #        volume.
-		    set comp [lindex [$dataobj components] 0]
-		    set tag $dataobj-$comp
-		    if { [info exists _obj2id($tag)] } {
-			set ivol $_obj2id($tag)
-			set _settings($this-$ivol-opacity) $sval
-			UpdateTransferFunction $ivol
-		    }
-                }
-            }
+            if {[isconnected] && $_activeVol != "" } {
+		set val [$inner.scales.opacity get]
+		set sval [expr { 0.01 * double($val) }]
+		set ivol $_activeVol
+		set _settings($this-$ivol-opacity) $sval
+		UpdateTransferFunction $ivol
+	    }
         }
 
         thickness {
-            if {[isconnected]} {
-                set dataobj [lindex [get] 0]
-                if {$dataobj != 0} {
-                    set val [$inner.scales.thickness get]
-                    # Scale values between 0.00001 and 0.01000
-                    set sval [expr {0.0001*double($val)}]
-		    # FIXME: This will change when we can select the current 
-		    #        volume.
-		    set comp [lindex [$dataobj components] 0]
-		    set tag $dataobj-$comp
-		    if { [info exists _obj2id($tag)] } {
-			set ivol $_obj2id($tag)
-			set _settings($this-$ivol-thickness) $sval
-			UpdateTransferFunction $ivol
-		    }
-                }
-            }
+            if {[isconnected] && $_activeVol != "" } {
+		set val [$inner.scales.thickness get]
+		# Scale values between 0.00001 and 0.01000
+		set sval [expr {0.0001*double($val)}]
+		set ivol $_activeVol
+		set _settings($this-$ivol-thickness) $sval
+		UpdateTransferFunction $ivol
+	    }
         }
         "outline" {
@@ -1368,14 +1357,5 @@
     set w [expr {[winfo width $itk_component(legend)]-20}]
     set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
-    set ivol ""
-    if { $ivol == "" } {
-	set dataobj [lindex [get] 0]
-	if {"" != $dataobj} {
-	    set comp [lindex [$dataobj components] 0]
-	    if {[info exists _obj2id($dataobj-$comp)]} {
-		set ivol $_obj2id($dataobj-$comp)
-	    }
-	}
-    }
+    set ivol $_activeVol
     if {$w > 0 && $h > 0 && "" != $ivol} {
         _send "legend $ivol $w $h"
@@ -1528,4 +1508,5 @@
 	}
     }
+    set _activeVol $ivol
     if { ![info exists _isomarkers($ivol)] } {
         return
@@ -1620,9 +1601,13 @@
         return
     }
-    set _currentVolId $ivol
+    set _activeVol $ivol
     $_dispatcher event -idle !send_transfunc
 }
 
-itcl::body Rappture::NanovisViewer::_AddIsoMarker { ivol x y } {
+itcl::body Rappture::NanovisViewer::_AddIsoMarker { x y } {
+    if { $_activeVol == "" } {
+	error "active volume isn't set"
+    }
+    set ivol $_activeVol
     set c $itk_component(legend)
     set m [IsoMarker \#auto $c $this $ivol]
