Changeset 4766 for branches/1.3/gui/scripts/vtkheightmapviewer.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/vtkheightmapviewer.tcl
r4759 r4766 63 63 public method scale {args} 64 64 65 protected method CameraReset {}66 protected method Connect {}67 protected method CurrentDatasets {args}68 protected method Disconnect {}69 protected method DoResize {}70 protected method DoRotate {}71 protected method AdjustSetting {what {value ""}}72 protected method AdjustMode {}73 protected method InitSettings { args }74 protected method Pan {option x y}75 protected method Pick {x y}76 protected method Rebuild {}77 protected method ReceiveDataset { args }78 protected method ReceiveImage { args }79 protected method ReceiveLegend { colormap title min max size }80 protected method Rotate {option x y}81 protected method Zoom {option}82 83 65 # The following methods are only used by this class. 66 private method AdjustSetting {what {value ""}} 84 67 private method BuildAxisTab {} 85 68 private method BuildCameraTab {} … … 87 70 private method BuildContourTab {} 88 71 private method BuildDownloadPopup { widget command } 72 private method CameraReset {} 89 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 {} 90 79 private method DrawLegend {} 91 80 private method EnterLegend { x y } 92 81 private method EventuallyRequestLegend {} 93 82 private method EventuallyResize { w h } 94 private method EventuallyRotate { q } 83 private method EventuallyRotate { q } 84 private method GetHeightmapScale {} 95 85 private method GetImage { args } 96 86 private method GetVtkData { args } 87 private method InitSettings { args } 97 88 private method IsValidObject { dataobj } 98 89 private method LeaveLegend {} 99 90 private method MotionLegend { x y } 91 private method Pan {option x y} 100 92 private method PanCamera {} 93 private method Pick {x y} 94 private method QuaternionToView { q } { 95 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 96 } 97 private method Rebuild {} 98 private method ReceiveDataset { args } 99 private method ReceiveImage { args } 100 private method ReceiveLegend { colormap title min max size } 101 101 private method RequestLegend {} 102 private method ResetAxes {} 103 private method Rotate {option x y} 102 104 private method SetCurrentColormap { color } 103 105 private method SetLegendTip { x y } 104 106 private method SetObjectStyle { dataobj comp } 105 private method GetHeightmapScale {}106 private method ResetAxes {}107 107 private method SetOrientation { side } 108 108 private method UpdateContourList {} 109 private method ViewToQuaternion {} { 110 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 111 } 112 private method Zoom {option} 109 113 110 114 private variable _arcball "" … … 201 205 # Initialize the view to some default parameters. 202 206 array set _view { 203 qw 0.36204 qx 0.25205 qy 0.50206 qz 0.70207 zoom 1.0208 xpan0209 ypan0210 ortho0207 -ortho 0 208 -qw 0.36 209 -qx 0.25 210 -qy 0.50 211 -qz 0.70 212 -xpan 0 213 -ypan 0 214 -zoom 1.0 211 215 } 212 216 set _arcball [blt::arcball create 100 100] 213 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 214 $_arcball quaternion $q 217 $_arcball quaternion [ViewToQuaternion] 215 218 216 219 array set _settings { … … 441 444 442 445 itcl::body Rappture::VtkHeightmapViewer::DoRotate {} { 443 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 444 SendCmd "camera orient $q" 446 SendCmd "camera orient [ViewToQuaternion]" 445 447 set _rotatePending 0 446 448 } … … 466 468 467 469 itcl::body Rappture::VtkHeightmapViewer::EventuallyRotate { q } { 468 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break470 QuaternionToView $q 469 471 if { !$_rotatePending } { 470 472 set _rotatePending 1 … … 949 951 950 952 SendCmd "axis lrot z 90" 951 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 952 $_arcball quaternion $q 953 $_arcball quaternion [ViewToQuaternion] 953 954 if {$_settings(-isheightmap) } { 954 if { $_view( ortho)} {955 if { $_view(-ortho)} { 955 956 SendCmd "camera mode ortho" 956 957 } else { … … 995 996 lappend info "dataset_size" $length 996 997 lappend info "dataset_tag" $tag 997 SendCmd [list "clientinfo" $info]998 SendCmd "clientinfo [list $info]" 998 999 } 999 1000 SendCmd "dataset add $tag data follows $length" … … 1086 1087 # 1087 1088 ResetAxes 1088 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1089 $_arcball quaternion $q 1089 $_arcball quaternion [ViewToQuaternion] 1090 1090 if {$_settings(-isheightmap) } { 1091 if { $_view( ortho)} {1091 if { $_view(-ortho)} { 1092 1092 SendCmd "camera mode ortho" 1093 1093 } else { … … 1164 1164 itcl::body Rappture::VtkHeightmapViewer::CameraReset {} { 1165 1165 array set _view { 1166 qw 0.361167 qx 0.251168 qy 0.501169 qz 0.701170 zoom 1.01171 xpan 01172 ypan 01166 -qw 0.36 1167 -qx 0.25 1168 -qy 0.50 1169 -qz 0.70 1170 -xpan 0 1171 -ypan 0 1172 -zoom 1.0 1173 1173 } 1174 1174 if { $_first != "" } { … … 1178 1178 } 1179 1179 } 1180 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1181 $_arcball quaternion $q 1180 $_arcball quaternion [ViewToQuaternion] 1182 1181 if {$_settings(-isheightmap) } { 1183 1182 DoRotate … … 1197 1196 switch -- $option { 1198 1197 "in" { 1199 set _view( zoom) [expr {$_view(zoom)*1.25}]1200 SendCmd "camera zoom $_view( zoom)"1198 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1199 SendCmd "camera zoom $_view(-zoom)" 1201 1200 } 1202 1201 "out" { 1203 set _view( zoom) [expr {$_view(zoom)*0.8}]1204 SendCmd "camera zoom $_view( zoom)"1202 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1203 SendCmd "camera zoom $_view(-zoom)" 1205 1204 } 1206 1205 "reset" { 1207 1206 array set _view { 1208 zoom 1.01209 xpan 01210 ypan 01207 -xpan 0 1208 -ypan 0 1209 -zoom 1.0 1211 1210 } 1212 1211 SendCmd "camera reset" … … 1216 1215 1217 1216 itcl::body Rappture::VtkHeightmapViewer::PanCamera {} { 1218 set x $_view( xpan)1219 set y $_view( ypan)1217 set x $_view(-xpan) 1218 set y $_view(-ypan) 1220 1219 SendCmd "camera pan $x $y" 1221 1220 } … … 1295 1294 set x [expr $x / double($w)] 1296 1295 set y [expr $y / double($h)] 1297 set _view( xpan) [expr $_view(xpan) + $x]1298 set _view( ypan) [expr $_view(ypan) + $y]1296 set _view(-xpan) [expr $_view(-xpan) + $x] 1297 set _view(-ypan) [expr $_view(-ypan) + $y] 1299 1298 PanCamera 1300 1299 return … … 1318 1317 set _click(x) $x 1319 1318 set _click(y) $y 1320 set _view( xpan) [expr $_view(xpan) - $dx]1321 set _view( ypan) [expr $_view(ypan) - $dy]1319 set _view(-xpan) [expr $_view(-xpan) - $dx] 1320 set _view(-ypan) [expr $_view(-ypan) - $dy] 1322 1321 PanCamera 1323 1322 } … … 1535 1534 $itk_component(scale_l) configure -state normal 1536 1535 $itk_component(outline) configure -state disabled 1537 if {$_view( ortho)} {1536 if {$_view(-ortho)} { 1538 1537 SendCmd "camera mode ortho" 1539 1538 } else { … … 1558 1557 ResetAxes 1559 1558 if { $bool } { 1560 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1559 set q [ViewToQuaternion] 1561 1560 $_arcball quaternion $q 1562 1561 SendCmd "camera orient $q" … … 1834 1833 set rgb [Color2RGB $itk_option(-plotforeground)] 1835 1834 if { !$_reset } { 1835 SendCmd "axis color all $rgb" 1836 1836 SendCmd "outline color $rgb" 1837 SendCmd "axis color all $rgb"1838 1837 } 1839 1838 } … … 2117 2116 label $inner.${tag}label -text $tag -font "Arial 9" 2118 2117 entry $inner.${tag} -font "Arial 9" -bg white \ 2119 -textvariable [itcl::scope _view( $tag)]2118 -textvariable [itcl::scope _view(-$tag)] 2120 2119 bind $inner.${tag} <Return> \ 2121 [itcl::code $this camera set ${tag}]2120 [itcl::code $this camera set -${tag}] 2122 2121 bind $inner.${tag} <KP_Enter> \ 2123 [itcl::code $this camera set ${tag}]2122 [itcl::code $this camera set -${tag}] 2124 2123 blt::table $inner \ 2125 2124 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 2130 2129 checkbutton $inner.ortho \ 2131 2130 -text "Orthographic Projection" \ 2132 -variable [itcl::scope _view( ortho)] \2133 -command [itcl::code $this camera set ortho] \2131 -variable [itcl::scope _view(-ortho)] \ 2132 -command [itcl::code $this camera set -ortho] \ 2134 2133 -font "Arial 9" 2135 2134 blt::table $inner \ … … 2152 2151 } 2153 2152 "set" { 2154 set wh o[lindex $args 0]2155 set x $_view($wh o)2153 set what [lindex $args 0] 2154 set x $_view($what) 2156 2155 set code [catch { string is double $x } result] 2157 2156 if { $code != 0 || !$result } { 2158 2157 return 2159 2158 } 2160 switch -- $wh o{2161 " ortho" {2162 if {$_view( ortho)} {2159 switch -- $what { 2160 "-ortho" { 2161 if {$_view($what)} { 2163 2162 SendCmd "camera mode ortho" 2164 2163 } else { … … 2166 2165 } 2167 2166 } 2168 " xpan" - "ypan" {2167 "-xpan" - "-ypan" { 2169 2168 PanCamera 2170 2169 } 2171 " qx" - "qy" - "qz" - "qw" {2172 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2170 "-qx" - "-qy" - "-qz" - "-qw" { 2171 set q [ViewToQuaternion] 2173 2172 $_arcball quaternion $q 2174 2173 EventuallyRotate $q 2175 2174 } 2176 " zoom" {2177 SendCmd "camera zoom $_view( zoom)"2175 "-zoom" { 2176 SendCmd "camera zoom $_view($what)" 2178 2177 } 2179 2178 } … … 2607 2606 bottom "0 1 0 0" 2608 2607 } 2609 foreach name { qw qx qyqz } value $positions($side) {2608 foreach name { -qw -qx -qy -qz } value $positions($side) { 2610 2609 set _view($name) $value 2611 2610 } 2612 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2611 set q [ViewToQuaternion] 2613 2612 $_arcball quaternion $q 2614 2613 SendCmd "camera orient $q" 2615 2614 SendCmd "camera reset" 2616 set _view( xpan) 02617 set _view( ypan) 02618 set _view( zoom) 1.02615 set _view(-xpan) 0 2616 set _view(-ypan) 0 2617 set _view(-zoom) 1.0 2619 2618 } 2620 2619
Note: See TracChangeset
for help on using the changeset viewer.