- Timestamp:
- May 27, 2009, 6:17:22 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/Makefile.in
r1463 r1471 48 48 $(srcdir)/field3dresult.tcl \ 49 49 $(srcdir)/filexfer.tcl \ 50 $(srcdir)/flowdial.tcl \ 50 51 $(srcdir)/flowhints.tcl \ 51 52 $(srcdir)/flowvisviewer.tcl \ -
trunk/gui/scripts/flowvisviewer.tcl
r1463 r1471 105 105 private method ComputeTransferFunc { tf } 106 106 private method EventuallyResize { w h } 107 private method EventuallyGoto { nSteps } 107 108 private method EventuallyResizeLegend { } 108 109 private method FlowCmd { dataobj comp nbytes extents } … … 113 114 private method ParseMarkersOption { tf markers } 114 115 private method WaitIcon { option widget } 115 116 private method str2millisecs { value } 117 private method millisecs2str { value } 118 private method IsMapped { widget } 116 119 private method GetFlowInfo { widget } 117 120 private method particles { tag name } … … 154 157 private variable _resizePending 0 155 158 private variable _resizeLegendPending 0 159 private variable _gotoPending 0 156 160 } 157 161 … … 191 195 $_dispatcher dispatch $this !play "[itcl::code $this flow next]; list" 192 196 197 # Draw legend event 198 $_dispatcher register !goto 199 $_dispatcher dispatch $this !goto "[itcl::code $this flow goto2]; list" 200 193 201 set _flow(state) 0 194 202 … … 220 228 221 229 array set _settings [subst { 230 $this-currenttime 0 222 231 $this-loop 0 223 232 $this-pan-x $_view(pan-x) … … 385 394 "Play continuously" 386 395 387 # Frame388 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 0394 } {395 usual396 ignore -highlightthickness397 rename -background -controlbackground controlBackground Background398 }399 $itk_component(frame) set 1400 401 396 itk_component add dial { 402 Rappture:: Radiodial $itk_component(flowcontrols).dial \397 Rappture::Flowdial $itk_component(flowcontrols).dial \ 403 398 -length 10 -valuewidth 0 -valuepadding 0 -padding 6 \ 404 399 -linecolor "" -activelinecolor "" \ 400 -min 0.0 -max 1.0 \ 401 -variable [itcl::scope _settings($this-currenttime)] \ 405 402 -knobimage [Rappture::icon knob2] -knobposition center@middle 406 403 } { 407 404 usual 408 keep-dialprogresscolor405 ignore -dialprogresscolor 409 406 rename -background -controlbackground controlBackground Background 410 407 } 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] 414 410 # Duration 415 411 itk_component add duration { … … 461 457 0,3 $itk_component(loop) -padx {2 0} \ 462 458 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} 467 462 468 463 blt::table configure $itk_component(flowcontrols) c* -resize none … … 2493 2488 set _height $h 2494 2489 if { !$_resizePending } { 2495 $_dispatcher event - idle!resize2490 $_dispatcher event -after 200 !resize 2496 2491 set _resizePending 1 2497 2492 } … … 2502 2497 $_dispatcher event -idle !legend 2503 2498 set _resizeLegendPending 1 2499 } 2500 } 2501 2502 itcl::body Rappture::FlowvisViewer::EventuallyGoto { nSteps } { 2503 set _flow(goto) $nSteps 2504 if { !$_gotoPending } { 2505 $_dispatcher event -after 1000 !goto 2506 set _gotoPending 1 2504 2507 } 2505 2508 } … … 2597 2600 set option [lindex $args 0] 2598 2601 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 } 2599 2623 "speed" { 2600 2624 set speed [$itk_component(speed) value] … … 2602 2626 } 2603 2627 "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 } { 2614 2630 bell 2615 2631 return 2616 2632 } 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 2624 2636 } 2625 2637 "off" { … … 2632 2644 flow duration 2633 2645 set _flow(state) 1 2634 set _ flow(time) 02646 set _settings($this-currenttime) 0 2635 2647 $itk_component(play) select 2636 2648 } … … 2651 2663 flow on 2652 2664 # 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) } { 2655 2668 set _settings($this-step) 1 2656 2669 SendCmd "flow reset" … … 2667 2680 } 2668 2681 "reset" { 2669 set _flow(time) 02670 2682 set _settings($this-currenttime) 0 2671 2683 SendCmd "flow reset" … … 2675 2687 } 2676 2688 "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 2688 2693 } 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) } { 2691 2697 if { !$_settings($this-loop) } { 2692 2698 flow off … … 2697 2703 SendCmd "flow next" 2698 2704 } 2699 set _settings($this-currenttime) $_flow(time)2700 2705 $_dispatcher event -after $_flow(delay) !play 2701 2706 } … … 2788 2793 } 2789 2794 2795 itcl::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 2809 itcl::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 2816 itcl::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.