Index: trunk/gui/scripts/vtkviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkviewer.tcl	(revision 3571)
+++ trunk/gui/scripts/vtkviewer.tcl	(revision 3592)
@@ -707,145 +707,7 @@
     set result [VisViewer::Connect $_hosts]
     if { $result } {
-        set w [winfo width $itk_component(view)]
-        set h [winfo height $itk_component(view)]
-        EventuallyResize $w $h
-    }
-    return $result
-}
-
-#
-# isconnected --
-#
-#       Indicates if we are currently connected to the visualization server.
-#
-itcl::body Rappture::VtkViewer::isconnected {} {
-    return [VisViewer::IsConnected]
-}
-
-#
-# disconnect --
-#
-itcl::body Rappture::VtkViewer::disconnect {} {
-    Disconnect
-    set _reset 1
-}
-
-#
-# Disconnect --
-#
-#       Clients use this method to disconnect from the current rendering
-#       server.
-#
-itcl::body Rappture::VtkViewer::Disconnect {} {
-    VisViewer::Disconnect
-
-    # disconnected -- no more data sitting on server
-    array unset _datasets 
-    array unset _data 
-    array unset _colormaps 
-}
-
-# ----------------------------------------------------------------------
-# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
-#
-# Invoked automatically whenever the "image" command comes in from
-# the rendering server.  Indicates that binary image data with the
-# specified <size> will follow.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::ReceiveImage { args } {
-    array set info {
-        -token "???"
-        -bytes 0
-        -type image
-    }
-    array set info $args
-    set bytes [ReceiveBytes $info(-bytes)]
-    if { $info(-type) == "image" } {
-        if 0 {
-            set f [open "last.ppm" "w"] 
-            puts $f $bytes
-            close $f
-        }
-        $_image(plot) configure -data $bytes
-        set time [clock seconds]
-        set date [clock format $time]
-        if { $_start > 0 } {
-            set finish [clock clicks -milliseconds]
-            set _start 0
-        }
-    } elseif { $info(type) == "print" } {
-        set tag $this-print-$info(-token)
-        set _hardcopy($tag) $bytes
-    }
-}
-
-#
-# ReceiveDataset --
-#
-itcl::body Rappture::VtkViewer::ReceiveDataset { args } {
-    if { ![isconnected] } {
-        return
-    }
-    set option [lindex $args 0]
-    switch -- $option {
-        "scalar" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z value tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y value tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "vector" {
-            set option [lindex $args 1]
-            switch -- $option {
-                "world" {
-                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
-                }
-                "pixel" {
-                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
-                }
-            }
-        }
-        "names" {
-            foreach { name } [lindex $args 1] {
-                #puts stderr "Dataset: $name"
-            }
-        }
-        default {
-            error "unknown dataset option \"$option\" from server"
-        }
-    }
-}
-
-# ----------------------------------------------------------------------
-# USAGE: Rebuild
-#
-# Called automatically whenever something changes that affects the
-# data in the widget.  Clears any existing data and rebuilds the
-# widget to display new data.
-# ----------------------------------------------------------------------
-itcl::body Rappture::VtkViewer::Rebuild {} {
-
-    set w [winfo width $itk_component(view)]
-    set h [winfo height $itk_component(view)]
-    if { $w < 2 || $h < 2 } {
-        $_dispatcher event -idle !rebuild
-        return
-    }
-
-    # 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).   
-    StartBufferingCommands
-
-    if { $_reset } {
         if { $_reportClientInfo }  {
-            # Tell the server the name of the tool, the version, and dataset
-            # that we are rendering.  Have to do it here because we don't know
-            # what data objects are using the renderer until be get here.
+            # Tell the server the viewer, hub, user and session.
+            # Do this immediately on connect before buffing any commands
 	    global env
 
@@ -866,4 +728,141 @@
         }
 
+        set w [winfo width $itk_component(view)]
+        set h [winfo height $itk_component(view)]
+        EventuallyResize $w $h
+    }
+    return $result
+}
+
+#
+# isconnected --
+#
+#       Indicates if we are currently connected to the visualization server.
+#
+itcl::body Rappture::VtkViewer::isconnected {} {
+    return [VisViewer::IsConnected]
+}
+
+#
+# disconnect --
+#
+itcl::body Rappture::VtkViewer::disconnect {} {
+    Disconnect
+    set _reset 1
+}
+
+#
+# Disconnect --
+#
+#       Clients use this method to disconnect from the current rendering
+#       server.
+#
+itcl::body Rappture::VtkViewer::Disconnect {} {
+    VisViewer::Disconnect
+
+    # disconnected -- no more data sitting on server
+    array unset _datasets 
+    array unset _data 
+    array unset _colormaps 
+}
+
+# ----------------------------------------------------------------------
+# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
+#
+# Invoked automatically whenever the "image" command comes in from
+# the rendering server.  Indicates that binary image data with the
+# specified <size> will follow.
+# ----------------------------------------------------------------------
+itcl::body Rappture::VtkViewer::ReceiveImage { args } {
+    array set info {
+        -token "???"
+        -bytes 0
+        -type image
+    }
+    array set info $args
+    set bytes [ReceiveBytes $info(-bytes)]
+    if { $info(-type) == "image" } {
+        if 0 {
+            set f [open "last.ppm" "w"] 
+            puts $f $bytes
+            close $f
+        }
+        $_image(plot) configure -data $bytes
+        set time [clock seconds]
+        set date [clock format $time]
+        if { $_start > 0 } {
+            set finish [clock clicks -milliseconds]
+            set _start 0
+        }
+    } elseif { $info(type) == "print" } {
+        set tag $this-print-$info(-token)
+        set _hardcopy($tag) $bytes
+    }
+}
+
+#
+# ReceiveDataset --
+#
+itcl::body Rappture::VtkViewer::ReceiveDataset { args } {
+    if { ![isconnected] } {
+        return
+    }
+    set option [lindex $args 0]
+    switch -- $option {
+        "scalar" {
+            set option [lindex $args 1]
+            switch -- $option {
+                "world" {
+                    foreach { x y z value tag } [lrange $args 2 end] break
+                }
+                "pixel" {
+                    foreach { x y value tag } [lrange $args 2 end] break
+                }
+            }
+        }
+        "vector" {
+            set option [lindex $args 1]
+            switch -- $option {
+                "world" {
+                    foreach { x y z vx vy vz tag } [lrange $args 2 end] break
+                }
+                "pixel" {
+                    foreach { x y vx vy vz tag } [lrange $args 2 end] break
+                }
+            }
+        }
+        "names" {
+            foreach { name } [lindex $args 1] {
+                #puts stderr "Dataset: $name"
+            }
+        }
+        default {
+            error "unknown dataset option \"$option\" from server"
+        }
+    }
+}
+
+# ----------------------------------------------------------------------
+# USAGE: Rebuild
+#
+# Called automatically whenever something changes that affects the
+# data in the widget.  Clears any existing data and rebuilds the
+# widget to display new data.
+# ----------------------------------------------------------------------
+itcl::body Rappture::VtkViewer::Rebuild {} {
+
+    set w [winfo width $itk_component(view)]
+    set h [winfo height $itk_component(view)]
+    if { $w < 2 || $h < 2 } {
+        $_dispatcher event -idle !rebuild
+        return
+    }
+
+    # 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).   
+    StartBufferingCommands
+
+    if { $_reset } {
         set _width $w
         set _height $h
