Ignore:
Timestamp:
Apr 13, 2010, 12:36:52 PM (15 years ago)
Author:
dkearney
Message:

spacing, tabs, blahh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/flowvisviewer.tcl

    r1545 r1694  
    1 
    21# ----------------------------------------------------------------------
    32#  COMPONENT: flowvisviewer - 3D flow rendering
     
    6665    public method overmarker { m x }
    6766    public method parameters {title args} {
    68         # do nothing
     67        # do nothing
    6968    }
    7069    public method rmdupmarker { m x }
     
    132131    private variable _obj2ovride   ;# maps dataobj => style override
    133132    private variable _serverObjs   ;# maps dataobj-component to volume ID
    134                                     # in the server
     133                                    # in the server
    135134    private variable _sendobjs ""  ;# list of data objs to send to server
    136135    private variable _recvObjs  ;# list of data objs to send to server
    137136    private variable _obj2style    ;# maps dataobj-component to transfunc
    138137    private variable _style2objs   ;# maps tf back to list of
    139                                     # dataobj-components using the tf.
    140     private variable _obj2flow;         # Maps dataobj-component to a flow.
     138                                    # dataobj-components using the tf.
     139    private variable _obj2flow;                # Maps dataobj-component to a flow.
    141140
    142141    private variable _click        ;# info used for rotate operations
     
    223222    # Initialize the view to some default parameters.
    224223    array set _view {
    225         theta   45
    226         phi     45
    227         psi     0
    228         zoom    1.0
    229         pan-x   0
    230         pan-y   0
     224        theta   45
     225        phi     45
     226        psi     0
     227        zoom    1.0
     228        pan-x        0
     229        pan-y        0
    231230    }
    232231    set _limits(vmin) 0.0
     
    234233
    235234    array set _settings [subst {
    236         $this-arrows            0
    237         $this-currenttime       0
    238         $this-duration          1:00
    239         $this-loop              0
    240         $this-pan-x             $_view(pan-x)
    241         $this-pan-y             $_view(pan-y)
    242         $this-phi               $_view(phi)
    243         $this-play              0
    244         $this-psi               $_view(psi)
    245         $this-speed             500
    246         $this-step              0
    247         $this-streams           0
    248         $this-theta             $_view(theta)
    249         $this-volume            1
    250         $this-xcutplane         0
    251         $this-xcutposition      0
    252         $this-ycutplane         0
    253         $this-ycutposition      0
    254         $this-zcutplane         0
    255         $this-zcutposition      0
    256         $this-zoom              $_view(zoom)
     235        $this-arrows                0
     236        $this-currenttime        0
     237        $this-duration                1:00
     238        $this-loop                0
     239        $this-pan-x                $_view(pan-x)
     240        $this-pan-y                $_view(pan-y)
     241        $this-phi                $_view(phi)
     242        $this-play                0
     243        $this-psi                $_view(psi)
     244        $this-speed                500
     245        $this-step                0
     246        $this-streams                0
     247        $this-theta                $_view(theta)
     248        $this-volume                1
     249        $this-xcutplane                0
     250        $this-xcutposition        0
     251        $this-ycutplane                0
     252        $this-ycutposition        0
     253        $this-zcutplane                0
     254        $this-zcutposition        0
     255        $this-zoom                $_view(zoom)
    257256    }]
    258257
    259258    itk_component add 3dview {
    260         label $itk_component(plotarea).vol -image $_image(plot) \
    261             -highlightthickness 0 -borderwidth 0
     259        label $itk_component(plotarea).vol -image $_image(plot) \
     260            -highlightthickness 0 -borderwidth 0
    262261    } {
    263         usual
    264         ignore -highlightthickness -borderwidth  -background
     262        usual
     263        ignore -highlightthickness -borderwidth  -background
    265264    }
    266265    set f [$itk_component(main) component controls]
     
    303302    itk_component add volume {
    304303        Rappture::PushButton $f.volume \
    305             -onimage [Rappture::icon volume-on] \
    306             -offimage [Rappture::icon volume-off] \
    307             -command [itcl::code $this FixSettings volume] \
    308             -variable [itcl::scope _settings($this-volume)]
     304            -onimage [Rappture::icon volume-on] \
     305            -offimage [Rappture::icon volume-off] \
     306            -command [itcl::code $this FixSettings volume] \
     307            -variable [itcl::scope _settings($this-volume)]
    309308    }
    310309    $itk_component(volume) select
     
    319318
    320319    bind $itk_component(3dview) <Configure> \
    321         [itcl::code $this EventuallyResize %w %h]
     320        [itcl::code $this EventuallyResize %w %h]
    322321
    323322    # Legend
     
    331330    }
    332331    bind $itk_component(legend) <Configure> \
    333         [itcl::code $this EventuallyResizeLegend]
     332        [itcl::code $this EventuallyResizeLegend]
    334333
    335334    # Hack around the Tk panewindow.  The problem is that the requested
     
    339338    pack forget $itk_component(3dview)
    340339    blt::table $itk_component(plotarea) \
    341         0,0 $itk_component(3dview) -fill both -reqwidth $w \
    342         1,0 $itk_component(legend) -fill x
     340        0,0 $itk_component(3dview) -fill both -reqwidth $w \
     341        1,0 $itk_component(legend) -fill x
    343342    blt::table configure $itk_component(plotarea) r1 -resize none   
    344343    # Create flow controls...
     
    347346        frame $itk_interior.flowcontrols
    348347    } {
    349         usual
     348        usual
    350349        rename -background -controlbackground controlBackground Background
    351350    }
    352351    pack forget $itk_component(main)
    353352    blt::table $itk_interior \
    354         0,0 $itk_component(main) -fill both  \
    355         1,0 $itk_component(flowcontrols) -fill x
     353        0,0 $itk_component(main) -fill both  \
     354        1,0 $itk_component(flowcontrols) -fill x
    356355    blt::table configure $itk_interior r1 -resize none
    357356
     
    361360            -borderwidth 1 -padx 1 -pady 1 \
    362361            -image [Rappture::icon flow-rewind] \
    363             -command [itcl::code $this flow reset]
     362            -command [itcl::code $this flow reset]
    364363    } {
    365364        usual
    366365        ignore -borderwidth
    367366        rename -highlightbackground -controlbackground controlBackground \
    368             Background
     367            Background
    369368    }
    370369    Rappture::Tooltip::for $itk_component(rewind) \
     
    376375            -borderwidth 1 -padx 1 -pady 1 \
    377376            -image [Rappture::icon flow-stop] \
    378             -command [itcl::code $this flow stop]
     377            -command [itcl::code $this flow stop]
    379378    } {
    380379        usual
    381380        ignore -borderwidth
    382381        rename -highlightbackground -controlbackground controlBackground \
    383             Background
     382            Background
    384383    }
    385384    Rappture::Tooltip::for $itk_component(stop) \
     
    389388    itk_component add play {
    390389        Rappture::PushButton $itk_component(flowcontrols).play \
    391             -onimage [Rappture::icon flow-pause] \
    392             -offimage [Rappture::icon flow-play] \
    393             -variable [itcl::scope _settings($this-play)] \
    394             -command [itcl::code $this flow toggle]
     390            -onimage [Rappture::icon flow-pause] \
     391            -offimage [Rappture::icon flow-play] \
     392            -variable [itcl::scope _settings($this-play)] \
     393            -command [itcl::code $this flow toggle]
    395394    }
    396395    set fg [option get $itk_component(hull) font Font]
     
    401400    itk_component add loop {
    402401        Rappture::PushButton $itk_component(flowcontrols).loop \
    403             -onimage [Rappture::icon flow-loop] \
    404             -offimage [Rappture::icon flow-loop] \
    405             -variable [itcl::scope _settings($this-loop)]
     402            -onimage [Rappture::icon flow-loop] \
     403            -offimage [Rappture::icon flow-loop] \
     404            -variable [itcl::scope _settings($this-loop)]
    406405    }
    407406    Rappture::Tooltip::for $itk_component(loop) \
     
    412411            -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \
    413412            -linecolor "" -activelinecolor "" \
    414             -min 0.0 -max 1.0 \
    415             -variable [itcl::scope _settings($this-currenttime)] \
     413            -min 0.0 -max 1.0 \
     414            -variable [itcl::scope _settings($this-currenttime)] \
    416415            -knobimage [Rappture::icon knob2] -knobposition center@middle
    417416    } {
     
    424423    # Duration
    425424    itk_component add duration {
    426         entry $itk_component(flowcontrols).duration \
    427             -textvariable [itcl::scope _settings($this-duration)] \
    428             -bg white -width 6 -font "arial 9"
     425        entry $itk_component(flowcontrols).duration \
     426            -textvariable [itcl::scope _settings($this-duration)] \
     427            -bg white -width 6 -font "arial 9"
    429428    } {
    430429        usual
    431         ignore -highlightthickness -background
     430        ignore -highlightthickness -background
    432431    }
    433432    bind $itk_component(duration) <Return> [itcl::code $this flow duration]
     
    438437
    439438    itk_component add durationlabel {
    440         label $itk_component(flowcontrols).durationl \
    441             -text "Duration:" -font $fg \
    442             -highlightthickness 0
     439        label $itk_component(flowcontrols).durationl \
     440            -text "Duration:" -font $fg \
     441            -highlightthickness 0
    443442    } {
    444443        usual
    445         ignore -highlightthickness
     444        ignore -highlightthickness
    446445        rename -background -controlbackground controlBackground Background
    447446    }
    448447
    449448    itk_component add speedlabel {
    450         label $itk_component(flowcontrols).speedl -text "Speed:" -font $fg \
    451             -highlightthickness 0
     449        label $itk_component(flowcontrols).speedl -text "Speed:" -font $fg \
     450            -highlightthickness 0
    452451    } {
    453452        usual
    454         ignore -highlightthickness
     453        ignore -highlightthickness
    455454        rename -background -controlbackground controlBackground Background
    456455    }
     
    458457    # Speed
    459458    itk_component add speed {
    460         Rappture::Flowspeed $itk_component(flowcontrols).speed \
    461             -min 1 -max 10 -width 3 -font "arial 9"
     459        Rappture::Flowspeed $itk_component(flowcontrols).speed \
     460            -min 1 -max 10 -width 3 -font "arial 9"
    462461    } {
    463462        usual
    464         ignore -highlightthickness
     463        ignore -highlightthickness
    465464        rename -background -controlbackground controlBackground Background
    466465    }
     
    473472
    474473    blt::table $itk_component(flowcontrols) \
    475         0,0 $itk_component(rewind) -padx {3 0} \
    476         0,1 $itk_component(stop) -padx {2 0} \
    477         0,2 $itk_component(play) -padx {2 0} \
    478         0,3 $itk_component(loop) -padx {2 0} \
    479         0,4 $itk_component(dial) -fill x -padx {2 0 } \
    480         0,5 $itk_component(duration) -padx { 0 0} \
    481         0,7 $itk_component(speed) -padx {2 3}
    482 
    483 #       0,6 $itk_component(speedlabel) -padx {2 0}
     474        0,0 $itk_component(rewind) -padx {3 0} \
     475        0,1 $itk_component(stop) -padx {2 0} \
     476        0,2 $itk_component(play) -padx {2 0} \
     477        0,3 $itk_component(loop) -padx {2 0} \
     478        0,4 $itk_component(dial) -fill x -padx {2 0 } \
     479        0,5 $itk_component(duration) -padx { 0 0} \
     480        0,7 $itk_component(speed) -padx {2 3}
     481
     482#        0,6 $itk_component(speedlabel) -padx {2 0}
    484483    blt::table configure $itk_component(flowcontrols) c* -resize none
    485484    blt::table configure $itk_component(flowcontrols) c4 -resize both
     
    494493
    495494    bind $itk_component(3dview) <Configure> \
    496         [itcl::code $this EventuallyResize %w %h]
     495        [itcl::code $this EventuallyResize %w %h]
    497496
    498497    # Bindings for panning via mouse
     
    585584    }
    586585    foreach comp [$dataobj components] {
    587         set flowobj [$dataobj flowhints $comp]
    588         if { $flowobj == "" } {
    589             puts stderr "no flowhints $dataobj-$comp"
    590             continue
    591         }
    592         set _obj2flow($dataobj-$comp) $flowobj
     586        set flowobj [$dataobj flowhints $comp]
     587        if { $flowobj == "" } {
     588            puts stderr "no flowhints $dataobj-$comp"
     589            continue
     590        }
     591        set _obj2flow($dataobj-$comp) $flowobj
    593592    }
    594593    set pos [lsearch -exact $dataobj $_dlist]
     
    673672        set pos [lsearch -exact $_dlist $dataobj]
    674673        if { $pos >= 0 } {
    675             foreach comp [$dataobj components] {
    676                 array unset _limits $dataobj-$comp-*
    677             }
    678             set _dlist [lreplace $_dlist $pos $pos]
    679             array unset _obj2ovride $dataobj-*
    680             array unset _obj2flow $dataobj-*
    681             array unset _serverObjs $dataobj-*
    682             array unset _obj2style $dataobj-*
     674            foreach comp [$dataobj components] {
     675                array unset _limits $dataobj-$comp-*
     676            }
     677            set _dlist [lreplace $_dlist $pos $pos]
     678            array unset _obj2ovride $dataobj-*
     679            array unset _obj2flow $dataobj-*
     680            array unset _serverObjs $dataobj-*
     681            array unset _obj2style $dataobj-*
    683682            set changed 1
    684683        }
     
    686685    # If anything changed, then rebuild the plot
    687686    if {$changed} {
    688         # Repair the reverse lookup
    689         foreach tf [array names _style2objs] {
    690             set list {}
    691             foreach {dataobj comp} $_style2objs($tf) break
    692             if { [info exists _serverObjs($dataobj-$comp)] } {
    693                 lappend list $dataobj $comp
    694             }
    695             if { $list == "" } {
    696                 array unset _style2objs $tf
    697             } else {
    698                 set _style2objs($tf) $list
    699             }
    700         }
     687        # Repair the reverse lookup
     688        foreach tf [array names _style2objs] {
     689            set list {}
     690            foreach {dataobj comp} $_style2objs($tf) break
     691            if { [info exists _serverObjs($dataobj-$comp)] } {
     692                lappend list $dataobj $comp
     693            }
     694            if { $list == "" } {
     695                array unset _style2objs $tf
     696            } else {
     697                set _style2objs($tf) $list
     698            }
     699        }
    701700        $_dispatcher event -idle !rebuild
    702701    }
     
    753752        coming {
    754753            if {[catch {
    755                 blt::winop snap $itk_component(plotarea) $_image(download)
    756             }]} {
     754                blt::winop snap $itk_component(plotarea) $_image(download)
     755            }]} {
    757756                $_image(download) configure -width 1 -height 1
    758757                $_image(download) put #000000
     
    760759        }
    761760        controls {
    762             if {![winfo exists $popup]} {
    763                 # if we haven't created the popup yet, do it now
    764                 Rappture::Balloon $popup \
    765                     -title "[Rappture::filexfer::label downloadWord] as..."
    766                 set inner [$popup component inner]
    767                 label $inner.summary -text "" -anchor w
    768                 pack $inner.summary -side top
    769                 set img $_image(plot)
    770                 set res "[image width $img]x[image height $img]"
    771                 radiobutton $inner.draft -text "Image (draft $res)" \
    772                     -variable Rappture::FlowvisViewer::_downloadPopup(format) \
    773                     -value draft
    774                 pack $inner.draft -anchor w
    775 
    776                 set res "640x480"
    777                 radiobutton $inner.medium -text "Movie (standard $res)" \
    778                     -variable Rappture::FlowvisViewer::_downloadPopup(format) \
    779                     -value $res
    780                 pack $inner.medium -anchor w
    781 
    782                 set res "1024x768"
    783                 radiobutton $inner.high -text "Movie (high quality $res)" \
    784                     -variable Rappture::FlowvisViewer::_downloadPopup(format) \
    785                     -value $res
    786                 pack $inner.high -anchor w
    787                 button $inner.go -text [Rappture::filexfer::label download] \
    788                     -command [lindex $args 0]
    789                 pack $inner.go -pady 4
    790                 $inner.draft select
    791             } else {
    792                 set inner [$popup component inner]
    793             }
    794             set num [llength [get]]
    795             set num [expr {($num == 1) ? "1 result" : "$num results"}]
    796             set word [Rappture::filexfer::label downloadWord]
    797             $inner.summary configure -text "$word $num in the following format:"
    798             update idletasks ;# fix initial sizes
    799             return $popup
    800         }
     761            if {![winfo exists $popup]} {
     762                # if we haven't created the popup yet, do it now
     763                Rappture::Balloon $popup \
     764                    -title "[Rappture::filexfer::label downloadWord] as..."
     765                set inner [$popup component inner]
     766                label $inner.summary -text "" -anchor w
     767                pack $inner.summary -side top
     768                set img $_image(plot)
     769                set res "[image width $img]x[image height $img]"
     770                radiobutton $inner.draft -text "Image (draft $res)" \
     771                    -variable Rappture::FlowvisViewer::_downloadPopup(format) \
     772                    -value draft
     773                pack $inner.draft -anchor w
     774
     775                set res "640x480"
     776                radiobutton $inner.medium -text "Movie (standard $res)" \
     777                    -variable Rappture::FlowvisViewer::_downloadPopup(format) \
     778                    -value $res
     779                pack $inner.medium -anchor w
     780
     781                set res "1024x768"
     782                radiobutton $inner.high -text "Movie (high quality $res)" \
     783                    -variable Rappture::FlowvisViewer::_downloadPopup(format) \
     784                    -value $res
     785                pack $inner.high -anchor w
     786                button $inner.go -text [Rappture::filexfer::label download] \
     787                    -command [lindex $args 0]
     788                pack $inner.go -pady 4
     789                $inner.draft select
     790            } else {
     791                set inner [$popup component inner]
     792            }
     793            set num [llength [get]]
     794            set num [expr {($num == 1) ? "1 result" : "$num results"}]
     795            set word [Rappture::filexfer::label downloadWord]
     796            $inner.summary configure -text "$word $num in the following format:"
     797            update idletasks ;# fix initial sizes
     798            return $popup
     799        }
    801800        now {
    802             if { [winfo exists $popup] } {
    803                 $popup deactivate
    804             }
    805             switch -- $_downloadPopup(format) {
    806                 draft {
    807                     # Get the image data (as base64) and decode it back to
    808                     # binary.  This is better than writing to temporary
    809                     # files.  When we switch to the BLT picture image it
    810                     # won't be necessary to decode the image data.
    811                     set bytes [$_image(plot) data -format "jpeg -quality 100"]
    812                     set bytes [Rappture::encoding::decode -as b64 $bytes]
    813                     return [list .jpg $bytes]
    814                 }
    815                 "640x480" {
    816                     return [$this GetMovie [lindex $args 0] 640 480]
    817                 }
    818                 "1024x768" {
    819                     return [$this GetMovie [lindex $args 0] 1024 768]
    820                 }
    821                 default {
    822                     error "bad download format $_downloadPopup(format)"
    823                 }
    824             }
    825         }
     801            if { [winfo exists $popup] } {
     802                $popup deactivate
     803            }
     804            switch -- $_downloadPopup(format) {
     805                draft {
     806                    # Get the image data (as base64) and decode it back to
     807                    # binary.  This is better than writing to temporary
     808                    # files.  When we switch to the BLT picture image it
     809                    # won't be necessary to decode the image data.
     810                    set bytes [$_image(plot) data -format "jpeg -quality 100"]
     811                    set bytes [Rappture::encoding::decode -as b64 $bytes]
     812                    return [list .jpg $bytes]
     813                }
     814                "640x480" {
     815                    return [$this GetMovie [lindex $args 0] 640 480]
     816                }
     817                "1024x768" {
     818                    return [$this GetMovie [lindex $args 0] 1024 768]
     819                }
     820                default {
     821                    error "bad download format $_downloadPopup(format)"
     822                }
     823            }
     824        }
    826825        default {
    827826            error "bad option \"$option\": should be coming, controls, now"
     
    898897itcl::body Rappture::FlowvisViewer::SendCmd { string } {
    899898    if { $_buffering } {
    900         append _outbuf $string "\n"
     899        append _outbuf $string "\n"
    901900    } else {
    902         foreach line [split $string \n] {
    903             SendEcho >>line $line
    904         }
    905         SendBytes "$string\n"
     901        foreach line [split $string \n] {
     902            SendEcho >>line $line
     903        }
     904        SendBytes "$string\n"
    906905    }
    907906}
     
    921920        foreach comp [$dataobj components] {
    922921            # Send the data as one huge base64-encoded mess -- yuck!
    923             set data [$dataobj blob $comp]
    924             set nbytes [string length $data]
    925             set extents [$dataobj extents $comp]
    926 
    927             # I have a field. Is a vector field or a volume field?
    928             if { $extents == 1 } {
    929                 set cmd "volume data follows $nbytes $dataobj-$comp\n"
    930             } else {
    931                 set cmd [FlowCmd $dataobj $comp $nbytes $extents]
    932                 if { $cmd == "" } {
    933                     puts stderr "no command"
    934                     continue
    935                 }
    936             }
    937             f { ![SendBytes $cmd] } {
    938                 puts stderr "can't send"
    939                 return
    940             }
     922            set data [$dataobj blob $comp]
     923            set nbytes [string length $data]
     924            set extents [$dataobj extents $comp]
     925
     926            # I have a field. Is a vector field or a volume field?
     927            if { $extents == 1 } {
     928                set cmd "volume data follows $nbytes $dataobj-$comp\n"
     929            } else {
     930                set cmd [FlowCmd $dataobj $comp $nbytes $extents]
     931                if { $cmd == "" } {
     932                    puts stderr "no command"
     933                    continue
     934                }
     935            }
     936            f { ![SendBytes $cmd] } {
     937                puts stderr "can't send"
     938                return
     939            }
    941940            if { ![SendBytes $data] } {
    942                 puts stderr "can't send"
     941                puts stderr "can't send"
    943942                return
    944943            }
     
    963962        }
    964963
    965         if 0 {
    966         set location [$_first hints camera]
    967         if { $location != "" } {
    968             array set _view $location
    969         }
    970         set _settings($this-theta) $_view(theta)
    971         set _settings($this-phi)   $_view(phi)
    972         set _settings($this-psi)   $_view(psi)
    973         set _settings($this-pan-x) $_view(pan-x)
    974         set _settings($this-pan-y) $_view(pan-y)
    975         set _settings($this-zoom)  $_view(zoom)
    976         set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    977         SendCmd "camera angle $xyz"
    978         PanCamera
    979         SendCmd "camera zoom $_view(zoom)"
    980         }
     964        if 0 {
     965        set location [$_first hints camera]
     966        if { $location != "" } {
     967            array set _view $location
     968        }
     969        set _settings($this-theta) $_view(theta)
     970        set _settings($this-phi)   $_view(phi)
     971        set _settings($this-psi)   $_view(psi)
     972        set _settings($this-pan-x) $_view(pan-x)
     973        set _settings($this-pan-y) $_view(pan-y)
     974        set _settings($this-zoom)  $_view(zoom)
     975        set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     976        SendCmd "camera angle $xyz"
     977        PanCamera
     978        SendCmd "camera zoom $_view(zoom)"
     979        }
    981980        # The active transfer function is by default the first component of
    982981        # the first data object.  This assumes that the data is always
     
    990989    # Actually write the commands to the server socket.  If it fails, we don't
    991990    # care.  We're finished here.
    992     SendBytes $_outbuf;                 
    993     set _buffering 0;                   # Turn off buffering.
    994     set _outbuf "";                     # Clear the buffer.             
     991    SendBytes $_outbuf;                       
     992    set _buffering 0;                        # Turn off buffering.
     993    set _outbuf "";                        # Clear the buffer.               
    995994}
    996995
     
    1000999itcl::body Rappture::FlowvisViewer::SendTransferFuncs {} {
    10011000    if { $_activeTf == "" } {
    1002         puts stderr "no active tf"
    1003         return
     1001        puts stderr "no active tf"
     1002        return
    10041003    }
    10051004    set tf $_activeTf
    10061005    if { $_first == "" } {
    1007         puts stderr "no first"
    1008         return
     1006        puts stderr "no first"
     1007        return
    10091008    }
    10101009
     
    10211020
    10221021    foreach key [array names _obj2style $_first-*] {
    1023         if { [info exists _obj2style($key)] } {
    1024             foreach tf $_obj2style($key) {
    1025                 ComputeTransferFunc $tf
    1026             }
    1027         }
     1022        if { [info exists _obj2style($key)] } {
     1023            foreach tf $_obj2style($key) {
     1024                ComputeTransferFunc $tf
     1025            }
     1026        }
    10281027    }
    10291028    EventuallyResizeLegend
     
    10391038itcl::body Rappture::FlowvisViewer::ReceiveImage { args } {
    10401039    array set info {
    1041         -token "???"
    1042         -bytes 0
    1043         -type image
     1040        -token "???"
     1041        -bytes 0
     1042        -type image
    10441043    }
    10451044    array set info $args
     
    10471046    ReceiveEcho <<line "<read $info(-bytes) bytes"
    10481047    switch -- $info(-type)  {
    1049         "image" {
    1050             $_image(plot) configure -data $bytes
    1051             #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]"
    1052         }
    1053         "print" {
    1054             set tag $this-$info(-token)
    1055             set _hardcopy($tag) $bytes
    1056         }
    1057         "movie" {
    1058             puts stderr "read [string length $bytes] bytes type=$info(-type) token=$info(-token)"
    1059             set tag $this-$info(-token)
    1060             set _hardcopy($tag) $bytes
    1061         }
    1062         default {
    1063             puts stderr "unknown download type $info(-type)"
    1064         }
     1048        "image" {
     1049            $_image(plot) configure -data $bytes
     1050            #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]"
     1051        }
     1052        "print" {
     1053            set tag $this-$info(-token)
     1054            set _hardcopy($tag) $bytes
     1055        }
     1056        "movie" {
     1057            puts stderr "read [string length $bytes] bytes type=$info(-type) token=$info(-token)"
     1058            set tag $this-$info(-token)
     1059            set _hardcopy($tag) $bytes
     1060        }
     1061        default {
     1062            puts stderr "unknown download type $info(-type)"
     1063        }
    10651064    }
    10661065}
     
    11231122# ReceiveData --
    11241123#
    1125 #       The procedure is the response from the render server to each "data
    1126 #       follows" command.  The server sends back a "data" command invoked our
    1127 #       the slave interpreter.  The purpose is to collect the min/max of the
    1128 #       volume sent to the render server.  Since the client (flowvisviewer)
    1129 #       doesn't parse 3D data formats, we rely on the server (flowvis) to
    1130 #       tell us what the limits are.  Once we've received the limits to all
    1131 #       the data we've sent (tracked by _recvObjs) we can then determine
    1132 #       what the transfer functions are for these # volumes.
     1124#        The procedure is the response from the render server to each "data
     1125#        follows" command.  The server sends back a "data" command invoked our
     1126#        the slave interpreter.  The purpose is to collect the min/max of the
     1127#        volume sent to the render server.  Since the client (flowvisviewer)
     1128#        doesn't parse 3D data formats, we rely on the server (flowvis) to
     1129#        tell us what the limits are.  Once we've received the limits to all
     1130#        the data we've sent (tracked by _recvObjs) we can then determine
     1131#        what the transfer functions are for these # volumes.
    11331132#
    11341133#       Note: There is a considerable tradeoff in having the server report
     
    11891188        foreach comp [$dataobj components] {
    11901189            # Send the data as one huge base64-encoded mess -- yuck!
    1191             set data [$dataobj blob $comp]
    1192             set nbytes [string length $data]
    1193             set extents [$dataobj extents $comp]
    1194             # I have a field. Is a vector field or a volume field?
    1195             if { $extents == 1 } {
    1196                 set cmd "volume data follows $nbytes $dataobj-$comp\n"
    1197             } else {
    1198                 set cmd [FlowCmd $dataobj $comp $nbytes $extents]
    1199                 if { $cmd == "" } {
    1200                     puts stderr "no command"
    1201                     continue
    1202                 }
    1203             }
    1204             append _outbuf $cmd
     1190            set data [$dataobj blob $comp]
     1191            set nbytes [string length $data]
     1192            set extents [$dataobj extents $comp]
     1193            # I have a field. Is a vector field or a volume field?
     1194            if { $extents == 1 } {
     1195                set cmd "volume data follows $nbytes $dataobj-$comp\n"
     1196            } else {
     1197                set cmd [FlowCmd $dataobj $comp $nbytes $extents]
     1198                if { $cmd == "" } {
     1199                    puts stderr "no command"
     1200                    continue
     1201                }
     1202            }
     1203            append _outbuf $cmd
    12051204            append _outbuf $data
    12061205            NameTransferFunc $dataobj $comp
     
    12221221    # nothing to send -- activate the proper volume
    12231222    if {"" != $_first} {
    1224         FixSettings light
    1225         FixSettings transp
     1223        FixSettings light
     1224        FixSettings transp
    12261225        set axis [$_first hints updir]
    12271226        if {"" != $axis} {
    12281227            SendCmd "up $axis"
    12291228        }
    1230         set location [$_first hints camera]
    1231         if { $location != "" } {
    1232             array set _view $location
    1233         }
     1229        set location [$_first hints camera]
     1230        if { $location != "" } {
     1231            array set _view $location
     1232        }
    12341233    }
    12351234    set _settings($this-theta) $_view(theta)
     
    12471246    foreach dataobj [get] {
    12481247        foreach comp [$dataobj components] {
    1249             NameTransferFunc $dataobj $comp
     1248            NameTransferFunc $dataobj $comp
    12501249        }
    12511250    }
     
    12581257            SendCmd "up $axis"
    12591258        }
    1260         set location [$_first hints camera]
    1261         if { $location != "" } {
    1262             array set _view $location
    1263         }
     1259        set location [$_first hints camera]
     1260        if { $location != "" } {
     1261            array set _view $location
     1262        }
    12641263        set comp [lindex [$_first components] 0]
    12651264        set _activeTf [lindex $_obj2style($_first-$comp) 0]
     
    12701269    set vols [CurrentVolumeIds -cutplanes]
    12711270    foreach axis {x y z} {
    1272         SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols"
    1273         set pos [expr {0.01*$_settings($this-${axis}cutposition)}]
    1274         SendCmd "cutplane position $pos $axis $vols"
     1271        SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols"
     1272        set pos [expr {0.01*$_settings($this-${axis}cutposition)}]
     1273        SendCmd "cutplane position $pos $axis $vols"
    12751274    }
    12761275    SendCmd "volume data state $_settings($this-volume)"
     
    12821281    SendBytes $_outbuf
    12831282    blt::busy release $itk_component(hull)
    1284     set _buffering 0;                   # Turn off buffering.
    1285     set _outbuf "";                     # Clear the buffer.             
     1283    set _buffering 0;                        # Turn off buffering.
     1284    set _outbuf "";                        # Clear the buffer.               
    12861285}
    12871286
     
    12961295    return ""
    12971296    if { $_first == "" } {
    1298         return
     1297        return
    12991298    }
    13001299    foreach key [array names _serverObjs *-*] {
     
    13231322itcl::body Rappture::FlowvisViewer::Zoom {option} {
    13241323    switch -- $option {
    1325         "in" {
    1326             set _view(zoom) [expr {$_view(zoom)*1.25}]
    1327             set _settings($this-zoom) $_view(zoom)
    1328         }
    1329         "out" {
    1330             set _view(zoom) [expr {$_view(zoom)*0.8}]
    1331             set _settings($this-zoom) $_view(zoom)
    1332         }
     1324        "in" {
     1325            set _view(zoom) [expr {$_view(zoom)*1.25}]
     1326            set _settings($this-zoom) $_view(zoom)
     1327        }
     1328        "out" {
     1329            set _view(zoom) [expr {$_view(zoom)*0.8}]
     1330            set _settings($this-zoom) $_view(zoom)
     1331        }
    13331332        "reset" {
    1334             array set _view {
    1335                 theta   45
    1336                 phi     45
    1337                 psi     0
    1338                 zoom    1.0
    1339                 pan-x   0
    1340                 pan-y   0
    1341             }
    1342             if { $_first != "" } {
    1343                 set location [$_first hints camera]
    1344                 if { $location != "" } {
    1345                     array set _view $location
    1346                 }
    1347             }
     1333            array set _view {
     1334                theta   45
     1335                phi     45
     1336                psi     0
     1337                zoom        1.0
     1338                pan-x        0
     1339                pan-y        0
     1340            }
     1341            if { $_first != "" } {
     1342                set location [$_first hints camera]
     1343                if { $location != "" } {
     1344                    array set _view $location
     1345                }
     1346            }
    13481347            set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    13491348            SendCmd "camera angle $xyz"
    1350             PanCamera
    1351             set _settings($this-theta) $_view(theta)
    1352             set _settings($this-phi)   $_view(phi)
    1353             set _settings($this-psi)   $_view(psi)
    1354             set _settings($this-pan-x) $_view(pan-x)
    1355             set _settings($this-pan-y) $_view(pan-y)
    1356             set _settings($this-zoom)  $_view(zoom)
     1349            PanCamera
     1350            set _settings($this-theta) $_view(theta)
     1351            set _settings($this-phi)   $_view(phi)
     1352            set _settings($this-psi)   $_view(psi)
     1353            set _settings($this-pan-x) $_view(pan-x)
     1354            set _settings($this-pan-y) $_view(pan-y)
     1355            set _settings($this-zoom)  $_view(zoom)
    13571356        }
    13581357    }
     
    14261425                }
    14271426
    1428                 set _view(theta)        $theta
    1429                 set _view(phi)          $phi
    1430                 set _view(psi)          $psi
     1427                set _view(theta)        $theta
     1428                set _view(phi)          $phi
     1429                set _view(psi)          $psi
    14311430                set xyz [Euler2XYZ $theta $phi $psi]
    1432                 set _settings($this-theta) $_view(theta)
    1433                 set _settings($this-phi)   $_view(phi)
    1434                 set _settings($this-psi)   $_view(psi)
     1431                set _settings($this-theta) $_view(theta)
     1432                set _settings($this-phi)   $_view(phi)
     1433                set _settings($this-psi)   $_view(psi)
    14351434                SendCmd "camera angle $xyz"
    14361435                set _click(x) $x
     
    14671466        set _view(pan-y) [expr $_view(pan-y) + $y]
    14681467        PanCamera
    1469         set _settings($this-pan-x) $_view(pan-x)
    1470         set _settings($this-pan-y) $_view(pan-y)
     1468        set _settings($this-pan-x) $_view(pan-x)
     1469        set _settings($this-pan-y) $_view(pan-y)
    14711470        return
    14721471    }
     
    14841483        set _view(pan-y) [expr $_view(pan-y) - $dy]
    14851484        PanCamera
    1486         set _settings($this-pan-x) $_view(pan-x)
    1487         set _settings($this-pan-y) $_view(pan-y)
     1485        set _settings($this-pan-x) $_view(pan-x)
     1486        set _settings($this-pan-y) $_view(pan-y)
    14881487    }
    14891488    if { $option == "release" } {
     
    15201519            switch -- $action {
    15211520                record {
    1522                     if { [$itk_component(rewind) cget -relief] != "sunken" } {
    1523                         $itk_component(rewind) configure -relief sunken
    1524                         $itk_component(stop) configure -relief raised
    1525                         $itk_component(play) configure -relief raised
    1526                         set inner $itk_component(settingsFrame)
    1527                         set frames [$inner.framecnt value]
    1528                         set _settings(nsteps) $frames
    1529                         set cmds "flow capture $frames"
    1530                         SendCmd $cmds
    1531                     }
     1521                    if { [$itk_component(rewind) cget -relief] != "sunken" } {
     1522                        $itk_component(rewind) configure -relief sunken
     1523                        $itk_component(stop) configure -relief raised
     1524                        $itk_component(play) configure -relief raised
     1525                        set inner $itk_component(settingsFrame)
     1526                        set frames [$inner.framecnt value]
     1527                        set _settings(nsteps) $frames
     1528                        set cmds "flow capture $frames"
     1529                        SendCmd $cmds
     1530                    }
    15321531                }
    15331532                stop {
    1534                     if { [$itk_component(stop) cget -relief] != "sunken" } {
    1535                         $itk_component(rewind) configure -relief raised
    1536                         $itk_component(stop) configure -relief sunken
    1537                         $itk_component(play) configure -relief raised
    1538                         _pause
    1539                         set cmds "flow reset"
    1540                         SendCmd $cmds
    1541                     }
     1533                    if { [$itk_component(stop) cget -relief] != "sunken" } {
     1534                        $itk_component(rewind) configure -relief raised
     1535                        $itk_component(stop) configure -relief sunken
     1536                        $itk_component(play) configure -relief raised
     1537                        _pause
     1538                        set cmds "flow reset"
     1539                        SendCmd $cmds
     1540                    }
    15421541                }
    15431542                play {
    1544                     if { [$itk_component(play) cget -relief] != "sunken" } {
    1545                         $itk_component(rewind) configure -relief raised
    1546                         $itk_component(stop) configure -relief raised
    1547                         $itk_component(play) configure \
    1548                             -image [Rappture::icon flow-pause] \
    1549                             -relief sunken
    1550                         bind $itk_component(play) <ButtonPress> \
    1551                             [itcl::code $this _pause]
    1552                         flow next
    1553                     }
     1543                    if { [$itk_component(play) cget -relief] != "sunken" } {
     1544                        $itk_component(rewind) configure -relief raised
     1545                        $itk_component(stop) configure -relief raised
     1546                        $itk_component(play) configure \
     1547                            -image [Rappture::icon flow-pause] \
     1548                            -relief sunken
     1549                        bind $itk_component(play) <ButtonPress> \
     1550                            [itcl::code $this _pause]
     1551                        flow next
     1552                    }
    15541553                }
    15551554                default {
     
    16031602        light {
    16041603            if { $_first != "" } {
    1605                 set comp [lindex [$_first components] 0]
    1606                 set tag $_first-$comp
     1604                set comp [lindex [$_first components] 0]
     1605                set tag $_first-$comp
    16071606                set diffuse [expr {0.1*$_settings($this-light)}]
    16081607                set specular [expr {sqrt($_settings($this-light)+1.0)}]
     
    16121611        transp {
    16131612            if { $_first != "" } {
    1614                 set comp [lindex [$_first components] 0]
    1615                 set tag $_first-$comp
     1613                set comp [lindex [$_first components] 0]
     1614                set tag $_first-$comp
    16161615                set opacity [expr {0.2*$_settings($this-transp)+1}]
    16171616                SendCmd "$tag configure -opacity $opacity"
     
    16391638        "outline" {
    16401639            if { $_first != "" } {
    1641                 set comp [lindex [$_first components] 0]
    1642                 set tag $_first-$comp
     1640                set comp [lindex [$_first components] 0]
     1641                set tag $_first-$comp
    16431642                SendCmd "$tag configure -outline $_settings($this-outline)"
    16441643            }
     
    16461645        "isosurface" {
    16471646            if { [isconnected] } {
    1648                 SendCmd "volume shading isosurface $_settings($this-isosurface)"
    1649             }
     1647                SendCmd "volume shading isosurface $_settings($this-isosurface)"
     1648            }
    16501649        }
    16511650        "grid" {
     
    16591658            }
    16601659        }
    1661         "legend" {
    1662             if { $_settings($this-legend) } {
    1663                 blt::table $itk_component(plotarea) \
    1664                     0,0 $itk_component(3dview) -fill both \
    1665                     1,0 $itk_component(legend) -fill x
    1666                 blt::table configure $itk_component(plotarea) r1 -resize none
    1667             } else {
    1668                 blt::table forget $itk_component(legend)
    1669             }
    1670         }
     1660        "legend" {
     1661            if { $_settings($this-legend) } {
     1662                blt::table $itk_component(plotarea) \
     1663                    0,0 $itk_component(3dview) -fill both \
     1664                    1,0 $itk_component(legend) -fill x
     1665                blt::table configure $itk_component(plotarea) r1 -resize none
     1666            } else {
     1667                blt::table forget $itk_component(legend)
     1668            }
     1669        }
    16711670        "volume" {
    16721671            if { $_first != "" } {
    1673                 set comp [lindex [$_first components] 0]
    1674                 set tag $_first-$comp
     1672                set comp [lindex [$_first components] 0]
     1673                set tag $_first-$comp
    16751674                SendCmd "$tag configure -volume $_settings($this-volume)"
    1676             }
     1675            }
    16771676        }
    16781677        "xcutplane" - "ycutplane" - "zcutplane" {
    1679             set axis [string range $what 0 0]
    1680             set bool $_settings($this-$what)
     1678            set axis [string range $what 0 0]
     1679            set bool $_settings($this-$what)
    16811680            if { [isconnected] } {
    1682                 set vols [CurrentVolumeIds -cutplanes]
    1683                 SendCmd "cutplane state $bool $axis $vols"
    1684             }
    1685             if { $bool } {
    1686                 $itk_component(${axis}CutScale) configure -state normal \
    1687                     -troughcolor white
     1681                set vols [CurrentVolumeIds -cutplanes]
     1682                SendCmd "cutplane state $bool $axis $vols"
     1683            }
     1684            if { $bool } {
     1685                $itk_component(${axis}CutScale) configure -state normal \
     1686                    -troughcolor white
    16881687            } else {
    1689                 $itk_component(${axis}CutScale) configure -state disabled \
    1690                     -troughcolor grey82
     1688                $itk_component(${axis}CutScale) configure -state disabled \
     1689                    -troughcolor grey82
    16911690            }
    16921691        }
     
    17111710
    17121711    if { $_first == "" } {
    1713         return
     1712        return
    17141713    }
    17151714    set comp [lindex [$_first components] 0]
     
    17181717    if {$w > 0 && $h > 0 && "" != $_activeTf} {
    17191718        #SendCmd "legend $_activeTf $w $h"
    1720         SendCmd "$tag legend $w $h"
     1719        SendCmd "$tag legend $w $h"
    17211720    } else {
    17221721    # Can't do this as this will remove the items associated with the
     
    17471746        -levels 6
    17481747        -opacity 1.0
    1749         -light 40
    1750         -transp 50
     1748        -light 40
     1749        -transp 50
    17511750    }
    17521751    array set style [lindex [$dataobj components -style $comp] 0]
     
    17741773        -levels 6
    17751774        -opacity 1.0
    1776         -light 40
    1777         -transp 50
     1775        -light 40
     1776        -transp 50
    17781777    }
    17791778    set dataobj ""; set comp ""
     
    18101809    }
    18111810    if { [info exists style(-nonuniformcolors)] } {
    1812         foreach { value color } $style(-nonuniformcolors) {
    1813             append cmap "$value [Color2RGB $color] "
    1814         }
     1811        foreach { value color } $style(-nonuniformcolors) {
     1812            append cmap "$value [Color2RGB $color] "
     1813        }
    18151814    } else {
    1816         set clist [split $style(-color) :]
    1817         set cmap "0.0 [Color2RGB white] "
    1818         for {set i 0} {$i < [llength $clist]} {incr i} {
    1819             set x [expr {double($i+1)/([llength $clist]+1)}]
    1820             set color [lindex $clist $i]
    1821             append cmap "$x [Color2RGB $color] "
    1822         }
    1823         append cmap "1.0 [Color2RGB $color]"
     1815        set clist [split $style(-color) :]
     1816        set cmap "0.0 [Color2RGB white] "
     1817        for {set i 0} {$i < [llength $clist]} {incr i} {
     1818            set x [expr {double($i+1)/([llength $clist]+1)}]
     1819            set color [lindex $clist $i]
     1820            append cmap "$x [Color2RGB $color] "
     1821        }
     1822        append cmap "1.0 [Color2RGB $color]"
    18241823    }
    18251824    set tag $this-$tf
     
    20462045    set _limits(vmax) 1.0
    20472046    if { ![info exists _style2objs($tf)] } {
    2048         puts stderr "no style2objs for $tf tf=($tf)"
    2049         return [array get _limits]
     2047        puts stderr "no style2objs for $tf tf=($tf)"
     2048        return [array get _limits]
    20502049    }
    20512050    set min ""; set max ""
    20522051    foreach {dataobj comp} $_style2objs($tf) {
    2053         set tag $dataobj-$comp
    2054         if { ![info exists _serverObjs($tag)] } {
    2055             puts stderr "$tag not in serverObjs?"
    2056             continue
    2057         }
    2058         if { ![info exists _limits($tag-min)] } {
    2059             puts stderr "$tag no min?"
    2060             continue
    2061         }
    2062         if { $min == "" || $min > $_limits($tag-min) } {
    2063             set min $_limits($tag-min)
    2064         }
    2065         if { $max == "" || $max < $_limits($tag-max) } {
    2066             set max $_limits($tag-max)
    2067         }
     2052        set tag $dataobj-$comp
     2053        if { ![info exists _serverObjs($tag)] } {
     2054            puts stderr "$tag not in serverObjs?"
     2055            continue
     2056        }
     2057        if { ![info exists _limits($tag-min)] } {
     2058            puts stderr "$tag no min?"
     2059            continue
     2060        }
     2061        if { $min == "" || $min > $_limits($tag-min) } {
     2062            set min $_limits($tag-min)
     2063        }
     2064        if { $max == "" || $max < $_limits($tag-max) } {
     2065            set max $_limits($tag-max)
     2066        }
    20682067    }
    20692068    if { $min != "" } {
    2070         set _limits(vmin) $min
     2069        set _limits(vmin) $min
    20712070    }
    20722071    if { $max != "" } {
    2073         set _limits(vmax) $max
     2072        set _limits(vmax) $max
    20742073    }
    20752074    return [array get _limits]
     
    20802079itcl::body Rappture::FlowvisViewer::BuildViewTab {} {
    20812080    foreach { key value } {
    2082         grid            0
    2083         axes            0
    2084         outline         1
    2085         volume          1
    2086         legend          1
    2087         particles       1
    2088         lic             1
     2081        grid                0
     2082        axes                0
     2083        outline                1
     2084        volume                1
     2085        legend                1
     2086        particles        1
     2087        lic                1
    20892088    } {
    2090         set _settings($this-$key) $value
     2089        set _settings($this-$key) $value
    20912090    }
    20922091
     
    21042103        -variable [itcl::scope _settings($this-isosurface)] \
    21052104        -command [itcl::code $this FixSettings isosurface] \
    2106         -font "Arial 9"
     2105        -font "Arial 9"
    21072106
    21082107    checkbutton $inner.axes \
     
    21102109        -variable [itcl::scope _settings($this-axes)] \
    21112110        -command [itcl::code $this FixSettings axes] \
    2112         -font "Arial 9"
     2111        -font "Arial 9"
    21132112
    21142113    checkbutton $inner.grid \
     
    21162115        -variable [itcl::scope _settings($this-grid)] \
    21172116        -command [itcl::code $this FixSettings grid] \
    2118         -font "Arial 9"
     2117        -font "Arial 9"
    21192118
    21202119    checkbutton $inner.outline \
     
    21222121        -variable [itcl::scope _settings($this-outline)] \
    21232122        -command [itcl::code $this FixSettings outline] \
    2124         -font "Arial 9"
     2123        -font "Arial 9"
    21252124
    21262125    checkbutton $inner.legend \
     
    21282127        -variable [itcl::scope _settings($this-legend)] \
    21292128        -command [itcl::code $this FixSettings legend] \
    2130         -font "Arial 9"
     2129        -font "Arial 9"
    21312130
    21322131    checkbutton $inner.volume \
     
    21342133        -variable [itcl::scope _settings($this-volume)] \
    21352134        -command [itcl::code $this FixSettings volume] \
    2136         -font "Arial 9"
     2135        -font "Arial 9"
    21372136
    21382137    checkbutton $inner.particles \
     
    21402139        -variable [itcl::scope _settings($this-particles)] \
    21412140        -command [itcl::code $this FixSettings particles] \
    2142         -font "Arial 9"
     2141        -font "Arial 9"
    21432142
    21442143    checkbutton $inner.lic \
     
    21462145        -variable [itcl::scope _settings($this-lic)] \
    21472146        -command [itcl::code $this FixSettings lic] \
    2148         -font "Arial 9"
     2147        -font "Arial 9"
    21492148
    21502149    frame $inner.frame
    21512150
    21522151    blt::table $inner \
    2153         0,0 $inner.axes  -columnspan 2 -anchor w \
    2154         1,0 $inner.grid  -columnspan 2 -anchor w \
    2155         2,0 $inner.outline  -columnspan 2 -anchor w \
    2156         3,0 $inner.volume  -columnspan 2 -anchor w \
    2157         4,0 $inner.legend  -columnspan 2 -anchor w
     2152        0,0 $inner.axes  -columnspan 2 -anchor w \
     2153        1,0 $inner.grid  -columnspan 2 -anchor w \
     2154        2,0 $inner.outline  -columnspan 2 -anchor w \
     2155        3,0 $inner.volume  -columnspan 2 -anchor w \
     2156        4,0 $inner.legend  -columnspan 2 -anchor w
    21582157
    21592158    bind $inner <Map> [itcl::code $this GetFlowInfo $inner]
     
    21652164itcl::body Rappture::FlowvisViewer::BuildVolumeTab {} {
    21662165    foreach { key value } {
    2167         light           40
    2168         transp          50
    2169         opacity         100
    2170         thickness       350
     2166        light                40
     2167        transp                50
     2168        opacity                100
     2169        thickness        350
    21712170    } {
    2172         set _settings($this-$key) $value
     2171        set _settings($this-$key) $value
    21732172    }
    21742173
     
    21852184        -variable [itcl::scope _settings($this-volume)] \
    21862185        -command [itcl::code $this FixSettings volume] \
    2187         -font "Arial 9"
     2186        -font "Arial 9"
    21882187
    21892188    label $inner.shading -text "Shading:" -font $fg
     
    21922191    ::scale $inner.light -from 0 -to 100 -orient horizontal \
    21932192        -variable [itcl::scope _settings($this-light)] \
    2194         -width 10 \
     2193        -width 10 \
    21952194        -showvalue off -command [itcl::code $this FixSettings light]
    21962195    label $inner.bright -text "Bright" -font $fg
     
    21992198    ::scale $inner.transp -from 0 -to 100 -orient horizontal \
    22002199        -variable [itcl::scope _settings($this-transp)] \
    2201         -width 10 \
     2200        -width 10 \
    22022201        -showvalue off -command [itcl::code $this FixSettings transp]
    22032202    label $inner.plastic -text "Plastic" -font $fg
     
    22062205    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    22072206        -variable [itcl::scope _settings($this-opacity)] \
    2208         -width 10 \
     2207        -width 10 \
    22092208        -showvalue off -command [itcl::code $this FixSettings opacity]
    22102209    label $inner.opaque -text "Opaque" -font $fg
     
    22132212    ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \
    22142213        -variable [itcl::scope _settings($this-thickness)] \
    2215         -width 10 \
     2214        -width 10 \
    22162215        -showvalue off -command [itcl::code $this FixSettings thickness]
    22172216    label $inner.thick -text "Thick" -font $fg
    22182217
    22192218    blt::table $inner \
    2220         0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \
    2221         1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \
    2222         2,0 $inner.dim -anchor e -pady 2 \
    2223         2,1 $inner.light -columnspan 2 -pady 2 -fill x \
    2224         2,3 $inner.bright -anchor w -pady 2 \
    2225         3,0 $inner.fog -anchor e -pady 2 \
    2226         3,1 $inner.transp -columnspan 2 -pady 2 -fill x \
    2227         3,3 $inner.plastic -anchor w -pady 2 \
    2228         4,0 $inner.clear -anchor e -pady 2 \
    2229         4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
    2230         4,3 $inner.opaque -anchor w -pady 2 \
    2231         5,0 $inner.thin -anchor e -pady 2 \
    2232         5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\
    2233         5,3 $inner.thick -anchor w -pady 2
     2219        0,0 $inner.vol -columnspan 4 -anchor w -pady 2 \
     2220        1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \
     2221        2,0 $inner.dim -anchor e -pady 2 \
     2222        2,1 $inner.light -columnspan 2 -pady 2 -fill x \
     2223        2,3 $inner.bright -anchor w -pady 2 \
     2224        3,0 $inner.fog -anchor e -pady 2 \
     2225        3,1 $inner.transp -columnspan 2 -pady 2 -fill x \
     2226        3,3 $inner.plastic -anchor w -pady 2 \
     2227        4,0 $inner.clear -anchor e -pady 2 \
     2228        4,1 $inner.opacity -columnspan 2 -pady 2 -fill x\
     2229        4,3 $inner.opaque -anchor w -pady 2 \
     2230        5,0 $inner.thin -anchor e -pady 2 \
     2231        5,1 $inner.thickness -columnspan 2 -pady 2 -fill x\
     2232        5,3 $inner.thick -anchor w -pady 2
    22342233
    22352234    if 0 {
    2236         0,0 $inner.dim  -anchor e -pady 2 \
    2237         0,1 $inner.light -columnspan 2 -pady 2 \
    2238         0,3 $inner.bright -anchor w -pady 2 \
    2239         1,0 $inner.fog -anchor e -pady 2 \
    2240         1,1 $inner.transp -columnspan 2 -pady 2 \
    2241         1,3 $inner.plastic -anchor w -pady 2 \
    2242         2,0 $inner.clear -anchor e -pady 2 \
    2243         2,1 $inner.opacity -columnspan 2 -pady 2 \
    2244         2,3 $inner.opaque -anchor w -pady 2 \
    2245         3,0 $inner.thin -anchor e -pady 2 \
    2246         3,1 $inner.thickness -columnspan 2 -pady 2 \
    2247         3,3 $inner.thick -anchor w -pady 2
     2235        0,0 $inner.dim  -anchor e -pady 2 \
     2236        0,1 $inner.light -columnspan 2 -pady 2 \
     2237        0,3 $inner.bright -anchor w -pady 2 \
     2238        1,0 $inner.fog -anchor e -pady 2 \
     2239        1,1 $inner.transp -columnspan 2 -pady 2 \
     2240        1,3 $inner.plastic -anchor w -pady 2 \
     2241        2,0 $inner.clear -anchor e -pady 2 \
     2242        2,1 $inner.opacity -columnspan 2 -pady 2 \
     2243        2,3 $inner.opaque -anchor w -pady 2 \
     2244        3,0 $inner.thin -anchor e -pady 2 \
     2245        3,1 $inner.thickness -columnspan 2 -pady 2 \
     2246        3,3 $inner.thick -anchor w -pady 2
    22482247    }
    22492248    blt::table configure $inner c0 c1 c3 r* -resize none
     
    22602259    itk_component add xCutButton {
    22612260        Rappture::PushButton $inner.xbutton \
    2262             -onimage [Rappture::icon x-cutplane] \
    2263             -offimage [Rappture::icon x-cutplane] \
    2264             -command [itcl::code $this FixSettings xcutplane] \
    2265             -variable [itcl::scope _settings($this-xcutplane)]
     2261            -onimage [Rappture::icon x-cutplane] \
     2262            -offimage [Rappture::icon x-cutplane] \
     2263            -command [itcl::code $this FixSettings xcutplane] \
     2264            -variable [itcl::scope _settings($this-xcutplane)]
    22662265    }
    22672266    Rappture::Tooltip::for $itk_component(xCutButton) \
     
    22732272            -borderwidth 1 -highlightthickness 0 \
    22742273            -command [itcl::code $this Slice move x] \
    2275             -variable [itcl::scope _settings($this-xcutposition)]
     2274            -variable [itcl::scope _settings($this-xcutposition)]
    22762275    } {
    22772276        usual
     
    22872286    itk_component add yCutButton {
    22882287        Rappture::PushButton $inner.ybutton \
    2289             -onimage [Rappture::icon y-cutplane] \
    2290             -offimage [Rappture::icon y-cutplane] \
    2291             -command [itcl::code $this FixSettings ycutplane] \
    2292             -variable [itcl::scope _settings($this-ycutplane)]
     2288            -onimage [Rappture::icon y-cutplane] \
     2289            -offimage [Rappture::icon y-cutplane] \
     2290            -command [itcl::code $this FixSettings ycutplane] \
     2291            -variable [itcl::scope _settings($this-ycutplane)]
    22932292    }
    22942293    Rappture::Tooltip::for $itk_component(yCutButton) \
     
    23002299            -borderwidth 1 -highlightthickness 0 \
    23012300            -command [itcl::code $this Slice move y] \
    2302             -variable [itcl::scope _settings($this-ycutposition)]
     2301            -variable [itcl::scope _settings($this-ycutposition)]
    23032302    } {
    23042303        usual
     
    23142313    itk_component add zCutButton {
    23152314        Rappture::PushButton $inner.zbutton \
    2316             -onimage [Rappture::icon z-cutplane] \
    2317             -offimage [Rappture::icon z-cutplane] \
    2318             -command [itcl::code $this FixSettings zcutplane] \
    2319             -variable [itcl::scope _settings($this-zcutplane)]
     2315            -onimage [Rappture::icon z-cutplane] \
     2316            -offimage [Rappture::icon z-cutplane] \
     2317            -command [itcl::code $this FixSettings zcutplane] \
     2318            -variable [itcl::scope _settings($this-zcutplane)]
    23202319    }
    23212320    Rappture::Tooltip::for $itk_component(zCutButton) \
     
    23272326            -borderwidth 1 -highlightthickness 0 \
    23282327            -command [itcl::code $this Slice move z] \
    2329             -variable [itcl::scope _settings($this-zcutposition)]
     2328            -variable [itcl::scope _settings($this-zcutposition)]
    23302329    } {
    23312330        usual
     
    23392338
    23402339    blt::table $inner \
    2341         1,1 $itk_component(xCutButton) \
    2342         1,2 $itk_component(yCutButton) \
    2343         1,3 $itk_component(zCutButton) \
    2344         0,1 $itk_component(xCutScale) \
    2345         0,2 $itk_component(yCutScale) \
    2346         0,3 $itk_component(zCutScale) \
     2340        1,1 $itk_component(xCutButton) \
     2341        1,2 $itk_component(yCutButton) \
     2342        1,3 $itk_component(zCutButton) \
     2343        0,1 $itk_component(xCutScale) \
     2344        0,2 $itk_component(yCutScale) \
     2345        0,3 $itk_component(zCutScale) \
    23472346
    23482347    blt::table configure $inner r0 r1 c* -resize none
     
    23612360    set row 0
    23622361    foreach tag $labels {
    2363         label $inner.${tag}label -text $tag -font "Arial 9"
    2364         entry $inner.${tag} -font "Arial 9"  -bg white \
    2365             -textvariable [itcl::scope _settings($this-$tag)]
    2366         bind $inner.${tag} <KeyPress-Return> \
    2367             [itcl::code $this camera set ${tag}]
    2368         blt::table $inner \
    2369             $row,0 $inner.${tag}label -anchor e -pady 2 \
    2370             $row,1 $inner.${tag} -anchor w -pady 2
     2362        label $inner.${tag}label -text $tag -font "Arial 9"
     2363        entry $inner.${tag} -font "Arial 9"  -bg white \
     2364            -textvariable [itcl::scope _settings($this-$tag)]
     2365        bind $inner.${tag} <KeyPress-Return> \
     2366            [itcl::code $this camera set ${tag}]
     2367        blt::table $inner \
     2368            $row,0 $inner.${tag}label -anchor e -pady 2 \
     2369            $row,1 $inner.${tag} -anchor w -pady 2
    23712370        blt::table configure $inner r$row -resize none
    2372         incr row
     2371        incr row
    23732372    }
    23742373    blt::table configure $inner c0 c1 -resize none
     
    23802379    set flowobj ""
    23812380    foreach key [array names _obj2flow] {
    2382         set flowobj $_obj2flow($key)
    2383         break
     2381        set flowobj $_obj2flow($key)
     2382        break
    23842383    }
    23852384    if { $flowobj == "" } {
    2386         return
     2385        return
    23872386    }
    23882387    if { [winfo exists $w.frame] } {
    2389         destroy $w.frame
     2388        destroy $w.frame
    23902389    }
    23912390    set inner [frame $w.frame]
    23922391    blt::table $w \
    2393         5,0 $inner -fill both -columnspan 2 -anchor nw
     2392        5,0 $inner -fill both -columnspan 2 -anchor nw
    23942393    array set hints [$flowobj hints]
    23952394    checkbutton $inner.showstreams -text "Streams Plane" \
    2396         -variable [itcl::scope _settings($this-streams)] \
    2397         -command  [itcl::code $this streams $key $hints(name)]  \
    2398         -font "Arial 9"
     2395        -variable [itcl::scope _settings($this-streams)] \
     2396        -command  [itcl::code $this streams $key $hints(name)]  \
     2397        -font "Arial 9"
    23992398    Rappture::Tooltip::for $inner.showstreams $hints(description)
    24002399
    24012400    checkbutton $inner.showarrows -text "Arrows" \
    2402         -variable [itcl::scope _settings($this-arrows)] \
    2403         -command  [itcl::code $this arrows $key $hints(name)]  \
    2404         -font "Arial 9"
    2405 
    2406     label $inner.particles -text "Particles"    -font "Arial 9 bold"
    2407     label $inner.boxes -text "Boxes"    -font "Arial 9 bold"
     2401        -variable [itcl::scope _settings($this-arrows)] \
     2402        -command  [itcl::code $this arrows $key $hints(name)]  \
     2403        -font "Arial 9"
     2404
     2405    label $inner.particles -text "Particles"         -font "Arial 9 bold"
     2406    label $inner.boxes -text "Boxes"         -font "Arial 9 bold"
    24082407
    24092408    blt::table $inner \
    2410         1,0 $inner.showstreams  -anchor w \
    2411         2,0 $inner.showarrows  -anchor w
     2409        1,0 $inner.showstreams  -anchor w \
     2410        2,0 $inner.showarrows  -anchor w
    24122411    blt::table configure $inner c0 c1 -resize none
    24132412    blt::table configure $inner c2 -resize expand
     
    24162415    set particles [$flowobj particles]
    24172416    if { [llength $particles] > 0 } {
    2418         blt::table $inner $row,0 $inner.particles  -anchor w
    2419         incr row
     2417        blt::table $inner $row,0 $inner.particles  -anchor w
     2418        incr row
    24202419    }
    24212420    foreach part $particles {
    2422         array unset info
    2423         array set info $part
    2424         set name $info(name)
    2425         if { ![info exists _settings($this-particles-$name)] } {
    2426             set _settings($this-particles-$name) $info(hide)
    2427         }
    2428         checkbutton $inner.part$row -text $info(label) \
    2429             -variable [itcl::scope _settings($this-particles-$name)] \
    2430             -onvalue 0 -offvalue 1 \
    2431             -command [itcl::code $this particles $key $name] \
    2432             -font "Arial 9"
    2433         Rappture::Tooltip::for $inner.part$row $info(description)
    2434         blt::table $inner $row,0 $inner.part$row -anchor w
    2435         if { !$_settings($this-particles-$name) } {
    2436             $inner.part$row select
    2437         }
    2438         incr row
     2421        array unset info
     2422        array set info $part
     2423        set name $info(name)
     2424        if { ![info exists _settings($this-particles-$name)] } {
     2425            set _settings($this-particles-$name) $info(hide)
     2426        }
     2427        checkbutton $inner.part$row -text $info(label) \
     2428            -variable [itcl::scope _settings($this-particles-$name)] \
     2429            -onvalue 0 -offvalue 1 \
     2430            -command [itcl::code $this particles $key $name] \
     2431            -font "Arial 9"
     2432        Rappture::Tooltip::for $inner.part$row $info(description)
     2433        blt::table $inner $row,0 $inner.part$row -anchor w
     2434        if { !$_settings($this-particles-$name) } {
     2435            $inner.part$row select
     2436        }
     2437        incr row
    24392438    }
    24402439    set boxes [$flowobj boxes]
    24412440    if { [llength $boxes] > 0 } {
    2442         blt::table $inner $row,0 $inner.boxes  -anchor w
    2443         incr row
     2441        blt::table $inner $row,0 $inner.boxes  -anchor w
     2442        incr row
    24442443    }
    24452444    foreach box $boxes {
    2446         array unset info
    2447         array set info $box
    2448         set name $info(name)
    2449         if { ![info exists _settings($this-box-$name)] } {
    2450             set _settings($this-box-$name) $info(hide)
    2451         }
    2452         checkbutton $inner.box$row -text $info(label) \
    2453             -variable [itcl::scope _settings($this-box-$name)] \
    2454             -onvalue 0 -offvalue 1 \
    2455             -command [itcl::code $this box $key $name] \
    2456             -font "Arial 9"
    2457         Rappture::Tooltip::for $inner.box$row $info(description)
    2458         blt::table $inner $row,0 $inner.box$row -anchor w
    2459         if { !$_settings($this-box-$name) } {
    2460             $inner.box$row select
    2461         }
    2462         incr row
     2445        array unset info
     2446        array set info $box
     2447        set name $info(name)
     2448        if { ![info exists _settings($this-box-$name)] } {
     2449            set _settings($this-box-$name) $info(hide)
     2450        }
     2451        checkbutton $inner.box$row -text $info(label) \
     2452            -variable [itcl::scope _settings($this-box-$name)] \
     2453            -onvalue 0 -offvalue 1 \
     2454            -command [itcl::code $this box $key $name] \
     2455            -font "Arial 9"
     2456        Rappture::Tooltip::for $inner.box$row $info(description)
     2457        blt::table $inner $row,0 $inner.box$row -anchor w
     2458        if { !$_settings($this-box-$name) } {
     2459            $inner.box$row select
     2460        }
     2461        incr row
    24632462    }
    24642463    blt::table configure $inner r* -resize none
     
    25412540    set _height $h
    25422541    if { !$_resizePending } {
    2543         $_dispatcher event -after 200 !resize
    2544         set _resizePending 1
     2542        $_dispatcher event -after 200 !resize
     2543        set _resizePending 1
    25452544    }
    25462545}
     
    25482547itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} {
    25492548    if { !$_resizeLegendPending } {
    2550         $_dispatcher event -after 100 !legend
    2551         set _resizeLegendPending 1
     2549        $_dispatcher event -after 100 !legend
     2550        set _resizeLegendPending 1
    25522551    }
    25532552}
     
    25562555    set _flow(goto) $nSteps
    25572556    if { !$_gotoPending } {
    2558         $_dispatcher event -after 1000 !goto
    2559         set _gotoPending 1
     2557        $_dispatcher event -after 1000 !goto
     2558        set _gotoPending 1
    25602559    }
    25612560}
     
    25642563itcl::body Rappture::FlowvisViewer::camera {option args} {
    25652564    switch -- $option {
    2566         "show" {
    2567             puts [array get _view]
    2568         }
    2569         "set" {
    2570             set who [lindex $args 0]
    2571             set x $_settings($this-$who)
    2572             set code [catch { string is double $x } result]
    2573             if { $code != 0 || !$result } {
    2574                 set _settings($this-$who) $_view($who)
    2575                 return
    2576             }
    2577             switch -- $who {
    2578                 "pan-x" - "pan-y" {
    2579                     set _view($who) $_settings($this-$who)
    2580                     PanCamera
    2581                 }
    2582                 "phi" - "theta" - "psi" {
    2583                     set _view($who) $_settings($this-$who)
    2584                     set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
    2585                     SendCmd "camera angle $xyz"
    2586                 }
    2587                 "zoom" {
    2588                     set _view($who) $_settings($this-$who)
    2589                     SendCmd "camera zoom $_view(zoom)"
    2590                 }
    2591             }
    2592         }
     2565        "show" {
     2566            puts [array get _view]
     2567        }
     2568        "set" {
     2569            set who [lindex $args 0]
     2570            set x $_settings($this-$who)
     2571            set code [catch { string is double $x } result]
     2572            if { $code != 0 || !$result } {
     2573                set _settings($this-$who) $_view($who)
     2574                return
     2575            }
     2576            switch -- $who {
     2577                "pan-x" - "pan-y" {
     2578                    set _view($who) $_settings($this-$who)
     2579                    PanCamera
     2580                }
     2581                "phi" - "theta" - "psi" {
     2582                    set _view($who) $_settings($this-$who)
     2583                    set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]
     2584                    SendCmd "camera angle $xyz"
     2585                }
     2586                "zoom" {
     2587                    set _view($who) $_settings($this-$who)
     2588                    SendCmd "camera zoom $_view(zoom)"
     2589                }
     2590            }
     2591        }
    25932592    }
    25942593}
     
    25972596    set tag "$dataobj-$comp"
    25982597    if { ![info exists _obj2flow($tag)] } {
    2599         append cmd "flow add $tag\n"
    2600         append cmd "$tag data follows $nbytes $extents\n"
    2601         return $cmd
     2598        append cmd "flow add $tag\n"
     2599        append cmd "$tag data follows $nbytes $extents\n"
     2600        return $cmd
    26022601    }
    26032602    set flowobj $_obj2flow($tag)
    26042603    if { $flowobj == "" } {
    2605         puts stderr "no flowobj"
    2606         return ""
     2604        puts stderr "no flowobj"
     2605        return ""
    26072606    }
    26082607    set cmd {}
     
    26222621    append cmd " -arrows $info(arrows)\n"
    26232622    foreach part [$flowobj particles] {
    2624         array unset info
    2625         array set info $part
    2626         set color [Color2RGB $info(color)]
    2627         append cmd "$tag particles add $info(name)"
    2628         append cmd " -position $info(position)"
    2629         append cmd " -hide $info(hide)"
    2630         append cmd " -axis $info(axis)"
    2631         append cmd " -color {$color}"
    2632         append cmd " -size $info(size)\n"
     2623        array unset info
     2624        array set info $part
     2625        set color [Color2RGB $info(color)]
     2626        append cmd "$tag particles add $info(name)"
     2627        append cmd " -position $info(position)"
     2628        append cmd " -hide $info(hide)"
     2629        append cmd " -axis $info(axis)"
     2630        append cmd " -color {$color}"
     2631        append cmd " -size $info(size)\n"
    26332632    }
    26342633    foreach box [$flowobj boxes] {
    2635         array unset info
    2636         set info(corner1) ""
    2637         set info(corner2) ""
    2638         array set info $box
    2639         if { $info(corner1) == "" || $info(corner2) == "" } {
    2640             continue
    2641         }
    2642         set color [Color2RGB $info(color)]
    2643         append cmd "$tag box add $info(name)"
     2634        array unset info
     2635        set info(corner1) ""
     2636        set info(corner2) ""
     2637        array set info $box
     2638        if { $info(corner1) == "" || $info(corner2) == "" } {
     2639            continue
     2640        }
     2641        set color [Color2RGB $info(color)]
     2642        append cmd "$tag box add $info(name)"
    26442643        append cmd " -color {$color}"
    2645         append cmd " -hide $info(hide)"
     2644        append cmd " -hide $info(hide)"
    26462645        append cmd " -linewidth $info(linewidth) "
    2647         append cmd " -corner1 {$info(corner1)} "
    2648         append cmd " -corner2 {$info(corner2)}\n"
     2646        append cmd " -corner1 {$info(corner1)} "
     2647          append cmd " -corner2 {$info(corner2)}\n"
    26492648    }   
    26502649    append cmd "$tag data follows $nbytes $extents\n"
     
    26592658# for flow visualization.
    26602659#
    2661 #       $this flow play
    2662 #       $this flow stop
    2663 #       $this flow toggle
    2664 #       $this flow reset
    2665 #       $this flow pause
    2666 #       $this flow next
     2660#        $this flow play
     2661#        $this flow stop
     2662#        $this flow toggle
     2663#        $this flow reset
     2664#        $this flow pause
     2665#        $this flow next
    26672666#
    26682667itcl::body Rappture::FlowvisViewer::flow { args } {
    26692668    set option [lindex $args 0]
    26702669    switch -- $option {
    2671         "goto2" {
    2672             puts stderr "actually sending \"flow goto $_flow(goto)\""
    2673             SendCmd "flow goto $_flow(goto)"
    2674             set _gotoPending 0
    2675         }
    2676         "goto" {
    2677             puts stderr "flow goto to $_settings($this-currenttime)"
    2678             # Figure out how many steps to the current time based upon
    2679             # the speed and duration.
    2680             set current $_settings($this-currenttime)
    2681             set speed [$itk_component(speed) value]
    2682             set time [str2millisecs $_settings($this-duration)]
    2683             $itk_component(dial) configure -max $time
    2684             set delay [expr int(round(500.0/$speed))]
    2685             set timePerStep [expr {double($time) / $delay}]
    2686             set nSteps [expr {int(ceil($current/$timePerStep))}]
    2687             EventuallyGoto $nSteps
    2688         }
    2689         "speed" {
    2690             set speed [$itk_component(speed) value]
    2691             set _flow(delay) [expr int(round(500.0/$speed))]
    2692         }
    2693         "duration" {
    2694             set max [str2millisecs $_settings($this-duration)]
    2695             if { $max < 0 } {
    2696                 bell
    2697                 return
    2698             }
    2699             set _flow(duration) $max
    2700             set _settings($this-duration) [millisecs2str $max]
    2701             $itk_component(dial) configure -max $max
    2702         }
    2703         "off" {
    2704             set _flow(state) 0
    2705             $_dispatcher cancel !play
    2706             $itk_component(play) deselect
    2707         }
    2708         "on" {
    2709             flow speed
    2710             flow duration
    2711             set _flow(state) 1
    2712             set _settings($this-currenttime) 0
    2713             $itk_component(play) select
    2714         }
    2715         "stop" {
    2716             if { $_flow(state) } {
    2717                 flow off
    2718                 flow reset
    2719             }
    2720         }
    2721         "pause" {
    2722             if { $_flow(state) } {
    2723                 flow off
    2724             }
    2725         }
    2726         "play" {
    2727             # If the flow is currently off, then restart it.
    2728             if { !$_flow(state) } {
    2729                 flow on
    2730                 # If we're at the end of the flow, reset the flow.
    2731                 set _settings($this-currenttime) \
    2732                     [expr {$_settings($this-currenttime) + $_flow(delay)}]
    2733                 if { $_settings($this-currenttime) >= $_flow(duration) } {
    2734                     set _settings($this-step) 1
    2735                     SendCmd "flow reset"
    2736                 }
    2737                 flow next
    2738             }
    2739         }
    2740         "toggle" {
    2741             if { $_settings($this-play) } {
    2742                 flow play
    2743             } else {
    2744                 flow pause
    2745             }
    2746         }
    2747         "reset" {
    2748             set _settings($this-currenttime) 0
    2749             SendCmd "flow reset"
    2750             if { !$_flow(state) } {
    2751                 SendCmd "flow next"
    2752             }
    2753         }
    2754         "next" {
    2755             if { ![IsMapped $itk_component(3dview)] } {
    2756                 flow stop
    2757                 return
    2758             }
    2759             set _settings($this-currenttime) \
    2760                 [expr {$_settings($this-currenttime) + $_flow(delay)}]
    2761             if { $_settings($this-currenttime) >= $_flow(duration) } {
    2762                 if { !$_settings($this-loop) } {
    2763                     flow off
    2764                     return
    2765                 }
    2766                 flow reset
    2767             } else {
    2768                 SendCmd "flow next"
    2769             }
    2770             $_dispatcher event -after $_flow(delay) !play
    2771         }
    2772         default {
    2773             error "bad option \"$option\": should be play, stop, toggle, or reset."
    2774         }
     2670        "goto2" {
     2671            puts stderr "actually sending \"flow goto $_flow(goto)\""
     2672            SendCmd "flow goto $_flow(goto)"
     2673            set _gotoPending 0
     2674        }
     2675        "goto" {
     2676            puts stderr "flow goto to $_settings($this-currenttime)"
     2677            # Figure out how many steps to the current time based upon
     2678            # the speed and duration.
     2679            set current $_settings($this-currenttime)
     2680            set speed [$itk_component(speed) value]
     2681            set time [str2millisecs $_settings($this-duration)]
     2682            $itk_component(dial) configure -max $time
     2683            set delay [expr int(round(500.0/$speed))]
     2684            set timePerStep [expr {double($time) / $delay}]
     2685            set nSteps [expr {int(ceil($current/$timePerStep))}]
     2686            EventuallyGoto $nSteps
     2687        }
     2688        "speed" {
     2689            set speed [$itk_component(speed) value]
     2690            set _flow(delay) [expr int(round(500.0/$speed))]
     2691        }
     2692        "duration" {
     2693            set max [str2millisecs $_settings($this-duration)]
     2694            if { $max < 0 } {
     2695                bell
     2696                return
     2697            }
     2698            set _flow(duration) $max
     2699            set _settings($this-duration) [millisecs2str $max]
     2700            $itk_component(dial) configure -max $max
     2701        }
     2702        "off" {
     2703            set _flow(state) 0
     2704            $_dispatcher cancel !play
     2705            $itk_component(play) deselect
     2706        }
     2707        "on" {
     2708            flow speed
     2709            flow duration
     2710            set _flow(state) 1
     2711            set _settings($this-currenttime) 0
     2712            $itk_component(play) select
     2713        }
     2714        "stop" {
     2715            if { $_flow(state) } {
     2716                flow off
     2717                flow reset
     2718            }
     2719        }
     2720        "pause" {
     2721            if { $_flow(state) } {
     2722                flow off
     2723            }
     2724        }
     2725        "play" {
     2726            # If the flow is currently off, then restart it.
     2727            if { !$_flow(state) } {
     2728                flow on
     2729                # If we're at the end of the flow, reset the flow.
     2730                set _settings($this-currenttime) \
     2731                    [expr {$_settings($this-currenttime) + $_flow(delay)}]
     2732                if { $_settings($this-currenttime) >= $_flow(duration) } {
     2733                    set _settings($this-step) 1
     2734                    SendCmd "flow reset"
     2735                }
     2736                flow next
     2737            }
     2738        }
     2739        "toggle" {
     2740            if { $_settings($this-play) } {
     2741                flow play
     2742            } else {
     2743                flow pause
     2744            }
     2745        }
     2746        "reset" {
     2747            set _settings($this-currenttime) 0
     2748            SendCmd "flow reset"
     2749            if { !$_flow(state) } {
     2750                SendCmd "flow next"
     2751            }
     2752        }
     2753        "next" {
     2754            if { ![IsMapped $itk_component(3dview)] } {
     2755                flow stop
     2756                return
     2757            }
     2758            set _settings($this-currenttime) \
     2759                [expr {$_settings($this-currenttime) + $_flow(delay)}]
     2760            if { $_settings($this-currenttime) >= $_flow(duration) } {
     2761                if { !$_settings($this-loop) } {
     2762                    flow off
     2763                    return
     2764                }
     2765                flow reset
     2766            } else {
     2767                SendCmd "flow next"
     2768            }
     2769            $_dispatcher event -after $_flow(delay) !play
     2770        }
     2771        default {
     2772            error "bad option \"$option\": should be play, stop, toggle, or reset."
     2773        }
    27752774    }
    27762775}
     
    27782777itcl::body Rappture::FlowvisViewer::WaitIcon  { option widget } {
    27792778    switch -- $option {
    2780         "start" {
    2781             $_dispatcher dispatch $this !waiticon \
    2782                 "[itcl::code $this WaitIcon "next" $widget] ; list"
    2783             set _icon 0
    2784             $widget configure -image [Rappture::icon bigroller${_icon}]
    2785             $_dispatcher event -after 100 !waiticon
    2786         }
    2787         "next" {
    2788             incr _icon
    2789             if { $_icon >= 8 } {
    2790                 set _icon 0
    2791             }
    2792             $widget configure -image [Rappture::icon bigroller${_icon}]
    2793             $_dispatcher event -after 100 !waiticon
    2794         }
    2795         "stop" {
    2796             $_dispatcher cancel !waiticon
    2797         }
     2779        "start" {
     2780            $_dispatcher dispatch $this !waiticon \
     2781                "[itcl::code $this WaitIcon "next" $widget] ; list"
     2782            set _icon 0
     2783            $widget configure -image [Rappture::icon bigroller${_icon}]
     2784            $_dispatcher event -after 100 !waiticon
     2785        }
     2786        "next" {
     2787            incr _icon
     2788            if { $_icon >= 8 } {
     2789                set _icon 0
     2790            }
     2791            $widget configure -image [Rappture::icon bigroller${_icon}]
     2792            $_dispatcher event -after 100 !waiticon
     2793        }
     2794        "stop" {
     2795            $_dispatcher cancel !waiticon
     2796        }
    27982797    }
    27992798}
     
    28092808    set popup .flowvisviewerprint
    28102809    if {![winfo exists $popup]} {
    2811         Rappture::Balloon $popup -title "Generating file..."
    2812         set inner [$popup component inner]
    2813         label $inner.title -text "Generating hardcopy." -font "Arial 10 bold"
    2814         label $inner.please -text "This may take a minute." -font "Arial 10"
    2815         label $inner.icon -image [Rappture::icon bigroller0]
    2816         button $inner.cancel -text "Cancel" -font "Arial 10 bold" \
    2817             -command [list set $var ""]
    2818         blt::table $inner \
    2819             0,0 $inner.title -columnspan 2 \
    2820             1,0 $inner.please -anchor w \
    2821             1,1 $inner.icon -anchor e  \
    2822             2,0 $inner.cancel -columnspan 2
    2823         blt::table configure $inner r0 -pady 4
    2824         blt::table configure $inner r2 -pady 4
    2825         bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
     2810        Rappture::Balloon $popup -title "Generating file..."
     2811        set inner [$popup component inner]
     2812        label $inner.title -text "Generating hardcopy." -font "Arial 10 bold"
     2813        label $inner.please -text "This may take a minute." -font "Arial 10"
     2814        label $inner.icon -image [Rappture::icon bigroller0]
     2815        button $inner.cancel -text "Cancel" -font "Arial 10 bold" \
     2816            -command [list set $var ""]
     2817        blt::table $inner \
     2818            0,0 $inner.title -columnspan 2 \
     2819            1,0 $inner.please -anchor w \
     2820            1,1 $inner.icon -anchor e  \
     2821            2,0 $inner.cancel -columnspan 2
     2822        blt::table configure $inner r0 -pady 4
     2823        blt::table configure $inner r2 -pady 4
     2824        bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
    28262825    } else {
    2827         set inner [$popup component inner]
     2826        set inner [$popup component inner]
    28282827    }
    28292828
     
    28512850
    28522851    if { $_hardcopy($this-$token) != "" } {
    2853         return [list .png $_hardcopy($this-$token)]
     2852        return [list .png $_hardcopy($this-$token)]
    28542853    }
    28552854    return ""
     
    28652864    set popup .flowvisviewermovie
    28662865    if {![winfo exists $popup]} {
    2867         Rappture::Balloon $popup -title "Generating movie..."
    2868         set inner [$popup component inner]
    2869         label $inner.title -text "Generating movie for download" \
    2870                 -font "Arial 10 bold"
    2871         label $inner.please -text "This may take a few minutes." \
    2872                 -font "Arial 10"
    2873         label $inner.icon -image [Rappture::icon bigroller0]
    2874         button $inner.cancel -text "Cancel" -font "Arial 10 bold" \
    2875             -command [list set $var ""]
    2876         blt::table $inner \
    2877             0,0 $inner.title -columnspan 2 \
    2878             1,0 $inner.please -anchor w \
    2879             1,1 $inner.icon -anchor e  \
    2880             2,0 $inner.cancel -columnspan 2
    2881         blt::table configure $inner r0 -pady 4
    2882         blt::table configure $inner r2 -pady 4
    2883         bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
     2866        Rappture::Balloon $popup -title "Generating movie..."
     2867        set inner [$popup component inner]
     2868        label $inner.title -text "Generating movie for download" \
     2869                -font "Arial 10 bold"
     2870        label $inner.please -text "This may take a few minutes." \
     2871                -font "Arial 10"
     2872        label $inner.icon -image [Rappture::icon bigroller0]
     2873        button $inner.cancel -text "Cancel" -font "Arial 10 bold" \
     2874            -command [list set $var ""]
     2875        blt::table $inner \
     2876            0,0 $inner.title -columnspan 2 \
     2877            1,0 $inner.please -anchor w \
     2878            1,1 $inner.icon -anchor e  \
     2879            2,0 $inner.cancel -columnspan 2
     2880        blt::table configure $inner r0 -pady 4
     2881        blt::table configure $inner r2 -pady 4
     2882        bind $inner.cancel <KeyPress-Return> [list $inner.cancel invoke]
    28842883    } else {
    2885         set inner [$popup component inner]
     2884        set inner [$popup component inner]
    28862885    }
    28872886    # Timeout is set to 10 minutes.
     
    29252924    SendCmd "flow reset"
    29262925    if { $_hardcopy($this-$token) != "" } {
    2927         return [list .mpg $_hardcopy($this-$token)]
     2926        return [list .mpg $_hardcopy($this-$token)]
    29282927    }
    29292928    return ""
     
    29352934    set mins 0
    29362935    if { [llength $parts] == 1 } {
    2937         scan [lindex $parts 0] "%d" secs
     2936        scan [lindex $parts 0] "%d" secs
    29382937    } else {
    2939         scan [lindex $parts 1] "%d" secs
    2940         scan [lindex $parts 0] "%d" mins
     2938        scan [lindex $parts 1] "%d" secs
     2939        scan [lindex $parts 0] "%d" mins
    29412940    }
    29422941    set ms [expr {(($mins * 60) + $secs) * 1000.0}]
    29432942    if { $ms > 600000.0 } {
    2944         set ms 600000.0
     2943        set ms 600000.0
    29452944    }
    29462945    if { $ms == 0.0 } {
    2947         set ms 60000.0
     2946        set ms 60000.0
    29482947    }
    29492948    return $ms
     
    29582957itcl::body Rappture::FlowvisViewer::IsMapped { w } {
    29592958    while { $w != "" }  {
    2960         if { ![winfo ismapped $w] } {
    2961             return 0
    2962         }
    2963         set w [winfo parent $w]
    2964         if { [winfo toplevel $w] == $w } {
    2965             break
    2966         }
     2959        if { ![winfo ismapped $w] } {
     2960            return 0
     2961        }
     2962        set w [winfo parent $w]
     2963        if { [winfo toplevel $w] == $w } {
     2964            break
     2965        }
    29672966    }
    29682967    return 1
Note: See TracChangeset for help on using the changeset viewer.