Changeset 5260 for branches/1.3
- Timestamp:
- Apr 17, 2015, 8:33:17 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/nanovisviewer.tcl
r5257 r5260 83 83 public method updateTransferFunctions {} 84 84 85 protected method Connect {}86 protected method CurrentDatasets {{what -all}}87 protected method Disconnect {}88 protected method DoResize {}89 protected method FixLegend {}90 protected method AdjustSetting {what {value ""}}91 protected method InitSettings { args }92 protected method Pan {option x y}93 protected method Rebuild {}94 protected method ReceiveData { args }95 protected method ReceiveImage { args }96 protected method ReceiveLegend { tf vmin vmax size }97 protected method Rotate {option x y}98 protected method SendTransferFuncs {}99 protected method Slice {option args}100 protected method SlicerTip {axis}101 protected method Zoom {option}102 103 85 # The following methods are only used by this class. 104 86 private method AddIsoMarker { x y } 87 private method AdjustSetting {what {value ""}} 105 88 private method BuildCameraTab {} 106 89 private method BuildCutplanesTab {} 107 90 private method BuildViewTab {} 108 91 private method BuildVolumeTab {} 109 private method ResetColormap { color }110 92 private method ComputeTransferFunc { tf } 93 private method Connect {} 94 private method CurrentDatasets {{what -all}} 95 private method Disconnect {} 96 private method DoResize {} 111 97 private method EventuallyResize { w h } 112 98 private method EventuallyResizeLegend { } 99 private method FixLegend {} 100 private method GetVolumeInfo { w } 101 private method InitSettings { args } 113 102 private method NameTransferFunc { dataobj comp } 103 private method Pan {option x y} 114 104 private method PanCamera {} 115 105 private method ParseLevelsOption { tf levels } 116 106 private method ParseMarkersOption { tf markers } 117 private method volume { tag name } 118 private method GetVolumeInfo { w } 107 private method QuaternionToView { q } { 108 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 109 } 110 private method Rebuild {} 111 private method ReceiveData { args } 112 private method ReceiveImage { args } 113 private method ReceiveLegend { tf vmin vmax size } 114 private method ResetColormap { color } 115 private method Rotate {option x y} 116 private method SendTransferFuncs {} 119 117 private method SetOrientation { side } 118 private method Slice {option args} 119 private method SlicerTip {axis} 120 private method ToggleVolume { tag name } 121 private method ViewToQuaternion {} { 122 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 123 } 124 private method Zoom {option} 120 125 121 126 private variable _arcball "" 122 127 123 private variable _dlist "" ;# list of data objects128 private variable _dlist "" ;# list of data objects 124 129 private variable _allDataObjs 125 private variable _obj2ovride ;# maps dataobj => style override130 private variable _obj2ovride ;# maps dataobj => style override 126 131 private variable _serverDatasets ;# contains all the dataobj-component 127 ;# to volumes in the server128 private variable _serverTfs ;# contains all the transfer functions129 ;# in the server.132 ;# to volumes in the server 133 private variable _serverTfs ;# contains all the transfer functions 134 ;# in the server. 130 135 private variable _recvdDatasets ;# list of data objs to send to server 131 136 private variable _dataset2style ;# maps dataobj-component to transfunc … … 133 138 # dataobj-components using the tf. 134 139 135 private variable _reset 1 ;# Connection to server has been reset136 private variable _click ;# info used for rotate operations137 private variable _limits ;# autoscale min/max for all axes138 private variable _view ;# view params for 3D view139 private variable _isomarkers ;# array of isosurface level values 0..1140 private variable _reset 1 ;# Connection to server has been reset 141 private variable _click ;# info used for rotate operations 142 private variable _limits ;# autoscale min/max for all axes 143 private variable _view ;# view params for 3D view 144 private variable _isomarkers ;# array of isosurface level values 0..1 140 145 private variable _settings 141 146 # Array of transfer functions in server. If 0 the transfer has been … … 143 148 # and loaded. 144 149 private variable _activeTfs 145 private variable _first "" ;# This is the topmost volume.150 private variable _first "" ;# This is the topmost volume. 146 151 147 152 common _downloadPopup ;# download options from popup … … 190 195 # Initialize the view to some default parameters. 191 196 array set _view { 192 qw 0.853553193 qx -0.353553194 qy 0.353553195 qz 0.146447196 zoom 1.0197 xpan 0198 ypan0197 -qw 0.853553 198 -qx -0.353553 199 -qy 0.353553 200 -qz 0.146447 201 -xpan 0 202 -ypan 0 203 -zoom 1.0 199 204 } 200 205 set _arcball [blt::arcball create 100 100] 201 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 202 $_arcball quaternion $q 206 $_arcball quaternion [ViewToQuaternion] 203 207 204 208 set _limits(vmin) 0.0 … … 207 211 208 212 array set _settings [subst { 209 $this-qw $_view( qw)210 $this-qx $_view( qx)211 $this-qy $_view( qy)212 $this-qz $_view( qz)213 $this-zoom $_view( zoom)214 $this-xpan $_view( xpan)215 $this-ypan $_view( ypan)213 $this-qw $_view(-qw) 214 $this-qx $_view(-qx) 215 $this-qy $_view(-qy) 216 $this-qz $_view(-qz) 217 $this-zoom $_view(-zoom) 218 $this-xpan $_view(-xpan) 219 $this-ypan $_view(-ypan) 216 220 $this-volume 1 217 221 $this-xcutplane 0 … … 243 247 } 244 248 pack $itk_component(reset) -side top -padx 2 -pady 2 245 Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" 249 Rappture::Tooltip::for $itk_component(reset) \ 250 "Reset the view to the default zoom level" 246 251 247 252 itk_component add zoomin { … … 292 297 293 298 # Legend 294 295 299 set _image(legend) [image create photo] 296 300 itk_component add legend { … … 887 891 DoResize 888 892 } 893 889 894 foreach dataobj [get] { 890 895 foreach cname [$dataobj components] { … … 901 906 if 0 { 902 907 set f [open "/tmp/volume.vtk" "w"] 903 puts $f $data 908 fconfigure $f -translation binary -encoding binary 909 puts -nonewline $f $data 904 910 close $f 905 911 } … … 931 937 # Reset the camera and other view parameters 932 938 # 933 set _settings($this-qw) $_view( qw)934 set _settings($this-qx) $_view( qx)935 set _settings($this-qy) $_view( qy)936 set _settings($this-qz) $_view( qz)937 set _settings($this-xpan) $_view( xpan)938 set _settings($this-ypan) $_view( ypan)939 set _settings($this-zoom) $_view( zoom)940 941 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]939 set _settings($this-qw) $_view(-qw) 940 set _settings($this-qx) $_view(-qx) 941 set _settings($this-qy) $_view(-qy) 942 set _settings($this-qz) $_view(-qz) 943 set _settings($this-xpan) $_view(-xpan) 944 set _settings($this-ypan) $_view(-ypan) 945 set _settings($this-zoom) $_view(-zoom) 946 947 set q [ViewToQuaternion] 942 948 $_arcball quaternion $q 943 949 SendCmd "camera orient $q" 944 950 SendCmd "camera reset" 945 951 PanCamera 946 SendCmd "camera zoom $_view( zoom)"952 SendCmd "camera zoom $_view(-zoom)" 947 953 InitSettings light2side light transp isosurface grid axes 948 954 … … 1024 1030 switch -- $option { 1025 1031 "in" { 1026 set _view( zoom) [expr {$_view(zoom)*1.25}]1027 set _settings($this-zoom) $_view( zoom)1028 SendCmd "camera zoom $_view( zoom)"1032 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1033 set _settings($this-zoom) $_view(-zoom) 1034 SendCmd "camera zoom $_view(-zoom)" 1029 1035 } 1030 1036 "out" { 1031 set _view( zoom) [expr {$_view(zoom)*0.8}]1032 set _settings($this-zoom) $_view( zoom)1033 SendCmd "camera zoom $_view( zoom)"1037 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1038 set _settings($this-zoom) $_view(-zoom) 1039 SendCmd "camera zoom $_view(-zoom)" 1034 1040 } 1035 1041 "reset" { 1036 1042 array set _view { 1037 qw 0.8535531038 qx -0.3535531039 qy 0.3535531040 qz 0.1464471041 zoom 1.01042 xpan01043 ypan01043 -qw 0.853553 1044 -qx -0.353553 1045 -qy 0.353553 1046 -qz 0.146447 1047 -xpan 0 1048 -ypan 0 1049 -zoom 1.0 1044 1050 } 1045 1051 if { $_first != "" } { … … 1049 1055 } 1050 1056 } 1051 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1057 set q [ViewToQuaternion] 1052 1058 $_arcball quaternion $q 1053 1059 SendCmd "camera orient $q" 1054 1060 SendCmd "camera reset" 1055 set _settings($this-qw) $_view( qw)1056 set _settings($this-qx) $_view( qx)1057 set _settings($this-qy) $_view( qy)1058 set _settings($this-qz) $_view( qz)1059 set _settings($this-xpan) $_view( xpan)1060 set _settings($this-ypan) $_view( ypan)1061 set _settings($this-zoom) $_view( zoom)1061 set _settings($this-qw) $_view(-qw) 1062 set _settings($this-qx) $_view(-qx) 1063 set _settings($this-qy) $_view(-qy) 1064 set _settings($this-qz) $_view(-qz) 1065 set _settings($this-xpan) $_view(-xpan) 1066 set _settings($this-ypan) $_view(-ypan) 1067 set _settings($this-zoom) $_view(-zoom) 1062 1068 } 1063 1069 } … … 1065 1071 1066 1072 itcl::body Rappture::NanovisViewer::PanCamera {} { 1067 #set x [expr ($_view(xpan)) / $_limits(xrange)] 1068 #set y [expr ($_view(ypan)) / $_limits(yrange)] 1069 set x $_view(xpan) 1070 set y $_view(ypan) 1073 set x $_view(-xpan) 1074 set y $_view(-ypan) 1071 1075 SendCmd "camera pan $x $y" 1072 1076 } 1073 1074 1077 1075 1078 # ---------------------------------------------------------------------- … … 1107 1110 1108 1111 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1109 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break1110 set _settings($this-qw) $_view( qw)1111 set _settings($this-qx) $_view( qx)1112 set _settings($this-qy) $_view( qy)1113 set _settings($this-qz) $_view( qz)1112 QuaternionToView $q 1113 set _settings($this-qw) $_view(-qw) 1114 set _settings($this-qx) $_view(-qx) 1115 set _settings($this-qy) $_view(-qy) 1116 set _settings($this-qz) $_view(-qz) 1114 1117 SendCmd "camera orient $q" 1115 1118 … … 1144 1147 set x [expr $x / double($w)] 1145 1148 set y [expr $y / double($h)] 1146 set _view( xpan) [expr $_view(xpan) + $x]1147 set _view( ypan) [expr $_view(ypan) + $y]1149 set _view(-xpan) [expr $_view(-xpan) + $x] 1150 set _view(-ypan) [expr $_view(-ypan) + $y] 1148 1151 PanCamera 1149 set _settings($this-xpan) $_view( xpan)1150 set _settings($this-ypan) $_view( ypan)1152 set _settings($this-xpan) $_view(-xpan) 1153 set _settings($this-ypan) $_view(-ypan) 1151 1154 return 1152 1155 } … … 1161 1164 set _click(x) $x 1162 1165 set _click(y) $y 1163 set _view( xpan) [expr $_view(xpan) - $dx]1164 set _view( ypan) [expr $_view(ypan) - $dy]1166 set _view(-xpan) [expr $_view(-xpan) - $dx] 1167 set _view(-ypan) [expr $_view(-ypan) - $dy] 1165 1168 PanCamera 1166 set _settings($this-xpan) $_view( xpan)1167 set _settings($this-ypan) $_view( ypan)1169 set _settings($this-xpan) $_view(-xpan) 1170 set _settings($this-ypan) $_view(-ypan) 1168 1171 } 1169 1172 if { $option == "release" } { … … 1913 1916 0,0 $inner.view_l -anchor e -pady 2 \ 1914 1917 0,1 $inner.view -anchor w -pady 2 1918 blt::table configure $inner r0 -resize none 1915 1919 1916 1920 set row 1 … … 1921 1925 -textvariable [itcl::scope _settings($this-$tag)] 1922 1926 bind $inner.${tag} <Return> \ 1923 [itcl::code $this camera set ${tag}]1927 [itcl::code $this camera set -${tag}] 1924 1928 bind $inner.${tag} <KP_Enter> \ 1925 [itcl::code $this camera set ${tag}]1929 [itcl::code $this camera set -${tag}] 1926 1930 blt::table $inner \ 1927 1931 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1931 1935 } 1932 1936 1933 blt::table configure $inner c* r*-resize none1937 blt::table configure $inner c* -resize none 1934 1938 blt::table configure $inner c2 -resize expand 1935 1939 blt::table configure $inner r$row -resize expand … … 1972 1976 itcl::body Rappture::NanovisViewer::SlicerTip {axis} { 1973 1977 set val [$itk_component(${axis}CutScale) get] 1974 # set val [expr {0.01*($val-50)1975 # *($_limits(${axis}max)-$_limits(${axis}min))1976 # + 0.5*($_limits(${axis}max)+$_limits(${axis}min))}]1977 1978 return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%" 1978 1979 } … … 2010 2011 } 2011 2012 "set" { 2012 set wh o[lindex $args 0]2013 set x $_settings($ this-$who)2013 set what [lindex $args 0] 2014 set x $_settings(${this}${what}) 2014 2015 set code [catch { string is double $x } result] 2015 2016 if { $code != 0 || !$result } { 2016 set _settings($ this-$who) $_view($who)2017 set _settings(${this}${what}) $_view($what) 2017 2018 return 2018 2019 } 2019 switch -- $wh o{2020 " xpan" - "ypan" {2021 set _view($wh o) $_settings($this-$who)2020 switch -- $what { 2021 "-xpan" - "-ypan" { 2022 set _view($what) $_settings(${this}${what}) 2022 2023 PanCamera 2023 2024 } 2024 " qx" - "qy" - "qz" - "qw" {2025 set _view($wh o) $_settings($this-$who)2026 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2025 "-qx" - "-qy" - "-qz" - "-qw" { 2026 set _view($what) $_settings(${this}${what}) 2027 set q [ViewToQuaternion] 2027 2028 $_arcball quaternion $q 2028 2029 SendCmd "camera orient $q" 2029 2030 } 2030 " zoom" {2031 set _view($wh o) $_settings($this-$who)2032 SendCmd "camera zoom $_view( zoom)"2031 "-zoom" { 2032 set _view($what) $_settings(${this}${what}) 2033 SendCmd "camera zoom $_view($what)" 2033 2034 } 2034 2035 } … … 2076 2077 -variable [itcl::scope _settings($this-volume-$name)] \ 2077 2078 -onvalue 0 -offvalue 1 \ 2078 -command [itcl::code $this volume $key $name] \2079 -command [itcl::code $this ToggleVolume $key $name] \ 2079 2080 -font "Arial 9" 2080 2081 Rappture::Tooltip::for $inner.vol$row $info(description) … … 2091 2092 } 2092 2093 2093 itcl::body Rappture::NanovisViewer:: volume { tag name } {2094 itcl::body Rappture::NanovisViewer::ToggleVolume { tag name } { 2094 2095 set bool $_settings($this-volume-$name) 2095 SendCmd "volume stat ue $bool $name"2096 SendCmd "volume state $bool $name" 2096 2097 } 2097 2098 … … 2105 2106 bottom "0.707107 0.707107 0 0" 2106 2107 } 2107 foreach name { qw qx qyqz } value $positions($side) {2108 foreach name { -qw -qx -qy -qz } value $positions($side) { 2108 2109 set _view($name) $value 2109 2110 } 2110 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2111 set q [ViewToQuaternion] 2111 2112 $_arcball quaternion $q 2112 2113 SendCmd "camera orient $q" 2113 2114 SendCmd "camera reset" 2114 set _view( xpan) 02115 set _view( ypan) 02116 set _view( zoom) 1.02117 set _settings($this-xpan) $_view( xpan)2118 set _settings($this-ypan) $_view( ypan)2119 set _settings($this-zoom) $_view( zoom)2120 } 2121 2115 set _view(-xpan) 0 2116 set _view(-ypan) 0 2117 set _view(-zoom) 1.0 2118 set _settings($this-xpan) $_view(-xpan) 2119 set _settings($this-ypan) $_view(-ypan) 2120 set _settings($this-zoom) $_view(-zoom) 2121 } 2122
Note: See TracChangeset
for help on using the changeset viewer.