- Timestamp:
- Nov 23, 2014, 12:58:31 AM (10 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/flowvisviewer.tcl
r4757 r4765 43 43 itk_option define -plotbackground plotBackground Background "" 44 44 itk_option define -plotoutline plotOutline PlotOutline "" 45 46 private variable _volcomponents ; # Array of components found47 private variable _componentsList ; # Array of components found48 private method BuildVolumeComponents {}49 private method GetDatasetsWithComponent { cname }50 45 51 46 constructor { hostlist args } { … … 77 72 public method updateTransferFunctions {} 78 73 79 protected method Connect {}80 protected method CurrentVolumeIds {{what -all}}81 protected method Disconnect {}82 protected method Resize {}83 protected method ResizeLegend {}84 protected method AdjustSetting {what {value ""}}85 protected method InitSettings { args }86 protected method Pan {option x y}87 protected method Rebuild {}88 protected method ReceiveData { args }89 protected method ReceiveImage { args }90 protected method ReceiveLegend { tf vmin vmax size }91 protected method Rotate {option x y}92 protected method SendTransferFuncs {}93 protected method Slice {option args}94 protected method SlicerTip {axis}95 protected method Zoom {option}96 97 74 # soon to be removed. 98 protected method Flow {option args} 99 protected method Play {} 100 protected method Pause {} 101 75 private method Flow {option args} 76 private method Play {} 77 private method Pause {} 102 78 103 79 # The following methods are only used by this class. 104 80 private method AdjustSetting {what {value ""}} 105 81 private method AddIsoMarker { x y } 106 82 private method BuildCameraTab {} 107 83 private method BuildCutplanesTab {} 108 84 private method BuildViewTab {} 85 private method BuildVolumeComponents {} 109 86 private method BuildVolumeTab {} 110 87 private method ComputeTransferFunc { tf } 88 private method Connect {} 89 private method CurrentVolumeIds {{what -all}} 90 private method Disconnect {} 111 91 private method EventuallyResize { w h } 112 92 private method EventuallyGoto { nSteps } 113 93 private method EventuallyResizeLegend { } 114 94 private method FlowCmd { dataobj comp nbytes extents } 95 private method GetDatasetsWithComponent { cname } 96 private method GetFlowInfo { widget } 115 97 private method GetMovie { widget width height } 116 98 private method GetPngImage { widget width height } 99 private method InitSettings { args } 117 100 private method NameTransferFunc { dataobj comp } 101 private method Pan {option x y} 118 102 private method PanCamera {} 119 103 private method ParseLevelsOption { tf levels } 120 104 private method ParseMarkersOption { tf markers } 105 private method QuaternionToView { q } { 106 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 107 } 108 private method Rebuild {} 109 private method ReceiveData { args } 110 private method ReceiveImage { args } 111 private method ReceiveLegend { tf vmin vmax size } 112 private method Resize {} 113 private method ResizeLegend {} 114 private method Rotate {option x y} 115 private method SendTransferFuncs {} 116 private method SetOrientation { side } 117 private method Slice {option args} 118 private method SlicerTip {axis} 119 private method ViewToQuaternion {} { 120 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 121 } 121 122 private method WaitIcon { option widget } 123 private method Zoom {option} 124 private method arrows { tag name } 125 private method box { tag name } 126 private method millisecs2str { value } 127 private method particles { tag name } 122 128 private method str2millisecs { value } 123 private method millisecs2str { value }124 private method GetFlowInfo { widget }125 private method particles { tag name }126 private method box { tag name }127 129 private method streams { tag name } 128 private method arrows { tag name }129 private method SetOrientation { side }130 130 131 131 private variable _arcball "" … … 149 149 private variable _activeTf "" ;# The currently active transfer function. 150 150 private variable _first "" ;# This is the topmost volume. 151 private variable _volcomponents ; # Array of components found 152 private variable _componentsList ; # Array of components found 151 153 private variable _nextToken 0 152 154 private variable _icon 0 … … 218 220 # Initialize the view to some default parameters. 219 221 array set _view { 220 qw 0.853553221 qx -0.353553222 qy 0.353553223 qz 0.146447224 zoom 1.0225 xpan 0226 ypan0222 -qw 0.853553 223 -qx -0.353553 224 -qy 0.353553 225 -qz 0.146447 226 -xpan 0 227 -ypan 0 228 -zoom 1.0 227 229 } 228 230 set _arcball [blt::arcball create 100 100] 229 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 230 $_arcball quaternion $q 231 $_arcball quaternion [ViewToQuaternion] 231 232 232 233 set _limits(v) [list 0.0 1.0] … … 234 235 235 236 array set _settings [subst { 236 $this-qw $_view( qw)237 $this-qx $_view( qx)238 $this-qy $_view( qy)239 $this-qz $_view( qz)240 $this-zoom $_view( zoom)241 $this-xpan $_view( xpan)242 $this-ypan $_view( ypan)237 $this-qw $_view(-qw) 238 $this-qx $_view(-qx) 239 $this-qy $_view(-qy) 240 $this-qz $_view(-qz) 241 $this-zoom $_view(-zoom) 242 $this-xpan $_view(-xpan) 243 $this-ypan $_view(-ypan) 243 244 $this-arrows 0 244 245 $this-currenttime 0 … … 1213 1214 1214 1215 } 1215 set _settings($this-qw) $_view( qw)1216 set _settings($this-qx) $_view( qx)1217 set _settings($this-qy) $_view( qy)1218 set _settings($this-qz) $_view( qz)1219 set _settings($this-xpan) $_view( xpan)1220 set _settings($this-ypan) $_view( ypan)1221 set _settings($this-zoom) $_view( zoom)1222 1223 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1216 set _settings($this-qw) $_view(-qw) 1217 set _settings($this-qx) $_view(-qx) 1218 set _settings($this-qy) $_view(-qy) 1219 set _settings($this-qz) $_view(-qz) 1220 set _settings($this-xpan) $_view(-xpan) 1221 set _settings($this-ypan) $_view(-ypan) 1222 set _settings($this-zoom) $_view(-zoom) 1223 1224 set q [ViewToQuaternion] 1224 1225 $_arcball quaternion $q 1225 1226 SendCmd "camera orient $q" 1226 1227 SendCmd "camera reset" 1227 1228 PanCamera 1228 SendCmd "camera zoom $_view( zoom)"1229 SendCmd "camera zoom $_view(-zoom)" 1229 1230 1230 1231 foreach dataobj [get] { … … 1305 1306 switch -- $option { 1306 1307 "in" { 1307 set _view( zoom) [expr {$_view(zoom)*1.25}]1308 set _settings($this-zoom) $_view( zoom)1309 SendCmd "camera zoom $_view( zoom)"1308 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1309 set _settings($this-zoom) $_view(-zoom) 1310 SendCmd "camera zoom $_view(-zoom)" 1310 1311 } 1311 1312 "out" { 1312 set _view( zoom) [expr {$_view(zoom)*0.8}]1313 set _settings($this-zoom) $_view( zoom)1314 SendCmd "camera zoom $_view( zoom)"1313 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1314 set _settings($this-zoom) $_view(-zoom) 1315 SendCmd "camera zoom $_view(-zoom)" 1315 1316 } 1316 1317 "reset" { 1317 1318 array set _view { 1318 qw 0.8535531319 qx -0.3535531320 qy 0.3535531321 qz 0.1464471322 zoom 1.01323 xpan01324 ypan01319 -qw 0.853553 1320 -qx -0.353553 1321 -qy 0.353553 1322 -qz 0.146447 1323 -zoom 1.0 1324 -xpan 0 1325 -ypan 0 1325 1326 } 1326 1327 if { $_first != "" } { … … 1330 1331 } 1331 1332 } 1332 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1333 set q [ViewToQuaternion] 1333 1334 $_arcball quaternion $q 1334 1335 SendCmd "camera orient $q" 1335 1336 SendCmd "camera reset" 1336 set _settings($this-qw) $_view( qw)1337 set _settings($this-qx) $_view( qx)1338 set _settings($this-qy) $_view( qy)1339 set _settings($this-qz) $_view( qz)1340 set _settings($this-xpan) $_view( xpan)1341 set _settings($this-ypan) $_view( ypan)1342 set _settings($this-zoom) $_view( zoom)1337 set _settings($this-qw) $_view(-qw) 1338 set _settings($this-qx) $_view(-qx) 1339 set _settings($this-qy) $_view(-qy) 1340 set _settings($this-qz) $_view(-qz) 1341 set _settings($this-xpan) $_view(-xpan) 1342 set _settings($this-ypan) $_view(-ypan) 1343 set _settings($this-zoom) $_view(-zoom) 1343 1344 } 1344 1345 } … … 1346 1347 1347 1348 itcl::body Rappture::FlowvisViewer::PanCamera {} { 1348 set x $_view( xpan)1349 set y $_view( ypan)1349 set x $_view(-xpan) 1350 set y $_view(-ypan) 1350 1351 SendCmd "camera pan $x $y" 1351 1352 } … … 1385 1386 1386 1387 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1387 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break1388 set _settings($this-qw) $_view( qw)1389 set _settings($this-qx) $_view( qx)1390 set _settings($this-qy) $_view( qy)1391 set _settings($this-qz) $_view( qz)1388 QuaternionToView $q 1389 set _settings($this-qw) $_view(-qw) 1390 set _settings($this-qx) $_view(-qx) 1391 set _settings($this-qy) $_view(-qy) 1392 set _settings($this-qz) $_view(-qz) 1392 1393 SendCmd "camera orient $q" 1393 1394 … … 1422 1423 set x [expr $x / double($w)] 1423 1424 set y [expr $y / double($h)] 1424 set _view( xpan) [expr $_view(xpan) + $x]1425 set _view( ypan) [expr $_view(ypan) + $y]1425 set _view(-xpan) [expr $_view(-xpan) + $x] 1426 set _view(-ypan) [expr $_view(-ypan) + $y] 1426 1427 PanCamera 1427 set _settings($this-xpan) $_view( xpan)1428 set _settings($this-ypan) $_view( ypan)1428 set _settings($this-xpan) $_view(-xpan) 1429 set _settings($this-ypan) $_view(-ypan) 1429 1430 return 1430 1431 } … … 1439 1440 set _click(x) $x 1440 1441 set _click(y) $y 1441 set _view( xpan) [expr $_view(xpan) - $dx]1442 set _view( ypan) [expr $_view(ypan) - $dy]1442 set _view(-xpan) [expr $_view(-xpan) - $dx] 1443 set _view(-ypan) [expr $_view(-ypan) - $dy] 1443 1444 PanCamera 1444 set _settings($this-xpan) $_view( xpan)1445 set _settings($this-ypan) $_view( ypan)1445 set _settings($this-xpan) $_view(-xpan) 1446 set _settings($this-ypan) $_view(-ypan) 1446 1447 } 1447 1448 if { $option == "release" } { … … 2384 2385 -textvariable [itcl::scope _settings($this-$tag)] 2385 2386 bind $inner.${tag} <Return> \ 2386 [itcl::code $this camera set ${tag}]2387 [itcl::code $this camera set -${tag}] 2387 2388 bind $inner.${tag} <KP_Enter> \ 2388 [itcl::code $this camera set ${tag}]2389 [itcl::code $this camera set -${tag}] 2389 2390 blt::table $inner \ 2390 2391 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 2588 2589 } 2589 2590 "set" { 2590 set wh o[lindex $args 0]2591 set x $_settings($ this-$who)2591 set what [lindex $args 0] 2592 set x $_settings(${this}${what}) 2592 2593 set code [catch { string is double $x } result] 2593 2594 if { $code != 0 || !$result } { 2594 set _settings($ this-$who) $_view($who)2595 set _settings(${this}${what}) $_view($what) 2595 2596 return 2596 2597 } 2597 switch -- $wh o{2598 " xpan" - "ypan" {2599 set _view($wh o) $_settings($this-$who)2598 switch -- $what { 2599 "-xpan" - "-ypan" { 2600 set _view($what) $_settings(${this}${what}) 2600 2601 PanCamera 2601 2602 } 2602 " qx" - "qy" - "qz" - "qw" {2603 set _view($wh o) $_settings($this-$who)2604 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2603 "-qx" - "-qy" - "-qz" - "-qw" { 2604 set _view($what) $_settings(${this}${what}) 2605 set q [ViewToQuaternion] 2605 2606 $_arcball quaternion $q 2606 2607 SendCmd "camera orient $q" 2607 2608 } 2608 " zoom" {2609 set _view($wh o) $_settings($this-$who)2610 SendCmd "camera zoom $_view( zoom)"2609 "-zoom" { 2610 set _view($what) $_settings(${this}${what}) 2611 SendCmd "camera zoom $_view($what)" 2611 2612 } 2612 2613 } … … 2986 2987 bottom "0.707107 0.707107 0 0" 2987 2988 } 2988 foreach name { qw qx qyqz } value $positions($side) {2989 foreach name { -qw -qx -qy -qz } value $positions($side) { 2989 2990 set _view($name) $value 2990 2991 } 2991 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2992 set q [ViewToQuaternion] 2992 2993 $_arcball quaternion $q 2993 2994 SendCmd "camera orient $q" 2994 2995 SendCmd "camera reset" 2995 set _view( xpan) 0.02996 set _view( ypan) 0.02997 set _view( zoom) 1.02998 set _settings($this-xpan) $_view( xpan)2999 set _settings($this-ypan) $_view( ypan)3000 set _settings($this-zoom) $_view( zoom)2996 set _view(-xpan) 0.0 2997 set _view(-ypan) 0.0 2998 set _view(-zoom) 1.0 2999 set _settings($this-xpan) $_view(-xpan) 3000 set _settings($this-ypan) $_view(-ypan) 3001 set _settings($this-zoom) $_view(-zoom) 3001 3002 } 3002 3003 -
trunk/gui/scripts/mapviewer.tcl
r4749 r4765 65 65 public method scale {args} 66 66 67 protected method AdjustSetting {what {value ""}} 68 protected method Connect {} 69 protected method CurrentLayers {args} 70 protected method Disconnect {} 71 protected method DoPan {} 72 protected method DoResize {} 73 protected method DoRotate {} 74 protected method InitSettings { args } 75 protected method KeyPress { key } 76 protected method KeyRelease { key } 77 protected method MouseClick { button x y } 78 protected method MouseDoubleClick { button x y } 79 protected method MouseDrag { button x y } 80 protected method MouseMotion {} 81 protected method MouseRelease { button x y } 82 protected method MouseScroll { direction } 83 protected method Pan {option x y} 84 protected method Pin {option x y} 85 protected method Rebuild {} 86 protected method ReceiveMapInfo { args } 87 protected method ReceiveScreenInfo { args } 88 protected method ReceiveImage { args } 89 protected method Rotate {option x y} 90 protected method Select {option x y} 91 protected method Zoom {option {x 0} {y 0}} 67 private method KeyPress { key } 68 private method KeyRelease { key } 69 private method MouseClick { button x y } 70 private method MouseDoubleClick { button x y } 71 private method MouseDrag { button x y } 72 private method MouseMotion {} 73 private method MouseRelease { button x y } 74 private method MouseScroll { direction } 92 75 93 76 # The following methods are only used by this class. 77 private method AdjustSetting {what {value ""}} 94 78 private method BuildCameraTab {} 95 79 private method BuildDownloadPopup { widget command } … … 97 81 private method BuildTerrainTab {} 98 82 private method ChangeLayerVisibility { dataobj layer } 83 private method Connect {} 84 private method CurrentLayers {args} 85 private method Disconnect {} 86 private method DoPan {} 87 private method DoResize {} 88 private method DoRotate {} 89 private method EarthFile {} 99 90 private method EventuallyHandleMotionEvent { x y } 100 91 private method EventuallyPan { dx dy } … … 103 94 private method GetImage { args } 104 95 private method GetNormalizedMouse { x y } 96 private method InitSettings { args } 105 97 private method MapIsGeocentric {} 98 private method Pan {option x y} 99 private method Pin {option x y} 100 private method Rebuild {} 101 private method ReceiveMapInfo { args } 102 private method ReceiveScreenInfo { args } 103 private method ReceiveImage { args } 104 private method Rotate {option x y} 105 private method Select {option x y} 106 106 private method SetLayerStyle { dataobj layer } 107 107 private method SetTerrainStyle { style } 108 108 private method SetOpacity { dataset } 109 109 private method UpdateLayerControls {} 110 private method EarthFile {}110 private method Zoom {option {x 0} {y 0}} 111 111 112 112 private variable _dlist ""; # list of data objects … … 1095 1095 lappend cinfo "dataset_label" [$dataobj hints label] 1096 1096 lappend cinfo "dataset_tag" $layer 1097 SendCmd [list "clientinfo" $cinfo]1097 SendCmd "clientinfo [list $cinfo]" 1098 1098 } 1099 1099 set _layers($layer) 1 … … 1526 1526 itcl::configbody Rappture::MapViewer::plotbackground { 1527 1527 if { [isconnected] } { 1528 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break1529 SendCmd "screen bgcolor $r $g $b"1528 set rgb [Color2RGB $itk_option(-plotbackground)] 1529 SendCmd "screen bgcolor $rgb" 1530 1530 } 1531 1531 } … … 1536 1536 itcl::configbody Rappture::MapViewer::plotforeground { 1537 1537 if { [isconnected] } { 1538 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1539 #fix this! 1540 #SendCmd "color background $r $g $b" 1538 set rgb [Color2RGB $itk_option(-plotforeground)] 1539 # FIXME: Set font foreground colors 1541 1540 } 1542 1541 } -
trunk/gui/scripts/nanovisviewer.tcl
r4749 r4765 113 113 private method ParseLevelsOption { cname levels } 114 114 private method ParseMarkersOption { cname markers } 115 private method QuaternionToView { q } { 116 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 117 } 115 118 private method Rebuild {} 116 119 private method ReceiveData { args } … … 126 129 private method SwitchComponent { cname } 127 130 private method ToggleVolume { tag name } 128 private method Zoom {option}129 131 private method ViewToQuaternion {} { 130 132 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 131 133 } 134 private method Zoom {option} 132 135 133 136 private variable _arcball "" … … 1136 1139 1137 1140 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1138 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break1141 QuaternionToView $q 1139 1142 set _settings(-qw) $_view(-qw) 1140 1143 set _settings(-qx) $_view(-qx) -
trunk/gui/scripts/vtkglyphviewer.tcl
r4763 r4765 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 } … … 1863 1863 label $inner.${tag}label -text $tag -font "Arial 9" 1864 1864 entry $inner.${tag} -font "Arial 9" -bg white \ 1865 -textvariable [itcl::scope _view( $tag)]1865 -textvariable [itcl::scope _view(-$tag)] 1866 1866 bind $inner.${tag} <Return> \ 1867 [itcl::code $this camera set ${tag}]1867 [itcl::code $this camera set -${tag}] 1868 1868 bind $inner.${tag} <KP_Enter> \ 1869 [itcl::code $this camera set ${tag}]1869 [itcl::code $this camera set -${tag}] 1870 1870 blt::table $inner \ 1871 1871 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1876 1876 checkbutton $inner.ortho \ 1877 1877 -text "Orthographic Projection" \ 1878 -variable [itcl::scope _view( ortho)] \1879 -command [itcl::code $this camera set ortho] \1878 -variable [itcl::scope _view(-ortho)] \ 1879 -command [itcl::code $this camera set -ortho] \ 1880 1880 -font "Arial 9" 1881 1881 blt::table $inner \ … … 2053 2053 } 2054 2054 "set" { 2055 set wh o[lindex $args 0]2056 set x $_view($wh o)2055 set what [lindex $args 0] 2056 set x $_view($what) 2057 2057 set code [catch { string is double $x } result] 2058 2058 if { $code != 0 || !$result } { 2059 2059 return 2060 2060 } 2061 switch -- $wh o{2062 " ortho" {2063 if {$_view( ortho)} {2061 switch -- $what { 2062 "-ortho" { 2063 if {$_view($what)} { 2064 2064 SendCmd "camera mode ortho" 2065 2065 } else { … … 2067 2067 } 2068 2068 } 2069 " xpan" - "ypan" {2069 "-xpan" - "-ypan" { 2070 2070 PanCamera 2071 2071 } 2072 " qx" - "qy" - "qz" - "qw" {2073 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2072 "-qx" - "-qy" - "-qz" - "-qw" { 2073 set q [ViewToQuaternion] 2074 2074 $_arcball quaternion $q 2075 2075 EventuallyRotate $q 2076 2076 } 2077 " zoom" {2078 SendCmd "camera zoom $_view( zoom)"2077 "-zoom" { 2078 SendCmd "camera zoom $_view($what)" 2079 2079 } 2080 2080 } … … 2574 2574 bottom "0.707107 0.707107 0 0" 2575 2575 } 2576 foreach name { qw qx qyqz } value $positions($side) {2576 foreach name { -qw -qx -qy -qz } value $positions($side) { 2577 2577 set _view($name) $value 2578 } 2579 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2578 } 2579 set q [ViewToQuaternion] 2580 2580 $_arcball quaternion $q 2581 2581 SendCmd "camera orient $q" 2582 2582 SendCmd "camera reset" 2583 set _view( xpan) 02584 set _view( ypan) 02585 set _view( zoom) 1.02586 } 2583 set _view(-xpan) 0 2584 set _view(-ypan) 0 2585 set _view(-zoom) 1.0 2586 } -
trunk/gui/scripts/vtkheightmapviewer.tcl
r4756 r4765 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 -
trunk/gui/scripts/vtkimageviewer.tcl
r4758 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 AdjustMode {}72 protected method InitSettings { args }73 protected method Pan {option x y}74 protected method Pick {x y}75 protected method Rebuild {}76 protected method ReceiveDataset { args }77 protected method ReceiveImage { args }78 protected method ReceiveLegend { colormap title min max size }79 protected method Rotate {option x y}80 protected method Zoom {option}81 82 65 # The following methods are only used by this class. 66 private method AdjustSetting {what {value ""}} 83 67 private method BuildAxisTab {} 84 68 private method BuildCameraTab {} … … 87 71 private method BuildDownloadPopup { widget command } 88 72 private method Combo { option } 73 private method Connect {} 74 private method CurrentDatasets {args} 75 private method Disconnect {} 76 private method DoResize {} 77 private method DoRotate {} 89 78 private method DrawLegend {} 90 79 private method EnterLegend { x y } … … 94 83 private method GetImage { args } 95 84 private method GetVtkData { args } 85 private method InitSettings { args } 96 86 private method IsValidObject { dataobj } 97 87 private method LeaveLegend {} 98 88 private method MotionLegend { x y } 89 private method Pan {option x y} 99 90 private method PanCamera {} 91 private method Pick {x y} 92 private method QuaternionToView { q } { 93 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 94 } 95 private method Rebuild {} 96 private method ReceiveDataset { args } 97 private method ReceiveImage { args } 98 private method ReceiveLegend { colormap title min max size } 100 99 private method RequestLegend {} 100 private method Rotate {option x y} 101 101 private method SetCurrentColormap { color } 102 102 private method SetLegendTip { x y } 103 103 private method SetObjectStyle { dataobj comp } 104 104 private method SetOrientation { side } 105 private method ViewToQuaternion {} { 106 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 107 } 108 private method Zoom {option} 105 109 106 110 private variable _arcball "" … … 196 200 # Initialize the view to some default parameters. 197 201 array set _view { 198 qw 0.36199 qx 0.25200 qy 0.50201 qz 0.70202 zoom 1.0203 xpan0204 ypan0205 ortho0202 -ortho 0 203 -qw 0.36 204 -qx 0.25 205 -qy 0.50 206 -qz 0.70 207 -xpan 0 208 -ypan 0 209 -zoom 1.0 206 210 } 207 211 set _arcball [blt::arcball create 100 100] 208 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 209 $_arcball quaternion $q 212 $_arcball quaternion [ViewToQuaternion] 210 213 211 214 array set _settings { … … 429 432 430 433 itcl::body Rappture::VtkImageViewer::DoRotate {} { 431 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 432 SendCmd "camera orient $q" 434 SendCmd "camera orient [ViewToQuaternion]" 433 435 set _rotatePending 0 434 436 } … … 454 456 455 457 itcl::body Rappture::VtkImageViewer::EventuallyRotate { q } { 456 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break458 QuaternionToView $q 457 459 if { !$_rotatePending } { 458 460 set _rotatePending 1 … … 926 928 927 929 SendCmd "axis lrot z 90" 928 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 929 $_arcball quaternion $q 930 $_arcball quaternion [ViewToQuaternion] 930 931 if {$_settings(view3D) } { 931 if { $_view( ortho)} {932 if { $_view(-ortho)} { 932 933 SendCmd "camera mode ortho" 933 934 } else { … … 971 972 lappend info "dataset_size" $length 972 973 lappend info "dataset_tag" $tag 973 SendCmd [list "clientinfo" $info]974 SendCmd "clientinfo [list $info]" 974 975 } 975 976 SendCmd "dataset add $tag data follows $length" … … 1044 1045 # Reset the camera and other view parameters 1045 1046 # 1046 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1047 $_arcball quaternion $q 1047 $_arcball quaternion [ViewToQuaternion] 1048 1048 if {$_settings(view3D) } { 1049 if { $_view( ortho)} {1049 if { $_view(-ortho)} { 1050 1050 SendCmd "camera mode ortho" 1051 1051 } else { … … 1130 1130 switch -- $option { 1131 1131 "in" { 1132 set _view( zoom) [expr {$_view(zoom)*1.25}]1133 SendCmd "camera zoom $_view( zoom)"1132 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1133 SendCmd "camera zoom $_view(-zoom)" 1134 1134 } 1135 1135 "out" { 1136 set _view( zoom) [expr {$_view(zoom)*0.8}]1137 SendCmd "camera zoom $_view( zoom)"1136 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1137 SendCmd "camera zoom $_view(-zoom)" 1138 1138 } 1139 1139 "reset" { 1140 1140 array set _view { 1141 qw 0.361142 qx 0.251143 qy 0.501144 qz 0.701145 zoom 1.01146 xpan 01147 ypan 01141 -qw 0.36 1142 -qx 0.25 1143 -qy 0.50 1144 -qz 0.70 1145 -xpan 0 1146 -ypan 0 1147 -zoom 1.0 1148 1148 } 1149 1149 if { $_first != "" } { … … 1153 1153 } 1154 1154 } 1155 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1156 $_arcball quaternion $q 1155 $_arcball quaternion [ViewToQuaternion] 1157 1156 if {$_settings(view3D) } { 1158 1157 DoRotate … … 1164 1163 1165 1164 itcl::body Rappture::VtkImageViewer::PanCamera {} { 1166 set x $_view( xpan)1167 set y $_view( ypan)1165 set x $_view(-xpan) 1166 set y $_view(-ypan) 1168 1167 SendCmd "camera pan $x $y" 1169 1168 } … … 1243 1242 set x [expr $x / double($w)] 1244 1243 set y [expr $y / double($h)] 1245 set _view( xpan) [expr $_view(xpan) + $x]1246 set _view( ypan) [expr $_view(ypan) + $y]1244 set _view(-xpan) [expr $_view(-xpan) + $x] 1245 set _view(-ypan) [expr $_view(-ypan) + $y] 1247 1246 PanCamera 1248 1247 return … … 1266 1265 set _click(x) $x 1267 1266 set _click(y) $y 1268 set _view( xpan) [expr $_view(xpan) - $dx]1269 set _view( ypan) [expr $_view(ypan) - $dy]1267 set _view(-xpan) [expr $_view(-xpan) - $dx] 1268 set _view(-ypan) [expr $_view(-ypan) - $dy] 1270 1269 PanCamera 1271 1270 } … … 1427 1426 $itk_component(opacity) configure -state normal 1428 1427 $itk_component(opacity_l) configure -state normal 1429 if {$_view( ortho)} {1428 if {$_view(-ortho)} { 1430 1429 SendCmd "camera mode ortho" 1431 1430 } else { … … 1442 1441 } 1443 1442 if { $bool } { 1444 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1443 set q [ViewToQuaternion] 1445 1444 $_arcball quaternion $q 1446 1445 SendCmd "camera orient $q" … … 1887 1886 label $inner.${tag}label -text $tag -font "Arial 9" 1888 1887 entry $inner.${tag} -font "Arial 9" -bg white \ 1889 -textvariable [itcl::scope _view( $tag)]1888 -textvariable [itcl::scope _view(-$tag)] 1890 1889 bind $inner.${tag} <Return> \ 1891 [itcl::code $this camera set ${tag}]1890 [itcl::code $this camera set -${tag}] 1892 1891 bind $inner.${tag} <KP_Enter> \ 1893 [itcl::code $this camera set ${tag}]1892 [itcl::code $this camera set -${tag}] 1894 1893 blt::table $inner \ 1895 1894 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1900 1899 checkbutton $inner.ortho \ 1901 1900 -text "Orthographic Projection" \ 1902 -variable [itcl::scope _view( ortho)] \1903 -command [itcl::code $this camera set ortho] \1901 -variable [itcl::scope _view(-ortho)] \ 1902 -command [itcl::code $this camera set -ortho] \ 1904 1903 -font "Arial 9" 1905 1904 blt::table $inner \ … … 1922 1921 } 1923 1922 "set" { 1924 set wh o[lindex $args 0]1925 set x $_view($wh o)1923 set what [lindex $args 0] 1924 set x $_view($what) 1926 1925 set code [catch { string is double $x } result] 1927 1926 if { $code != 0 || !$result } { 1928 1927 return 1929 1928 } 1930 switch -- $wh o{1931 " ortho" {1932 if {$_view( ortho)} {1929 switch -- $what { 1930 "-ortho" { 1931 if {$_view($what)} { 1933 1932 SendCmd "camera mode ortho" 1934 1933 } else { … … 1936 1935 } 1937 1936 } 1938 " xpan" - "ypan" {1937 "-xpan" - "-ypan" { 1939 1938 PanCamera 1940 1939 } 1941 " qx" - "qy" - "qz" - "qw" {1942 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1940 "-qx" - "-qy" - "-qz" - "-qw" { 1941 set q [ViewToQuaternion] 1943 1942 $_arcball quaternion $q 1944 1943 EventuallyRotate $q 1945 1944 } 1946 " zoom" {1947 SendCmd "camera zoom $_view( zoom)"1945 "-zoom" { 1946 SendCmd "camera zoom $_view($what)" 1948 1947 } 1949 1948 } … … 2323 2322 bottom "0 1 0 0" 2324 2323 } 2325 foreach name { qw qx qyqz } value $positions($side) {2324 foreach name { -qw -qx -qy -qz } value $positions($side) { 2326 2325 set _view($name) $value 2327 2326 } 2328 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2327 set q [ViewToQuaternion] 2329 2328 $_arcball quaternion $q 2330 2329 SendCmd "camera orient $q" 2331 2330 SendCmd "camera reset" 2332 set _view( xpan) 02333 set _view( ypan) 02334 set _view( zoom) 1.02335 } 2331 set _view(-xpan) 0 2332 set _view(-ypan) 0 2333 set _view(-zoom) 1.0 2334 } -
trunk/gui/scripts/vtkisosurfaceviewer.tcl
r4757 r4765 95 95 private method PanCamera {} 96 96 private method Pick {x y} 97 private method QuaternionToView { q } { 98 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 99 } 97 100 private method Rebuild {} 98 101 private method ReceiveDataset { args } … … 107 110 private method SetOrientation { side } 108 111 private method Slice {option args} 109 private method Zoom {option}110 112 private method ViewToQuaternion {} { 111 113 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 112 114 } 115 private method Zoom {option} 113 116 114 117 private variable _arcball "" … … 464 467 EnableWaitDialog 500 465 468 Connect 469 # FIXME: Removing this update breaks wizard mode (see examples/3D) 470 # However, it also allows an error in the initialization order 471 # where FieldResult::add is called from ResultViewer before this 472 # constructor is completed. 473 #update 466 474 } 467 475 … … 523 531 524 532 itcl::body Rappture::VtkIsosurfaceViewer::EventuallyRotate { q } { 525 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break533 QuaternionToView $q 526 534 if { !$_rotatePending } { 527 535 set _rotatePending 1 … … 1151 1159 "reset" { 1152 1160 array set _view { 1153 -qw 0.8535531154 -qx -0.3535531155 -qy 0.3535531156 -qz 0.1464471157 -xpan 01158 -ypan 01159 -zoom 1.01161 -qw 0.853553 1162 -qx -0.353553 1163 -qy 0.353553 1164 -qz 0.146447 1165 -xpan 0 1166 -ypan 0 1167 -zoom 1.0 1160 1168 } 1161 1169 if { $_first != "" } { … … 1233 1241 itcl::body Rappture::VtkIsosurfaceViewer::Pick {x y} { 1234 1242 foreach tag [CurrentDatasets -visible] { 1235 SendCmd NoSplash"dataset getscalar pixel $x $y $tag"1243 SendCmd "dataset getscalar pixel $x $y $tag" 1236 1244 } 1237 1245 } … … 2021 2029 } 2022 2030 2023 2024 2025 2031 # 2026 2032 # camera -- … … 2055 2061 } 2056 2062 "-zoom" { 2057 SendCmd "camera zoom $_view( -zoom)"2063 SendCmd "camera zoom $_view($what)" 2058 2064 } 2059 2065 } … … 2566 2572 foreach name { -qw -qx -qy -qz } value $positions($side) { 2567 2573 set _view($name) $value 2568 } 2574 } 2569 2575 set q [ViewToQuaternion] 2570 2576 $_arcball quaternion $q -
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 } -
trunk/gui/scripts/vtkstreamlinesviewer.tcl
r4757 r4765 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 DoReseed {}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 64 # The following methods are only used by this class. 65 private method AdjustSetting {what {value ""}} 82 66 private method BuildAxisTab {} 83 67 private method BuildCameraTab {} … … 89 73 private method DrawLegend {} 90 74 private method Combo { option } 75 private method Connect {} 76 private method CurrentDatasets {args} 77 private method Disconnect {} 78 private method DoResize {} 79 private method DoReseed {} 80 private method DoRotate {} 91 81 private method EnterLegend { x y } 92 82 private method EventuallyResize { w h } … … 96 86 private method GetImage { args } 97 87 private method GetVtkData { args } 88 private method InitSettings { args } 98 89 private method IsValidObject { dataobj } 99 90 private method LeaveLegend {} 100 91 private method MotionLegend { x y } 92 private method Pan {option x y} 101 93 private method PanCamera {} 94 private method Pick {x y} 95 private method QuaternionToView { q } { 96 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 97 } 98 private method Rebuild {} 99 private method ReceiveDataset { args } 100 private method ReceiveImage { args } 101 private method ReceiveLegend { colormap title vmin vmax size } 102 102 private method RequestLegend {} 103 private method Rotate {option x y} 103 104 private method SetColormap { dataobj comp } 104 105 private method ChangeColormap { dataobj comp color } … … 107 108 private method Slice {option args} 108 109 private method SetOrientation { side } 110 private method ViewToQuaternion {} { 111 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 112 } 113 private method Zoom {option} 109 114 110 115 private variable _arcball "" … … 210 215 # Initialize the view to some default parameters. 211 216 array set _view { 212 qw 0.853553213 qx -0.353553214 qy0.353553215 qz 0.146447216 zoom 1.0217 xpan 0218 ypan 0219 ortho0217 -ortho 0 218 -qw 0.853553 219 -qx -0.353553 220 -qy 0.353553 221 -qz 0.146447 222 -xpan 0 223 -ypan 0 224 -zoom 1.0 220 225 } 221 226 set _arcball [blt::arcball create 100 100] 222 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 223 $_arcball quaternion $q 227 $_arcball quaternion [ViewToQuaternion] 224 228 225 229 array set _settings [subst { … … 400 404 bind $itk_component(view) <ButtonRelease-1> \ 401 405 [itcl::code $this Rotate release %x %y] 402 bind $itk_component(view) <Configure> \ 403 [itcl::code $this EventuallyResize %w %h] 404 405 if 0 { 406 bind $itk_component(view) <Configure> \ 407 [itcl::code $this EventuallyResize %w %h] 408 } 406 409 407 # Bindings for panning via mouse 410 408 bind $itk_component(view) <ButtonPress-2> \ … … 481 479 482 480 itcl::body Rappture::VtkStreamlinesViewer::DoRotate {} { 483 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 484 SendCmd "camera orient $q" 481 SendCmd "camera orient [ViewToQuaternion]" 485 482 set _rotatePending 0 486 483 } … … 516 513 517 514 itcl::body Rappture::VtkStreamlinesViewer::EventuallyRotate { q } { 518 foreach { _view(qw) _view(qx) _view(qy) _view(qz) } $q break515 QuaternionToView $q 519 516 if { !$_rotatePending } { 520 517 set _rotatePending 1 … … 1075 1072 1076 1073 # Reset the camera and other view parameters 1077 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1078 $_arcball quaternion $q 1079 if {$_view(ortho)} { 1074 $_arcball quaternion [ViewToQuaternion] 1075 if {$_view(-ortho)} { 1080 1076 SendCmd "camera mode ortho" 1081 1077 } else { … … 1151 1147 switch -- $option { 1152 1148 "in" { 1153 set _view( zoom) [expr {$_view(zoom)*1.25}]1154 SendCmd "camera zoom $_view( zoom)"1149 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1150 SendCmd "camera zoom $_view(-zoom)" 1155 1151 } 1156 1152 "out" { 1157 set _view( zoom) [expr {$_view(zoom)*0.8}]1158 SendCmd "camera zoom $_view( zoom)"1153 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1154 SendCmd "camera zoom $_view(-zoom)" 1159 1155 } 1160 1156 "reset" { 1161 1157 array set _view { 1162 qw 0.8535531163 qx -0.3535531164 qy 0.3535531165 qz 0.1464471166 zoom 1.01167 xpan 01168 ypan01158 -qw 0.853553 1159 -qx -0.353553 1160 -qy 0.353553 1161 -qz 0.146447 1162 -xpan 0 1163 -ypan 0 1164 -zoom 1.0 1169 1165 } 1170 1166 if { $_first != "" } { … … 1174 1170 } 1175 1171 } 1176 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 1177 $_arcball quaternion $q 1172 $_arcball quaternion [ViewToQuaternion] 1178 1173 DoRotate 1179 1174 SendCmd "camera reset" … … 1183 1178 1184 1179 itcl::body Rappture::VtkStreamlinesViewer::PanCamera {} { 1185 set x $_view( xpan)1186 set y $_view( ypan)1180 set x $_view(-xpan) 1181 set y $_view(-ypan) 1187 1182 SendCmd "camera pan $x $y" 1188 1183 } 1189 1190 1184 1191 1185 # ---------------------------------------------------------------------- … … 1262 1256 set x [expr $x / double($w)] 1263 1257 set y [expr $y / double($h)] 1264 set _view( xpan) [expr $_view(xpan) + $x]1265 set _view( ypan) [expr $_view(ypan) + $y]1258 set _view(-xpan) [expr $_view(-xpan) + $x] 1259 set _view(-ypan) [expr $_view(-ypan) + $y] 1266 1260 PanCamera 1267 1261 return … … 1285 1279 set _click(x) $x 1286 1280 set _click(y) $y 1287 set _view( xpan) [expr $_view(xpan) - $dx]1288 set _view( ypan) [expr $_view(ypan) - $dy]1281 set _view(-xpan) [expr $_view(-xpan) - $dx] 1282 set _view(-ypan) [expr $_view(-ypan) - $dy] 1289 1283 PanCamera 1290 1284 } … … 1609 1603 itcl::configbody Rappture::VtkStreamlinesViewer::plotbackground { 1610 1604 if { [isconnected] } { 1611 foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break1612 SendCmd "screen bgcolor $r $g $b"1605 set rgb [Color2RGB $itk_option(-plotbackground)] 1606 SendCmd "screen bgcolor $rgb" 1613 1607 } 1614 1608 } … … 1619 1613 itcl::configbody Rappture::VtkStreamlinesViewer::plotforeground { 1620 1614 if { [isconnected] } { 1621 foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break 1622 #fix this! 1623 #SendCmd "color background $r $g $b" 1615 set rgb [Color2RGB $itk_option(-plotforeground)] 1616 SendCmd "axis color all $rgb" 1617 SendCmd "outline color $rgb" 1618 SendCmd "cutplane color $rgb" 1624 1619 } 1625 1620 } … … 1869 1864 label $inner.${tag}label -text $tag -font "Arial 9" 1870 1865 entry $inner.${tag} -font "Arial 9" -bg white \ 1871 -textvariable [itcl::scope _view( $tag)]1866 -textvariable [itcl::scope _view(-$tag)] 1872 1867 bind $inner.${tag} <Return> \ 1873 [itcl::code $this camera set ${tag}]1868 [itcl::code $this camera set -${tag}] 1874 1869 bind $inner.${tag} <KP_Enter> \ 1875 [itcl::code $this camera set ${tag}]1870 [itcl::code $this camera set -${tag}] 1876 1871 blt::table $inner \ 1877 1872 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1882 1877 checkbutton $inner.ortho \ 1883 1878 -text "Orthographic Projection" \ 1884 -variable [itcl::scope _view( ortho)] \1885 -command [itcl::code $this camera set ortho] \1879 -variable [itcl::scope _view(-ortho)] \ 1880 -command [itcl::code $this camera set -ortho] \ 1886 1881 -font "Arial 9" 1887 1882 blt::table $inner \ … … 2049 2044 } 2050 2045 "set" { 2051 set wh o[lindex $args 0]2052 set x $_view($wh o)2046 set what [lindex $args 0] 2047 set x $_view($what) 2053 2048 set code [catch { string is double $x } result] 2054 2049 if { $code != 0 || !$result } { 2055 2050 return 2056 2051 } 2057 switch -- $wh o{2058 " ortho" {2059 if {$_view( ortho)} {2052 switch -- $what { 2053 "-ortho" { 2054 if {$_view($what)} { 2060 2055 SendCmd "camera mode ortho" 2061 2056 } else { … … 2063 2058 } 2064 2059 } 2065 " xpan" - "ypan" {2060 "-xpan" - "-ypan" { 2066 2061 PanCamera 2067 2062 } 2068 " qx" - "qy" - "qz" - "qw" {2069 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2063 "-qx" - "-qy" - "-qz" - "-qw" { 2064 set q [ViewToQuaternion] 2070 2065 $_arcball quaternion $q 2071 2066 EventuallyRotate $q 2072 2067 } 2073 " zoom" {2074 SendCmd "camera zoom $_view( zoom)"2068 "-zoom" { 2069 SendCmd "camera zoom $_view($what)" 2075 2070 } 2076 2071 } … … 2432 2427 bottom "0.707107 0.707107 0 0" 2433 2428 } 2434 foreach name { qw qx qyqz } value $positions($side) {2429 foreach name { -qw -qx -qy -qz } value $positions($side) { 2435 2430 set _view($name) $value 2436 2431 } 2437 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2432 set q [ViewToQuaternion] 2438 2433 $_arcball quaternion $q 2439 2434 SendCmd "camera orient $q" 2440 2435 SendCmd "camera reset" 2441 set _view( xpan) 02442 set _view( ypan) 02443 set _view( zoom) 1.02444 } 2436 set _view(-xpan) 0 2437 set _view(-ypan) 0 2438 set _view(-zoom) 1.0 2439 } -
trunk/gui/scripts/vtksurfaceviewer.tcl
r4757 r4765 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 -
trunk/gui/scripts/vtkviewer.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 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 -
trunk/gui/scripts/vtkvolumeviewer.tcl
r4764 r4765 63 63 public method updateTransferFunctions {} 64 64 65 private method AddNewMarker { x y } 65 66 private method BuildVolumeComponents {} 66 67 private method ComputeAlphamap { cname } … … 69 70 private method GetDatasetsWithComponent { cname } 70 71 private method HideAllMarkers {} 71 private method AddNewMarker { x y }72 72 private method InitComponentSettings { cname } 73 73 private method ParseLevelsOption { cname levels } 74 74 private method ParseMarkersOption { cname markers } 75 private method RemoveMarker { x y } 75 76 private method ResetColormap { cname color } 76 77 private method SendTransferFunctions {} 77 78 private method SetInitialTransferFunction { dataobj cname } 78 private method SetOrientation { side }79 79 private method SwitchComponent { cname } 80 private method RemoveMarker { x y }81 private method ViewToQuaternion {} {82 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)]83 }84 private method QuaternionToView { q } {85 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break86 }87 80 88 81 private variable _alphamap … … 98 91 private variable _transferFunctionEditors 99 92 100 protected method Connect {}101 protected method CurrentDatasets {args}102 protected method Disconnect {}103 protected method DoResize {}104 protected method DoRotate {}105 protected method AdjustSetting {what {value ""}}106 protected method InitSettings { args }107 protected method Pan {option x y}108 protected method Pick {x y}109 protected method Rebuild {}110 protected method ReceiveDataset { args }111 protected method ReceiveImage { args }112 protected method ReceiveLegend { colormap title vmin vmax size }113 protected method Rotate {option x y}114 protected method Zoom {option}115 116 93 # The following methods are only used by this class. 117 94 private method AdjustSetting {what {value ""}} 118 95 private method BuildAxisTab {} 119 96 private method BuildCameraTab {} … … 125 102 private method DrawLegendOld {} 126 103 private method Combo { option } 104 private method Connect {} 105 private method CurrentDatasets {args} 106 private method Disconnect {} 107 private method DoResize {} 108 private method DoRotate {} 127 109 private method EnterLegend { x y } 128 110 private method EventuallyResize { w h } … … 132 114 private method GetImage { args } 133 115 private method GetVtkData { args } 116 private method InitSettings { args } 134 117 private method IsValidObject { dataobj } 135 118 private method LeaveLegend {} 136 private method MotionLegend { x y } 119 private method MotionLegend { x y } 120 private method Pan {option x y} 137 121 private method PanCamera {} 122 private method Pick {x y} 123 private method QuaternionToView { q } { 124 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 125 } 126 private method Rebuild {} 127 private method ReceiveDataset { args } 128 private method ReceiveImage { args } 129 private method ReceiveLegend { colormap title vmin vmax size } 138 130 private method RequestLegend {} 131 private method Rotate {option x y} 139 132 private method SetLegendTip { x y } 140 133 private method SetObjectStyle { dataobj comp } 134 private method SetOrientation { side } 141 135 private method Slice {option args} 136 private method ViewToQuaternion {} { 137 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 138 } 139 private method Zoom {option} 142 140 143 141 private variable _arcball "" … … 234 232 # Initialize the view to some default parameters. 235 233 array set _view { 234 -ortho 0 236 235 -qw 0.853553 237 236 -qx -0.353553 238 237 -qy 0.353553 239 238 -qz 0.146447 240 -zoom 1.0241 239 -xpan 0 242 240 -ypan 0 243 - ortho 0241 -zoom 1.0 244 242 } 245 243 set _arcball [blt::arcball create 100 100] … … 414 412 bind $itk_component(view) <ButtonRelease-1> \ 415 413 [itcl::code $this Rotate release %x %y] 416 bind $itk_component(view) <Configure> \417 [itcl::code $this EventuallyResize %w %h]418 414 419 415 # Bindings for panning via mouse … … 1057 1053 lappend info "dataset_size" $length 1058 1054 lappend info "dataset_tag" $tag 1059 SendCmd [list "clientinfo" $info]1060 } 1061 append _outbuf "dataset add $tag data follows $length\n"1055 SendCmd "clientinfo [list $info]" 1056 } 1057 SendCmd "dataset add $tag data follows $length" 1062 1058 append _outbuf $bytes 1063 1059 set _datasets($tag) 1 … … 1209 1205 -qy 0.353553 1210 1206 -qz 0.146447 1207 -xpan 0 1208 -ypan 0 1211 1209 -zoom 1.0 1212 -xpan 01213 -ypan 01214 1210 } 1215 1211 if { $_first != "" } { … … 1231 1227 SendCmd "camera pan $x $y" 1232 1228 } 1233 1234 1229 1235 1230 # ----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.