Changeset 921 for trunk/gui/scripts/heightmapviewer.tcl
- Timestamp:
- Mar 5, 2008, 5:20:56 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/heightmapviewer.tcl
r919 r921 42 42 43 43 constructor { hostlist args } { 44 44 Rappture::VisViewer::constructor $hostlist 45 45 } { 46 46 # defined below 47 47 } 48 48 destructor { 49 49 # defined below 50 50 } 51 51 … … 57 57 public method download {option args} 58 58 public method parameters {title args} { 59 59 # do nothing 60 60 } 61 61 protected method Connect {} … … 92 92 93 93 private common _settings ;# Array used for checkbuttons and radiobuttons 94 94 95 95 } 96 96 … … 107 107 $_dispatcher register !legend 108 108 $_dispatcher dispatch $this !legend \ 109 109 "[itcl::code $this _fixSettings legend]; list" 110 110 # Send dataobjs event 111 111 $_dispatcher register !send_dataobjs 112 112 $_dispatcher dispatch $this !send_dataobjs \ 113 113 "[itcl::code $this _send_dataobjs]; list" 114 114 # Rebuild event 115 115 $_dispatcher register !rebuild … … 126 126 # Initialize the view to some default parameters. 127 127 array set _view { 128 theta45129 phi45130 psi0131 zoom1.0132 xfocus0133 yfocus0134 zfocus0128 theta 45 129 phi 45 130 psi 0 131 zoom 1.0 132 xfocus 0 133 yfocus 0 134 zfocus 0 135 135 } 136 136 set _obj2id(count) 0 … … 209 209 set ::Rappture::HeightmapViewer::_settings($this-grid) 1 210 210 ::checkbutton $inner.f.grid \ 211 212 213 211 -text "Show Grid" \ 212 -variable ::Rappture::HeightmapViewer::_settings($this-grid) \ 213 -command [itcl::code $this _fixSettings grid] 214 214 grid $inner.f.grid -row 0 -column 0 -sticky w 215 215 216 216 set ::Rappture::HeightmapViewer::_settings($this-axes) 1 217 217 ::checkbutton $inner.f.axes \ 218 219 220 218 -text "Show Axes" \ 219 -variable ::Rappture::HeightmapViewer::_settings($this-axes) \ 220 -command [itcl::code $this _fixSettings axes] 221 221 grid $inner.f.axes -row 1 -column 0 -sticky w 222 222 223 223 set ::Rappture::HeightmapViewer::_settings($this-contourlines) 1 224 224 ::checkbutton $inner.f.contour \ 225 226 227 225 -text "Show Contour Lines" \ 226 -variable ::Rappture::HeightmapViewer::_settings($this-contourlines) \ 227 -command [itcl::code $this _fixSettings contourlines] 228 228 grid $inner.f.contour -row 2 -column 0 -sticky w 229 229 … … 305 305 set _obj2ovride($dataobj-width) $params(-width) 306 306 set _obj2ovride($dataobj-raise) $params(-raise) 307 307 $_dispatcher event -idle !rebuild 308 308 } 309 309 } … … 329 329 foreach obj $dlist { 330 330 if { [info exists _obj2ovride($obj-raise)] && 331 331 $_obj2ovride($obj-raise)} { 332 332 set i [lsearch -exact $dlist $obj] 333 333 if {$i >= 0} { … … 387 387 # if anything changed, then rebuild the plot 388 388 if {$changed} { 389 389 $_dispatcher event -idle !rebuild 390 390 } 391 391 } … … 438 438 coming { 439 439 if {[catch { 440 441 440 blt::winop snap $itk_component(area) $_image(download) 441 }]} { 442 442 $_image(download) configure -width 1 -height 1 443 443 $_image(download) put #000000 … … 517 517 # _send 518 518 # 519 # 520 # 521 # 519 # Send commands off to the rendering server. If we're currently 520 # sending data objects to the server, buffer the commands to be 521 # sent later. 522 522 # 523 523 itcl::body Rappture::HeightmapViewer::_send {string} { 524 524 if {[llength $_sendobjs] > 0} { 525 525 append _outbuf $string "\n" 526 526 } else { 527 528 529 530 531 527 if {[SendBytes $string]} { 528 foreach line [split $string \n] { 529 SendEcho >>line $line 530 } 531 } 532 532 } 533 533 } … … 545 545 # Reset the overall limits 546 546 if { $_sendobjs != "" } { 547 548 547 set _limits(vmin) "" 548 set _limits(vmax) "" 549 549 } 550 550 foreach dataobj $_sendobjs { … … 553 553 set data [$dataobj blob $comp] 554 554 555 556 557 558 559 560 561 555 foreach { vmin vmax } [$dataobj limits v] break 556 if { $_limits(vmin) == "" || $vmin < $_limits(vmin) } { 557 set _limits(vmin) $vmin 558 } 559 if { $_limits(vmax) == "" || $vmax > $_limits(vmax) } { 560 set _limits(vmax) $vmax 561 } 562 562 563 563 # tell the engine to expect some data … … 566 566 return 567 567 } 568 569 570 571 568 if { ![SendBytes $data] } { 569 return 570 } 571 set id $_obj2id(count) 572 572 incr _obj2id(count) 573 573 set _id2obj($id) [list $dataobj $comp] 574 574 set _obj2id($dataobj-$comp) $id 575 575 set _receiveids($id) 1 576 576 577 577 # … … 738 738 } 739 739 "reset" { 740 741 theta45742 phi45743 psi0744 zoom1.0745 746 740 array set _view { 741 theta 45 742 phi 45 743 psi 0 744 zoom 1.0 745 } 746 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 747 747 _send "camera angle $xyz" 748 748 } … … 763 763 click { 764 764 $itk_component(3dview) configure -cursor fleur 765 set _click(x) 766 set _click(y) 767 set _click(theta) 768 set _click(phi) 765 set _click(x) $x 766 set _click(y) $y 767 set _click(theta) $_view(theta) 768 set _click(phi) $_view(phi) 769 769 } 770 770 drag { … … 809 809 } 810 810 811 set _view(theta) 812 set _view(phi) 813 set _view(psi) 814 811 set _view(theta) $theta 812 set _view(phi) $phi 813 set _view(psi) $psi 814 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 815 815 _send "camera angle $xyz" 816 816 set _click(x) $x … … 852 852 itcl::body Rappture::HeightmapViewer::_fixSettings { what {value ""} } { 853 853 switch -- $what { 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 854 "legend" { 855 set lineht [font metrics $itk_option(-font) -linespace] 856 set w [expr {[winfo width $itk_component(legend)]-20}] 857 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 858 set imap "" 859 860 set dataobj [lindex [get] 0] 861 if {"" != $dataobj} { 862 set comp [lindex [$dataobj components] 0] 863 if {[info exists _obj2id($dataobj-$comp)]} { 864 set imap $_obj2id($dataobj-$comp) 865 } 866 } 867 if {$w > 0 && $h > 0 && "" != $imap} { 868 _send "heightmap legend $imap $w $h" 869 } else { 870 $itk_component(legend) delete all 871 } 872 } 873 "grid" { 874 if { [isconnected] } { 875 _send "grid visible $_settings($this-grid)" 876 } 877 } 878 "axes" { 879 if { [isconnected] } { 880 _send "axis visible $_settings($this-axes)" 881 } 882 } 883 "contourlines" { 884 if {[isconnected]} { 885 set dataobj [lindex [get] 0] 886 if {"" != $dataobj} { 887 set comp [lindex [$dataobj components] 0] 888 if {[info exists _obj2id($dataobj-$comp)]} { 889 set i $_obj2id($dataobj-$comp) 890 set bool $_settings($this-contourlines) 891 _send "heightmap linecontour visible $bool $i" 892 } 893 } 894 } 895 } 896 896 default { 897 897 error "don't know how to fix $what: should be grid, axes, contourlines, or legend" … … 974 974 itcl::configbody Rappture::HeightmapViewer::plotoutline { 975 975 if {[isconnected]} { 976 977 } 978 } 976 _send "grid linecolor [Color2RGB $itk_option(-plotoutline)]" 977 } 978 }
Note: See TracChangeset
for help on using the changeset viewer.