Changeset 4766 for branches/1.3/gui/scripts/vtkviewer.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/vtkviewer.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 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 ReceiveLegend { colormap title vmin vmax size }78 protected method Rotate {option x y}79 protected method Zoom {option}80 81 65 # The following methods are only used by this class. 66 private method AdjustSetting {what {value ""}} 82 67 private method BuildAxisTab {} 83 68 private method BuildCameraTab {} … … 89 74 private method BuildPolydataTab {} 90 75 private method ChangeColormap { dataobj comp color } 76 private method Connect {} 77 private method CurrentDatasets {args} 78 private method Disconnect {} 79 private method DoResize {} 80 private method DoRotate {} 91 81 private method DrawLegend {} 92 82 private method EnterLegend { x y } … … 101 91 private method GetImage { args } 102 92 private method GetVtkData { args } 93 private method InitSettings { args } 103 94 private method IsValidObject { dataobj } 104 95 private method LeaveLegend {} 105 96 private method MotionLegend { x y } 97 private method Pan {option x y} 106 98 private method PanCamera {} 99 private method Pick {x y} 100 private method QuaternionToView { q } { 101 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 102 } 103 private method Rebuild {} 104 private method ReceiveDataset { args } 105 private method ReceiveImage { args } 106 private method ReceiveLegend { colormap title vmin vmax size } 107 107 private method RequestLegend {} 108 private method Rotate {option x y} 108 109 private method SetAtomScale {} 109 110 private method SetBondScale {} … … 118 119 private method SetPolydataOpacity {} 119 120 private method Slice {option args} 121 private method ViewToQuaternion {} { 122 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 123 } 124 private method Zoom {option} 120 125 121 126 private variable _arcball "" … … 220 225 # Populate parser with commands handle incoming requests 221 226 # 222 $_parser alias image 223 $_parser alias dataset 224 $_parser alias legend 227 $_parser alias image [itcl::code $this ReceiveImage] 228 $_parser alias dataset [itcl::code $this ReceiveDataset] 229 $_parser alias legend [itcl::code $this ReceiveLegend] 225 230 226 231 # Initialize the view to some default parameters. 227 232 array set _view { 228 qw 0.853553229 qx -0.353553230 qy0.353553231 qz 0.146447232 zoom 1.0233 xpan 0234 ypan 0235 ortho0233 -ortho 0 234 -qw 0.853553 235 -qx -0.353553 236 -qy 0.353553 237 -qz 0.146447 238 -xpan 0 239 -ypan 0 240 -zoom 1.0 236 241 } 237 242 set _arcball [blt::arcball create 100 100] 238 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 239 $_arcball quaternion $q 243 $_arcball quaternion [ViewToQuaternion] 240 244 241 245 set _limits(zmin) 0.0 … … 358 362 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 359 363 360 BuildAxisTab 361 #BuildCutawayTab 362 BuildCameraTab 364 if { [catch { 365 BuildAxisTab 366 #BuildCutawayTab 367 BuildCameraTab 368 } errs] != 0 } { 369 puts stderr errs=$errs 370 } 363 371 364 372 # Legend 365 366 373 set _image(legend) [image create photo] 367 374 itk_component add legend { … … 389 396 bind $itk_component(view) <ButtonRelease-1> \ 390 397 [itcl::code $this Rotate release %x %y] 391 bind $itk_component(view) <Configure> \392 [itcl::code $this EventuallyResize %w %h]393 398 394 399 # Bindings for panning via mouse … … 468 473 469 474 itcl::body Rappture::VtkViewer::DoRotate {} { 470 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 471 SendCmd "camera orient $q" 475 SendCmd "camera orient [ViewToQuaternion]" 472 476 set _rotatePending 0 473 477 } … … 484 488 485 489 itcl::body Rappture::VtkViewer::EventuallyRotate { q } { 486 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break490 QuaternionToView $q 487 491 if { !$_rotatePending } { 488 492 set _rotatePending 1 … … 920 924 921 925 # disconnected -- no more data sitting on server 926 set _outbuf "" 922 927 array unset _datasets 923 928 array unset _data … … 1068 1073 lappend info "dataset_size" $length 1069 1074 lappend info "dataset_tag" $tag 1070 SendCmd [list "clientinfo" $info]1075 SendCmd "clientinfo [list $info]" 1071 1076 } 1072 1077 SendCmd "dataset add $tag data follows $length" … … 1123 1128 } 1124 1129 1125 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1126 $_arcball quaternion $q 1130 $_arcball quaternion [ViewToQuaternion] 1127 1131 SendCmd "camera reset" 1128 if { $_view( ortho)} {1132 if { $_view(-ortho)} { 1129 1133 SendCmd "camera mode ortho" 1130 1134 } else { … … 1207 1211 switch -- $option { 1208 1212 "in" { 1209 set _view( zoom) [expr {$_view(zoom)*1.25}]1210 SendCmd "camera zoom $_view( zoom)"1213 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1214 SendCmd "camera zoom $_view(-zoom)" 1211 1215 } 1212 1216 "out" { 1213 set _view( zoom) [expr {$_view(zoom)*0.8}]1214 SendCmd "camera zoom $_view( zoom)"1217 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1218 SendCmd "camera zoom $_view(-zoom)" 1215 1219 } 1216 1220 "reset" { 1217 1221 array set _view { 1218 qw 0.8535531219 qx -0.3535531220 qy 0.3535531221 qz 0.1464471222 zoom 1.01223 xpan 01224 ypan01222 -qw 0.853553 1223 -qx -0.353553 1224 -qy 0.353553 1225 -qz 0.146447 1226 -xpan 0 1227 -ypan 0 1228 -zoom 1.0 1225 1229 } 1226 1230 if { $_first != "" } { … … 1230 1234 } 1231 1235 } 1232 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1233 $_arcball quaternion $q 1236 $_arcball quaternion [ViewToQuaternion] 1234 1237 DoRotate 1235 1238 SendCmd "camera reset" … … 1239 1242 1240 1243 itcl::body Rappture::VtkViewer::PanCamera {} { 1241 set x $_view( xpan)1242 set y $_view( ypan)1244 set x $_view(-xpan) 1245 set y $_view(-ypan) 1243 1246 SendCmd "camera pan $x $y" 1244 1247 } … … 1317 1320 set x [expr $x / double($w)] 1318 1321 set y [expr $y / double($h)] 1319 set _view( xpan) [expr $_view(xpan) + $x]1320 set _view( ypan) [expr $_view(ypan) + $y]1322 set _view(-xpan) [expr $_view(-xpan) + $x] 1323 set _view(-ypan) [expr $_view(-ypan) + $y] 1321 1324 PanCamera 1322 1325 return … … 1340 1343 set _click(x) $x 1341 1344 set _click(y) $y 1342 set _view( xpan) [expr $_view(xpan) - $dx]1343 set _view( ypan) [expr $_view(ypan) - $dy]1345 set _view(-xpan) [expr $_view(-xpan) - $dx] 1346 set _view(-ypan) [expr $_view(-ypan) - $dy] 1344 1347 PanCamera 1345 1348 } … … 1876 1879 itcl::configbody Rappture::VtkViewer::plotbackground { 1877 1880 if { [isconnected] } { 1878 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break1879 SendCmd "screen bgcolor $r $g $b"1881 set rgb [Color2RGB $itk_option(-plotbackground)] 1882 SendCmd "screen bgcolor $rgb" 1880 1883 } 1881 1884 } … … 1886 1889 itcl::configbody Rappture::VtkViewer::plotforeground { 1887 1890 if { [isconnected] } { 1888 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break1889 #fix this!1890 #SendCmd "color background $r $g $b"1891 set rgb [Color2RGB $itk_option(-plotforeground)] 1892 SendCmd "axis color all $rgb" 1893 SendCmd "outline color $rgb" 1891 1894 } 1892 1895 } … … 2223 2226 label $inner.${tag}label -text $tag -font "Arial 9" 2224 2227 entry $inner.${tag} -font "Arial 9" -bg white \ 2225 -textvariable [itcl::scope _view( $tag)]2228 -textvariable [itcl::scope _view(-$tag)] 2226 2229 bind $inner.${tag} <Return> \ 2227 [itcl::code $this camera set ${tag}]2230 [itcl::code $this camera set -${tag}] 2228 2231 bind $inner.${tag} <KP_Enter> \ 2229 [itcl::code $this camera set ${tag}]2232 [itcl::code $this camera set -${tag}] 2230 2233 blt::table $inner \ 2231 2234 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 2236 2239 checkbutton $inner.ortho \ 2237 2240 -text "Orthographic Projection" \ 2238 -variable [itcl::scope _view( ortho)] \2239 -command [itcl::code $this camera set ortho] \2241 -variable [itcl::scope _view(-ortho)] \ 2242 -command [itcl::code $this camera set -ortho] \ 2240 2243 -font "Arial 9" 2241 2244 blt::table $inner \ … … 2547 2550 } 2548 2551 "set" { 2549 set wh o[lindex $args 0]2550 set x $_view($wh o)2552 set what [lindex $args 0] 2553 set x $_view($what) 2551 2554 set code [catch { string is double $x } result] 2552 2555 if { $code != 0 || !$result } { 2553 2556 return 2554 2557 } 2555 switch -- $wh o{2556 " ortho" {2557 if {$_view( ortho)} {2558 switch -- $what { 2559 "-ortho" { 2560 if {$_view($what)} { 2558 2561 SendCmd "camera mode ortho" 2559 2562 } else { … … 2561 2564 } 2562 2565 } 2563 " xpan" - "ypan" {2566 "-xpan" - "-ypan" { 2564 2567 PanCamera 2565 2568 } 2566 " qx" - "qy" - "qz" - "qw" {2567 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2569 "-qx" - "-qy" - "-qz" - "-qw" { 2570 set q [ViewToQuaternion] 2568 2571 $_arcball quaternion $q 2569 2572 EventuallyRotate $q 2570 2573 } 2571 " zoom" {2572 SendCmd "camera zoom $_view( zoom)"2574 "-zoom" { 2575 SendCmd "camera zoom $_view($what)" 2573 2576 } 2574 2577 } … … 3040 3043 bottom "0.707107 0.707107 0 0" 3041 3044 } 3042 foreach name { qw qx qyqz } value $positions($side) {3045 foreach name { -qw -qx -qy -qz } value $positions($side) { 3043 3046 set _view($name) $value 3044 3047 } 3045 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]3048 set q [ViewToQuaternion] 3046 3049 $_arcball quaternion $q 3047 3050 SendCmd "camera orient $q" 3048 3051 SendCmd "camera reset" 3049 set _view( xpan) 03050 set _view( ypan) 03051 set _view( zoom) 1.03052 set _view(-xpan) 0 3053 set _view(-ypan) 0 3054 set _view(-zoom) 1.0 3052 3055 } 3053 3056
Note: See TracChangeset
for help on using the changeset viewer.