Changeset 1220
- Timestamp:
- Nov 17, 2008 2:20:16 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/curve.tcl
r1013 r1220 268 268 set xydata [$_curve get $cname.xy] 269 269 if {"" != $xydata} { 270 set xv [blt::vector create x$_counter] 271 set yv [blt::vector create y$_counter] 272 273 foreach line [split $xydata \n] { 274 if {[scan $line {%g %g} xval yval] == 2} { 275 $xv append $xval 276 $yv append $yval 277 } 278 } 270 set xv [blt::vector create \#auto] 271 set yv [blt::vector create \#auto] 272 set tmp [blt::vector create \#auto] 273 $tmp set $xydata 274 $tmp split $xv $yv 275 blt::vector destroy $tmp 279 276 } 280 277 … … 322 319 return $_ymarkers; 323 320 } 321 -
trunk/gui/scripts/field.tcl
r1189 r1220 574 574 set xv [blt::vector create x$_counter] 575 575 set yv [blt::vector create y$_counter] 576 577 foreach line [split $xydata \n] { 578 if {[scan $line {%g %g} xval yval] == 2} { 579 $xv append $xval 580 $yv append $yval 581 } 582 } 576 set tmp [blt::vector create \#auto] 577 $tmp set $xydata 578 $tmp split $xv $yv 579 blt::vector destroy $tmp 583 580 } 584 581 } -
trunk/gui/scripts/heightmapviewer.tcl
r1215 r1220 738 738 } 739 739 740 # 740 # Reset the screen size. 741 set w [winfo width $itk_component(3dview)] 742 set h [winfo height $itk_component(3dview)] 743 _send "screen $w $h" 744 741 745 # Reset the camera and other view parameters 742 #743 _send "camera angle [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)]"746 set xyz [Euler2XYZ $_view(theta) $_view(phi) $_view(psi)] 747 _send "camera angle $xyz" 744 748 _send "camera zoom $_view(zoom)" 745 749 -
trunk/gui/scripts/molvisviewer.tcl
r1215 r1220 67 67 public method rock {option} 68 68 public method representation {option {model "all"} } 69 public method ResetView {} 69 70 70 71 protected method _send {args} … … 78 79 protected method _vmouse2 {option b m x y} 79 80 protected method _vmouse {option b m x y} 80 81 81 private method _receive_image { size cacheid frame rock } 82 82 … … 90 90 private variable _dobj2raise ;# maps dataobj => raise flag 0/1 91 91 private variable _dobj2ghost 92 93 private variable view_ 92 94 93 95 private variable _model … … 138 140 set _hostlist $hostlist 139 141 142 array set view_ { 143 zoom 0 144 mx 0 145 my 0 146 mz 0 147 x 0 148 y 0 149 z 0 150 } 151 140 152 array set _settings [subst { 141 153 $this-model $_mrepresentation … … 160 172 -borderwidth 1 -padx 1 -pady 1 \ 161 173 -bitmap [Rappture::icon reset] \ 162 -command [itcl::code $this _send "reset"]174 -command [itcl::code $this ResetView] 163 175 } { 164 176 usual … … 593 605 594 606 } 607 595 608 if { $changed } { 596 609 array unset _imagecache … … 608 621 _update 609 622 } 623 # Reset screen size 610 624 set w [winfo width $itk_component(3dview)] 611 625 set h [winfo height $itk_component(3dview)] 612 626 _send "screen $w $h" 627 # Reset viewing parameters 628 _send "reset" 629 _send "rotate $view_(mx) $view_(my) $view_(mz)" 630 _send "pan $view_(x) $view_(y)" 631 _send "zoom $view_(zoom)" 613 632 614 633 set _inrebuild 0 … … 645 664 if { [winfo ismapped $itk_component(3dview)] } { 646 665 _send "screen $w $h" 647 _send "reset -push" 666 # Why do a reset? 667 #_send "reset -push" 648 668 } else { 649 669 _send "screen -defer $w $h" 650 _send "reset -push" 670 # Why do a reset? 671 #_send "reset -push" 651 672 } 652 673 } … … 671 692 set dx [expr $x - $_mevent(x)] 672 693 set dy [expr $y - $_mevent(y)] 694 set view_(x) [expr $view_(x) + $dx] 695 set view_(y) [expr $view_(y) + $dy] 673 696 _send "pan $dx $dy" 674 697 } … … 691 714 switch -- $option { 692 715 "in" { 716 set view_(zoom) [expr $view_(zoom) + $factor] 693 717 _send "zoom $factor" 694 718 } 695 719 "out" { 720 set view_(zoom) [expr $view_(zoom) - $factor] 696 721 _send "zoom -$factor" 697 722 } 698 723 "reset" { 724 set view_(zoom) 0 699 725 _send "reset" 700 726 } … … 839 865 set mz $dx 840 866 } 867 # Accumlate movements 868 set view_(mx) [expr {$view_(mx) + $mx}] 869 set view_(my) [expr {$view_(my) + $my}] 870 set view_(mz) [expr {$view_(mz) + $mz}] 841 871 _send "rotate $mx $my $mz" 842 872 } … … 990 1020 } 991 1021 } 1022 } 1023 1024 # 1025 # ResetView 1026 # 1027 itcl::body Rappture::MolvisViewer::ResetView {} { 1028 array set view_ { 1029 mx 0 1030 my 0 1031 mz 0 1032 x 0 1033 y 0 1034 z 0 1035 zoom 0 1036 } 1037 _send "reset" 992 1038 } 993 1039 … … 1066 1112 } 1067 1113 } 1114 -
trunk/gui/scripts/nanovisviewer.tcl
r1215 r1220 1243 1243 # ---------------------------------------------------------------------- 1244 1244 itcl::body Rappture::NanovisViewer::_pan {option x y} { 1245 return 1246 # Experimental stuff 1245 1247 if { $option == "click" } { 1246 1248 $itk_component(3dview) configure -cursor hand1 -
trunk/gui/scripts/visviewer.tcl
r1160 r1220 22 22 itk_option define -receivecommand receiveCommand ReceiveCommand "" 23 23 24 private common _servers ;# array of visualization server lists 25 set _servers(nanovis) "" 26 set _servers(pymol) "" 24 private common servers_ ;# array of visualization server lists 25 set servers_(nanovis) "bilby.hubzero.org:2000" 26 set servers_(pymol) "bilby.hubzero.org:2020" 27 28 private variable sid_ "" ;# socket connection to server 29 private common done_ ;# Used to indicate status of send. 30 private variable buffer_ ;# buffer for incoming/outgoing commands 31 # Number of milliseconds to wait before idle timeout. 32 #private variable idleTimeout_ 3600000 33 #private variable idleTimeout_ 0 34 private variable idleTimeout_ 5000 27 35 28 36 protected variable _dispatcher "" ;# dispatcher for !events 29 37 protected variable _hosts "" ;# list of hosts for server 30 protected variable _sid "" ;# socket connection to server31 38 protected variable _parser "" ;# interpreter for incoming commands 32 39 protected variable _image 33 private common _done ;# Used to indicate status of send.34 private variable _buffer ;# buffer for incoming/outgoing commands35 40 36 41 constructor { hostlist args } { … … 46 51 private method _SendHelper {} 47 52 private method _SendHelper.old {} 53 private method _CheckConnection {} 48 54 49 55 protected method SendEcho { channel {data ""} } … … 65 71 } 66 72 public proc GetServerList { tag } { 67 return $ _servers($tag)73 return $servers_($tag) 68 74 } 69 75 public proc SetServerList { tag namelist } { 70 76 _CheckNameList $namelist 71 set _servers($tag) $namelist77 set servers_($tag) $namelist 72 78 } 73 79 public proc SetPymolServerList { namelist } { … … 87 93 $_dispatcher register !serverDown 88 94 $_dispatcher dispatch $this !serverDown "[itcl::code $this _ServerDown]; list" 95 $_dispatcher register !timeout 96 $_dispatcher dispatch $this !timeout "[itcl::code $this Disconnect]; list" 89 97 90 98 _CheckNameList $hostlist 91 99 set _hostlist $hostlist 92 set _buffer(in) ""93 set _buffer(out) ""100 set buffer_(in) "" 101 set buffer_(out) "" 94 102 # 95 103 # Create a parser to handle incoming requests … … 139 147 # 140 148 itcl::body Rappture::VisViewer::destructor {} { 149 $_dispatcher cancel !timeout 141 150 interp delete $_parser 142 array unset _done$this151 array unset done_ $this 143 152 } 144 153 … … 202 211 while {1} { 203 212 SendEcho <<line "connecting to $hostname:$port..." 204 if { [catch {socket $hostname $port} _sid] != 0 } {213 if { [catch {socket $hostname $port} sid_] != 0 } { 205 214 if {[llength $servers] == 0} { 206 215 blt::busy release $itk_component(hull) … … 212 221 continue 213 222 } 214 fconfigure $ _sid-translation binary -encoding binary223 fconfigure $sid_ -translation binary -encoding binary 215 224 216 225 # send memory requirement to the load balancer 217 puts -nonewline $ _sid[binary format I $memorySize]218 flush $ _sid226 puts -nonewline $sid_ [binary format I $memorySize] 227 flush $sid_ 219 228 220 229 # read back a reconnection order 221 set data [read $ _sid4]230 set data [read $sid_ 4] 222 231 if {[binary scan $data cccc b1 b2 b3 b4] != 4} { 223 232 blt::busy release $itk_component(hull) … … 234 243 # release the busy window over the hull. 235 244 $_dispatcher cancel !serverDown 245 if { $idleTimeout_ > 0 } { 246 $_dispatcher event -after $idleTimeout_ !timeout 247 } 236 248 blt::busy release $itk_component(hull) 237 fconfigure $ _sid-buffering line238 fileevent $ _sidreadable [itcl::code $this _ReceiveHelper]249 fconfigure $sid_ -buffering line 250 fileevent $sid_ readable [itcl::code $this _ReceiveHelper] 239 251 return 1 240 252 } … … 254 266 # 255 267 itcl::body Rappture::VisViewer::Disconnect {} { 268 $_dispatcher cancel !timeout 256 269 if { [IsConnected] } { 257 catch {close $_sid} err 258 set _sid "" 259 $_dispatcher event -after 750 !serverDown 260 } 261 set _buffer(in) "" 270 catch {close $sid_} err 271 set sid_ "" 272 } 273 set buffer_(in) "" 262 274 } 263 275 … … 268 280 # 269 281 itcl::body Rappture::VisViewer::IsConnected {} { 270 return [expr {"" != $ _sid}]271 } 272 273 # 274 # _SendHelper--282 return [expr {"" != $sid_}] 283 } 284 285 # 286 # CheckConection -- 275 287 # 276 288 # Helper routine called from a file event to send data when the 277 289 # connection is writable (i.e. not blocked). Sets a magic 278 # variable _done($this) when we're done. 290 # variable done_($this) when we're done. 291 # 292 itcl::body Rappture::VisViewer::_CheckConnection {} { 293 if { [IsConnected] } { 294 if { [eof $sid_] } { 295 error "unexpected eof on socket" 296 } 297 $_dispatcher cancel !timeout 298 if { $idleTimeout_ > 0 } { 299 $_dispatcher event -after $idleTimeout_ !timeout 300 } 301 return 1 302 } 303 # If we aren't connected, assume it's because the connection to the 304 # visualization server broke. Try to open a connection and trigger a 305 # rebuild. 306 $_dispatcher cancel !serverDown 307 set x [expr {[winfo rootx $itk_component(area)]+10}] 308 set y [expr {[winfo rooty $itk_component(area)]+10}] 309 Rappture::Tooltip::cue @$x,$y "Connecting..." 310 set code [catch { Connect } ok] 311 if { $code == 0 && $ok} { 312 $_dispatcher event -idle !rebuild 313 Rappture::Tooltip::cue hide 314 return 1 315 } else { 316 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." 317 return 0 318 } 319 } 320 321 # 322 # Flush -- 323 # 324 # Flushes the socket. 325 # 326 itcl::body Rappture::VisViewer::Flush {} { 327 if { [_CheckConnection] } { 328 flush $sid_ 329 } 330 } 331 332 333 # 334 # _SendHelper -- 335 # 336 # Helper routine called from a file event to send data when the 337 # connection is writable (i.e. not blocked). Sets a magic 338 # variable done_($this) when we're done. 279 339 # 280 340 itcl::body Rappture::VisViewer::_SendHelper {} { 281 puts $_sid $_buffer(out) 282 flush $_sid 283 set _done($this) 1; # Success 341 if { ![_CheckConnection] } { 342 return 0 343 } 344 puts $sid_ $buffer_(out) 345 flush $sid_ 346 set done_($this) 1; # Success 284 347 } 285 348 … … 289 352 # Helper routine called from a file event to send data when the 290 353 # connection is writable (i.e. not blocked). Sends data in chunks 291 # of 8k (or less). Sets magic variable _done($this) to indicate354 # of 8k (or less). Sets magic variable done_($this) to indicate 292 355 # that we're either finished (success) or could not send bytes to 293 356 # the server (failure). 294 357 # 295 358 itcl::body Rappture::VisViewer::_SendHelper.old {} { 296 set bytesLeft [string length $_buffer(out)] 359 if { ![_CheckConnection] } { 360 return 0 361 } 362 set bytesLeft [string length $buffer_(out)] 297 363 if { $bytesLeft > 0} { 298 set chunk [string range $ _buffer(out) 0 8095]299 set _buffer(out) [string range $_buffer(out) 8096 end]364 set chunk [string range $buffer_(out) 0 8095] 365 set buffer_(out) [string range $buffer_(out) 8096 end] 300 366 incr bytesLeft -8096 301 367 set code [catch { 302 368 if { $bytesLeft > 0 } { 303 puts -nonewline $ _sid$chunk369 puts -nonewline $sid_ $chunk 304 370 } else { 305 puts $ _sid$chunk371 puts $sid_ $chunk 306 372 } 307 373 } err] 308 374 if { $code != 0 } { 309 puts stderr "error sending data to $ _sid: $err"375 puts stderr "error sending data to $sid_: $err" 310 376 Disconnect 311 set _done($this) 0; # Failure377 set done_($this) 0; # Failure 312 378 } 313 379 } else { 314 set _done($this) 1; # Success380 set done_($this) 1; # Success 315 381 } 316 382 } … … 324 390 SendEcho >>line $bytes 325 391 326 if { ![IsConnected]} { 327 # If we aren't connected, assume it's because the connection to the 328 # visualization server broke. Try to open a connection and trigger a 329 # rebuild. 330 $_dispatcher cancel !serverDown 331 set x [expr {[winfo rootx $itk_component(area)]+10}] 332 set y [expr {[winfo rooty $itk_component(area)]+10}] 333 Rappture::Tooltip::cue @$x,$y "Connecting..." 334 set code [catch { Connect } ok] 335 if { $code == 0 && $ok} { 336 $_dispatcher event -idle !rebuild 337 Rappture::Tooltip::cue hide 338 return 1 339 } else { 340 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." 341 return 0 342 } 392 if { ![_CheckConnection] } { 393 return 0 343 394 } 344 395 # Even though the data is sent in only 1 "puts", we need to verify that 345 396 # the server is ready first. Wait for the socket to become writable 346 397 # before sending anything. 347 set _done($this) 1348 set _buffer(out) $bytes349 fileevent $ _sidwritable [itcl::code $this _SendHelper]350 tkwait variable ::Rappture::VisViewer:: _done($this)351 fileevent $ _sidwritable ""352 flush $ _sid353 set _buffer(out) ""354 return $ _done($this)398 set done_($this) 1 399 set buffer_(out) $bytes 400 fileevent $sid_ writable [itcl::code $this _SendHelper] 401 tkwait variable ::Rappture::VisViewer::done_($this) 402 fileevent $sid_ writable "" 403 flush $sid_ 404 set buffer_(out) "" 405 return $done_($this) 355 406 } 356 407 … … 361 412 # 362 413 itcl::body Rappture::VisViewer::ReceiveBytes { size } { 363 if { [eof $_sid] } {364 error "unexpected eof on socket" 365 } 366 set bytes [read $ _sid$size]414 if { ![_CheckConnection] } { 415 return 0 416 } 417 set bytes [read $sid_ $size] 367 418 ReceiveEcho <<line "<read $size bytes" 368 419 return $bytes … … 389 440 # 390 441 itcl::body Rappture::VisViewer::_ReceiveHelper {} { 391 if { [IsConnected] } { 392 if { [eof $_sid] } { 393 error "_receive: unexpected eof on socket" 394 } 395 if { [gets $_sid line] < 0 } { 396 Disconnect 397 } 398 set line [string trim $line] 399 if { $line == "" } { 400 return 401 } 402 if { [string equal [string range $line 0 2] "nv>"] } { 403 ReceiveEcho <<line $line 404 append _buffer(in) [string range $line 3 end] 405 append _buffer(in) "\n" 406 if {[info complete $_buffer(in)]} { 407 set request $_buffer(in) 408 set _buffer(in) "" 409 $_parser eval $request 410 } 411 } else { 412 # this shows errors coming back from the engine 413 ReceiveEcho <<error $line 414 puts stderr "Render Server Error: $line" 415 } 416 } 417 } 418 419 420 # 421 # Flush -- 422 # 423 # Flushes the socket. 424 # 425 itcl::body Rappture::VisViewer::Flush {} { 426 if { [IsConnected] } { 427 flush $_sid 442 if { ![_CheckConnection] } { 443 return 0 444 } 445 if { [gets $sid_ line] < 0 } { 446 Disconnect 447 } 448 set line [string trim $line] 449 if { $line == "" } { 450 return 451 } 452 if { [string equal [string range $line 0 2] "nv>"] } { 453 ReceiveEcho <<line $line 454 append buffer_(in) [string range $line 3 end] 455 append buffer_(in) "\n" 456 if {[info complete $buffer_(in)]} { 457 set request $buffer_(in) 458 set buffer_(in) "" 459 $_parser eval $request 460 } 461 } else { 462 # this shows errors coming back from the engine 463 ReceiveEcho <<error $line 464 puts stderr "Render Server Error: $line" 428 465 } 429 466 }
Note: See TracChangeset
for help on using the changeset viewer.