Changeset 1506 for trunk/gui/scripts/flowvisviewer.tcl
- Timestamp:
- Jun 10, 2009 2:40:56 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/flowvisviewer.tcl
r1498 r1506 111 111 private method FlowCmd { dataobj comp nbytes extents } 112 112 private method GetMovie { widget width height } 113 private method GetPngImage { widget width height } 113 114 private method NameTransferFunc { dataobj comp } 114 115 private method PanCamera {} … … 147 148 private variable _first "" ;# This is the topmost volume. 148 149 private variable _buffering 0 150 private variable _nextToken 0 151 private variable _icon 0 149 152 private variable _flow 150 153 # This … … 152 155 # function to use when changing markers, 153 156 # opacity, or thickness. 154 common _downloadPopup ;# download options from popup157 private common _downloadPopup ;# download options from popup 155 158 156 159 private common _hardcopy … … 200 203 $_dispatcher register !goto 201 204 $_dispatcher dispatch $this !goto "[itcl::code $this flow goto2]; list" 205 206 $_dispatcher register !movietimeout 207 $_dispatcher register !waiticon 202 208 203 209 set _flow(state) 0 … … 735 741 # ---------------------------------------------------------------------- 736 742 itcl::body Rappture::FlowvisViewer::download {option args} { 743 set popup .flowvisviewerdownload 737 744 switch $option { 738 745 coming { … … 745 752 } 746 753 controls { 747 set popup .flowvisviewerdownload 748 if {![winfo exists .flowvisviewerdownload]} { 754 if {![winfo exists $popup]} { 749 755 # if we haven't created the popup yet, do it now 750 756 Rappture::Balloon $popup \ … … 756 762 set res "[image width $img]x[image height $img]" 757 763 radiobutton $inner.draft -text "Image (draft $res)" \ 758 -variable Rappture:: MolvisViewer::_downloadPopup(format) \764 -variable Rappture::FlowvisViewer::_downloadPopup(format) \ 759 765 -value draft 760 766 pack $inner.draft -anchor w … … 762 768 set res "640x480" 763 769 radiobutton $inner.medium -text "Movie (standard $res)" \ 764 -variable Rappture:: MolvisViewer::_downloadPopup(format) \770 -variable Rappture::FlowvisViewer::_downloadPopup(format) \ 765 771 -value $res 766 772 pack $inner.medium -anchor w … … 768 774 set res "1024x768" 769 775 radiobutton $inner.high -text "Movie (high quality $res)" \ 770 -variable Rappture:: MolvisViewer::_downloadPopup(format) \776 -variable Rappture::FlowvisViewer::_downloadPopup(format) \ 771 777 -value $res 772 778 pack $inner.high -anchor w … … 780 786 set num [llength [get]] 781 787 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:" 783 790 update idletasks ;# fix initial sizes 784 791 return $popup 785 792 } 786 793 now { 787 set popup .molvisviewerdownload 788 if {[winfo exists .molvisviewerdownload]} { 794 if { [winfo exists $popup] } { 789 795 $popup deactivate 790 796 } … … 796 802 # won't be necessary to decode the image data. 797 803 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] 800 806 } 801 807 "640x480" { … … 804 810 "1024x768" { 805 811 return [$this GetMovie [lindex $args 0] 1024 768] 812 } 813 default { 814 error "bad download format $_downloadPopup(format)" 806 815 } 807 816 } … … 1032 1041 set bytes [ReceiveBytes $info(-bytes)] 1033 1042 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 } 1043 1060 } 1044 1061 } … … 2786 2803 } 2787 2804 2788 itcl::body Rappture:: MolvisViewer::GetPngImage { widget width height } {2805 itcl::body Rappture::FlowvisViewer::GetPngImage { widget width height } { 2789 2806 set token "print[incr _nextToken]" 2790 set var ::Rappture:: MolvisViewer::_hardcopy($this-$token)2807 set var ::Rappture::FlowvisViewer::_hardcopy($this-$token) 2791 2808 set $var "" 2792 2809 … … 2794 2811 $_dispatcher dispatch $this !pngtimeout "set $var {} ; list" 2795 2812 2796 set popup . molvisviewerprint2813 set popup .flowvisviewerprint 2797 2814 if {![winfo exists $popup]} { 2798 2815 Rappture::Balloon $popup -title "Generating file..." … … 2845 2862 itcl::body Rappture::FlowvisViewer::GetMovie { widget width height } { 2846 2863 set token "movie[incr _nextToken]" 2847 set var ::Rappture:: MolvisViewer::_hardcopy($this-$token)2864 set var ::Rappture::FlowvisViewer::_hardcopy($this-$token) 2848 2865 set $var "" 2849 2866 … … 2870 2887 set inner [$popup component inner] 2871 2888 } 2872 $_dispatcher event -after 60000 !movietimeout2889 $_dispatcher event -after 300000 !movietimeout 2873 2890 WaitIcon start $inner.icon 2874 2891 grab set -local $inner … … 2877 2894 flow duration 2878 2895 flow speed 2879 set nframes [expr $_flow(duration) / $_flow(delay)]2896 set nframes [expr round($_flow(duration) / $_flow(delay))] 2880 2897 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] 2883 2902 SendCmd "flow video $width $height $nframes $framerate $bitrate $token" 2884 2903 … … 2891 2910 tkwait variable $var 2892 2911 2912 puts stderr "I'm back in [expr [clock seconds] - $start] seconds." 2893 2913 # Clean up. 2894 $_dispatcher cancel ! pngtimeout2914 $_dispatcher cancel !movietimeout 2895 2915 WaitIcon stop $inner.icon 2896 2916 grab release $inner
Note: See TracChangeset
for help on using the changeset viewer.