Index: trunk/gui/scripts/vtkviewer.tcl
===================================================================
--- trunk/gui/scripts/vtkviewer.tcl	(revision 2426)
+++ trunk/gui/scripts/vtkviewer.tcl	(revision 2464)
@@ -80,5 +80,6 @@
     # The following methods are only used by this class.
     private method BuildCameraTab {}
-    private method BuildViewTab {}
+    private method BuildVolumeTab {}
+    private method BuildStreamsTab {}
     private method BuildAxisTab {}
     private method BuildColormap { colormap dataobj comp }
@@ -114,5 +115,5 @@
     private variable _reset 1	   ;# indicates if camera needs to be reset
                                     # to starting position.
-
+    private variable _haveStreams 0
     # Array of transfer functions in server.  If 0 the transfer has been
     # defined but not loaded.  If 1 the transfer function has been named
@@ -185,4 +186,6 @@
     array set _settings [subst {
         $this-axes		1
+        $this-seeds		1
+        $this-streamlines	1
         $this-edges		1
         $this-lighting		1
@@ -259,7 +262,12 @@
     Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
 
-    BuildViewTab
-    BuildAxisTab
-    BuildCameraTab
+    if { [catch { 
+	BuildVolumeTab
+	BuildAxisTab
+	BuildStreamsTab
+	BuildCameraTab
+    } errs] != 0 } {
+	puts stderr err=$errs
+    }
 
     # Hack around the Tk panewindow.  The problem is that the requested 
@@ -539,4 +547,5 @@
     foreach dataobj $args {
         array set bounds [limits $dataobj]
+ puts stderr bounds=[array get bounds]
 	if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} {
 	    set _limits(xmin) $bounds(xmin)
@@ -803,4 +812,5 @@
     set _limits(vmax) ""
     set _first ""
+    set _haveStreams 0
     foreach dataobj [get -objects] {
 	if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
@@ -852,6 +862,11 @@
     FixSettings axes
     FixSettings edges
+    FixSettings seeds
+    FixSettings streamlines
     FixSettings axismode
 
+    if { !$_haveStreams } {
+	$itk_component(main) disable "Streams Settings" 
+    }
     if {"" != $_first} {
         set location [$_first hints camera]
@@ -1049,4 +1064,10 @@
 	}
 	"drag" {
+	    if { ![info exists _click(x)] } {
+		set _click(x) $x
+	    }
+	    if { ![info exists _click(y)] } {
+		set _click(y) $y
+	    }
 	    set w [winfo width $itk_component(view)]
 	    set h [winfo height $itk_component(view)]
@@ -1077,75 +1098,102 @@
 # ----------------------------------------------------------------------
 itcl::body Rappture::VtkViewer::FixSettings {what {value ""}} {
+    if { ![isconnected] } {
+	return
+    }
     switch -- $what {
         "opacity" {
-            if {[isconnected]} {
-                set val $_settings($this-opacity)
-                set sval [expr { 0.01 * double($val) }]
-		foreach dataset [CurrentDatasets -visible $_first] {
-		    SendCmd "polydata opacity $sval $dataset"
-		}
+	    set val $_settings($this-opacity)
+	    set sval [expr { 0.01 * double($val) }]
+	    foreach dataset [CurrentDatasets -visible $_first] {
+		SendCmd "polydata opacity $sval $dataset"
+	    }
+        }
+        "wireframe" {
+	    set bool $_settings($this-wireframe)
+	    foreach dataset [CurrentDatasets -visible $_first] {
+		SendCmd "polydata wireframe $bool $dataset"
             }
         }
-        "wireframe" {
-            if {[isconnected]} {
-		set bool $_settings($this-wireframe)
-		foreach dataset [CurrentDatasets -visible $_first] {
-		    SendCmd "polydata wireframe $bool $dataset"
-		}
+        "volume" {
+	    set bool $_settings($this-volume)
+	    foreach dataset [CurrentDatasets -visible $_first] {
+		SendCmd "polydata visible $bool $dataset"
             }
         }
-        "volume" {
-            if {[isconnected]} {
-		set bool $_settings($this-volume)
-		foreach dataset [CurrentDatasets -visible $_first] {
-		    SendCmd "polydata visible $bool $dataset"
-		}
+        "lighting" {
+	    set bool $_settings($this-lighting)
+	    foreach dataset [CurrentDatasets -visible $_first] {
+		SendCmd "polydata lighting $bool $dataset"
             }
         }
-        "lighting" {
-            if {[isconnected]} {
-		set bool $_settings($this-lighting)
-		foreach dataset [CurrentDatasets -visible $_first] {
-		    SendCmd "polydata lighting $bool $dataset"
-		}
-            }
-        }
         "grid-x" {
-            if {[isconnected]} {
-		set bool $_settings($this-grid-x)
-		SendCmd "axis grid x $bool"
-            }
+	    set bool $_settings($this-grid-x)
+	    SendCmd "axis grid x $bool"
         }
         "grid-y" {
-            if {[isconnected]} {
-		set bool $_settings($this-grid-y)
-		SendCmd "axis grid y $bool"
-            }
+	    set bool $_settings($this-grid-y)
+	    SendCmd "axis grid y $bool"
         }
         "grid-z" {
-            if {[isconnected]} {
-		set bool $_settings($this-grid-z)
-		SendCmd "axis grid z $bool"
-            }
+	    set bool $_settings($this-grid-z)
+	    SendCmd "axis grid z $bool"
+        }
+        "axes" {
+	    set bool $_settings($this-axes)
+	    SendCmd "axis visible all $bool"
+        }
+        "axismode" {
+	    set mode [$itk_component(axismode) value]
+	    set mode [$itk_component(axismode) translate $mode]
+	    SendCmd "axis flymode $mode"
         }
         "edges" {
-            if {[isconnected]} {
-		set bool $_settings($this-edges)
-		foreach dataset [CurrentDatasets -visible $_first] {
+	    set bool $_settings($this-edges)
+	    foreach dataset [CurrentDatasets -visible $_first] {
+		foreach {dataobj comp} [split $dataset -] break
+		if { [$dataobj type $comp] != "streamlines" } {
 		    SendCmd "polydata edges $bool $dataset"
 		}
             }
         }
-        "axes" {
-            if { [isconnected] } {
-		set bool $_settings($this-axes)
-                SendCmd "axis visible all $bool"
+        "seeds" {
+	    set bool $_settings($this-seeds)
+	    foreach dataset [CurrentDatasets -visible $_first] {
+		foreach {dataobj comp} [split $dataset -] break
+		if { [$dataobj type $comp] == "streamlines" } {
+		    SendCmd "streamlines seed visible $bool $dataset"
+		}
+	    }
+        }
+        "streamlines" {
+	    set bool $_settings($this-streamlines)
+	    foreach dataset [CurrentDatasets -visible $_first] {
+		foreach {dataobj comp} [split $dataset -] break
+		if { [$dataobj type $comp] == "streamlines" } {
+		    if { $bool } {
+			SendCmd "streamlines add $dataset"
+		    } else {
+			SendCmd "streamlines delete $dataset"
+		    }
+		}
             }
         }
-        "axismode" {
-            if { [isconnected] } {
-		set mode [$itk_component(axismode) value]
-		set mode [$itk_component(axismode) translate $mode]
-                SendCmd "axis flymode $mode"
+        "streammode" {
+	    set mode [$itk_component(streammode) value]
+	    foreach dataset [CurrentDatasets -visible $_first] {
+		foreach {dataobj comp} [split $dataset -] break
+		if { [$dataobj type $comp] == "streamlines" } {
+		    switch -- $mode {
+			"lines" {
+			    SendCmd "streamlines lines $dataset"
+			}
+			"ribbons" {
+			    SendCmd "streamlines ribbons 3.0 20 $dataset"
+			}
+			"tubes" {
+			    SendCmd "streamlines tubes 20 10 $dataset"
+			}
+		    }
+		}
             }
         }
@@ -1279,6 +1327,5 @@
 }
 
-
-itcl::body Rappture::VtkViewer::BuildViewTab {} {
+itcl::body Rappture::VtkViewer::BuildVolumeTab {} {
 
     set fg [option get $itk_component(hull) font Font]
@@ -1286,7 +1333,13 @@
 
     set inner [$itk_component(main) insert end \
-        -title "View Settings" \
-        -icon [Rappture::icon wrench]]
+        -title "Volume Settings" \
+        -icon [Rappture::icon volume-on]]
     $inner configure -borderwidth 4
+
+    checkbutton $inner.volume \
+        -text "Visible" \
+        -variable [itcl::scope _settings($this-volume)] \
+        -command [itcl::code $this FixSettings volume] \
+        -font "Arial 9"
 
     checkbutton $inner.wireframe \
@@ -1296,16 +1349,4 @@
         -font "Arial 9"
 
-    checkbutton $inner.axes \
-        -text "Axes" \
-        -variable [itcl::scope _settings($this-axes)] \
-        -command [itcl::code $this FixSettings axes] \
-        -font "Arial 9"
-
-    checkbutton $inner.volume \
-        -text "Volume" \
-        -variable [itcl::scope _settings($this-volume)] \
-        -command [itcl::code $this FixSettings volume] \
-        -font "Arial 9"
-
     checkbutton $inner.lighting \
         -text "Lighting" \
@@ -1320,26 +1361,24 @@
         -font "Arial 9"
 
-    label $inner.clear -text "Clear" -font "Arial 9"
+    label $inner.opacity_l -text "Opacity" -font "Arial 9"
     ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
         -variable [itcl::scope _settings($this-opacity)] \
         -width 10 \
         -showvalue off -command [itcl::code $this FixSettings opacity]
-    label $inner.opaque -text "Opaque" -font "Arial 9"
 
     blt::table $inner \
-        0,0 $inner.axes -columnspan 4 -anchor w -pady 2 \
-        1,0 $inner.volume -columnspan 4 -anchor w -pady 2 \
-        2,0 $inner.wireframe -columnspan 4 -anchor w -pady 2 \
-        3,0 $inner.lighting  -columnspan 4 -anchor w \
-        4,0 $inner.edges -columnspan 4 -anchor w -pady 2 \
-        6,0 $inner.clear -anchor e -pady 2 \
-        6,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
-        6,3 $inner.opaque -anchor w -pady 2 
+        0,0 $inner.volume -columnspan 4 -anchor w -pady 2 \
+        1,0 $inner.wireframe -columnspan 4 -anchor w -pady 2 \
+        2,0 $inner.lighting  -columnspan 4 -anchor w \
+        3,0 $inner.edges -columnspan 4 -anchor w -pady 2 \
+        4,0 $inner.opacity_l -anchor w -pady 2 \
+        5,0 $inner.opacity -columnspan 2 -pady 2 -fill x 
 
     blt::table configure $inner r* -resize none
-    blt::table configure $inner r7 -resize expand
-}
-
-itcl::body Rappture::VtkViewer::BuildAxisTab {} {
+    blt::table configure $inner r6 -resize expand
+}
+
+
+itcl::body Rappture::VtkViewer::BuildStreamsTab {} {
 
     set fg [option get $itk_component(hull) font Font]
@@ -1347,6 +1386,60 @@
 
     set inner [$itk_component(main) insert end \
+        -title "Streams Settings" \
+        -icon [Rappture::icon stream]]
+    $inner configure -borderwidth 4
+
+    checkbutton $inner.streamlines \
+        -text "Visible" \
+        -variable [itcl::scope _settings($this-streamlines)] \
+        -command [itcl::code $this FixSettings streamlines] \
+        -font "Arial 9"
+
+    checkbutton $inner.seeds \
+        -text "Show seeds" \
+        -variable [itcl::scope _settings($this-seeds)] \
+        -command [itcl::code $this FixSettings seeds] \
+        -font "Arial 9"
+
+    label $inner.streammode -text "Mode" \
+        -font "Arial 9" 
+
+    itk_component add streammode {
+	Rappture::Combobox $inner.streammode_combo -width 10 -editable no
+    }
+    $inner.streammode_combo choices insert end \
+        "lines"    "lines" \
+        "ribbons"   "ribbons" \
+        "tubes"     "tubes" 
+    $itk_component(streammode) value "lines"
+    bind $inner.streammode_combo <<Value>> \
+	[itcl::code $this FixSettings streammode]
+
+    label $inner.opacity_l -text "Opacity" -font "Arial 9"
+    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
+        -variable [itcl::scope _settings($this-opacity)] \
+        -width 10 \
+        -showvalue off -command [itcl::code $this FixSettings opacity]
+
+    blt::table $inner \
+        0,0 $inner.streamlines -columnspan 4 -anchor w -pady 2 \
+        1,0 $inner.seeds -columnspan 4 -anchor w -pady 2 \
+        2,0 $inner.streammode -anchor w -pady 2 \
+        2,1 $inner.streammode_combo -cspan 3 -anchor w -pady 2 \
+        3,0 $inner.opacity_l -pady 2 -fill x\
+        4,0 $inner.opacity -columnspan 2 -pady 2 -fill x
+
+    blt::table configure $inner r* -resize none
+    blt::table configure $inner r5 -resize expand
+}
+
+itcl::body Rappture::VtkViewer::BuildAxisTab {} {
+
+    set fg [option get $itk_component(hull) font Font]
+    #set bfg [option get $itk_component(hull) boldFont Font]
+
+    set inner [$itk_component(main) insert end \
         -title "Axis Settings" \
-        -icon [Rappture::icon cog]]
+        -icon [Rappture::icon axis1]]
     $inner configure -borderwidth 4
 
@@ -1559,19 +1652,38 @@
 
 itcl::body Rappture::VtkViewer::SetObjectStyle { dataobj comp } {
-    array set props {
-        -color \#6666FF
-        -edgevisibility 1
-        -edgecolor black
-        -linewidth 1.0
-        -opacity 1.0
-	-wireframe 0
-	-lighting 1
-    }
     # Parse style string.
+    set tag $dataobj-$comp
+    set type [$dataobj type $comp]
+    if { $type == "streamlines" } {
+	array set props {
+	    -color \#808080
+	    -edgevisibility 0
+	    -edgecolor black
+	    -linewidth 1.0
+	    -opacity 0.4
+	    -wireframe 0
+	    -lighting 1
+	    -seeds 1
+	    -seedcolor white
+	}
+	SendCmd "streamlines add $tag"
+	SendCmd "streamlines seed visible off"
+	set _haveStreams 1
+    } else {
+	array set props {
+	    -color \#6666FF
+	    -edgevisibility 1
+	    -edgecolor black
+	    -linewidth 1.0
+	    -opacity 1.0
+	    -wireframe 0
+	    -lighting 1
+	}
+    } 
     set style [$dataobj style $comp]
-    set tag $dataobj-$comp
     array set props $style
+
+    SendCmd "polydata edges $props(-edgevisibility) $tag"
     SendCmd "polydata color [Color2RGB $props(-color)] $tag"
-    SendCmd "polydata edges $props(-edgevisibility) $tag"
     SendCmd "polydata lighting $props(-lighting) $tag"
     SendCmd "polydata linecolor [Color2RGB $props(-edgecolor)] $tag"
