Changeset 4766 for branches/1.3/gui/scripts/vtkglyphviewer.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/vtkglyphviewer.tcl
r4762 r4766 62 62 public method scale {args} 63 63 64 protected method Connect {}65 protected method CurrentDatasets {args}66 protected method Disconnect {}67 protected method DoResize {}68 protected method DoRotate {}69 protected method AdjustSetting {what {value ""}}70 protected method InitSettings { args }71 protected method Pan {option x y}72 protected method Pick {x y}73 protected method Rebuild {}74 protected method ReceiveDataset { args }75 protected method ReceiveImage { args }76 protected method ReceiveLegend { colormap title vmin vmax size }77 protected method Rotate {option x y}78 protected method Zoom {option}79 80 64 # The following methods are only used by this class. 65 private method AdjustSetting {what {value ""}} 81 66 private method BuildAxisTab {} 82 67 private method BuildCameraTab {} … … 87 72 private method DrawLegend {} 88 73 private method Combo { option } 74 private method Connect {} 75 private method CurrentDatasets {args} 76 private method Disconnect {} 77 private method DoResize {} 78 private method DoRotate {} 89 79 private method EnterLegend { x y } 90 80 private method EventuallyResize { w h } … … 94 84 private method GetImage { args } 95 85 private method GetVtkData { args } 86 private method InitSettings { args } 96 87 private method IsValidObject { dataobj } 97 88 private method LeaveLegend {} 98 89 private method MotionLegend { x y } 90 private method Pan {option x y} 99 91 private method PanCamera {} 92 private method Pick {x y} 93 private method QuaternionToView { q } { 94 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 95 } 96 private method Rebuild {} 97 private method ReceiveDataset { args } 98 private method ReceiveImage { args } 99 private method ReceiveLegend { colormap title vmin vmax size } 100 100 private method RequestLegend {} 101 private method Rotate {option x y} 101 102 private method SetLegendTip { x y } 102 103 private method SetObjectStyle { dataobj comp } … … 104 105 private method SetCurrentColormap { color } 105 106 private method SetOrientation { side } 107 private method ViewToQuaternion {} { 108 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 109 } 110 private method Zoom {option} 106 111 107 112 private variable _arcball "" … … 202 207 # Initialize the view to some default parameters. 203 208 array set _view { 204 qw 0.853553205 qx -0.353553206 qy0.353553207 qz 0.146447208 zoom 1.0209 xpan 0210 ypan 0211 ortho0209 -ortho 0 210 -qw 0.853553 211 -qx -0.353553 212 -qy 0.353553 213 -qz 0.146447 214 -xpan 0 215 -ypan 0 216 -zoom 1.0 212 217 } 213 218 set _arcball [blt::arcball create 100 100] 214 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 215 $_arcball quaternion $q 219 $_arcball quaternion [ViewToQuaternion] 216 220 217 221 array set _settings [subst { … … 466 470 467 471 itcl::body Rappture::VtkGlyphViewer::DoRotate {} { 468 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 469 SendCmd "camera orient $q" 472 SendCmd "camera orient [ViewToQuaternion]" 470 473 set _rotatePending 0 471 474 } … … 491 494 492 495 itcl::body Rappture::VtkGlyphViewer::EventuallyRotate { q } { 493 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break496 QuaternionToView $q 494 497 if { !$_rotatePending } { 495 498 set _rotatePending 1 … … 836 839 array unset _data 837 840 array unset _colormaps 838 array unset _seeds839 841 array unset _dataset2style 840 842 array unset _obj2datasets … … 947 949 # Reset the camera and other view parameters 948 950 # 949 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 950 $_arcball quaternion $q 951 if {$_view(ortho)} { 951 $_arcball quaternion [ViewToQuaternion] 952 if {$_view(-ortho)} { 952 953 SendCmd "camera mode ortho" 953 954 } else { … … 1130 1131 switch -- $option { 1131 1132 "in" { 1132 set _view( zoom) [expr {$_view(zoom)*1.25}]1133 SendCmd "camera zoom $_view( zoom)"1133 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1134 SendCmd "camera zoom $_view(-zoom)" 1134 1135 } 1135 1136 "out" { 1136 set _view( zoom) [expr {$_view(zoom)*0.8}]1137 SendCmd "camera zoom $_view( zoom)"1137 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1138 SendCmd "camera zoom $_view(-zoom)" 1138 1139 } 1139 1140 "reset" { 1140 1141 array set _view { 1141 qw0.8535531142 qx-0.3535531143 qy0.3535531144 qz0.1464471145 zoom 1.01146 xpan01147 ypan01142 -qw 0.853553 1143 -qx -0.353553 1144 -qy 0.353553 1145 -qz 0.146447 1146 -xpan 0 1147 -ypan 0 1148 -zoom 1.0 1148 1149 } 1149 1150 if { $_first != "" } { … … 1153 1154 } 1154 1155 } 1155 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1156 $_arcball quaternion $q 1156 $_arcball quaternion [ViewToQuaternion] 1157 1157 DoRotate 1158 1158 SendCmd "camera reset" … … 1162 1162 1163 1163 itcl::body Rappture::VtkGlyphViewer::PanCamera {} { 1164 set x $_view( xpan)1165 set y $_view( ypan)1164 set x $_view(-xpan) 1165 set y $_view(-ypan) 1166 1166 SendCmd "camera pan $x $y" 1167 1167 } … … 1221 1221 itcl::body Rappture::VtkGlyphViewer::Pick {x y} { 1222 1222 foreach tag [CurrentDatasets -visible] { 1223 SendCmd NoSplash"dataset getscalar pixel $x $y $tag"1223 SendCmd "dataset getscalar pixel $x $y $tag" 1224 1224 } 1225 1225 } … … 1240 1240 set x [expr $x / double($w)] 1241 1241 set y [expr $y / double($h)] 1242 set _view( xpan) [expr $_view(xpan) + $x]1243 set _view( ypan) [expr $_view(ypan) + $y]1242 set _view(-xpan) [expr $_view(-xpan) + $x] 1243 set _view(-ypan) [expr $_view(-ypan) + $y] 1244 1244 PanCamera 1245 1245 return … … 1263 1263 set _click(x) $x 1264 1264 set _click(y) $y 1265 set _view( xpan) [expr $_view(xpan) - $dx]1266 set _view( ypan) [expr $_view(ypan) - $dy]1265 set _view(-xpan) [expr $_view(-xpan) - $dx] 1266 set _view(-ypan) [expr $_view(-ypan) - $dy] 1267 1267 PanCamera 1268 1268 } … … 1856 1856 label $inner.${tag}label -text $tag -font "Arial 9" 1857 1857 entry $inner.${tag} -font "Arial 9" -bg white \ 1858 -textvariable [itcl::scope _view( $tag)]1858 -textvariable [itcl::scope _view(-$tag)] 1859 1859 bind $inner.${tag} <Return> \ 1860 [itcl::code $this camera set ${tag}]1860 [itcl::code $this camera set -${tag}] 1861 1861 bind $inner.${tag} <KP_Enter> \ 1862 [itcl::code $this camera set ${tag}]1862 [itcl::code $this camera set -${tag}] 1863 1863 blt::table $inner \ 1864 1864 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1869 1869 checkbutton $inner.ortho \ 1870 1870 -text "Orthographic Projection" \ 1871 -variable [itcl::scope _view( ortho)] \1872 -command [itcl::code $this camera set ortho] \1871 -variable [itcl::scope _view(-ortho)] \ 1872 -command [itcl::code $this camera set -ortho] \ 1873 1873 -font "Arial 9" 1874 1874 blt::table $inner \ … … 2046 2046 } 2047 2047 "set" { 2048 set wh o[lindex $args 0]2049 set x $_view($wh o)2048 set what [lindex $args 0] 2049 set x $_view($what) 2050 2050 set code [catch { string is double $x } result] 2051 2051 if { $code != 0 || !$result } { 2052 2052 return 2053 2053 } 2054 switch -- $wh o{2055 " ortho" {2056 if {$_view( ortho)} {2054 switch -- $what { 2055 "-ortho" { 2056 if {$_view($what)} { 2057 2057 SendCmd "camera mode ortho" 2058 2058 } else { … … 2060 2060 } 2061 2061 } 2062 " xpan" - "ypan" {2062 "-xpan" - "-ypan" { 2063 2063 PanCamera 2064 2064 } 2065 " qx" - "qy" - "qz" - "qw" {2066 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2065 "-qx" - "-qy" - "-qz" - "-qw" { 2066 set q [ViewToQuaternion] 2067 2067 $_arcball quaternion $q 2068 2068 EventuallyRotate $q 2069 2069 } 2070 " zoom" {2071 SendCmd "camera zoom $_view( zoom)"2070 "-zoom" { 2071 SendCmd "camera zoom $_view($what)" 2072 2072 } 2073 2073 } … … 2551 2551 bottom "0.707107 0.707107 0 0" 2552 2552 } 2553 foreach name { qw qx qyqz } value $positions($side) {2553 foreach name { -qw -qx -qy -qz } value $positions($side) { 2554 2554 set _view($name) $value 2555 } 2556 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2555 } 2556 set q [ViewToQuaternion] 2557 2557 $_arcball quaternion $q 2558 2558 SendCmd "camera orient $q" 2559 2559 SendCmd "camera reset" 2560 set _view( xpan) 02561 set _view( ypan) 02562 set _view( zoom) 1.02563 } 2560 set _view(-xpan) 0 2561 set _view(-ypan) 0 2562 set _view(-zoom) 1.0 2563 }
Note: See TracChangeset
for help on using the changeset viewer.