Changeset 456
- Timestamp:
- Jun 2, 2006, 9:40:16 PM (18 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/contourresult.tcl
r413 r456 571 571 # 572 572 set mesh [$dataobj mesh $comp] 573 if {"" == $mesh} { 574 set x [expr {[winfo rootx $itk_component(area)]+10}] 575 set y [expr {[winfo rooty $itk_component(area)]+10}] 576 Rappture::Tooltip::cue @$x,$y "This data requires the visualization server, and that appears to be down. Please try your simulation again later." 577 return 578 } 573 579 switch -- [$mesh GetClassName] { 574 580 vtkPoints { -
trunk/gui/scripts/nanovisviewer.tcl
r450 r456 51 51 protected method _receive {} 52 52 protected method _receive_image {option size} 53 protected method _receive_legend {ivol vmin vmax size} 53 54 54 55 protected method _rebuild {} … … 60 61 protected method _state {comp} 61 62 protected method _fixSettings {what {value ""}} 63 protected method _fixLegend {} 62 64 protected method _color2rgb {color} 63 65 protected method _euler2xyz {theta phi psi} 66 67 private variable _dispatcher "" ;# dispatcher for !events 64 68 65 69 private variable _nvhost "" ;# host name for nanovis server … … 68 72 private variable _parser "" ;# interpreter for incoming commands 69 73 private variable _buffer ;# buffer for incoming/outgoing commands 70 private variable _image "";# image displayed in plotting area74 private variable _image ;# image displayed in plotting area 71 75 72 76 private variable _dlist "" ;# list of data objects 73 77 private variable _dims "" ;# dimensionality of data objects 74 78 private variable _obj2style ;# maps dataobj => style settings 79 private variable _obj2ovride ;# maps dataobj => style override 75 80 private variable _obj2id ;# maps dataobj => volume ID in server 76 81 private variable _sendobjs "" ;# list of data objs to send to server … … 90 95 # ---------------------------------------------------------------------- 91 96 itcl::body Rappture::NanovisViewer::constructor {nvhost nvport args} { 92 puts "nanovisviewer $nvhost $nvport = $this" 97 Rappture::dispatcher _dispatcher 98 $_dispatcher register !legend 99 $_dispatcher dispatch $this !legend "[itcl::code $this _fixLegend]; list" 100 93 101 set _buffer(in) "" 94 102 set _buffer(out) "" … … 102 110 } 103 111 $_parser alias image [itcl::code $this _receive_image] 112 $_parser alias legend [itcl::code $this _receive_legend] 104 113 105 114 # … … 355 364 # RENDERING AREA 356 365 # 357 set _image [image create photo] 366 set _image(legend) [image create photo] 367 itk_component add legend { 368 canvas $itk_interior.legend -height 50 -highlightthickness 0 369 } { 370 usual 371 ignore -highlightthickness 372 rename -background -plotbackground plotBackground Background 373 } 374 pack $itk_component(legend) -side bottom -fill x 375 bind $itk_component(legend) <Configure> \ 376 [list $_dispatcher event -idle !legend] 377 378 set _image(plot) [image create photo] 358 379 itk_component add area { 359 label $itk_interior.area -image $_image 380 label $itk_interior.area -image $_image(plot) -highlightthickness 0 381 } { 382 usual 383 ignore -highlightthickness 360 384 } 361 385 pack $itk_component(area) -expand yes -fill both … … 383 407 after cancel [itcl::code $this _send_dataobjs] 384 408 after cancel [itcl::code $this _rebuild] 385 image delete $_image 409 image delete $_image(plot) 410 image delete $_image(legend) 386 411 interp delete $_parser 387 412 } … … 416 441 if {$pos < 0} { 417 442 lappend _dlist $dataobj 418 set _obj2 style($dataobj-color) $params(-color)419 set _obj2 style($dataobj-width) $params(-width)420 set _obj2 style($dataobj-raise) $params(-raise)443 set _obj2ovride($dataobj-color) $params(-color) 444 set _obj2ovride($dataobj-width) $params(-width) 445 set _obj2ovride($dataobj-raise) $params(-raise) 421 446 422 447 after cancel [itcl::code $this _rebuild] … … 435 460 set dlist $_dlist 436 461 foreach obj $dlist { 437 if {[info exists _obj2 style($obj-raise)] && $_obj2style($obj-raise)} {462 if {[info exists _obj2ovride($obj-raise)] && $_obj2ovride($obj-raise)} { 438 463 set i [lsearch -exact $dlist $obj] 439 464 if {$i >= 0} { … … 463 488 if {$pos >= 0} { 464 489 set _dlist [lreplace $_dlist $pos $pos] 465 foreach key [array names _obj2 style $dataobj-*] {466 unset _obj2 style($key)490 foreach key [array names _obj2ovride $dataobj-*] { 491 unset _obj2ovride($key) 467 492 } 468 493 set changed 1 … … 530 555 # 531 556 set tmpfile /tmp/image[pid].jpg 532 $_image write $tmpfile -format jpeg557 $_image(plot) write $tmpfile -format jpeg 533 558 set fid [open $tmpfile r] 534 559 fconfigure $fid -encoding binary -translation binary … … 553 578 # ---------------------------------------------------------------------- 554 579 itcl::body Rappture::NanovisViewer::connect {{host ""} {port ""}} { 555 puts " connecting... $host $port"556 580 disconnect 557 581 … … 572 596 # 573 597 while {1} { 574 puts "connecting to $_nvhost:$_nvport"575 598 if {[catch {socket $_nvhost $_nvport} sid]} { 576 599 return 0 … … 593 616 [expr {$b4 & 0xff}]] 594 617 595 puts " got back $addr"596 618 if {[string equal $addr "0.0.0.0"]} { 597 619 fconfigure $sid -buffering line 598 620 fileevent $sid readable [itcl::code $this _receive] 599 621 set _sid $sid 622 tk_messageBox -message "Continue?" 600 623 return 1 601 624 } … … 668 691 append _buffer(out) $args "\n" 669 692 } else { 670 puts "send: $args" 693 set fid [open /tmp/debug a] 694 puts $fid "send: $args" 695 close $fid 671 696 puts $_sid $args 672 697 } … … 696 721 return 697 722 } 723 set fid [open /tmp/debug a] 724 puts $fid $cmdstr 725 puts $fid $data 726 close $fid 698 727 699 728 while {[string length $data] > 0} { … … 716 745 set _obj2id($dataobj-$comp) $_obj2id(count) 717 746 incr _obj2id(count) 747 748 # 749 # Determine the transfer function needed for this volume 750 # and make sure that it's defined on the server. 751 # 752 catch {unset style} 753 array set style { 754 -color rainbow 755 -levels 6 756 -opacity 0.5 757 } 758 array set style [lindex [$dataobj components -style $comp] 0] 759 set sname "$style(-color):$style(-levels):$style(-opacity)" 760 761 if {$style(-color) == "rainbow"} { 762 set style(-color) "white:yellow:green:cyan:blue:magenta" 763 } 764 set clist [split $style(-color) :] 765 set cmap "0.0 [_color2rgb white] " 766 for {set i 0} {$i < [llength $clist]} {incr i} { 767 set xval [expr {double($i+1)/([llength $clist]+1)}] 768 set color [lindex $clist $i] 769 append cmap "$xval [_color2rgb $color] " 770 } 771 append cmap "1.0 [_color2rgb $color]" 772 773 set max $style(-opacity) 774 set levels $style(-levels) 775 set wmap "0.0 0.0 " 776 set delta [expr {0.125/($levels+1)}] 777 for {set i 1} {$i <= $levels} {incr i} { 778 # add spikes in the middle 779 set xval [expr {double($i)/($levels+1)}] 780 append wmap "[expr {$xval-$delta-0.01}] 0.0 [expr {$xval-$delta}] $max [expr {$xval+$delta}] $max [expr {$xval+$delta+0.01}] 0.0 " 781 } 782 append wmap "1.0 0.0 " 783 784 set cmdstr [list transfunc define $sname $cmap $wmap] 785 puts "send: $cmdstr" 786 set fid [open /tmp/debug a] 787 puts $fid $cmdstr 788 close $fid 789 if {[catch {puts $_sid $cmdstr} err]} { 790 disconnect 791 set x [expr {[winfo rootx $itk_component(area)]+10}] 792 set y [expr {[winfo rooty $itk_component(area)]+10}] 793 Rappture::Tooltip::cue @$x,$y "Lost connection to visualization server" 794 puts "oops: $err" 795 return 796 } 797 798 set _obj2style($dataobj-$comp) $sname 718 799 } 719 800 } … … 725 806 set state [string match $first-* $key] 726 807 _send volume state $state $_obj2id($key) 808 if {[info exists _obj2style($key)]} { 809 _send volume shading transfunc $_obj2style($key) $_obj2id($key) 810 } 727 811 } 728 812 … … 735 819 736 820 # if there are any commands in the buffer, send them now that we're done 821 set fid [open /tmp/debug a] 822 puts $fid $_buffer(out) 823 close $fid 737 824 if {[catch {puts $_sid $_buffer(out)} err]} { 738 825 disconnect … … 742 829 } 743 830 set _buffer(out) "" 831 832 $_dispatcher event -idle !legend 744 833 } 745 834 … … 779 868 if {"" != $_sid} { 780 869 set bytes [read $_sid $size] 781 $_image configure -data $bytes870 $_image(plot) configure -data $bytes 782 871 puts "--IMAGE" 872 } 873 } 874 875 # ---------------------------------------------------------------------- 876 # USAGE: _receive_legend <volume> <vmin> <vmax> <size> 877 # 878 # Invoked automatically whenever the "legend" command comes in from 879 # the rendering server. Indicates that binary image data with the 880 # specified <size> will follow. 881 # ---------------------------------------------------------------------- 882 itcl::body Rappture::NanovisViewer::_receive_legend {ivol vmin vmax size} { 883 if {"" != $_sid} { 884 set bytes [read $_sid $size] 885 $_image(legend) configure -data $bytes 886 puts "--LEGEND $vmin - $vmax" 887 888 set c $itk_component(legend) 889 set w [winfo width $c] 890 set h [winfo height $c] 891 if {"" == [$c find withtag transfunc]} { 892 $c create image [expr {$w/2}] [expr {$h/2}] -anchor c \ 893 -image $_image(legend) -tags transfunc 894 } else { 895 $c coords transfunc [expr {$w/2}] [expr {$h/2}] 896 } 783 897 } 784 898 } … … 821 935 set state [string match $first-* $key] 822 936 _send volume state $state $_obj2id($key) 937 if {[info exists _obj2style($key)]} { 938 _send volume shading transfunc $_obj2style($key) $_obj2id($key) 939 } 823 940 } 824 941 … … 829 946 } 830 947 eval _send volume data state [_state volume] [_currentVolumeIds] 948 $_dispatcher event -idle !legend 831 949 } 832 950 … … 862 980 set first [lindex [get] 0] 863 981 foreach key [array names _obj2id *-*] { 864 set state [string match $first-* $key] 865 lappend rlist $_obj2id($key) 982 if {[string match $first-* $key]} { 983 lappend rlist $_obj2id($key) 984 } 866 985 } 867 986 return $rlist … … 893 1012 eval _send camera angle [_euler2xyz $_view(theta) $_view(phi) $_view(psi)] 894 1013 _send camera zoom $_view(zoom) 895 896 _send transfunc define default { 0 0 0 1 0.5 1 1 0 0 0.8 }897 1014 } 898 1015 } … … 1117 1234 1118 1235 # ---------------------------------------------------------------------- 1236 # USAGE: _fixLegend 1237 # 1238 # Used internally to update the legend area whenever it changes size 1239 # or when the field changes. Asks the server to send a new legend 1240 # for the current field. 1241 # ---------------------------------------------------------------------- 1242 itcl::body Rappture::NanovisViewer::_fixLegend {} { 1243 set w [expr {[winfo width $itk_component(legend)]-20}] 1244 set h [expr {[winfo height $itk_component(legend)]-20}] 1245 set ivol "" 1246 1247 set dataobj [lindex [get] 0] 1248 set comp [lindex [$dataobj components] 0] 1249 if {[info exists _obj2id($dataobj-$comp)]} { 1250 set ivol $_obj2id($dataobj-$comp) 1251 } 1252 puts "fixLegend $w $h $ivol in [get]" 1253 1254 if {$w > 0 && $h > 0 && "" != $ivol} { 1255 _send legend $ivol $w $h 1256 } else { 1257 $itk_component(legend) delete all 1258 } 1259 } 1260 1261 # ---------------------------------------------------------------------- 1119 1262 # USAGE: _color2rgb <color> 1120 1263 # -
trunk/gui/scripts/radiodial.tcl
r428 r456 375 375 if {"" != $itk_option(-dialprogresscolor) 376 376 && [llength $_values] > 0 && "" != $_current} { 377 set frac [expr {double($_current-$min)/($max-$min)}] 377 if {$max != $min} { 378 set frac [expr {double($_current-$min)/($max-$min)}] 379 } else { 380 set frac 0. 381 } 378 382 set xx1 [expr {$frac*($x1-$x0) + $x0}] 379 383 $c create rectangle [expr {$x0+1}] [expr {$y0+3}] $xx1 [expr {$y1-2}] \ -
trunk/gui/scripts/sequence.tcl
r435 r456 118 118 foreach val [lsort $how [array names _dataobjs]] { 119 119 lappend _indices [list $val $n] 120 incr n 120 121 } 121 122 } else { -
trunk/gui/scripts/sequenceresult.tcl
r435 r456 414 414 pack $viewer -expand yes -fill both 415 415 } 416 ::Rappture::Field { 417 Rappture::Field3DResult $viewer 418 pack $viewer -expand yes -fill both 419 } 416 420 default { 417 421 error "don't know how to view sequences of $type"
Note: See TracChangeset
for help on using the changeset viewer.