Changeset 1514 for trunk


Ignore:
Timestamp:
Jun 13, 2009 1:02:20 PM (15 years ago)
Author:
gah
Message:

allow user to cancel the movie download

Location:
trunk/gui/scripts
Files:
3 edited

Legend:

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

    r1511 r1514  
    26152615    set _settings($this-duration) $info(duration)
    26162616    $itk_component(speed) value $info(speed)
    2617     append cmd "flow add $tag -position $info(position) -axis $info(axis) "
    2618     append cmd "-volume $info(volume) -outline $info(outline) "
    2619     append cmd "-slice $info(streams) -arrows $info(arrows)\n"
     2617    append cmd "flow add $tag"
     2618    append cmd " -position $info(position)"
     2619    append cmd " -axis $info(axis)"
     2620    append cmd " -volume $info(volume)"
     2621    append cmd " -outline $info(outline)"
     2622    append cmd " -slice $info(streams)"
     2623    append cmd " -arrows $info(arrows)\n"
    26202624    foreach part [$flowobj particles] {
    26212625        array unset info
    26222626        array set info $part
    26232627        set color [Color2RGB $info(color)]
    2624         append cmd "$tag particles add $info(name) -position $info(position) "
    2625         append cmd "-axis $info(axis) -color {$color} -size $info(size)\n"
     2628        append cmd "$tag particles add $info(name)"
     2629        append cmd " -position $info(position)"
     2630        append cmd " -hide $info(hide)"
     2631        append cmd " -axis $info(axis)"
     2632        append cmd " -color {$color}"
     2633        append cmd " -size $info(size)\n"
    26262634    }
    26272635    foreach box [$flowobj boxes] {
     
    26342642        }
    26352643        set color [Color2RGB $info(color)]
    2636         append cmd "$tag box add $info(name) -color {$color} "
    2637         append cmd "-hide $info(hide) -linewidth $info(linewidth) "
    2638         append cmd "-corner1 {$info(corner1)} -corner2 {$info(corner2)}\n"
     2644        append cmd "$tag box add $info(name)"
     2645        append cmd " -color {$color}"
     2646        append cmd " -hide $info(hide)"
     2647        append cmd " -linewidth $info(linewidth) "
     2648        append cmd " -corner1 {$info(corner1)} "
     2649        append cmd " -corner2 {$info(corner2)}\n"
    26392650    }   
    26402651    append cmd "$tag data follows $nbytes $extents\n"
     
    28492860}
    28502861
    2851 itcl::body Rappture::FlowvisViewer::GetMovie { widget width height } {
     2862itcl::body Rappture::FlowvisViewer::GetMovie { widget w h } {
    28522863    set token "movie[incr _nextToken]"
    28532864    set var ::Rappture::FlowvisViewer::_hardcopy($this-$token)
     
    28582869    set popup .flowvisviewermovie
    28592870    if {![winfo exists $popup]} {
    2860         Rappture::Balloon $popup -title "Generating video..."
     2871        Rappture::Balloon $popup -title "Generating movie..."
    28612872        set inner [$popup component inner]
    2862         label $inner.title -text "Generating Hardcopy" -font "Arial 10 bold"
    2863         label $inner.please -text "This may take a few minutes." -font "Arial 10"
     2873        label $inner.title -text "Generating movie for download" \
     2874                -font "Arial 10 bold"
     2875        label $inner.please -text "This may take a few minutes." \
     2876                -font "Arial 10"
    28642877        label $inner.icon -image [Rappture::icon bigroller0]
    28652878        button $inner.cancel -text "Cancel" -font "Arial 10 bold" \
     
    28762889        set inner [$popup component inner]
    28772890    }
    2878     $_dispatcher event -after 300000 !movietimeout
     2891    # Timeout is set to 10 minutes.
     2892    $_dispatcher event -after 600000 !movietimeout
    28792893    WaitIcon start $inner.icon
    28802894    grab set -local $inner
     
    28852899    set nframes [expr round($_flow(duration) / $_flow(delay))]
    28862900    set framerate [expr 1000.0 / $_flow(delay)]
     2901
     2902    # These are specific to MPEG1 video generation
    28872903    set framerate 25.0
    2888     set bitrate 6000000
     2904    set bitrate 6.0e+6
    28892905
    28902906    set start [clock seconds]
    2891     SendCmd "flow video $width $height $nframes $framerate $bitrate $token"
     2907    SendCmd "flow video $token -width $w -height $h -numframes $nframes "
    28922908   
    28932909    $popup activate $widget below
    28942910    update
    2895     # We wait here for either
    2896     #  1) the png to be delivered or
    2897     #  2) timeout or 
    2898     #  3) user cancels the operation.
     2911    # We wait here until
     2912    #  1. the movie is delivered or
     2913    #  2. we've timed out or 
     2914    #  3. the user has canceled the operation.b
    28992915    tkwait variable $var
    29002916
    2901     puts stderr "I'm back in [expr [clock seconds] - $start] seconds."
     2917    puts stderr "Video generated in [expr [clock seconds] - $start] seconds."
     2918
    29022919    # Clean up.
    29032920    $_dispatcher cancel !movietimeout
     
    29082925    update
    29092926
     2927    # This will both cancel the movie generation (if it hasn't already
     2928    # completed) and reset the flow.
     2929    SendCmd "flow reset"
    29102930    if { $_hardcopy($this-$token) != "" } {
    29112931        return [list .mpg $_hardcopy($this-$token)]
  • trunk/gui/scripts/nanovisviewer.tcl

    r1448 r1514  
    5656    public method camera {option args}
    5757    public method delete {args}
     58    public method disconnect {}
    5859    public method download {option args}
    5960    public method get {args}
     
    6162    public method limits { tf }
    6263    public method overmarker { m x }
     64    public method sendto { string }
    6365    public method parameters {title args} {
    6466        # do nothing
     
    6971
    7072    protected method Connect {}
    71     protected method CurrentVolumeIds {{what -all}}
     73    protected method CurrentVolumes {{what -all}}
    7274    protected method Disconnect {}
    7375    protected method DoResize {}
     
    106108    private variable _allDataObjs
    107109    private variable _obj2ovride   ;# maps dataobj => style override
    108     private variable _obj2id       ;# maps dataobj-component to volume ID
    109                                     # in the server
    110     private variable _id2obj       ;# maps dataobj => volume ID in server
     110    private variable _serverObjs   ;# contains all the dataobj-component
     111                                   ;# to volumes in the server
    111112    private variable _sendobjs ""  ;# list of data objs to send to server
    112     private variable _receiveIds   ;# list of data objs to send to server
     113    private variable _recvdObjs   ;# list of data objs to send to server
    113114    private variable _obj2style    ;# maps dataobj-component to transfunc
    114115    private variable _style2objs   ;# maps tf back to list of
     
    186187        pan-y   0
    187188    }
    188     set _obj2id(count) 0
    189     set _id2obj(count) 0
    190189    set _limits(vmin) 0.0
    191190    set _limits(vmax) 1.0
     
    463462        if { $pos >= 0 } {
    464463            foreach comp [$dataobj components] {
    465                 if { [info exists obj2id($dataobj-$comp)] } {
    466                     set ivol $_obj2id($dataobj-$comp)
    467                     array unset _limits $ivol-*
     464                set tag $dataobj-$comp
     465                if { [info exists obj2id($tag)] } {
     466                    array unset _limits $tag-*
    468467                }
    469468            }
    470469            set _dlist [lreplace $_dlist $pos $pos]
    471470            array unset _obj2ovride $dataobj-*
    472             array unset _obj2id $dataobj-*
     471            array unset _serverObjs $dataobj-*
    473472            array unset _obj2style $dataobj-*
    474473            set changed 1
     
    481480            set list {}
    482481            foreach {dataobj comp} $_style2objs($tf) break
    483             if { [info exists _obj2id($dataobj-$comp)] } {
     482            if { [info exists _serverObjs($dataobj-$comp)] } {
    484483                lappend list $dataobj $comp
    485484            }
     
    599598
    600599#
     600# disconnect --
     601#
     602itcl::body Rappture::NanovisViewer::disconnect {} {
     603    Disconnect
     604}
     605
     606#
    601607# Disconnect --
    602608#
     
    609615    # disconnected -- no more data sitting on server
    610616    set _outbuf ""
    611     catch {unset _obj2id}
    612     array unset _id2obj
    613     set _obj2id(count) 0
    614     set _id2obj(count) 0
     617    catch {unset _serverObjs}
    615618    set _sendobjs ""
     619}
     620
     621#
     622# sendto --
     623#
     624itcl::body Rappture::NanovisViewer::sendto { bytes } {
     625    SendBytes "$bytes\n"
    616626}
    617627
     
    655665                return
    656666            }
    657             set ivol $_obj2id(count)
    658             incr _obj2id(count)
    659667            NameTransferFunc $dataobj $comp
    660             set _receiveIds($ivol) 1
     668            set _recvdObjs($dataobj-$comp) 1
    661669        }
    662670    }
     
    687695    }
    688696    SendCmd "volume state 0"
    689     set vols {}
    690     foreach key [array names _obj2id $_first-*] {
    691         lappend vols $_obj2id($key)
    692     }
     697    set vols [array names _serverObjs $_first-*]
    693698    if { $vols != ""  && $_settings($this-volume) } {
    694699        SendCmd "volume state 1 $vols"
    695700    }
    696701    # sync the state of slicers
    697     set vols [CurrentVolumeIds -cutplanes]
     702    set vols [CurrentVolumes -cutplanes]
    698703    foreach axis {x y z} {
    699704        SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols"
     
    809814    set w [winfo width $c]
    810815    set h [winfo height $c]
    811     #foreach { dataobj comp } $_id2obj($ivol) break
    812816    set lx 10
    813817    set ly [expr {$h - 1}]
     
    849853#       doesn't parse 3D data formats, we rely on the server (nanovis) to
    850854#       tell us what the limits are.  Once we've received the limits to all
    851 #       the data we've sent (tracked by _receiveIds) we can then determine
     855#       the data we've sent (tracked by _recvdObjs) we can then determine
    852856#       what the transfer functions are for these volumes.
    853857#
     
    868872    array set info $args
    869873
    870     set ivol $info(id);         # Id of volume created by server.
    871874    set tag $info(tag)
    872875    set parts [split $tag -]
     
    875878    # Volumes don't exist until we're told about them.
    876879    #
    877     set _id2obj($ivol) $parts
    878880    set dataobj [lindex $parts 0]
    879     set _obj2id($tag) $ivol
     881    set _serverObjs($tag) $tag
    880882    if { $_settings($this-volume) && $dataobj == $_first } {
    881         SendCmd "volume state 1 $ivol"
    882     }
    883     set _limits($ivol-min) $info(min);  # Minimum value of the volume.
    884     set _limits($ivol-max) $info(max);  # Maximum value of the volume.
     883        SendCmd "volume state 1 $tag"
     884    }
     885    set _limits($tag-min) $info(min);  # Minimum value of the volume.
     886    set _limits($tag-max) $info(max);  # Maximum value of the volume.
    885887    set _limits(vmin)      $info(vmin); # Overall minimum value.
    886888    set _limits(vmax)      $info(vmax); # Overall maximum value.
    887889
    888     unset _receiveIds($ivol)
     890    unset _recvdObjs($tag)
    889891    if { [array size _receiveIds] == 0 } {
    890892        updatetransferfuncs
     
    936938    foreach dataobj [get] {
    937939        set comp [lindex [$dataobj components] 0]
    938         if {![info exists _obj2id($dataobj-$comp)]} {
     940        if {![info exists _serverObjs($dataobj-$comp)]} {
    939941            set i [lsearch -exact $_sendobjs $dataobj]
    940942            if {$i < 0} {
     
    971973        }
    972974        SendCmd "volume state 0"
    973         foreach key [array names _obj2id $_first-*] {
    974             SendCmd "volume state 1 $_obj2id($key)"
    975         }
    976         #
    977         # The _obj2id and _id2style arrays may or may not have the right
    978         # information.  It's possible for the server to know about volumes
    979         # that the client has assumed it's deleted.  We could add checks.
    980         # But this problem needs to be fixed not bandaided.
    981         set comp [lindex [$_first components] 0]
    982         set ivol $_obj2id($_first-$comp)
    983 
     975        set vols [array names _serverObjs $_first-*]
     976        if { $vols != "" } {
     977            SendCmd "volume state 1 $vols"
     978        }
    984979        foreach comp [$_first components] {
    985980            NameTransferFunc $_first $comp
     
    988983
    989984    # sync the state of slicers
    990     set vols [CurrentVolumeIds -cutplanes]
     985    set vols [CurrentVolumes -cutplanes]
    991986    foreach axis {x y z} {
    992987        SendCmd "cutplane state $_settings($this-${axis}cutplane) $axis $vols"
     
    10051000
    10061001# ----------------------------------------------------------------------
    1007 # USAGE: CurrentVolumeIds ?-cutplanes?
     1002# USAGE: CurrentVolumes ?-cutplanes?
    10081003#
    10091004# Returns a list of volume server IDs for the current volume being
     
    10111006# of IDs if the current data object has multiple components.
    10121007# ----------------------------------------------------------------------
    1013 itcl::body Rappture::NanovisViewer::CurrentVolumeIds {{what -all}} {
     1008itcl::body Rappture::NanovisViewer::CurrentVolumes {{what -all}} {
    10141009    set rlist ""
    10151010    if { $_first == "" } {
    10161011        return
    10171012    }
    1018     foreach key [array names _obj2id *-*] {
    1019         if {[string match $_first-* $key]} {
    1020             array set style {
    1021                 -cutplanes 1
    1022             }
    1023             foreach {dataobj comp} [split $key -] break
    1024             array set style [lindex [$dataobj components -style $comp] 0]
    1025 
    1026             if {$what != "-cutplanes" || $style(-cutplanes)} {
    1027                 lappend rlist $_obj2id($key)
    1028             }
     1013    foreach key [array names _serverObjs $_first-*] {
     1014        array set style {
     1015            -cutplanes 1
     1016        }
     1017        foreach {dataobj comp} [split $key -] break
     1018        array set style [lindex [$dataobj components -style $comp] 0]
     1019        if {$what != "-cutplanes" || $style(-cutplanes)} {
     1020            lappend rlist $key
    10291021        }
    10301022    }
     
    12891281        "volume" {
    12901282            if { [isconnected] } {
    1291                 set vols [CurrentVolumeIds -cutplanes]
     1283                set vols [CurrentVolumes -cutplanes]
    12921284                SendCmd "volume data state $_settings($this-volume) $vols"
    12931285            }
     
    12971289            set bool $_settings($this-$what)
    12981290            if { [isconnected] } {
    1299                 set vols [CurrentVolumeIds -cutplanes]
     1291                set vols [CurrentVolumes -cutplanes]
    13001292                SendCmd "cutplane state $bool $axis $vols"
    13011293            }
     
    14791471    }
    14801472    SendBytes "transfunc define $tf { $cmap } { $wmap }\n"
    1481     if { [info exists _obj2id($dataobj-$comp)] } {
    1482         return [SendBytes "volume shading transfunc $tf $_obj2id($dataobj-$comp)\n"]
     1473    if { [info exists _serverObjs($dataobj-$comp)] } {
     1474        return [SendBytes "volume shading transfunc $tf $dataobj-$comp\n"]
    14831475    }
    14841476}
     
    16491641    set min ""; set max ""
    16501642    foreach {dataobj comp} $_style2objs($tf) {
    1651         if { ![info exists _obj2id($dataobj-$comp)] } {
     1643        set tag $dataobj-$comp
     1644        if { ![info exists _serverObjs($tag)] } {
    16521645            continue
    16531646        }
    1654         set ivol $_obj2id($dataobj-$comp)
    1655         if { ![info exists _limits($ivol-min)] } {
     1647        if { ![info exists _limits($tag-min)] } {
    16561648            continue
    16571649        }
    1658         if { $min == "" || $min > $_limits($ivol-min) } {
    1659             set min $_limits($ivol-min)
    1660         }
    1661         if { $max == "" || $max < $_limits($ivol-max) } {
    1662             set max $_limits($ivol-max)
     1650        if { $min == "" || $min > $_limits($tag-min) } {
     1651            set min $_limits($tag-min)
     1652        }
     1653        if { $max == "" || $max < $_limits($tag-max) } {
     1654            set max $_limits($tag-max)
    16631655        }
    16641656    }
     
    19581950
    19591951            set newpos [expr {0.01*$newval}]
    1960             set ids [CurrentVolumeIds -cutplanes]
    1961             SendCmd "cutplane position $newpos $axis $ids"
     1952            set vols [CurrentVolumes -cutplanes]
     1953            SendCmd "cutplane position $newpos $axis $vols"
    19621954        }
    19631955        default {
  • trunk/gui/scripts/unirect3d.tcl

    r1511 r1514  
    5757    set path [$field get $cname.mesh]
    5858    set m [$xmlobj element -as object $path]
    59     puts stderr [$m children]
    6059    GetValue $m "xaxis.max" _xMax
    6160    GetValue $m "xaxis.min" _xMin
     
    8988# ----------------------------------------------------------------------
    9089itcl::body Rappture::Unirect3d::blob {} {
    91     set time [time {
    9290    lappend data "unirect3d"
    9391    lappend data "xmin" $_xMin "xmax" $_xMax "xnum" $_xNum
     
    9896        lappend data "values" [$_values range 0 end]
    9997    }
    100     }]
    101     puts stderr blob7=$time
    10298    return $data
    103     #return [Rappture::encoding::encode -as b64 "$data"]
    10499}
    105100
Note: See TracChangeset for help on using the changeset viewer.