Index: trunk/gui/scripts/field.tcl
===================================================================
--- trunk/gui/scripts/field.tcl	(revision 3415)
+++ trunk/gui/scripts/field.tcl	(revision 3416)
@@ -1078,4 +1078,5 @@
     puts $f $contents 
     close $f
+
     $reader SetFileName $tmpfile
     $reader ReadAllScalarsOn
@@ -1132,6 +1133,6 @@
     lappend limits v [list $vmin $vmax]
     set _comp2limits($cname) $limits
-    $reader Delete
     file delete $tmpfile
+    rename $reader ""
 }
 
Index: trunk/gui/scripts/vtkheightmapviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkheightmapviewer.tcl	(revision 3415)
+++ trunk/gui/scripts/vtkheightmapviewer.tcl	(revision 3416)
@@ -941,5 +941,4 @@
 	$_arcball quaternion $q 
 	if {$_settings(isHeightmap) } {
-	    SendCmd "camera reset"
 	    if { $_view(ortho)} {
 		SendCmd "camera mode ortho"
@@ -947,6 +946,7 @@
 		SendCmd "camera mode persp"
 	    }
+	    SendCmd "camera reset"
+            DoRotate
 	} 	    
-	DoRotate
 	PanCamera
     }
@@ -1070,5 +1070,4 @@
 	$_arcball quaternion $q 
 	if {$_settings(isHeightmap) } {
-	    SendCmd "camera reset"
 	    if { $_view(ortho)} {
 		SendCmd "camera mode ortho"
@@ -1076,6 +1075,7 @@
 		SendCmd "camera mode persp"
 	    }
+	    SendCmd "camera reset"
+            DoRotate
 	}
-	DoRotate
 	PanCamera
 	InitSettings axisXGrid axisYGrid axisZGrid \
@@ -1172,5 +1172,4 @@
                 ypan    0 
             }
-            SendCmd "camera reset all"
             if { $_first != "" } {
                 set location [$_first hints camera]
@@ -1181,5 +1180,8 @@
             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
             $_arcball quaternion $q
-            DoRotate
+            SendCmd "camera reset"
+            if {$_settings(isHeightmap) } {
+                DoRotate
+            }
         }
     }
@@ -1523,6 +1525,15 @@
         "isHeightmap" {
 	    set bool $_settings(isHeightmap)
+            incr _buffering 
+            if { $_buffering == 1 } {
+                set _outbuf ""
+            }
 	    if { $bool } {
 		$itk_component(lighting) configure -state normal
+                if {$_view(ortho)} {
+                    SendCmd "camera mode ortho"
+                } else {
+                    SendCmd "camera mode persp"
+                }
 	    } else {
 		$itk_component(lighting) configure -state disabled
@@ -1562,9 +1573,4 @@
                 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
                 $_arcball quaternion $q
-                if {$_view(ortho)} {
-                    SendCmd "camera mode ortho"
-                } else {
-                    SendCmd "camera mode persp"
-                }
                 SendCmd "camera orient $q" 
             } else {
@@ -1574,4 +1580,9 @@
                 bind $c <ButtonRelease-1> {}
                 SendCmd "camera mode image"
+            }
+            incr _buffering -1
+            if { $_buffering == 0 } {
+                sendto $_outbuf
+                set _outbuf ""
             }
         }
@@ -2050,6 +2061,6 @@
         foreach comp [$dataobj components] {
             set tag $dataobj-$comp
-            set contents [ConvertToVtkData $dataobj $comp]
-            #set contents [$dataobj vtkdata $comp]
+            #set contents [ConvertToVtkData $dataobj $comp]
+            set contents [$dataobj vtkdata $comp]
             append bytes "$contents\n\n"
         }
@@ -2138,4 +2149,6 @@
     SendCmd "heightmap wireframe $_settings(wireframe) $tag"
     SendCmd "heightmap colormap $_currentColormap $tag"
+    set color [$itk_component(isolinecolor) value]
+    SendCmd "heightmap isolinecolor [Color2RGB $color] $tag"
 }
 
@@ -2175,8 +2188,7 @@
 # DrawLegend --
 #
-#       Draws the legend in it's own canvas which resides to the right
-#       of the contour plot area.
-#
-itcl::body Rappture::VtkHeightmapViewer::DrawLegend { name } {
+#       Draws the legend in the own canvas on the right side of the plot area.
+#
+itcl::body Rappture::VtkHeightmapViewer::DrawLegend { fname } {
     set c $itk_component(view)
     set w [winfo width $c]
@@ -2185,14 +2197,14 @@
     set lineht [font metrics $font -linespace]
     
-    if { $name == "component" } {
+    if { $fname == "component" } {
 	set title ""
     } else {
-	if { [info exists _fields($name)] } {
-	    foreach { title units } $_fields($name) break
+	if { [info exists _fields($fname)] } {
+	    foreach { title units } $_fields($fname) break
 	    if { $units != "" } {
 		set title [format "%s (%s)" $title $units]
 	    }
 	} else {
-	    set title $name
+	    set title $fname
 	}
     }
@@ -2302,29 +2314,11 @@
 itcl::body Rappture::VtkHeightmapViewer::SetIsolineTip { x y value } {
     set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-    
-    if { [info exists _fields($_title)] } {
-        foreach { title units } $_fields($_title) break
-        if { $units != "" } {
-            set title [format "%s (%s)" $title $units]
-        }
-    } else {
-        set title $_title
-    }
-    set imgHeight [image height $_image(legend)]
-    set coords [$c coords colormap]
-    set imgX [expr $w - [image width $_image(legend)] - 2]
-    set imgY [expr $y - 2 * ($lineht + 2)]
-
     .rappturetooltip configure -icon ""
 
-    # Compute the value of the point
-    set tipx [expr $x + 15] 
-    set tipy [expr $y - 5]
+    # Compute the position of the tip
+    set tx [expr $x + 15] 
+    set ty [expr $y - 5]
     Rappture::Tooltip::text $c "Isoline $value"
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy    
+    Rappture::Tooltip::tooltip show $c +$tx,+$ty    
 }
 
@@ -2364,8 +2358,6 @@
     set lineht [font metrics $font -linespace]
     
-    set imgHeight [image height $_image(legend)]
-    set coords [$c coords colormap]
-    set imgX [expr $w - [image width $_image(legend)] - 2]
-    set imgY [expr $y - 2 * ($lineht + 2)]
+    set ih [image height $_image(legend)]
+    set iy [expr $y - ($lineht + 2)]
 
     if { [info exists _fields($_title)] } {
@@ -2377,9 +2369,15 @@
         set title $_title
     }
+    # If there's a legend title, increase the offset by the line height.
+    if { $title != "" } {
+        incr iy $lineht
+    }
+
     # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
-        #puts stderr "out of range: $imgY"
+    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
+        #puts stderr "out of range: $iy"
         return
     }
+
     if { ![info exists _image(swatch)] } {
         set _image(swatch) [image create photo -width 24 -height 24]
@@ -2393,5 +2391,5 @@
     if { [info exists _limits(v)] } {
         foreach { vmin vmax } $_limits(v) break
-        set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
+        set t [expr 1.0 - (double($iy) / double($ih-1))]
         set value [expr $t * ($vmax - $vmin) + $vmin]
     } else {
Index: trunk/gui/scripts/vtkisosurfaceviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkisosurfaceviewer.tcl	(revision 3415)
+++ trunk/gui/scripts/vtkisosurfaceviewer.tcl	(revision 3416)
@@ -1182,5 +1182,4 @@
                 ypan   0
             }
-            SendCmd "camera reset all"
             if { $_first != "" } {
                 set location [$_first hints camera]
@@ -1191,4 +1190,5 @@
             set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
             $_arcball quaternion $q
+            SendCmd "camera reset"
             DoRotate
         }
@@ -2217,11 +2217,10 @@
     set w [winfo width $c]
     set h [winfo height $c]
+
     set font "Arial 8"
     set lineht [font metrics $font -linespace]
     
-    set imgHeight [image height $_image(legend)]
-    set coords [$c coords colormap]
-    set imgX [expr $w - [image width $_image(legend)] - 2]
-    set imgY [expr $y - 2 * ($lineht + 2)]
+    set ih [image height $_image(legend)]
+    set iy [expr $y - ($lineht + 2)]
 
     set title ""
@@ -2240,6 +2239,11 @@
 	}
     }
+    # If there's a legend title, increase the offset by the line height.
+    if { $title != "" } {
+        incr iy $lineht
+    }
+
     # Make a swatch of the selected color
-    if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
+    if { [catch { $_image(legend) get 10 $iy } pixel] != 0 } {
         return
     }
@@ -2252,17 +2256,15 @@
     .rappturetooltip configure -icon $_image(swatch)
 
-    .rappturetooltip configure -icon $_image(swatch)
-
     # Compute the value of the point
     if { [info exists _limits(vmax)] && [info exists _limits(vmin)] } {
-        set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
+        set t [expr 1.0 - (double($iy) / double($ih-1))]
         set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
     } else {
         set value 0.0
     }
-    set tipx [expr $x + 15] 
-    set tipy [expr $y - 5]
+    set tx [expr $x + 15] 
+    set ty [expr $y - 5]
     Rappture::Tooltip::text $c "$title $value"
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy    
+    Rappture::Tooltip::tooltip show $c +$tx,+$ty    
 }
 
@@ -2328,6 +2330,5 @@
 # DrawLegend --
 #
-#       Draws the legend in it's own canvas which resides to the right
-#       of the contour plot area.
+#       Draws the legend in the own canvas on the right side of the plot area.
 #
 itcl::body Rappture::VtkIsosurfaceViewer::DrawLegend { name } {
@@ -2455,42 +2456,11 @@
 itcl::body Rappture::VtkIsosurfaceViewer::SetIsolineTip { x y value } {
     set c $itk_component(view)
-    set w [winfo width $c]
-    set h [winfo height $c]
-    set font "Arial 8"
-    set lineht [font metrics $font -linespace]
-    
-    if { [info exists _fields($_title)] } {
-        foreach { title units } $_fields($_title) break
-	if { $title == "component" } {
-	    set title ""
-	}
-        if { $units != "" } {
-            set title [format "%s (%s)" $title $units]
-        }
-    } else {
-        set title $_title
-    }
-    # Make a swatch of the selected color
-    set imgHeight [image height $_image(legend)]
-    set coords [$c coords colormap]
-    set imgX [expr $w - [image width $_image(legend)] - 2]
-    set imgY [expr $y - 2 * ($lineht + 2)]
-
-    if { [catch { $_image(legend) get 10 $imgY } pixel] != 0 } {
-        return
-    }
-    if { ![info exists _image(swatch)] } {
-        set _image(swatch) [image create photo -width 24 -height 24]
-    }
-    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 
-    .rappturetooltip configure -icon $_image(swatch)
-
-     # Compute the value of the point
-    set tipx [expr $x + 15] 
-    set tipy [expr $y - 5]
+    .rappturetooltip configure -icon ""
+
+    # Compute the position of the tip
+    set tx [expr $x + 15] 
+    set ty [expr $y - 5]
     Rappture::Tooltip::text $c "Isosurface $value"
-    Rappture::Tooltip::tooltip show $c +$tipx,+$tipy    
+    Rappture::Tooltip::tooltip show $c +$tx,+$ty    
 }
 
