- Timestamp:
- May 17, 2015, 4:33:53 PM (9 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field.tcl
r5463 r5526 1335 1335 set cname "component" 1336 1336 } 1337 # VTK file data: 1338 if { [info exists _comp2vtk($cname)] } { 1339 return $_comp2vtk($cname) 1340 } 1337 1341 # DX: Convert DX to VTK 1338 1342 if {[info exists _comp2dx($cname)]} { 1339 1343 set data $_comp2dx($cname) 1340 set data [Rappture::encoding::decode $data]1344 set data [Rappture::encoding::decode -as zb64 $data] 1341 1345 return [Rappture::DxToVtk $data] 1342 }1343 # VTK file data:1344 if { [info exists _comp2vtk($cname)] } {1345 return $_comp2vtk($cname)1346 1346 } 1347 1347 # Points on mesh: Construct VTK file output. -
trunk/gui/scripts/flowvisviewer.tcl
r5381 r5526 75 75 private method BuildCameraTab {} 76 76 private method BuildCutplanesTab {} 77 private method BuildDownloadPopup { widget command } 77 78 private method BuildViewTab {} 78 79 private method BuildVolumeComponents {} … … 90 91 private method GetDatasetsWithComponent { cname } 91 92 private method GetFlowInfo { widget } 93 private method GetImage { args } 92 94 private method GetMovie { widget width height } 93 95 private method GetPngImage { widget width height } 96 private method GetVtkData { args } 94 97 private method InitSettings { args } 95 98 private method NameTransferFunction { dataobj comp } … … 787 790 # ---------------------------------------------------------------------- 788 791 itcl::body Rappture::FlowvisViewer::download {option args} { 789 set popup .flowvisviewerdownload790 792 switch $option { 791 793 coming { … … 798 800 } 799 801 controls { 800 if {![winfo exists $popup]} { 801 # if we haven't created the popup yet, do it now 802 Rappture::Balloon $popup \ 803 -title "[Rappture::filexfer::label downloadWord] as..." 804 set inner [$popup component inner] 805 label $inner.summary -text "" -anchor w 806 pack $inner.summary -side top 807 set img $_image(plot) 808 set res "[image width $img]x[image height $img]" 809 radiobutton $inner.draft -text "Image (draft $res)" \ 810 -variable Rappture::FlowvisViewer::_downloadPopup(format) \ 811 -value draft 812 pack $inner.draft -anchor w 813 814 set res "640x480" 815 radiobutton $inner.medium -text "Movie (standard $res)" \ 816 -variable Rappture::FlowvisViewer::_downloadPopup(format) \ 817 -value $res 818 pack $inner.medium -anchor w 819 820 set res "1024x768" 821 radiobutton $inner.high -text "Movie (high quality $res)" \ 822 -variable Rappture::FlowvisViewer::_downloadPopup(format) \ 823 -value $res 824 pack $inner.high -anchor w 825 button $inner.go -text [Rappture::filexfer::label download] \ 826 -command [lindex $args 0] 827 pack $inner.go -pady 4 828 $inner.draft select 802 set popup .flowvisviewerdownload 803 if { ![winfo exists $popup] } { 804 set inner [BuildDownloadPopup $popup [lindex $args 0]] 829 805 } else { 830 806 set inner [$popup component inner] 831 807 } 832 set num [llength [get]] 833 set num [expr {($num == 1) ? "1 result" : "$num results"}] 808 # FIXME: we only support download of current active component 809 #set num [llength [get]] 810 #set num [expr {($num == 1) ? "1 result" : "$num results"}] 811 set num "current flow" 834 812 set word [Rappture::filexfer::label downloadWord] 835 813 $inner.summary configure -text "$word $num in the following format:" 836 update idletasks ;# fix initial sizes 837 update 814 update idletasks ;# Fix initial sizes 838 815 return $popup 839 816 } 840 817 now { 818 set popup .flowvisviewerdownload 841 819 if { [winfo exists $popup] } { 842 820 $popup deactivate 843 821 } 844 822 switch -- $_downloadPopup(format) { 845 draft {846 # Get the image data (as base64) and decode it back to847 # binary. This is better than writing to temporary848 # files. When we switch to the BLT picture image it849 # won't be necessary to decode the image data.850 set bytes [$_image(plot) data -format "jpeg -quality 100"]851 set bytes [Rappture::encoding::decode -as b64 $bytes]852 return [list .jpg $bytes]853 }854 823 "640x480" { 855 824 return [$this GetMovie [lindex $args 0] 640 480] … … 857 826 "1024x768" { 858 827 return [$this GetMovie [lindex $args 0] 1024 768] 828 } 829 "image" { 830 return [$this GetImage [lindex $args 0]] 831 } 832 "vtk" { 833 return [$this GetVtkData [lindex $args 0]] 859 834 } 860 835 default { … … 2744 2719 } 2745 2720 2721 itcl::body Rappture::FlowvisViewer::GetVtkData { args } { 2722 # FIXME: We can only put one component of one dataset in a single 2723 # VTK file. To download all components/results, we would need 2724 # to put them in an archive (e.g. zip or tar file) 2725 if { $_first != "" } { 2726 set cname [lindex [$_first components] 0] 2727 set bytes [$_first vtkdata $cname] 2728 return [list .vtk $bytes] 2729 } 2730 puts stderr "Failed to get vtkdata for $_first-$_current" 2731 return "" 2732 } 2733 2734 itcl::body Rappture::FlowvisViewer::GetImage { args } { 2735 if { [image width $_image(download)] > 0 && 2736 [image height $_image(download)] > 0 } { 2737 set bytes [$_image(download) data -format "jpeg -quality 100"] 2738 set bytes [Rappture::encoding::decode -as b64 $bytes] 2739 return [list .jpg $bytes] 2740 } 2741 return "" 2742 } 2743 2746 2744 itcl::body Rappture::FlowvisViewer::GetPngImage { widget width height } { 2747 2745 set token "print[incr _nextToken]" … … 2878 2876 } 2879 2877 2878 itcl::body Rappture::FlowvisViewer::BuildDownloadPopup { popup command } { 2879 Rappture::Balloon $popup \ 2880 -title "[Rappture::filexfer::label downloadWord] as..." 2881 set inner [$popup component inner] 2882 label $inner.summary -text "" -anchor w 2883 radiobutton $inner.vtk_button -text "VTK data file" \ 2884 -variable [itcl::scope _downloadPopup(format)] \ 2885 -font "Arial 9" \ 2886 -value vtk 2887 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 2888 2889 radiobutton $inner.image_button -text "Image File" \ 2890 -variable [itcl::scope _downloadPopup(format)] \ 2891 -font "Arial 9 " \ 2892 -value image 2893 Rappture::Tooltip::for $inner.image_button \ 2894 "Save as digital image." 2895 2896 set res "640x480" 2897 radiobutton $inner.movie_std -text "Movie (standard $res)" \ 2898 -variable [itcl::scope _downloadPopup(format)] \ 2899 -value $res 2900 Rappture::Tooltip::for $inner.movie_std \ 2901 "Save as movie file." 2902 2903 set res "1024x768" 2904 radiobutton $inner.movie_high -text "Movie (high quality $res)" \ 2905 -variable [itcl::scope _downloadPopup(format)] \ 2906 -value $res 2907 Rappture::Tooltip::for $inner.movie_high \ 2908 "Save as movie file." 2909 2910 button $inner.ok -text "Save" \ 2911 -highlightthickness 0 -pady 2 -padx 3 \ 2912 -command $command \ 2913 -compound left \ 2914 -image [Rappture::icon download] 2915 2916 button $inner.cancel -text "Cancel" \ 2917 -highlightthickness 0 -pady 2 -padx 3 \ 2918 -command [list $popup deactivate] \ 2919 -compound left \ 2920 -image [Rappture::icon cancel] 2921 2922 blt::table $inner \ 2923 0,0 $inner.summary -cspan 2 \ 2924 1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \ 2925 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2926 3,0 $inner.movie_std -anchor w -cspan 2 -padx { 4 0 } \ 2927 4,0 $inner.movie_high -anchor w -cspan 2 -padx { 4 0 } \ 2928 6,1 $inner.cancel -width .9i -fill y \ 2929 6,0 $inner.ok -padx 2 -width .9i -fill y 2930 blt::table configure $inner r5 -height 4 2931 blt::table configure $inner r6 -pady 4 2932 raise $inner.image_button 2933 $inner.vtk_button invoke 2934 return $inner 2935 } 2936 2880 2937 itcl::body Rappture::FlowvisViewer::str2millisecs { value } { 2881 2938 set parts [split $value :] -
trunk/gui/scripts/nanovisviewer.tcl
r5514 r5526 71 71 private method BuildCameraTab {} 72 72 private method BuildCutplanesTab {} 73 private method BuildDownloadPopup { widget command } 73 74 private method BuildViewTab {} 74 75 private method BuildVolumeComponents {} … … 86 87 private method GetColormap { cname color } 87 88 private method GetDatasetsWithComponent { cname } 89 private method GetImage { args } 90 private method GetVtkData { args } 88 91 private method HideAllMarkers {} 89 92 private method InitComponentSettings { cname } … … 602 605 } 603 606 controls { 604 # no controls for this download yet 605 return "" 607 set popup .nanovisdownload 608 if { ![winfo exists $popup] } { 609 set inner [BuildDownloadPopup $popup [lindex $args 0]] 610 } else { 611 set inner [$popup component inner] 612 } 613 # FIXME: we only support download of current active component 614 #set num [llength [get]] 615 #set num [expr {($num == 1) ? "1 result" : "$num results"}] 616 set num "current field component" 617 set word [Rappture::filexfer::label downloadWord] 618 $inner.summary configure -text "$word $num in the following format:" 619 update idletasks ;# Fix initial sizes 620 return $popup 606 621 } 607 622 now { 608 # Get the image data (as base64) and decode it back to binary. 609 # This is better than writing to temporary files. When we switch 610 # to the BLT picture image it won't be necessary to decode the 611 # image data. 612 if { [image width $_image(plot)] > 0 && 613 [image height $_image(plot)] > 0 } { 614 set bytes [$_image(plot) data -format "jpeg -quality 100"] 615 set bytes [Rappture::encoding::decode -as b64 $bytes] 616 return [list .jpg $bytes] 623 set popup .nanovisdownload 624 if { [winfo exists $popup] } { 625 $popup deactivate 626 } 627 switch -- $_downloadPopup(format) { 628 "image" { 629 return [$this GetImage [lindex $args 0]] 630 } 631 "vtk" { 632 return [$this GetVtkData [lindex $args 0]] 633 } 617 634 } 618 635 return "" … … 2020 2037 } 2021 2038 2039 itcl::body Rappture::NanovisViewer::GetVtkData { args } { 2040 # FIXME: We can only put one component of one dataset in a single 2041 # VTK file. To download all components/results, we would need 2042 # to put them in an archive (e.g. zip or tar file) 2043 if { $_first != "" && $_current != "" } { 2044 set bytes [$_first vtkdata $_current] 2045 return [list .vtk $bytes] 2046 } 2047 puts stderr "Failed to get vtkdata for $_first-$_current" 2048 return "" 2049 } 2050 2051 itcl::body Rappture::NanovisViewer::GetImage { args } { 2052 if { [image width $_image(download)] > 0 && 2053 [image height $_image(download)] > 0 } { 2054 set bytes [$_image(download) data -format "jpeg -quality 100"] 2055 set bytes [Rappture::encoding::decode -as b64 $bytes] 2056 return [list .jpg $bytes] 2057 } 2058 return "" 2059 } 2060 2061 itcl::body Rappture::NanovisViewer::BuildDownloadPopup { popup command } { 2062 Rappture::Balloon $popup \ 2063 -title "[Rappture::filexfer::label downloadWord] as..." 2064 set inner [$popup component inner] 2065 label $inner.summary -text "" -anchor w 2066 2067 radiobutton $inner.vtk_button -text "VTK data file" \ 2068 -variable [itcl::scope _downloadPopup(format)] \ 2069 -font "Arial 9" \ 2070 -value vtk 2071 Rappture::Tooltip::for $inner.vtk_button "Save as VTK data file." 2072 2073 radiobutton $inner.image_button -text "Image File" \ 2074 -variable [itcl::scope _downloadPopup(format)] \ 2075 -font "Arial 9 " \ 2076 -value image 2077 Rappture::Tooltip::for $inner.image_button \ 2078 "Save as digital image." 2079 2080 button $inner.ok -text "Save" \ 2081 -highlightthickness 0 -pady 2 -padx 3 \ 2082 -command $command \ 2083 -compound left \ 2084 -image [Rappture::icon download] 2085 2086 button $inner.cancel -text "Cancel" \ 2087 -highlightthickness 0 -pady 2 -padx 3 \ 2088 -command [list $popup deactivate] \ 2089 -compound left \ 2090 -image [Rappture::icon cancel] 2091 2092 blt::table $inner \ 2093 0,0 $inner.summary -cspan 2 \ 2094 1,0 $inner.vtk_button -anchor w -cspan 2 -padx { 4 0 } \ 2095 2,0 $inner.image_button -anchor w -cspan 2 -padx { 4 0 } \ 2096 4,1 $inner.cancel -width .9i -fill y \ 2097 4,0 $inner.ok -padx 2 -width .9i -fill y 2098 blt::table configure $inner r3 -height 4 2099 blt::table configure $inner r4 -pady 4 2100 raise $inner.image_button 2101 $inner.vtk_button invoke 2102 return $inner 2103 } 2104 2022 2105 itcl::body Rappture::NanovisViewer::SetOrientation { side } { 2023 2106 array set positions {
Note: See TracChangeset
for help on using the changeset viewer.