Changeset 1471 for trunk/gui


Ignore:
Timestamp:
May 27, 2009, 6:17:22 PM (15 years ago)
Author:
gah
Message:

added dial to flowvisviewer

Location:
trunk/gui/scripts
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/Makefile.in

    r1463 r1471  
    4848                $(srcdir)/field3dresult.tcl \
    4949                $(srcdir)/filexfer.tcl \
     50                $(srcdir)/flowdial.tcl \
    5051                $(srcdir)/flowhints.tcl \
    5152                $(srcdir)/flowvisviewer.tcl \
  • trunk/gui/scripts/flowvisviewer.tcl

    r1463 r1471  
    105105    private method ComputeTransferFunc { tf }
    106106    private method EventuallyResize { w h }
     107    private method EventuallyGoto { nSteps }
    107108    private method EventuallyResizeLegend { }
    108109    private method FlowCmd { dataobj comp nbytes extents }
     
    113114    private method ParseMarkersOption { tf markers }
    114115    private method WaitIcon { option widget }
    115 
     116    private method str2millisecs { value }
     117    private method millisecs2str { value }
     118    private method IsMapped { widget }
    116119    private method GetFlowInfo { widget }
    117120    private method particles { tag name }
     
    154157    private variable _resizePending 0
    155158    private variable _resizeLegendPending 0
     159    private variable _gotoPending 0
    156160}
    157161
     
    191195    $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list"
    192196   
     197    # Draw legend event
     198    $_dispatcher register !goto
     199    $_dispatcher dispatch $this !goto "[itcl::code $this flow goto2]; list"
     200
    193201    set _flow(state) 0
    194202
     
    220228
    221229    array set _settings [subst {
     230        $this-currenttime       0
    222231        $this-loop              0
    223232        $this-pan-x             $_view(pan-x)
     
    385394        "Play continuously"
    386395
    387     # Frame
    388     itk_component add frame {
    389         ::scale $itk_component(flowcontrols).frame -from 1 -to 100 \
    390             -showvalue 0 -orient horizontal -width 14 \
    391             -state disabled \
    392             -variable [itcl::scope _settings($this-currenttime)]  \
    393             -highlightthickness 0
    394     } {
    395         usual
    396         ignore -highlightthickness
    397         rename -background -controlbackground controlBackground Background
    398     }
    399     $itk_component(frame) set 1
    400 
    401396    itk_component add dial {
    402         Rappture::Radiodial $itk_component(flowcontrols).dial \
     397        Rappture::Flowdial $itk_component(flowcontrols).dial \
    403398            -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \
    404399            -linecolor "" -activelinecolor "" \
     400            -min 0.0 -max 1.0 \
     401            -variable [itcl::scope _settings($this-currenttime)] \
    405402            -knobimage [Rappture::icon knob2] -knobposition center@middle
    406403    } {
    407404        usual
    408         keep -dialprogresscolor
     405        ignore -dialprogresscolor
    409406        rename -background -controlbackground controlBackground Background
    410407    }
    411     grid $itk_component(dial) -row 1 -column 1 -sticky ew
    412     bind $itk_component(dial) <<Value>> [itcl::code $this _fixValue]
    413 
     408    $itk_component(dial) current 0.0
     409    bind $itk_component(dial) <<Value>> [itcl::code $this flow goto]
    414410    # Duration
    415411    itk_component add duration {
     
    461457        0,3 $itk_component(loop) -padx {2 0} \
    462458        0,4 $itk_component(dial) -fill x -padx {2 0 } \
    463         0,5 $itk_component(speedlabel) -padx {2 0} \
    464         0,6 $itk_component(speed) -padx {2 0} \
    465         0,7 $itk_component(durationlabel) -padx {2 0} \
    466         0,8 $itk_component(duration) -padx { 2 3}
     459        0,5 $itk_component(duration) -padx { 0 0} \
     460        0,6 $itk_component(speedlabel) -padx {2 0} \
     461        0,7 $itk_component(speed) -padx {2 3}
    467462
    468463    blt::table configure $itk_component(flowcontrols) c* -resize none
     
    24932488    set _height $h
    24942489    if { !$_resizePending } {
    2495         $_dispatcher event -idle !resize
     2490        $_dispatcher event -after 200 !resize
    24962491        set _resizePending 1
    24972492    }
     
    25022497        $_dispatcher event -idle !legend
    25032498        set _resizeLegendPending 1
     2499    }
     2500}
     2501
     2502itcl::body Rappture::FlowvisViewer::EventuallyGoto { nSteps } {
     2503    set _flow(goto) $nSteps
     2504    if { !$_gotoPending } {
     2505        $_dispatcher event -after 1000 !goto
     2506        set _gotoPending 1
    25042507    }
    25052508}
     
    25972600    set option [lindex $args 0]
    25982601    switch -- $option {
     2602        "goto2" {
     2603            puts stderr "actually sending \"flow goto $_flow(goto)\""
     2604            SendCmd "flow goto $_flow(goto)"
     2605            set _gotoPending 0
     2606        }
     2607        "goto" {
     2608            puts stderr "flow goto to $_settings($this-currenttime)"
     2609            # Figure out how many steps to the current time based upon
     2610            # the speed and duration.
     2611            set current $_settings($this-currenttime)
     2612            set speed [$itk_component(speed) value]
     2613            set time [str2millisecs $_settings($this-duration)]
     2614            $itk_component(dial) configure -max $time
     2615            set delay [expr int(round(500.0/$speed))]
     2616            puts stderr "duration=$time delay=$delay current=$current"
     2617            set timePerStep [expr {double($time) / $delay}]
     2618            puts stderr "timePerStep=$timePerStep"
     2619            set nSteps [expr {int(ceil($current/$timePerStep))}]
     2620            puts stderr "nSteps=$nSteps"
     2621            EventuallyGoto $nSteps
     2622        }
    25992623        "speed" {
    26002624            set speed [$itk_component(speed) value]
     
    26022626        }
    26032627        "duration" {
    2604             set value $_settings($this-duration)
    2605             set pattern1 {^ *([0-9]+):([0-5][0-9]) *$}
    2606             set pattern2 {^ *:([0-5][0-9]) *$}
    2607             if { [string is int $value] } {
    2608                 set _flow(duration) [expr $value * 1000]
    2609             } elseif { [regexp $pattern1 $value match mins secs] } {
    2610                 set _flow(duration) [expr (($mins * 60) + $secs) * 1000]
    2611             } elseif { [regexp $pattern2 $value match secs] } {
    2612                 set _flow(duration) [expr $secs * 1000]
    2613             } else {
     2628            set max [str2millisecs $_settings($this-duration)]
     2629            if { $max < 0 } {
    26142630                bell
    26152631                return
    26162632            }
    2617             if { $_flow(duration) > 600000 } {
    2618                 set _flow(duration) 600000
    2619             }
    2620             set min [expr $_flow(duration) / 60000]
    2621             set sec [expr ($_flow(duration) - ($min*60000)) / 1000]
    2622             set _settings($this-duration) [format %02d:%02d $min $sec]
    2623             $itk_component(frame) configure -to $_flow(duration)
     2633            set _flow(duration) $max
     2634            set _settings($this-duration) [millisecs2str $max]
     2635            $itk_component(dial) configure -max $max
    26242636        }
    26252637        "off" {
     
    26322644            flow duration
    26332645            set _flow(state) 1
    2634             set _flow(time) 0
     2646            set _settings($this-currenttime) 0
    26352647            $itk_component(play) select
    26362648        }
     
    26512663                flow on
    26522664                # If we're at the end of the flow, reset the flow.
    2653                 incr _flow(time) $_flow(delay)
    2654                 if { $_flow(time) >= $_flow(duration) } {
     2665                set _settings($this-currenttime) \
     2666                    [expr {$_settings($this-currenttime) + $_flow(delay)}]
     2667                if { $_settings($this-currenttime) >= $_flow(duration) } {
    26552668                    set _settings($this-step) 1
    26562669                    SendCmd "flow reset"
     
    26672680        }
    26682681        "reset" {
    2669             set _flow(time) 0
    26702682            set _settings($this-currenttime) 0
    26712683            SendCmd "flow reset"
     
    26752687        }
    26762688        "next" {
    2677             set w $itk_component(3dview)
    2678             while { $w != "" }  {
    2679                 if { ![winfo ismapped $w] } {
    2680                     flow stop
    2681                     puts stderr "$w isn't mapped"
    2682                     return
    2683                 }
    2684                 set w [winfo parent $w]
    2685                 if { [winfo toplevel $w] == $w } {
    2686                     break
    2687                 }
     2689            if { ![IsMapped $itk_component(3dview)] } {
     2690                flow stop
     2691                puts stderr "$w isn't mapped"
     2692                return
    26882693            }
    2689             incr _flow(time) $_flow(delay)
    2690             if { $_flow(time) >= $_flow(duration) } {
     2694            set _settings($this-currenttime) \
     2695                [expr {$_settings($this-currenttime) + $_flow(delay)}]
     2696            if { $_settings($this-currenttime) >= $_flow(duration) } {
    26912697                if { !$_settings($this-loop) } {
    26922698                    flow off
     
    26972703                SendCmd "flow next"
    26982704            }
    2699             set _settings($this-currenttime) $_flow(time)
    27002705            $_dispatcher event -after $_flow(delay) !play
    27012706        }
     
    27882793}
    27892794
     2795itcl::body Rappture::FlowvisViewer::str2millisecs { value } {
     2796    set pattern1 {^ *([0-9]+):([0-5][0-9]) *$}
     2797    set pattern2 {^ *:([0-5][0-9]) *$}
     2798    if { [string is int $value] } {
     2799        return [expr $value * 1000.0]
     2800    } elseif { [regexp $pattern1 $value match mins secs] } {
     2801        return [expr (($mins * 60) + $secs) * 1000.0]
     2802    } elseif { [regexp $pattern2 $value match secs] } {
     2803        return [expr $secs * 1000.0]
     2804    } else {
     2805        return -1
     2806    }
     2807}
     2808
     2809itcl::body Rappture::FlowvisViewer::millisecs2str { value } {
     2810    set min [expr floor($value / 60000.0)]
     2811    set sec [expr ($value - ($min*60000.0)) / 1000.0]
     2812    puts stderr "min=$min sec=$sec"
     2813    return [format %02d:%02d [expr round($min)] [expr round($sec)]]
     2814}
     2815
     2816itcl::body Rappture::FlowvisViewer::IsMapped { w } {
     2817    while { $w != "" }  {
     2818        if { ![winfo ismapped $w] } {
     2819            return 0
     2820        }
     2821        set w [winfo parent $w]
     2822        if { [winfo toplevel $w] == $w } {
     2823            break
     2824        }
     2825    }
     2826    return 1
     2827}
Note: See TracChangeset for help on using the changeset viewer.