Ignore:
Timestamp:
Jun 10, 2009 2:40:56 PM (15 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

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

    r1498 r1506  
    111111    private method FlowCmd { dataobj comp nbytes extents }
    112112    private method GetMovie { widget width height }
     113    private method GetPngImage { widget width height }
    113114    private method NameTransferFunc { dataobj comp }
    114115    private method PanCamera {}
     
    147148    private variable _first ""     ;# This is the topmost volume.
    148149    private variable _buffering 0
     150    private variable _nextToken 0
     151    private variable _icon 0
    149152    private variable _flow
    150153    # This
     
    152155    # function to use when changing markers,
    153156    # opacity, or thickness.
    154     common _downloadPopup          ;# download options from popup
     157    private common _downloadPopup          ;# download options from popup
    155158
    156159    private common _hardcopy
     
    200203    $_dispatcher register !goto
    201204    $_dispatcher dispatch $this !goto "[itcl::code $this flow goto2]; list"
     205
     206    $_dispatcher register !movietimeout
     207    $_dispatcher register !waiticon
    202208
    203209    set _flow(state) 0
     
    735741# ----------------------------------------------------------------------
    736742itcl::body Rappture::FlowvisViewer::download {option args} {
     743    set popup .flowvisviewerdownload
    737744    switch $option {
    738745        coming {
     
    745752        }
    746753        controls {
    747             set popup .flowvisviewerdownload
    748             if {![winfo exists .flowvisviewerdownload]} {
     754            if {![winfo exists $popup]} {
    749755                # if we haven't created the popup yet, do it now
    750756                Rappture::Balloon $popup \
     
    756762                set res "[image width $img]x[image height $img]"
    757763                radiobutton $inner.draft -text "Image (draft $res)" \
    758                     -variable Rappture::MolvisViewer::_downloadPopup(format) \
     764                    -variable Rappture::FlowvisViewer::_downloadPopup(format) \
    759765                    -value draft
    760766                pack $inner.draft -anchor w
     
    762768                set res "640x480"
    763769                radiobutton $inner.medium -text "Movie (standard $res)" \
    764                     -variable Rappture::MolvisViewer::_downloadPopup(format) \
     770                    -variable Rappture::FlowvisViewer::_downloadPopup(format) \
    765771                    -value $res
    766772                pack $inner.medium -anchor w
     
    768774                set res "1024x768"
    769775                radiobutton $inner.high -text "Movie (high quality $res)" \
    770                     -variable Rappture::MolvisViewer::_downloadPopup(format) \
     776                    -variable Rappture::FlowvisViewer::_downloadPopup(format) \
    771777                    -value $res
    772778                pack $inner.high -anchor w
     
    780786            set num [llength [get]]
    781787            set num [expr {($num == 1) ? "1 result" : "$num results"}]
    782             $inner.summary configure -text "[Rappture::filexfer::label downloadWord] $num in the following format:"
     788            set word [Rappture::filexfer::label downloadWord]
     789            $inner.summary configure -text "$word $num in the following format:"
    783790            update idletasks ;# fix initial sizes
    784791            return $popup
    785792        }
    786793        now {
    787             set popup .molvisviewerdownload
    788             if {[winfo exists .molvisviewerdownload]} {
     794            if { [winfo exists $popup] } {
    789795                $popup deactivate
    790796            }
     
    796802                    # won't be necessary to decode the image data.
    797803                    set bytes [$_image(plot) data -format "jpeg -quality 100"]
    798                     set data [Rappture::encoding::decode -as b64 $data]
    799                     return [list .jpg $data]
     804                    set bytes [Rappture::encoding::decode -as b64 $bytes]
     805                    return [list .jpg $bytes]
    800806                }
    801807                "640x480" {
     
    804810                "1024x768" {
    805811                    return [$this GetMovie [lindex $args 0] 1024 768]
     812                }
     813                default {
     814                    error "bad download format $_downloadPopup(format)"
    806815                }
    807816            }
     
    10321041    set bytes [ReceiveBytes $info(-bytes)]
    10331042    ReceiveEcho <<line "<read $info(-bytes) bytes"
    1034     if { $info(-type) == "image" } {
    1035         $_image(plot) configure -data $bytes
    1036         #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]"
    1037     } elseif { $info(type) == "print" } {
    1038         set tag $this-print-$info(-token)
    1039         set _hardcopy($tag) $bytes
    1040     } elseif { $info(type) == "movie" } {
    1041         set tag $this-movie-$info(-token)
    1042         set _hardcopy($tag) $bytes
     1043    switch -- $info(-type)  {
     1044        "image" {
     1045            $_image(plot) configure -data $bytes
     1046            #puts stderr "image received [image width $_image(plot)] by [image height $_image(plot)]"
     1047        }
     1048        "print" {
     1049            set tag $this-$info(-token)
     1050            set _hardcopy($tag) $bytes
     1051        }
     1052        "movie" {
     1053            puts stderr "read [string length $bytes] bytes type=$info(-type) token=$info(-token)"
     1054            set tag $this-$info(-token)
     1055            set _hardcopy($tag) $bytes
     1056        }
     1057        default {
     1058            puts stderr "unknown download type $info(-type)"
     1059        }
    10431060    }
    10441061}
     
    27862803}
    27872804
    2788 itcl::body Rappture::MolvisViewer::GetPngImage  { widget width height } {
     2805itcl::body Rappture::FlowvisViewer::GetPngImage  { widget width height } {
    27892806    set token "print[incr _nextToken]"
    2790     set var ::Rappture::MolvisViewer::_hardcopy($this-$token)
     2807    set var ::Rappture::FlowvisViewer::_hardcopy($this-$token)
    27912808    set $var ""
    27922809
     
    27942811    $_dispatcher dispatch $this !pngtimeout "set $var {} ; list"
    27952812
    2796     set popup .molvisviewerprint
     2813    set popup .flowvisviewerprint
    27972814    if {![winfo exists $popup]} {
    27982815        Rappture::Balloon $popup -title "Generating file..."
     
    28452862itcl::body Rappture::FlowvisViewer::GetMovie { widget width height } {
    28462863    set token "movie[incr _nextToken]"
    2847     set var ::Rappture::MolvisViewer::_hardcopy($this-$token)
     2864    set var ::Rappture::FlowvisViewer::_hardcopy($this-$token)
    28482865    set $var ""
    28492866
     
    28702887        set inner [$popup component inner]
    28712888    }
    2872     $_dispatcher event -after 60000 !movietimeout
     2889    $_dispatcher event -after 300000 !movietimeout
    28732890    WaitIcon start $inner.icon
    28742891    grab set -local $inner
     
    28772894    flow duration
    28782895    flow speed
    2879     set nframes [expr $_flow(duration) / $_flow(delay)]
     2896    set nframes [expr round($_flow(duration) / $_flow(delay))]
    28802897    set framerate [expr 1000.0 / $_flow(delay)]
    2881     set bitrate 2000
    2882 
     2898    set framerate 25.0
     2899    set bitrate 400000
     2900
     2901    set start [clock seconds]
    28832902    SendCmd "flow video $width $height $nframes $framerate $bitrate $token"
    28842903   
     
    28912910    tkwait variable $var
    28922911
     2912    puts stderr "I'm back in [expr [clock seconds] - $start] seconds."
    28932913    # Clean up.
    2894     $_dispatcher cancel !pngtimeout
     2914    $_dispatcher cancel !movietimeout
    28952915    WaitIcon stop $inner.icon
    28962916    grab release $inner
Note: See TracChangeset for help on using the changeset viewer.