- Timestamp:
- Mar 6, 2009 8:41:16 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/heightmapviewer.tcl
r1250 r1294 1 2 1 # ---------------------------------------------------------------------- 3 2 # COMPONENT: heightmapviewer - 3D volume rendering … … 42 41 itk_option define -plotoutline plotOutline PlotOutline "" 43 42 44 constructor { hostlist args } { 45 Rappture::VisViewer::constructor $hostlist 46 } { 47 # defined below 48 } 49 destructor { 50 # defined below 43 constructor { hostlist args } { 44 Rappture::VisViewer::constructor $hostlist 45 } { 46 # defined below 47 } 48 destructor { 49 # defined below 51 50 } 52 51 53 52 public proc SetServerList { namelist } { 54 53 Rappture::VisViewer::SetServerList "nanovis" $namelist 55 54 } 56 55 public method add {dataobj {settings ""}} … … 59 58 public method scale {args} 60 59 public method download {option args} 61 public method parameters {title args} { 62 # do nothing 60 public method parameters {title args} { 61 # do nothing 63 62 } 64 63 protected method Connect {} … … 95 94 96 95 private common settings_ ;# Array used for checkbuttons and radiobuttons 97 96 98 97 } 99 98 … … 133 132 psi 0 134 133 zoom 1.0 135 dx 136 dy 134 dx 0 135 dy 0 137 136 } 138 137 set obj2id_(count) 0 … … 203 202 Rappture::Balloon $itk_component(controls).panel -title "Settings" 204 203 set inner [$itk_component(controls).panel component inner] 205 204 206 205 frame $inner.f 207 206 pack $inner.f -side top -fill x 208 207 grid columnconfigure $inner.f 1 -weight 1 209 208 set fg [option get $itk_component(hull) font Font] 210 209 211 210 set ::Rappture::HeightmapViewer::settings_($this-grid) 1 212 211 ::checkbutton $inner.f.grid \ … … 233 232 ::checkbutton $inner.f.wireframe \ 234 233 -text "Wireframe" \ 235 234 -onvalue "wireframe" -offvalue "fill" \ 236 235 -variable ::Rappture::HeightmapViewer::settings_($this-wireframe) \ 237 236 -command [itcl::code $this _fixSettings wireframe] … … 289 288 # Bindings for zoom via keyboard 290 289 bind $itk_component(3dview) <KeyPress-Prior> \ 291 290 [itcl::code $this _zoom out] 292 291 bind $itk_component(3dview) <KeyPress-Next> \ 293 292 [itcl::code $this _zoom in] 294 293 295 294 bind $itk_component(3dview) <Enter> "focus $itk_component(3dview)" 296 295 297 296 if {[string equal "x11" [tk windowingsystem]]} { 298 299 300 297 # Bindings for zoom via mouse 298 bind $itk_component(3dview) <4> [itcl::code $this _zoom out] 299 bind $itk_component(3dview) <5> [itcl::code $this _zoom in] 301 300 } 302 301 … … 601 600 # tell the engine to expect some data 602 601 set nbytes [string length $data] 603 602 if { ![SendBytes "heightmap data follows $nbytes"] } { 604 603 return 605 604 … … 787 786 psi 0 788 787 zoom 1.0 789 dx0790 dy0788 dx 0 789 dy 0 791 790 } 792 791 set xyz [Euler2XYZ $view_(theta) $view_(phi) $view_(psi)] … … 801 800 # USAGE: $this _pan click x y 802 801 # $this _pan drag x y 803 # 802 # $this _pan release x y 804 803 # 805 804 # Called automatically when the user clicks on one of the zoom … … 811 810 set h [winfo height $itk_component(3dview)] 812 811 if { $option == "set" } { 813 814 815 816 812 set x [expr $x / double($w)] 813 set y [expr $y / double($h)] 814 set view_(dx) [expr $view_(dx) + $x] 815 set view_(dy) [expr $view_(dy) + $y] 817 816 _send "camera pan $view_(dx) $view_(dy)" 818 819 } 820 if { $option == "click" } { 821 822 817 return 818 } 819 if { $option == "click" } { 820 set click_(x) $x 821 set click_(y) $y 823 822 $itk_component(3dview) configure -cursor hand1 824 823 } 825 824 if { $option == "drag" || $option == "release" } { 826 827 828 829 830 831 832 825 set dx [expr ($click_(x) - $x)/double($w)] 826 set dy [expr ($click_(y) - $y)/double($h)] 827 set click_(x) $x 828 set click_(y) $y 829 set view_(dx) [expr $view_(dx) - $dx] 830 set view_(dy) [expr $view_(dy) - $dy] 831 _send "camera pan $view_(dx) $view_(dy)" 833 832 } 834 833 if { $option == "release" } { … … 849 848 click { 850 849 $itk_component(3dview) configure -cursor fleur 851 852 853 854 855 856 850 array set click_ [subst { 851 x $x 852 y $y 853 theta $view_(theta) 854 phi $view_(phi) 855 }] 857 856 } 858 857 drag { … … 945 944 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 946 945 set imap "" 947 946 948 947 set dataobj [lindex [get] 0] 949 948 if {"" != $dataobj} { … … 1032 1031 # add spikes in the middle 1033 1032 set xval [expr {double($i)/($levels+1)}] 1034 1035 1036 1037 1033 lappend wmap [expr {$xval-$delta-0.01}] 0.0 1034 lappend wmap [expr {$xval-$delta}] $opacity 1035 lappend wmap [expr {$xval+$delta}] $opacity 1036 lappend wmap [expr {$xval+$delta+0.01}] 0.0 1038 1037 } 1039 1038 lappend wmap 1.0 0.0 … … 1042 1041 set delta 0.05 1043 1042 foreach xval [split $levels ,] { 1044 lappend wmap [expr {$xval-$delta}] 0.0 1045 1046 1043 lappend wmap [expr {$xval-$delta}] 0.0 1044 lappend $xval $opacity 1045 lappend [expr {$xval+$delta}] 0.0 1047 1046 } 1048 1047 lappend wmap 1.0 0.0 -
trunk/gui/scripts/visviewer.tcl
r1277 r1294 35 35 private variable idleTimeout_ 43200000; # 12 hours 36 36 #private variable idleTimeout_ 5000; # 5 seconds 37 #private variable idleTimeout_ 0; 37 #private variable idleTimeout_ 0; # No timeout 38 38 39 39 protected variable _dispatcher "" ;# dispatcher for !events … … 133 133 # 134 134 itk_component add drawer { 135 136 137 -handlesize 1 -sashwidth 2135 panedwindow $itk_interior.drawer \ 136 -orient horizontal -opaqueresize 1 -handlepad 0 \ 137 -handlesize 1 -sashwidth 2 138 138 } 139 139 pack $itk_component(drawer) -expand yes -fill both … … 207 207 # Connect -- 208 208 # 209 # Connect to the visualization server (e.g. nanovis, pymolproxy). 210 # Creates an event callback that is triggered when we are idle 211 # (no I/O with the server) for some specified time. Sends the server 212 # some estimate of the size of our job [soon to be deprecated]. 213 # If it's too busy, that server may forward us to another [this 209 # Connect to the visualization server (e.g. nanovis, pymolproxy). 210 # Creates an event callback that is triggered when we are idle 211 # (no I/O with the server) for some specified time. Sends the server 212 # some estimate of the size of our job [soon to be deprecated]. 213 # If it's too busy, that server may forward us to another [this 214 214 # was been turned off in nanoscale]. 215 215 # … … 260 260 # release the busy window over the hull. 261 261 $_dispatcher cancel !serverDown 262 263 264 262 if { $idleTimeout_ > 0 } { 263 $_dispatcher event -after $idleTimeout_ !timeout 264 } 265 265 blt::busy release $itk_component(hull) 266 266 fconfigure $sid_ -buffering line … … 308 308 itcl::body Rappture::VisViewer::_CheckConnection {} { 309 309 if { [IsConnected] } { 310 311 312 313 314 315 316 317 310 if { [eof $sid_] } { 311 error "unexpected eof on socket" 312 } 313 $_dispatcher cancel !timeout 314 if { $idleTimeout_ > 0 } { 315 $_dispatcher event -after $idleTimeout_ !timeout 316 } 317 return 1 318 318 } 319 319 # If we aren't connected, assume it's because the connection to the … … 326 326 set code [catch { Connect } ok] 327 327 if { $code == 0 && $ok} { 328 329 Rappture::Tooltip::cue hide 330 328 $_dispatcher event -idle !rebuild 329 Rappture::Tooltip::cue hide 330 return 1 331 331 } else { 332 333 332 Rappture::Tooltip::cue @$x,$y "Can't connect to visualization server. This may be a network problem. Wait a few moments and try resetting the view." 333 return 0 334 334 } 335 335 } … … 356 356 itcl::body Rappture::VisViewer::_SendHelper {} { 357 357 if { ![_CheckConnection] } { 358 358 return 0 359 359 } 360 360 puts $sid_ $buffer_(out) … … 374 374 itcl::body Rappture::VisViewer::_SendHelper.old {} { 375 375 if { ![_CheckConnection] } { 376 376 return 0 377 377 } 378 378 set bytesLeft [string length $buffer_(out)] … … 407 407 408 408 if { ![_CheckConnection] } { 409 409 return 0 410 410 } 411 411 # Even though the data is sent in only 1 "puts", we need to verify that … … 429 429 itcl::body Rappture::VisViewer::ReceiveBytes { size } { 430 430 if { ![_CheckConnection] } { 431 431 return 0 432 432 } 433 433 set bytes [read $sid_ $size] … … 457 457 itcl::body Rappture::VisViewer::_ReceiveHelper {} { 458 458 if { ![_CheckConnection] } { 459 459 return 0 460 460 } 461 461 set n [gets $sid_ line] 462 462 463 463 if { $n < 0 } { 464 465 464 Disconnect 465 return 0 466 466 } 467 467 set line [string trim $line] 468 468 if { $line == "" } { 469 469 return 470 470 } 471 471 if { [string compare -length 3 $line "nv>"] == 0 } { 472 473 474 475 476 477 478 479 472 ReceiveEcho <<line $line 473 append buffer_(in) [string range $line 3 end] 474 append buffer_(in) "\n" 475 if {[info complete $buffer_(in)]} { 476 set request $buffer_(in) 477 set buffer_(in) "" 478 $_parser eval $request 479 } 480 480 } elseif { [string compare -length 20 $line "NanoVis Server Error:"] == 0} { 481 482 483 481 # this shows errors coming back from the engine 482 ReceiveEcho <<error $line 483 puts stderr "Render Server Error: $line\n" 484 484 } else { 485 486 487 485 # this shows errors coming back from the engine 486 ReceiveEcho <<error $line 487 puts stderr "Garbled message: $line\n" 488 488 } 489 489 }
Note: See TracChangeset
for help on using the changeset viewer.