Index: /trunk/gui/scripts/nanovisviewer.tcl
===================================================================
--- /trunk/gui/scripts/nanovisviewer.tcl	(revision 878)
+++ /trunk/gui/scripts/nanovisviewer.tcl	(revision 879)
@@ -44,5 +44,9 @@
     public method delete {args}
     public method scale {args}
-    public method getLimits {} {
+    public method getLimits { { option "-current"} } {
+	if { $option == "-current" } {
+	    set dataobj [lindex [get] 0]
+	    return [list $_limits($dataobj-vmin) $_limits($dataobj-vmax)]
+	}
 	return [list $_limits(vmin) $_limits(vmax)]
     }
@@ -77,9 +81,11 @@
     protected method _fixLegend {}
     protected method _serverDown {}
-    protected method _getTransfuncData {dataobj comp}
+    protected method _genTransfuncData {dataobj comp}
     public method update_transfer_function {}
     public method remove_duplicate_isomarker { m x }
     public method _addIsoMarker { x y }
     protected method _initIsoMarkers {dataobj comp}
+    protected method _hideIsoMarkers {dataobj}
+    protected method _showIsoMarkers {dataobj}
     protected method _color2rgb {color}
     protected method _euler2xyz {theta phi psi}
@@ -94,4 +100,5 @@
 
     private variable _dlist ""     ;# list of data objects
+    private variable _all_data_objs
     private variable _dims ""      ;# dimensionality of data objects
     private variable _obj2style    ;# maps dataobj => style settings
@@ -176,5 +183,5 @@
 	set _tick [$c create image 0 $h \
 		-image $_normal_icon -anchor s \
-		-tags "$this $obj"]
+		-tags "$this $obj" -state hidden]
 	set _label [$c create text 0 $h \
 		-anchor n -fill white -font "Helvetica 6" \
@@ -192,6 +199,14 @@
 
     public method get_relative_value {} {
-	foreach {min max} [$_nvobj getLimits] break
+	foreach {min max} [$_nvobj getLimits -current] break
 	return [expr {($_value-$min)/($max - $min)}]
+    }
+    public method show {} {
+	set_absolute_value $_value
+	$_canvas itemconfigure $_tick -state normal
+	$_canvas raise $_tick
+    }
+    public method hide {} {
+	$_canvas itemconfigure $_tick -state hidden
     }
     public method get_screen_position { } { 
@@ -210,16 +225,12 @@
     public method set_absolute_value { x } {
 	set _value $x
-
-	set w [winfo width $_canvas]
-	set h [winfo height $_canvas]
-	set y0 10
-	set y1 [expr {$y0+22-1}]
+	set y 31
 	$_canvas itemconfigure $_label -text [format %.4g $_value]
-	set screen_pos [get_screen_position]
-	$_canvas coords $_tick $screen_pos [expr $y1+3]
-	$_canvas coords $_label $screen_pos [expr {$y1+5}]
+	set x [get_screen_position]
+	$_canvas coords $_tick $x [expr {$y+3}]
+	$_canvas coords $_label $x [expr {$y+5}]
     }
     public method set_relative_value { x } {
-	foreach {min max} [$_nvobj getLimits] break 
+	foreach {min max} [$_nvobj getLimits -current] break 
 	set r [expr $max - $min]
 	set_absolute_value [expr {($x * $r) + $min}]
@@ -642,4 +653,5 @@
     if {$pos < 0} {
         lappend _dlist $dataobj
+	set _all_data_objs($dataobj) 1
         set _obj2ovride($dataobj-color) $params(-color)
         set _obj2ovride($dataobj-width) $params(-width)
@@ -1072,5 +1084,5 @@
             #
 	    _initIsoMarkers $dataobj $comp
-            foreach {sname cmap wmap} [_getTransfuncData $dataobj $comp] break
+            foreach {sname cmap wmap} [_genTransfuncData $dataobj $comp] break
             set cmdstr [list transfunc define $sname $cmap $wmap]
             _send_echo >>line $cmdstr
@@ -1095,4 +1107,5 @@
         }
     }
+    _showIsoMarkers $first 
     # if there are any commands in the buffer, send them now that we're done
     _send_echo >>line $_buffer(out)
@@ -1210,6 +1223,15 @@
 	set volume $info(id)
 	foreach { dataobj comp } $_id2obj($volume) break
-	set _limits(vmin-$dataobj-$comp) $info(min)
-	set _limits(vmax-$dataobj-$comp) $info(max)
+	if { ![info exists _limits($dataobj-vmin] } {
+	    set _limits($dataobj-vmin) $info(min)
+	    set _limits($dataobj-vmax) $info(max)
+	} else {
+	    if { $_limits($dataobj-vmin) > $info(min) } {
+		set _limits($dataobj-vmin) $info(min)
+	    } 
+	    if { $_limits($dataobj-vmax) > $info(max) } {
+		set _limits($dataobj-vmax) $info(max)
+	    } 
+	}	    
 	set _limits(vmin) $info(vmin)
 	set _limits(vmax) $info(vmax)
@@ -1276,11 +1298,7 @@
             }
         }
-        foreach key [array names _obj2id *-*] {
-            set state [string match $first-* $key]
-            _send volume state $state $_obj2id($key)
-            if {[info exists _obj2style($key)]} {
-                _send volume shading transfunc $_obj2style($key) $_obj2id($key)
-            }
-        }
+
+	_showIsoMarkers $first
+	update_transfer_function
 
         # sync the state of slicers
@@ -1543,76 +1561,4 @@
 
 # ----------------------------------------------------------------------
-# USAGE: _probe start <x> <y>
-# USAGE: _probe update <x> <y>
-# USAGE: _probe end <x> <y>
-#
-# Used internally to handle the various probe operations, when the
-# user clicks and drags on the legend area.  The probe changes the
-# transfer function to highlight the area being selected in the
-# legend.
-# ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::_probe {option args} {
-    set c $itk_component(legend)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set y0 10
-    set y1 [expr {$y0+[image height $_image(legend)]-1}]
-
-    set dataobj [lindex [get] 0]
-    if {"" == $dataobj} {
-        return
-    }
-    set comp [lindex [$dataobj components] 0]
-    if {![info exists _obj2style($dataobj-$comp)]} {
-        return
-    }
-
-    switch -- $option {
-        start {
-            # create the probe marker on the legend
-            $c create rect 0 0 5 $h -width 3 \
-                -outline black -fill "" -tags markerbg
-            $c create rect 0 0 5 $h -width 1 \
-                -outline white -fill "" -tags marker
-
-            # define a new transfer function
-            _send transfunc define probe {0 0 0 0 1 0 0 0} {0 0 1 0}
-            _send volume shading transfunc probe $_obj2id($dataobj-$comp)
-
-            # now, probe this point
-            eval _probe update $args
-        }
-        update {
-            set x [lindex $args 0]
-            if {$x < 10} {set x 10}
-            if {$x > $w-10} {set x [expr {$w-10}]}
-            foreach tag {markerbg marker} {
-                $c coords $tag [expr {$x-2}] [expr {$y0-2}] \
-                    [expr {$x+2}] [expr {$y1+2}]
-            }
-
-            # value of the probe point, in the range 0-1
-            set val [expr {double($x-10)/($w-20)}]
-            set dl [expr {($val > 0.1) ? 0.1 : $val}]
-            set dr [expr {($val < 0.9) ? 0.1 : 1-$val}]
-
-            # compute a transfer function for the probe value
-            foreach {sname cmap wmap} [_getTransfuncData $dataobj $comp] break
-            set wmap "0.0 0.0 [expr {$val-$dl}] 0.0 $val 1.0 [expr {$val+$dr}] 0.0 1.0 0.0"
-            _send transfunc define probe $cmap $wmap
-        }
-        end {
-            $c delete marker markerbg
-
-            # put the volume back to its old transfer function
-            _send volume shading transfunc $_obj2style($dataobj-$comp) $_obj2id($dataobj-$comp)
-        }
-        default {
-            error "bad option \"$option\": should be start, update, end"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
 # USAGE: _state <component>
 #
@@ -1669,5 +1615,6 @@
             if {[isconnected]} {
                 set val $Rappture::NanovisViewer::_isosurface($this)
-                _send "volume" "shading" "isosurface" $val
+		set dataobj [lindex [get] 0]
+                _send "volume" "shading" "isosurface" $val 
             }
 	}	    
@@ -1698,9 +1645,8 @@
         }
     }
-
     if {$w > 0 && $h > 0 && "" != $ivol} {
         _send legend $ivol $w $h
     } else {
-        $itk_component(legend) delete all
+        #$itk_component(legend) delete all
     }
 }
@@ -1720,5 +1666,5 @@
 
 # ----------------------------------------------------------------------
-# USAGE: _getTransfuncData <dataobj> <comp>
+# USAGE: _genTransfuncData <dataobj> <comp>
 #
 # Used internally to compute the colormap and alpha map used to define
@@ -1726,5 +1672,5 @@
 # Returns: name {v r g b ...} {v w ...}
 # ----------------------------------------------------------------------
-itcl::body Rappture::NanovisViewer::_getTransfuncData {dataobj comp} {
+itcl::body Rappture::NanovisViewer::_genTransfuncData {dataobj comp} {
     array set style {
         -color rainbow
@@ -1857,6 +1803,27 @@
 }
 
+itcl::body Rappture::NanovisViewer::_hideIsoMarkers {dataobj} {
+    if { [info exists _isomarkers($dataobj)] } {
+	foreach m $_isomarkers($dataobj) {
+	    $m hide
+	}
+    }
+}
+
+itcl::body Rappture::NanovisViewer::_showIsoMarkers {dataobj} {
+    foreach obj [array names _all_data_objs] {
+	_hideIsoMarkers $obj
+    }
+    if { ![info exists _isomarkers($dataobj)] } {
+	return
+    }
+    foreach m $_isomarkers($dataobj) {
+	$m show
+    }
+}
+
 itcl::body Rappture::NanovisViewer::_initIsoMarkers {dataobj comp} {
     if { [info exists _isomarkers($dataobj)] } {
+	_hideIsoMarkers $dataObj
 	return
     }
@@ -1910,6 +1877,6 @@
         return
     }
-    # compute a transfer function for the probe value
-    foreach {sname cmap wmap} [_getTransfuncData $dataobj $comp] break
+    # Compute a transfer function for the current data set.
+    foreach {sname cmap wmap} [_genTransfuncData $dataobj $comp] break
     _send transfunc define $_obj2style($key) $cmap $wmap
     _send volume shading transfunc $_obj2style($key) $_obj2id($key)
@@ -1919,13 +1886,13 @@
 itcl::body Rappture::NanovisViewer::_addIsoMarker { x y } {
     set dataobj [lindex [get] 0]
-    if {"" == $dataobj} {
-        return 0
-    }
-    set key $dataobj
+    if {$dataobj == ""} {
+        return 0;			# No data sets defined
+    }
     set c $itk_component(legend)
     set m [IsoMarker \#auto $c $this]
     set w [winfo width $c]
     $m set_relative_value [expr {double($x-10)/($w-20)}]
-    lappend _isomarkers($key) $m
+    $m show
+    lappend _isomarkers($dataobj) $m
     update_transfer_function
     return 1
@@ -1937,22 +1904,23 @@
         return 0
     }
-    set key $dataobj
-    set list {}
     set bool 1
-    set marker [namespace tail $marker]
-    foreach m $_isomarkers($key) {
-	set sx [$m get_screen_position]
-	if { $m != $marker } {
-	    if { $x >= ($sx-3) && $x <= ($sx+3) } {
-		$marker set_relative_value [$m get_relative_value]
-		itcl::delete object $m
-		set bool 0
-		continue
+    if { [info exists _isomarkers($dataobj)] } {
+	set list {}
+	set marker [namespace tail $marker]
+	foreach m $_isomarkers($dataobj) {
+	    set sx [$m get_screen_position]
+	    if { $m != $marker } {
+		if { $x >= ($sx-3) && $x <= ($sx+3) } {
+		    $marker set_relative_value [$m get_relative_value]
+		    itcl::delete object $m
+		    set bool 0
+		    continue
+		}
 	    }
+	    lappend list $m
 	}
-	lappend list $m
-    }
-    set _isomarkers($key) $list
-    update_transfer_function
+	set _isomarkers($dataobj) $list
+	update_transfer_function
+    }
     return $bool
 }
