Changeset 4766 for branches/1.3/gui/scripts/vtksurfaceviewer.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/vtksurfaceviewer.tcl
r4759 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 {} … … 85 70 private method BuildSurfaceTab {} 86 71 private method Combo { option } 72 private method Connect {} 73 private method CurrentDatasets {args} 74 private method Disconnect {} 75 private method DoResize {} 76 private method DoRotate {} 87 77 private method DrawLegend {} 88 78 private method EnterLegend { x y } … … 92 82 private method GetImage { args } 93 83 private method GetVtkData { args } 84 private method InitSettings { args } 94 85 private method IsValidObject { dataobj } 95 86 private method LeaveLegend {} 96 87 private method MotionLegend { x y } 88 private method Pan {option x y} 97 89 private method PanCamera {} 90 private method Pick {x y} 91 private method QuaternionToView { q } { 92 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 93 } 94 private method Rebuild {} 95 private method ReceiveDataset { args } 96 private method ReceiveImage { args } 97 private method ReceiveLegend { colormap title vmin vmax size } 98 98 private method RequestLegend {} 99 private method Rotate {option x y} 99 100 private method SetLegendTip { x y } 100 101 private method SetObjectStyle { dataobj comp } … … 102 103 private method SetOrientation { side } 103 104 private method UpdateContourList {} 105 private method ViewToQuaternion {} { 106 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 107 } 108 private method Zoom {option} 104 109 105 110 private variable _arcball "" … … 187 192 # Initialize the view to some default parameters. 188 193 array set _view { 189 qw 0.853553190 qx -0.353553191 qy0.353553192 qz 0.146447193 zoom 1.0194 xpan 0195 ypan 0196 ortho0194 -ortho 0 195 -qw 0.853553 196 -qx -0.353553 197 -qy 0.353553 198 -qz 0.146447 199 -xpan 0 200 -ypan 0 201 -zoom 1.0 197 202 } 198 203 set _arcball [blt::arcball create 100 100] 199 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 200 $_arcball quaternion $q 204 $_arcball quaternion [ViewToQuaternion] 201 205 202 206 array set _settings { … … 320 324 puts stderr errs=$errs 321 325 } 326 322 327 # Legend 323 324 328 set _image(legend) [image create photo] 325 329 itk_component add legend { … … 424 428 425 429 itcl::body Rappture::VtkSurfaceViewer::DoRotate {} { 426 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 427 SendCmd "camera orient $q" 430 SendCmd "camera orient [ViewToQuaternion]" 428 431 set _rotatePending 0 429 432 } … … 449 452 450 453 itcl::body Rappture::VtkSurfaceViewer::EventuallyRotate { q } { 451 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break454 QuaternionToView $q 452 455 if { !$_rotatePending } { 453 456 set _rotatePending 1 … … 497 500 } 498 501 499 500 502 # ---------------------------------------------------------------------- 501 503 # USAGE: delete ?<dataobj1> <dataobj2> ...? … … 785 787 array unset _data 786 788 array unset _colormaps 787 array unset _seeds788 789 array unset _dataset2style 789 790 array unset _obj2datasets … … 808 809 if 0 { 809 810 set f [open "last.ppm" "w"] 810 puts $f $bytes 811 fconfigure $f -encoding binary 812 puts -nonewline $f $bytes 811 813 close $f 812 814 } … … 898 900 # Reset the camera and other view parameters 899 901 # 900 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 901 $_arcball quaternion $q 902 if {$_view(ortho)} { 902 $_arcball quaternion [ViewToQuaternion] 903 if {$_view(-ortho)} { 903 904 SendCmd "camera mode ortho" 904 905 } else { … … 944 945 SendCmd "clientinfo [list $info]" 945 946 } 946 append _outbuf "dataset add $tag data follows $length\n"947 SendCmd "dataset add $tag data follows $length" 947 948 append _outbuf $bytes 948 949 set _datasets($tag) 1 … … 1078 1079 switch -- $option { 1079 1080 "in" { 1080 set _view( zoom) [expr {$_view(zoom)*1.25}]1081 SendCmd "camera zoom $_view( zoom)"1081 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1082 SendCmd "camera zoom $_view(-zoom)" 1082 1083 } 1083 1084 "out" { 1084 set _view( zoom) [expr {$_view(zoom)*0.8}]1085 SendCmd "camera zoom $_view( zoom)"1085 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1086 SendCmd "camera zoom $_view(-zoom)" 1086 1087 } 1087 1088 "reset" { 1088 1089 array set _view { 1089 qw0.8535531090 qx-0.3535531091 qy0.3535531092 qz0.1464471093 zoom 1.01094 xpan01095 ypan01090 -qw 0.853553 1091 -qx -0.353553 1092 -qy 0.353553 1093 -qz 0.146447 1094 -xpan 0 1095 -ypan 0 1096 -zoom 1.0 1096 1097 } 1097 1098 if { $_first != "" } { … … 1101 1102 } 1102 1103 } 1103 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1104 $_arcball quaternion $q 1104 $_arcball quaternion [ViewToQuaternion] 1105 1105 DoRotate 1106 1106 SendCmd "camera reset" … … 1110 1110 1111 1111 itcl::body Rappture::VtkSurfaceViewer::PanCamera {} { 1112 set x $_view( xpan)1113 set y $_view( ypan)1112 set x $_view(-xpan) 1113 set y $_view(-ypan) 1114 1114 SendCmd "camera pan $x $y" 1115 1115 } 1116 1117 1116 1118 1117 # ---------------------------------------------------------------------- … … 1170 1169 itcl::body Rappture::VtkSurfaceViewer::Pick {x y} { 1171 1170 foreach tag [CurrentDatasets -visible] { 1172 SendCmd NoSplash"dataset getscalar pixel $x $y $tag"1171 SendCmd "dataset getscalar pixel $x $y $tag" 1173 1172 } 1174 1173 } … … 1189 1188 set x [expr $x / double($w)] 1190 1189 set y [expr $y / double($h)] 1191 set _view( xpan) [expr $_view(xpan) + $x]1192 set _view( ypan) [expr $_view(ypan) + $y]1190 set _view(-xpan) [expr $_view(-xpan) + $x] 1191 set _view(-ypan) [expr $_view(-ypan) + $y] 1193 1192 PanCamera 1194 1193 return … … 1212 1211 set _click(x) $x 1213 1212 set _click(y) $y 1214 set _view( xpan) [expr $_view(xpan) - $dx]1215 set _view( ypan) [expr $_view(ypan) - $dy]1213 set _view(-xpan) [expr $_view(-xpan) - $dx] 1214 set _view(-ypan) [expr $_view(-ypan) - $dy] 1216 1215 PanCamera 1217 1216 } … … 1751 1750 label $inner.${tag}label -text $tag -font "Arial 9" 1752 1751 entry $inner.${tag} -font "Arial 9" -bg white \ 1753 -textvariable [itcl::scope _view( $tag)]1752 -textvariable [itcl::scope _view(-$tag)] 1754 1753 bind $inner.${tag} <Return> \ 1755 [itcl::code $this camera set ${tag}]1754 [itcl::code $this camera set -${tag}] 1756 1755 bind $inner.${tag} <KP_Enter> \ 1757 [itcl::code $this camera set ${tag}]1756 [itcl::code $this camera set -${tag}] 1758 1757 blt::table $inner \ 1759 1758 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1764 1763 checkbutton $inner.ortho \ 1765 1764 -text "Orthographic Projection" \ 1766 -variable [itcl::scope _view( ortho)] \1767 -command [itcl::code $this camera set ortho] \1765 -variable [itcl::scope _view(-ortho)] \ 1766 -command [itcl::code $this camera set -ortho] \ 1768 1767 -font "Arial 9" 1769 1768 blt::table $inner \ … … 1786 1785 } 1787 1786 "set" { 1788 set wh o[lindex $args 0]1789 set x $_view($wh o)1787 set what [lindex $args 0] 1788 set x $_view($what) 1790 1789 set code [catch { string is double $x } result] 1791 1790 if { $code != 0 || !$result } { 1792 1791 return 1793 1792 } 1794 switch -- $wh o{1795 " ortho" {1796 if {$_view( ortho)} {1793 switch -- $what { 1794 "-ortho" { 1795 if {$_view($what)} { 1797 1796 SendCmd "camera mode ortho" 1798 1797 } else { … … 1800 1799 } 1801 1800 } 1802 " xpan" - "ypan" {1801 "-xpan" - "-ypan" { 1803 1802 PanCamera 1804 1803 } 1805 " qx" - "qy" - "qz" - "qw" {1806 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1804 "-qx" - "-qy" - "-qz" - "-qw" { 1805 set q [ViewToQuaternion] 1807 1806 $_arcball quaternion $q 1808 1807 EventuallyRotate $q 1809 1808 } 1810 " zoom" {1811 SendCmd "camera zoom $_view( zoom)"1809 "-zoom" { 1810 SendCmd "camera zoom $_view($what)" 1812 1811 } 1813 1812 } … … 2271 2270 bottom "0.707107 0.707107 0 0" 2272 2271 } 2273 foreach name { qw qx qyqz } value $positions($side) {2272 foreach name { -qw -qx -qy -qz } value $positions($side) { 2274 2273 set _view($name) $value 2275 2274 } 2276 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2275 set q [ViewToQuaternion] 2277 2276 $_arcball quaternion $q 2278 2277 SendCmd "camera orient $q" 2279 2278 SendCmd "camera reset" 2280 set _view( xpan) 02281 set _view( ypan) 02282 set _view( zoom) 1.02279 set _view(-xpan) 0 2280 set _view(-ypan) 0 2281 set _view(-zoom) 1.0 2283 2282 } 2284 2283 … … 2298 2297 blt::vector destroy $v 2299 2298 } 2300
Note: See TracChangeset
for help on using the changeset viewer.