Index: trunk/gui/scripts/visviewer.tcl
===================================================================
--- trunk/gui/scripts/visviewer.tcl	(revision 5126)
+++ trunk/gui/scripts/visviewer.tcl	(revision 5127)
@@ -28,13 +28,13 @@
     set _servers(vtkvis)  "localhost:2010"
 
-    protected variable _serverType "???";# Type of server.
-    protected variable _sid ""      ;   # socket connection to server
     private common _done            ;   # Used to indicate status of send.
     private variable _buffer        ;   # buffer for incoming/outgoing commands
+    private variable _blockOnWrite 0;   # Should writes to socket block?
     private variable _initialized
     private variable _isOpen 0
     private variable _afterId -1
     private variable _icon 0
-
+    private variable _trace 0        ;    # Protocol tracing for console
+    private variable _logging 0      ;    # Command logging to file
     # Number of milliseconds to wait before idle timeout.  If greater than 0,
     # automatically disconnect from the visualization server when idle timeout
@@ -44,11 +44,10 @@
     #private variable _idleTimeout 0;       # No timeout
 
+    protected variable _serverType "???";# Type of server.
+    protected variable _sid ""      ;   # socket connection to server
     protected variable _maxConnects 100
     protected variable _outbuf       ;    # buffer for outgoing commands
     protected variable _buffering 0
     protected variable _cmdSeq 0     ;    # Command sequence number
-
-    private variable _trace 0        ;    # Protocol tracing for console
-    private variable _logging 0      ;    # Command logging to file
 
     protected variable _dispatcher "";  # dispatcher for !events
@@ -71,17 +70,16 @@
     }
     # Used internally only.
-    private method Shuffle { servers }
+    private method BuildConsole {}
+    private method DebugConsole {}
+    private method HideConsole {}
     private method ReceiveHelper {}
-    private method ServerDown {}
+    private method SendDebugCommand {}
     private method SendHelper {}
     private method SendHelper.old {}
+    private method ServerDown {}
+    private method Shuffle { servers }
+    private method TraceComm { channel {data {}} }
     private method WaitDialog { state }
-
-    protected method ToggleConsole {}
-    private method DebugConsole {}
-    private method BuildConsole {}
-    private method HideConsole {}
-    private method TraceComm { channel {data {}} }
-    private method SendDebugCommand {}
+    private method Waiting { option widget }
 
     protected method CheckConnection {}
@@ -89,4 +87,5 @@
     protected method ColorsToColormap { colors }
     protected method Connect { servers }
+    protected method DisableWaitDialog {}
     protected method Disconnect {}
     protected method EnableWaitDialog { timeout }
@@ -100,5 +99,6 @@
     protected method ReceiveEcho { channel {data ""} }
     protected method SendBytes { bytes }
-    protected method SendCmd {string}
+    protected method SendCmd { string }
+    protected method SendData { bytes }
     protected method SendEcho { channel {data ""} }
     protected method StartBufferingCommands {}
@@ -106,6 +106,5 @@
     protected method StopBufferingCommands {}
     protected method StopWaiting {}
-
-    private method Waiting { option widget }
+    protected method ToggleConsole {}
 
     private proc CheckNameList { namelist }  {
@@ -205,4 +204,7 @@
             file delete /tmp/recording.log
         }
+    }
+    if { [info exists env(VISTRACE)] } {
+        set _trace 1
     }
     eval itk_initialize $args
@@ -463,5 +465,5 @@
     }
     set _buffer(out) $bytes
-    if {0} {
+    if {_blockOnWrite} {
         # Let's try this approach: allow a write to block so we don't
         # re-enter SendBytes
@@ -510,4 +512,8 @@
 itcl::body Rappture::VisViewer::EnableWaitDialog { value } {
     set _waitTimeout $value
+}
+
+itcl::body Rappture::VisViewer::DisableWaitDialog {} {
+    set _waitTimeout 0
 }
 
@@ -1194,7 +1200,6 @@
 # SendCmd
 #
-#       Send commands off to the rendering server.  If we're currently
-#       sending data objects to the server, buffer the commands to be
-#       sent later.
+#       Send command off to the rendering server.  If we're currently
+#       buffering, the command is queued to be sent later.
 #
 itcl::body Rappture::VisViewer::SendCmd {string} {
@@ -1209,2 +1214,19 @@
     }
 }
+
+#
+# SendData
+#
+#       Send data off to the rendering server.  If we're currently
+#       buffering, the data is queued to be sent later.
+#
+itcl::body Rappture::VisViewer::SendData {bytes} {
+    if {$_trace} {
+        puts stderr "$_cmdSeq>>data payload"
+    }
+    if { $_buffering } {
+        append _outbuf $bytes
+    } else {
+        SendBytes $bytes
+    }
+}
