Changeset 4766 for branches/1.3/gui/scripts/vtkimageviewer.tcl
- Timestamp:
- Nov 23, 2014, 1:12:25 AM (10 years ago)
- Location:
- branches/1.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
-
branches/1.3/gui/scripts/vtkimageviewer.tcl
r4759 r4766 63 63 public method scale {args} 64 64 65 protected method Connect {}66 protected method CurrentDatasets {args}67 protected method Disconnect {}68 protected method DoResize {}69 protected method DoRotate {}70 protected method AdjustSetting {what {value ""}}71 protected method AdjustMode {}72 protected method InitSettings { args }73 protected method Pan {option x y}74 protected method Pick {x y}75 protected method Rebuild {}76 protected method ReceiveDataset { args }77 protected method ReceiveImage { args }78 protected method ReceiveLegend { colormap title min max size }79 protected method Rotate {option x y}80 protected method Zoom {option}81 82 65 # The following methods are only used by this class. 66 private method AdjustSetting {what {value ""}} 83 67 private method BuildAxisTab {} 84 68 private method BuildCameraTab {} … … 87 71 private method BuildDownloadPopup { widget command } 88 72 private method Combo { option } 73 private method Connect {} 74 private method CurrentDatasets {args} 75 private method Disconnect {} 76 private method DoResize {} 77 private method DoRotate {} 89 78 private method DrawLegend {} 90 79 private method EnterLegend { x y } … … 94 83 private method GetImage { args } 95 84 private method GetVtkData { args } 85 private method InitSettings { args } 96 86 private method IsValidObject { dataobj } 97 87 private method LeaveLegend {} 98 88 private method MotionLegend { x y } 89 private method Pan {option x y} 99 90 private method PanCamera {} 91 private method Pick {x y} 92 private method QuaternionToView { q } { 93 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 94 } 95 private method Rebuild {} 96 private method ReceiveDataset { args } 97 private method ReceiveImage { args } 98 private method ReceiveLegend { colormap title min max size } 100 99 private method RequestLegend {} 100 private method Rotate {option x y} 101 101 private method SetCurrentColormap { color } 102 102 private method SetLegendTip { x y } 103 103 private method SetObjectStyle { dataobj comp } 104 104 private method SetOrientation { side } 105 private method ViewToQuaternion {} { 106 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 107 } 108 private method Zoom {option} 105 109 106 110 private variable _arcball "" … … 196 200 # Initialize the view to some default parameters. 197 201 array set _view { 198 qw 0.36199 qx 0.25200 qy 0.50201 qz 0.70202 zoom 1.0203 xpan0204 ypan0205 ortho0202 -ortho 0 203 -qw 0.36 204 -qx 0.25 205 -qy 0.50 206 -qz 0.70 207 -xpan 0 208 -ypan 0 209 -zoom 1.0 206 210 } 207 211 set _arcball [blt::arcball create 100 100] 208 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 209 $_arcball quaternion $q 212 $_arcball quaternion [ViewToQuaternion] 210 213 211 214 array set _settings { … … 429 432 430 433 itcl::body Rappture::VtkImageViewer::DoRotate {} { 431 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 432 SendCmd "camera orient $q" 434 SendCmd "camera orient [ViewToQuaternion]" 433 435 set _rotatePending 0 434 436 } … … 454 456 455 457 itcl::body Rappture::VtkImageViewer::EventuallyRotate { q } { 456 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break458 QuaternionToView $q 457 459 if { !$_rotatePending } { 458 460 set _rotatePending 1 … … 926 928 927 929 SendCmd "axis lrot z 90" 928 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 929 $_arcball quaternion $q 930 $_arcball quaternion [ViewToQuaternion] 930 931 if {$_settings(view3D) } { 931 if { $_view( ortho)} {932 if { $_view(-ortho)} { 932 933 SendCmd "camera mode ortho" 933 934 } else { … … 971 972 lappend info "dataset_size" $length 972 973 lappend info "dataset_tag" $tag 973 SendCmd [list "clientinfo" $info]974 SendCmd "clientinfo [list $info]" 974 975 } 975 976 SendCmd "dataset add $tag data follows $length" … … 1044 1045 # Reset the camera and other view parameters 1045 1046 # 1046 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1047 $_arcball quaternion $q 1047 $_arcball quaternion [ViewToQuaternion] 1048 1048 if {$_settings(view3D) } { 1049 if { $_view( ortho)} {1049 if { $_view(-ortho)} { 1050 1050 SendCmd "camera mode ortho" 1051 1051 } else { … … 1130 1130 switch -- $option { 1131 1131 "in" { 1132 set _view( zoom) [expr {$_view(zoom)*1.25}]1133 SendCmd "camera zoom $_view( zoom)"1132 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1133 SendCmd "camera zoom $_view(-zoom)" 1134 1134 } 1135 1135 "out" { 1136 set _view( zoom) [expr {$_view(zoom)*0.8}]1137 SendCmd "camera zoom $_view( zoom)"1136 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1137 SendCmd "camera zoom $_view(-zoom)" 1138 1138 } 1139 1139 "reset" { 1140 1140 array set _view { 1141 qw 0.361142 qx 0.251143 qy 0.501144 qz 0.701145 zoom 1.01146 xpan 01147 ypan 01141 -qw 0.36 1142 -qx 0.25 1143 -qy 0.50 1144 -qz 0.70 1145 -xpan 0 1146 -ypan 0 1147 -zoom 1.0 1148 1148 } 1149 1149 if { $_first != "" } { … … 1153 1153 } 1154 1154 } 1155 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1156 $_arcball quaternion $q 1155 $_arcball quaternion [ViewToQuaternion] 1157 1156 if {$_settings(view3D) } { 1158 1157 DoRotate … … 1164 1163 1165 1164 itcl::body Rappture::VtkImageViewer::PanCamera {} { 1166 set x $_view( xpan)1167 set y $_view( ypan)1165 set x $_view(-xpan) 1166 set y $_view(-ypan) 1168 1167 SendCmd "camera pan $x $y" 1169 1168 } … … 1243 1242 set x [expr $x / double($w)] 1244 1243 set y [expr $y / double($h)] 1245 set _view( xpan) [expr $_view(xpan) + $x]1246 set _view( ypan) [expr $_view(ypan) + $y]1244 set _view(-xpan) [expr $_view(-xpan) + $x] 1245 set _view(-ypan) [expr $_view(-ypan) + $y] 1247 1246 PanCamera 1248 1247 return … … 1266 1265 set _click(x) $x 1267 1266 set _click(y) $y 1268 set _view( xpan) [expr $_view(xpan) - $dx]1269 set _view( ypan) [expr $_view(ypan) - $dy]1267 set _view(-xpan) [expr $_view(-xpan) - $dx] 1268 set _view(-ypan) [expr $_view(-ypan) - $dy] 1270 1269 PanCamera 1271 1270 } … … 1427 1426 $itk_component(opacity) configure -state normal 1428 1427 $itk_component(opacity_l) configure -state normal 1429 if {$_view( ortho)} {1428 if {$_view(-ortho)} { 1430 1429 SendCmd "camera mode ortho" 1431 1430 } else { … … 1442 1441 } 1443 1442 if { $bool } { 1444 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1443 set q [ViewToQuaternion] 1445 1444 $_arcball quaternion $q 1446 1445 SendCmd "camera orient $q" … … 1887 1886 label $inner.${tag}label -text $tag -font "Arial 9" 1888 1887 entry $inner.${tag} -font "Arial 9" -bg white \ 1889 -textvariable [itcl::scope _view( $tag)]1888 -textvariable [itcl::scope _view(-$tag)] 1890 1889 bind $inner.${tag} <Return> \ 1891 [itcl::code $this camera set ${tag}]1890 [itcl::code $this camera set -${tag}] 1892 1891 bind $inner.${tag} <KP_Enter> \ 1893 [itcl::code $this camera set ${tag}]1892 [itcl::code $this camera set -${tag}] 1894 1893 blt::table $inner \ 1895 1894 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1900 1899 checkbutton $inner.ortho \ 1901 1900 -text "Orthographic Projection" \ 1902 -variable [itcl::scope _view( ortho)] \1903 -command [itcl::code $this camera set ortho] \1901 -variable [itcl::scope _view(-ortho)] \ 1902 -command [itcl::code $this camera set -ortho] \ 1904 1903 -font "Arial 9" 1905 1904 blt::table $inner \ … … 1922 1921 } 1923 1922 "set" { 1924 set wh o[lindex $args 0]1925 set x $_view($wh o)1923 set what [lindex $args 0] 1924 set x $_view($what) 1926 1925 set code [catch { string is double $x } result] 1927 1926 if { $code != 0 || !$result } { 1928 1927 return 1929 1928 } 1930 switch -- $wh o{1931 " ortho" {1932 if {$_view( ortho)} {1929 switch -- $what { 1930 "-ortho" { 1931 if {$_view($what)} { 1933 1932 SendCmd "camera mode ortho" 1934 1933 } else { … … 1936 1935 } 1937 1936 } 1938 " xpan" - "ypan" {1937 "-xpan" - "-ypan" { 1939 1938 PanCamera 1940 1939 } 1941 " qx" - "qy" - "qz" - "qw" {1942 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1940 "-qx" - "-qy" - "-qz" - "-qw" { 1941 set q [ViewToQuaternion] 1943 1942 $_arcball quaternion $q 1944 1943 EventuallyRotate $q 1945 1944 } 1946 " zoom" {1947 SendCmd "camera zoom $_view( zoom)"1945 "-zoom" { 1946 SendCmd "camera zoom $_view($what)" 1948 1947 } 1949 1948 } … … 2323 2322 bottom "0 1 0 0" 2324 2323 } 2325 foreach name { qw qx qyqz } value $positions($side) {2324 foreach name { -qw -qx -qy -qz } value $positions($side) { 2326 2325 set _view($name) $value 2327 2326 } 2328 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2327 set q [ViewToQuaternion] 2329 2328 $_arcball quaternion $q 2330 2329 SendCmd "camera orient $q" 2331 2330 SendCmd "camera reset" 2332 set _view( xpan) 02333 set _view( ypan) 02334 set _view( zoom) 1.02335 } 2331 set _view(-xpan) 0 2332 set _view(-ypan) 0 2333 set _view(-zoom) 1.0 2334 }
Note: See TracChangeset
for help on using the changeset viewer.