Changeset 4765 for trunk/gui/scripts/vtkmeshviewer.tcl
- Timestamp:
- Nov 23, 2014, 12:58:31 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkmeshviewer.tcl
r4757 r4765 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 InitSettings { args }72 protected method Pan {option x y}73 protected method Pick {x y}74 protected method Rebuild {}75 protected method ReceiveDataset { args }76 protected method ReceiveImage { args }77 protected method Rotate {option x y}78 protected method Zoom {option}79 80 65 # The following methods are only used by this class. 66 private method AdjustSetting {what {value ""}} 81 67 private method BuildAxisTab {} 82 68 private method BuildCameraTab {} 83 69 private method BuildDownloadPopup { widget command } 84 70 private method BuildPolydataTab {} 71 private method Connect {} 72 private method CurrentDatasets {args} 73 private method Disconnect {} 74 private method DoResize {} 75 private method DoRotate {} 85 76 private method EventuallyResize { w h } 86 77 private method EventuallyRotate { q } … … 88 79 private method GetImage { args } 89 80 private method GetVtkData { args } 81 private method InitSettings { args } 90 82 private method IsValidObject { dataobj } 83 private method Pan {option x y} 91 84 private method PanCamera {} 85 private method Pick {x y} 86 private method QuaternionToView { q } { 87 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 88 } 89 private method Rebuild {} 90 private method ReceiveDataset { args } 91 private method ReceiveImage { args } 92 private method Rotate {option x y} 92 93 private method SetObjectStyle { dataobj } 93 94 private method SetOrientation { side } 94 95 private method SetPolydataOpacity {} 96 private method ViewToQuaternion {} { 97 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 98 } 99 private method Zoom {option} 95 100 96 101 private variable _arcball "" … … 164 169 # Initialize the view to some default parameters. 165 170 array set _view { 166 qw 0.853553167 qx -0.353553168 qy0.353553169 qz 0.146447170 zoom 1.0171 xpan 0172 ypan 0173 ortho0171 -ortho 0 172 -qw 0.853553 173 -qx -0.353553 174 -qy 0.353553 175 -qz 0.146447 176 -xpan 0 177 -ypan 0 178 -zoom 1.0 174 179 } 175 180 set _arcball [blt::arcball create 100 100] 176 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 177 $_arcball quaternion $q 181 $_arcball quaternion [ViewToQuaternion] 178 182 179 183 set _limits(zmin) 0.0 … … 291 295 bind $itk_component(view) <ButtonRelease-1> \ 292 296 [itcl::code $this Rotate release %x %y] 293 bind $itk_component(view) <Configure> \294 [itcl::code $this EventuallyResize %w %h]295 297 296 298 # Bindings for panning via mouse … … 370 372 371 373 itcl::body Rappture::VtkMeshViewer::DoRotate {} { 372 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 373 SendCmd "camera orient $q" 374 SendCmd "camera orient [ViewToQuaternion]" 374 375 set _rotatePending 0 375 376 } … … 386 387 387 388 itcl::body Rappture::VtkMeshViewer::EventuallyRotate { q } { 388 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break389 QuaternionToView $q 389 390 if { !$_rotatePending } { 390 391 set _rotatePending 1 … … 855 856 lappend info "dataset_size" $length 856 857 lappend info "dataset_tag" $tag 857 SendCmd [list "clientinfo" $info]858 SendCmd "clientinfo [list $info]" 858 859 } 859 860 SendCmd "dataset add $tag data follows $length" … … 893 894 #SendCmd "axis lformat all %g" 894 895 895 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 896 $_arcball quaternion $q 896 $_arcball quaternion [ViewToQuaternion] 897 897 SendCmd "camera reset" 898 if { $_view( ortho)} {898 if { $_view(-ortho)} { 899 899 SendCmd "camera mode ortho" 900 900 } else { … … 971 971 switch -- $option { 972 972 "in" { 973 set _view( zoom) [expr {$_view(zoom)*1.25}]974 SendCmd "camera zoom $_view( zoom)"973 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 974 SendCmd "camera zoom $_view(-zoom)" 975 975 } 976 976 "out" { 977 set _view( zoom) [expr {$_view(zoom)*0.8}]978 SendCmd "camera zoom $_view( zoom)"977 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 978 SendCmd "camera zoom $_view(-zoom)" 979 979 } 980 980 "reset" { 981 981 array set _view { 982 qw 0.853553983 qx -0.353553984 qy 0.353553985 qz 0.146447986 zoom 1.0987 xpan 0988 ypan0982 -qw 0.853553 983 -qx -0.353553 984 -qy 0.353553 985 -qz 0.146447 986 -xpan 0 987 -ypan 0 988 -zoom 1.0 989 989 } 990 990 if { $_first != "" } { … … 994 994 } 995 995 } 996 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 997 $_arcball quaternion $q 996 $_arcball quaternion [ViewToQuaternion] 998 997 DoRotate 999 998 SendCmd "camera reset" … … 1003 1002 1004 1003 itcl::body Rappture::VtkMeshViewer::PanCamera {} { 1005 set x $_view( xpan)1006 set y $_view( ypan)1004 set x $_view(-xpan) 1005 set y $_view(-ypan) 1007 1006 SendCmd "camera pan $x $y" 1008 1007 } … … 1081 1080 set x [expr $x / double($w)] 1082 1081 set y [expr $y / double($h)] 1083 set _view( xpan) [expr $_view(xpan) + $x]1084 set _view( ypan) [expr $_view(ypan) + $y]1082 set _view(-xpan) [expr $_view(-xpan) + $x] 1083 set _view(-ypan) [expr $_view(-ypan) + $y] 1085 1084 PanCamera 1086 1085 return … … 1104 1103 set _click(x) $x 1105 1104 set _click(y) $y 1106 set _view( xpan) [expr $_view(xpan) - $dx]1107 set _view( ypan) [expr $_view(ypan) - $dy]1105 set _view(-xpan) [expr $_view(-xpan) - $dx] 1106 set _view(-ypan) [expr $_view(-ypan) - $dy] 1108 1107 PanCamera 1109 1108 } … … 1214 1213 itcl::configbody Rappture::VtkMeshViewer::plotbackground { 1215 1214 if { [isconnected] } { 1216 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break1217 SendCmd "screen bgcolor $r $g $b"1215 set rgb [Color2RGB $itk_option(-plotbackground)] 1216 SendCmd "screen bgcolor $rgb" 1218 1217 } 1219 1218 } … … 1224 1223 itcl::configbody Rappture::VtkMeshViewer::plotforeground { 1225 1224 if { [isconnected] } { 1226 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break1227 #fix this!1228 #SendCmd "color background $r $g $b"1225 set rgb [Color2RGB $itk_option(-plotforeground)] 1226 SendCmd "axis color all $rgb" 1227 SendCmd "outline color $rgb" 1229 1228 } 1230 1229 } … … 1442 1441 label $inner.${tag}label -text $tag -font "Arial 9" 1443 1442 entry $inner.${tag} -font "Arial 9" -bg white \ 1444 -textvariable [itcl::scope _view( $tag)]1443 -textvariable [itcl::scope _view(-$tag)] 1445 1444 bind $inner.${tag} <Return> \ 1446 [itcl::code $this camera set ${tag}]1445 [itcl::code $this camera set -${tag}] 1447 1446 bind $inner.${tag} <KP_Enter> \ 1448 [itcl::code $this camera set ${tag}]1447 [itcl::code $this camera set -${tag}] 1449 1448 blt::table $inner \ 1450 1449 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1455 1454 checkbutton $inner.ortho \ 1456 1455 -text "Orthographic Projection" \ 1457 -variable [itcl::scope _view( ortho)] \1458 -command [itcl::code $this camera set ortho] \1456 -variable [itcl::scope _view(-ortho)] \ 1457 -command [itcl::code $this camera set -ortho] \ 1459 1458 -font "Arial 9" 1460 1459 blt::table $inner \ … … 1477 1476 } 1478 1477 "set" { 1479 set wh o[lindex $args 0]1480 set x $_view($wh o)1478 set what [lindex $args 0] 1479 set x $_view($what) 1481 1480 set code [catch { string is double $x } result] 1482 1481 if { $code != 0 || !$result } { 1483 1482 return 1484 1483 } 1485 switch -- $wh o{1486 " ortho" {1487 if {$_view( ortho)} {1484 switch -- $what { 1485 "-ortho" { 1486 if {$_view($what)} { 1488 1487 SendCmd "camera mode ortho" 1489 1488 } else { … … 1491 1490 } 1492 1491 } 1493 " xpan" - "ypan" {1492 "-xpan" - "-ypan" { 1494 1493 PanCamera 1495 1494 } 1496 " qx" - "qy" - "qz" - "qw" {1497 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1495 "-qx" - "-qy" - "-qz" - "-qw" { 1496 set q [ViewToQuaternion] 1498 1497 $_arcball quaternion $q 1499 1498 EventuallyRotate $q 1500 1499 } 1501 " zoom" {1502 SendCmd "camera zoom $_view( zoom)"1500 "-zoom" { 1501 SendCmd "camera zoom $_view($what)" 1503 1502 } 1504 1503 } … … 1637 1636 bottom "0.707107 0.707107 0 0" 1638 1637 } 1639 foreach name { qw qx qyqz } value $positions($side) {1638 foreach name { -qw -qx -qy -qz } value $positions($side) { 1640 1639 set _view($name) $value 1641 1640 } 1642 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1641 set q [ViewToQuaternion] 1643 1642 $_arcball quaternion $q 1644 1643 SendCmd "camera orient $q" 1645 1644 SendCmd "camera reset" 1646 set _view( xpan) 01647 set _view( ypan) 01648 set _view( zoom) 1.01649 } 1645 set _view(-xpan) 0 1646 set _view(-ypan) 0 1647 set _view(-zoom) 1.0 1648 }
Note: See TracChangeset
for help on using the changeset viewer.