Changeset 3592
- Timestamp:
- Mar 27, 2013, 2:01:06 PM (12 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field3dresult.tcl
r3330 r3592 56 56 } 57 57 array set flags $args 58 switch -- $flags(-mode) { 58 set servers "" 59 switch -- $flags(-mode) { 59 60 "auto" - "nanovis" - "flowvis" { 60 61 set servers [Rappture::VisViewer::GetServerList "nanovis"] … … 65 66 "vtk" { 66 67 # Old vtk contour widget 67 set servers ""68 68 } 69 69 default { -
trunk/gui/scripts/flowvisviewer.tcl
r3555 r3592 860 860 set result [VisViewer::Connect $_hosts] 861 861 if { $result } { 862 if { $_reportClientInfo } { 863 # Tell the server the viewer, hub, user and session. 864 # Do this immediately on connect before buffing any commands 865 global env 866 867 set info {} 868 set user "???" 869 if { [info exists env(USER)] } { 870 set user $env(USER) 871 } 872 set session "???" 873 if { [info exists env(SESSION)] } { 874 set session $env(SESSION) 875 } 876 lappend info "hub" [exec hostname] 877 lappend info "client" "flowvisviewer" 878 lappend info "user" $user 879 lappend info "session" $session 880 SendCmd "clientinfo [list $info]" 881 } 882 862 883 set w [winfo width $itk_component(3dview)] 863 884 set h [winfo height $itk_component(3dview)] … … 1185 1206 1186 1207 set _first "" 1187 1188 if { $_reset } {1189 if { $_reportClientInfo } {1190 # Tell the server the name of the tool, the version, and1191 # dataset that we are rendering. Have to do it here because1192 # we don't know what data objects are using the renderer until1193 # be get here.1194 global env1195 1196 set info {}1197 set user "???"1198 if { [info exists env(USER)] } {1199 set user $env(USER)1200 }1201 set session "???"1202 if { [info exists env(SESSION)] } {1203 set session $env(SESSION)1204 }1205 lappend info "hub" [exec hostname]1206 lappend info "client" "flowvisviewer"1207 lappend info "user" $user1208 lappend info "session" $session1209 SendCmd "clientinfo [list $info]"1210 }1211 }1212 1208 foreach dataobj [get] { 1213 1209 foreach comp [$dataobj components] { -
trunk/gui/scripts/molvisviewer.tcl
r3454 r3592 683 683 set result [VisViewer::Connect $hosts] 684 684 if { $result } { 685 $_dispatcher event -idle !rebuild686 }687 return $result688 }689 690 #691 # Disconnect --692 #693 # Clients use this method to disconnect from the current rendering694 # server.695 #696 itcl::body Rappture::MolvisViewer::Disconnect {} {697 VisViewer::Disconnect698 699 # disconnected -- no more data sitting on server700 catch { after cancel $_rocker(afterid) }701 catch { after cancel $_mevent(afterid) }702 array unset _dataobjs703 array unset _model704 array unset _mlist705 array unset _imagecache706 707 set _state(server) 1708 set _state(client) 1709 global readyForNextFrame710 set readyForNextFrame 1711 set _reset 1712 }713 714 itcl::body Rappture::MolvisViewer::ServerCmd { cmd } {715 debug "in ServerCmd ($cmd)\n"716 717 if { $_state(server) != $_state(client) } {718 SendCmd "frame -defer $_state(client)"719 set _state(server) $_state(client)720 }721 if { $_rocker(server) != $_rocker(client) } {722 SendCmd "rock -defer $_rocker(client)"723 set _rocker(server) $_rocker(client)724 }725 SendCmd "$cmd"726 }727 728 #729 # ReceiveImage -bytes <size>730 #731 # Invoked automatically whenever the "image" command comes in from732 # the rendering server. Indicates that binary image data with the733 # specified <size> will follow.734 #735 set count 0736 itcl::body Rappture::MolvisViewer::ReceiveImage { size cacheid frame rock } {737 global readyForNextFrame738 set readyForNextFrame 1739 set tag "$frame,$rock"740 global count741 incr count742 if { $cacheid != $_cacheid } {743 array unset _imagecache744 set _cacheid $cacheid745 }746 #debug "reading $size bytes from proxy\n"747 set data [ReceiveBytes $size]748 #debug "success: reading $size bytes from proxy\n"749 if { [string match "print*" $cacheid] } {750 # $frame is the token that we sent to the proxy.751 set _hardcopy($this-$cacheid) $data752 puts stderr "setting _hardcopy($this-$cacheid)"753 } else {754 set _imagecache($tag) $data755 #debug "CACHED: $tag,$cacheid"756 $_image(plot) configure -data $data757 set _image(id) $tag758 }759 }760 761 itcl::body Rappture::MolvisViewer::BuildSettingsTab {} {762 set fg [option get $itk_component(hull) font Font]763 764 set inner [$itk_component(main) insert end \765 -title "Settings" \766 -icon [Rappture::icon wrench]]767 $inner configure -borderwidth 4768 769 label $inner.pict -image $_settings($this-modelimg)770 771 label $inner.rep_l -text "Molecule Representation" \772 -font "Arial 9"773 774 itk_component add representation {775 Rappture::Combobox $inner.rep -width 20 -editable no776 }777 $inner.rep choices insert end \778 "ballnstick" "ball and stick" \779 "spheres" "spheres" \780 "sticks" "sticks" \781 "lines" "lines" \782 "cartoon" "cartoon"783 784 bind $inner.rep <<Value>> [itcl::code $this Representation]785 $inner.rep value "ball and stick"786 787 scale $inner.spherescale -width 10 -font "Arial 9" \788 -from 0.1 -to 2.0 -resolution 0.05 -label "Sphere Scale" \789 -showvalue true -orient horizontal \790 -command [itcl::code $this EventuallyChangeSettings] \791 -variable Rappture::MolvisViewer::_settings($this-spherescale)792 $inner.spherescale set $_settings($this-spherescale)793 Rappture::Tooltip::for $inner.spherescale \794 "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."795 796 scale $inner.stickradius -width 10 -font "Arial 9" \797 -from 0.1 -to 1.0 -resolution 0.025 -label "Stick Radius" \798 -showvalue true -orient horizontal \799 -command [itcl::code $this EventuallyChangeSettings] \800 -variable Rappture::MolvisViewer::_settings($this-stickradius)801 Rappture::Tooltip::for $inner.stickradius \802 "Adjust scale of bonds (sticks)."803 $inner.stickradius set $_settings($this-stickradius)804 805 checkbutton $inner.labels -text "Show labels on atoms" \806 -command [itcl::code $this labels update] \807 -variable [itcl::scope _settings($this-showlabels)] \808 -font "Arial 9"809 Rappture::Tooltip::for $inner.labels \810 "Display atom symbol and serial number."811 812 checkbutton $inner.rock -text "Rock model back and forth" \813 -command [itcl::code $this Rock toggle] \814 -variable Rappture::MolvisViewer::_settings($this-rock) \815 -font "Arial 9"816 Rappture::Tooltip::for $inner.rock \817 "Rotate the object back and forth around the y-axis."818 819 checkbutton $inner.ortho -text "Orthoscopic projection" \820 -command [itcl::code $this OrthoProjection update] \821 -variable Rappture::MolvisViewer::_settings($this-ortho) \822 -font "Arial 9"823 Rappture::Tooltip::for $inner.ortho \824 "Toggle between orthoscopic/perspective projection modes."825 826 checkbutton $inner.cartoontrace -text "Cartoon Trace" \827 -command [itcl::code $this CartoonTrace update] \828 -variable [itcl::scope _settings($this-cartoontrace)] \829 -font "Arial 9"830 Rappture::Tooltip::for $inner.cartoontrace \831 "Set cartoon representation of bonds (sticks)."832 833 checkbutton $inner.cell -text "Parallelepiped" \834 -command [itcl::code $this Cell toggle] \835 -font "Arial 9"836 $inner.cell select837 838 label $inner.spacer839 blt::table $inner \840 0,0 $inner.labels -anchor w -pady {1 0} \841 1,0 $inner.rock -anchor w -pady {1 0} \842 2,0 $inner.ortho -anchor w -pady {1 0} \843 3,0 $inner.cartoontrace -anchor w -pady {1 0} \844 4,0 $inner.cell -anchor w -pady {1 0} \845 5,0 $inner.rep_l -anchor w -pady { 2 0 } \846 6,0 $inner.rep -anchor w \847 7,0 $inner.spherescale -fill x -pady {3 0} \848 8,0 $inner.stickradius -fill x -pady {1 0} \849 850 blt::table configure $inner r* -resize none851 blt::table configure $inner r10 -resize expand852 }853 854 # ----------------------------------------------------------------------855 # USAGE: Rebuild856 #857 # Called automatically whenever something changes that affects the858 # data in the widget. Clears any existing data and rebuilds the859 # widget to display new data.860 # ----------------------------------------------------------------------861 itcl::body Rappture::MolvisViewer::Rebuild {} {862 debug "in rebuild"863 set changed 0864 865 # Turn on buffering of commands to the server. We don't want to866 # be preempted by a server disconnect/reconnect (that automatically867 # generates a new call to Rebuild).868 StartBufferingCommands869 set _cell 0870 871 if { $_reset } {872 set _rocker(server) 0873 set _cacheid 0874 875 685 if { $_reportClientInfo } { 876 # Tell the server the name of the tool, the version, and dataset 877 # that we are rendering. Have to do it here because we don't know 878 # what data objects are using the renderer until be get here. 686 # Tell the server the viewer, hub, user and session. 687 # Do this immediately on connect before buffing any commands 879 688 global env 880 689 … … 894 703 ServerCmd "clientinfo [list $info]" 895 704 } 705 706 $_dispatcher event -idle !rebuild 707 } 708 return $result 709 } 710 711 # 712 # Disconnect -- 713 # 714 # Clients use this method to disconnect from the current rendering 715 # server. 716 # 717 itcl::body Rappture::MolvisViewer::Disconnect {} { 718 VisViewer::Disconnect 719 720 # disconnected -- no more data sitting on server 721 catch { after cancel $_rocker(afterid) } 722 catch { after cancel $_mevent(afterid) } 723 array unset _dataobjs 724 array unset _model 725 array unset _mlist 726 array unset _imagecache 727 728 set _state(server) 1 729 set _state(client) 1 730 global readyForNextFrame 731 set readyForNextFrame 1 732 set _reset 1 733 } 734 735 itcl::body Rappture::MolvisViewer::ServerCmd { cmd } { 736 debug "in ServerCmd ($cmd)\n" 737 738 if { $_state(server) != $_state(client) } { 739 SendCmd "frame -defer $_state(client)" 740 set _state(server) $_state(client) 741 } 742 if { $_rocker(server) != $_rocker(client) } { 743 SendCmd "rock -defer $_rocker(client)" 744 set _rocker(server) $_rocker(client) 745 } 746 SendCmd "$cmd" 747 } 748 749 # 750 # ReceiveImage -bytes <size> 751 # 752 # Invoked automatically whenever the "image" command comes in from 753 # the rendering server. Indicates that binary image data with the 754 # specified <size> will follow. 755 # 756 set count 0 757 itcl::body Rappture::MolvisViewer::ReceiveImage { size cacheid frame rock } { 758 global readyForNextFrame 759 set readyForNextFrame 1 760 set tag "$frame,$rock" 761 global count 762 incr count 763 if { $cacheid != $_cacheid } { 764 array unset _imagecache 765 set _cacheid $cacheid 766 } 767 #debug "reading $size bytes from proxy\n" 768 set data [ReceiveBytes $size] 769 #debug "success: reading $size bytes from proxy\n" 770 if { [string match "print*" $cacheid] } { 771 # $frame is the token that we sent to the proxy. 772 set _hardcopy($this-$cacheid) $data 773 puts stderr "setting _hardcopy($this-$cacheid)" 774 } else { 775 set _imagecache($tag) $data 776 #debug "CACHED: $tag,$cacheid" 777 $_image(plot) configure -data $data 778 set _image(id) $tag 779 } 780 } 781 782 itcl::body Rappture::MolvisViewer::BuildSettingsTab {} { 783 set fg [option get $itk_component(hull) font Font] 784 785 set inner [$itk_component(main) insert end \ 786 -title "Settings" \ 787 -icon [Rappture::icon wrench]] 788 $inner configure -borderwidth 4 789 790 label $inner.pict -image $_settings($this-modelimg) 791 792 label $inner.rep_l -text "Molecule Representation" \ 793 -font "Arial 9" 794 795 itk_component add representation { 796 Rappture::Combobox $inner.rep -width 20 -editable no 797 } 798 $inner.rep choices insert end \ 799 "ballnstick" "ball and stick" \ 800 "spheres" "spheres" \ 801 "sticks" "sticks" \ 802 "lines" "lines" \ 803 "cartoon" "cartoon" 804 805 bind $inner.rep <<Value>> [itcl::code $this Representation] 806 $inner.rep value "ball and stick" 807 808 scale $inner.spherescale -width 10 -font "Arial 9" \ 809 -from 0.1 -to 2.0 -resolution 0.05 -label "Sphere Scale" \ 810 -showvalue true -orient horizontal \ 811 -command [itcl::code $this EventuallyChangeSettings] \ 812 -variable Rappture::MolvisViewer::_settings($this-spherescale) 813 $inner.spherescale set $_settings($this-spherescale) 814 Rappture::Tooltip::for $inner.spherescale \ 815 "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius." 816 817 scale $inner.stickradius -width 10 -font "Arial 9" \ 818 -from 0.1 -to 1.0 -resolution 0.025 -label "Stick Radius" \ 819 -showvalue true -orient horizontal \ 820 -command [itcl::code $this EventuallyChangeSettings] \ 821 -variable Rappture::MolvisViewer::_settings($this-stickradius) 822 Rappture::Tooltip::for $inner.stickradius \ 823 "Adjust scale of bonds (sticks)." 824 $inner.stickradius set $_settings($this-stickradius) 825 826 checkbutton $inner.labels -text "Show labels on atoms" \ 827 -command [itcl::code $this labels update] \ 828 -variable [itcl::scope _settings($this-showlabels)] \ 829 -font "Arial 9" 830 Rappture::Tooltip::for $inner.labels \ 831 "Display atom symbol and serial number." 832 833 checkbutton $inner.rock -text "Rock model back and forth" \ 834 -command [itcl::code $this Rock toggle] \ 835 -variable Rappture::MolvisViewer::_settings($this-rock) \ 836 -font "Arial 9" 837 Rappture::Tooltip::for $inner.rock \ 838 "Rotate the object back and forth around the y-axis." 839 840 checkbutton $inner.ortho -text "Orthoscopic projection" \ 841 -command [itcl::code $this OrthoProjection update] \ 842 -variable Rappture::MolvisViewer::_settings($this-ortho) \ 843 -font "Arial 9" 844 Rappture::Tooltip::for $inner.ortho \ 845 "Toggle between orthoscopic/perspective projection modes." 846 847 checkbutton $inner.cartoontrace -text "Cartoon Trace" \ 848 -command [itcl::code $this CartoonTrace update] \ 849 -variable [itcl::scope _settings($this-cartoontrace)] \ 850 -font "Arial 9" 851 Rappture::Tooltip::for $inner.cartoontrace \ 852 "Set cartoon representation of bonds (sticks)." 853 854 checkbutton $inner.cell -text "Parallelepiped" \ 855 -command [itcl::code $this Cell toggle] \ 856 -font "Arial 9" 857 $inner.cell select 858 859 label $inner.spacer 860 blt::table $inner \ 861 0,0 $inner.labels -anchor w -pady {1 0} \ 862 1,0 $inner.rock -anchor w -pady {1 0} \ 863 2,0 $inner.ortho -anchor w -pady {1 0} \ 864 3,0 $inner.cartoontrace -anchor w -pady {1 0} \ 865 4,0 $inner.cell -anchor w -pady {1 0} \ 866 5,0 $inner.rep_l -anchor w -pady { 2 0 } \ 867 6,0 $inner.rep -anchor w \ 868 7,0 $inner.spherescale -fill x -pady {3 0} \ 869 8,0 $inner.stickradius -fill x -pady {1 0} \ 870 871 blt::table configure $inner r* -resize none 872 blt::table configure $inner r10 -resize expand 873 } 874 875 # ---------------------------------------------------------------------- 876 # USAGE: Rebuild 877 # 878 # Called automatically whenever something changes that affects the 879 # data in the widget. Clears any existing data and rebuilds the 880 # widget to display new data. 881 # ---------------------------------------------------------------------- 882 itcl::body Rappture::MolvisViewer::Rebuild {} { 883 debug "in rebuild" 884 set changed 0 885 886 # Turn on buffering of commands to the server. We don't want to 887 # be preempted by a server disconnect/reconnect (that automatically 888 # generates a new call to Rebuild). 889 StartBufferingCommands 890 set _cell 0 891 892 if { $_reset } { 893 set _rocker(server) 0 894 set _cacheid 0 895 896 896 ServerCmd "raw -defer {set auto_color,0}" 897 897 ServerCmd "raw -defer {set auto_show_lines,0}" -
trunk/gui/scripts/nanovisviewer.tcl
r3571 r3592 606 606 set result [VisViewer::Connect $_hosts] 607 607 if { $result } { 608 if { $_reportClientInfo } { 609 # Tell the server the viewer, hub, user and session. 610 # Do this immediately on connect before buffing any commands 611 global env 612 613 set info {} 614 set user "???" 615 if { [info exists env(USER)] } { 616 set user $env(USER) 617 } 618 set session "???" 619 if { [info exists env(SESSION)] } { 620 set session $env(SESSION) 621 } 622 lappend info "hub" [exec hostname] 623 lappend info "client" "nanovisviewer" 624 lappend info "user" $user 625 lappend info "session" $session 626 SendCmd "clientinfo [list $info]" 627 } 628 608 629 set w [winfo width $itk_component(3dview)] 609 630 set h [winfo height $itk_component(3dview)] … … 868 889 $_arcball resize $w $h 869 890 DoResize 870 }871 if { $_reset } {872 if { $_reportClientInfo } {873 # Tell the server the name of the tool, the version, and874 # dataset that we are rendering. Have to do it here because875 # we don't know what data objects are using the renderer until876 # be get here.877 global env878 879 set info {}880 set user "???"881 if { [info exists env(USER)] } {882 set user $env(USER)883 }884 set session "???"885 if { [info exists env(SESSION)] } {886 set session $env(SESSION)887 }888 lappend info "hub" [exec hostname]889 lappend info "client" "nanovisviewer"890 lappend info "user" $user891 lappend info "session" $session892 SendCmd "clientinfo [list $info]"893 }894 891 } 895 892 foreach dataobj [get] { -
trunk/gui/scripts/vtkheightmapviewer.tcl
r3587 r3592 725 725 set result [VisViewer::Connect $_hosts] 726 726 if { $result } { 727 if { $_reportClientInfo } { 728 # Tell the server the viewer, hub, user and session. 729 # Do this immediately on connect before buffing any commands 730 global env 731 732 set info {} 733 set user "???" 734 if { [info exists env(USER)] } { 735 set user $env(USER) 736 } 737 set session "???" 738 if { [info exists env(SESSION)] } { 739 set session $env(SESSION) 740 } 741 lappend info "hub" [exec hostname] 742 lappend info "client" "vtkheightmapviewer" 743 lappend info "user" $user 744 lappend info "session" $session 745 SendCmd "clientinfo [list $info]" 746 } 747 727 748 set w [winfo width $itk_component(view)] 728 749 set h [winfo height $itk_component(view)] … … 864 885 $_dispatcher event -idle !rebuild 865 886 return 866 }867 868 if { $_reset && $_reportClientInfo } {869 # Tell the server the name of the tool, the version, and dataset870 # that we are rendering. Have to do it here because we don't know871 # what data objects are using the renderer until be get here.872 global env873 874 set info {}875 set user "???"876 if { [info exists env(USER)] } {877 set user $env(USER)878 }879 set session "???"880 if { [info exists env(SESSION)] } {881 set session $env(SESSION)882 }883 lappend info "hub" [exec hostname]884 lappend info "client" "vtkheightmapviewer"885 lappend info "user" $user886 lappend info "session" $session887 SendCmd "clientinfo [list $info]"888 887 } 889 888 -
trunk/gui/scripts/vtkisosurfaceviewer.tcl
r3571 r3592 777 777 set result [VisViewer::Connect $_hosts] 778 778 if { $result } { 779 if { $_reportClientInfo } { 780 # Tell the server the viewer, hub, user and session. 781 # Do this immediately on connect before buffing any commands 782 global env 783 784 set info {} 785 set user "???" 786 if { [info exists env(USER)] } { 787 set user $env(USER) 788 } 789 set session "???" 790 if { [info exists env(SESSION)] } { 791 set session $env(SESSION) 792 } 793 lappend info "hub" [exec hostname] 794 lappend info "client" "vtkisosurfaceviewer" 795 lappend info "user" $user 796 lappend info "session" $session 797 SendCmd "clientinfo [list $info]" 798 } 799 779 800 set w [winfo width $itk_component(view)] 780 801 set h [winfo height $itk_component(view)] … … 927 948 928 949 if { $_reset } { 929 if { $_reportClientInfo } {930 # Tell the server the name of the tool, the version, and dataset931 # that we are rendering. Have to do it here because we don't know932 # what data objects are using the renderer until be get here.933 global env934 935 set info {}936 set user "???"937 if { [info exists env(USER)] } {938 set user $env(USER)939 }940 set session "???"941 if { [info exists env(SESSION)] } {942 set session $env(SESSION)943 }944 lappend info "hub" [exec hostname]945 lappend info "client" "vtkisosurfaceviewer"946 lappend info "user" $user947 lappend info "session" $session948 SendCmd "clientinfo [list $info]"949 }950 950 set _width $w 951 951 set _height $h -
trunk/gui/scripts/vtkstreamlinesviewer.tcl
r3571 r3592 802 802 set result [VisViewer::Connect $_hosts] 803 803 if { $result } { 804 if { $_reportClientInfo } { 805 # Tell the server the viewer, hub, user and session. 806 # Do this immediately on connect before buffing any commands 807 global env 808 809 set info {} 810 set user "???" 811 if { [info exists env(USER)] } { 812 set user $env(USER) 813 } 814 set session "???" 815 if { [info exists env(SESSION)] } { 816 set session $env(SESSION) 817 } 818 lappend info "hub" [exec hostname] 819 lappend info "client" "vtkstreamlinesviewer" 820 lappend info "user" $user 821 lappend info "session" $session 822 SendCmd "clientinfo [list $info]" 823 } 824 804 825 set w [winfo width $itk_component(view)] 805 826 set h [winfo height $itk_component(view)] … … 957 978 set _first "" 958 979 if { $_reset } { 959 if { $_reportClientInfo } {960 # Tell the server the name of the tool, the version, and dataset961 # that we are rendering. Have to do it here because we don't know962 # what data objects are using the renderer until be get here.963 global env964 965 set info {}966 set user "???"967 if { [info exists env(USER)] } {968 set user $env(USER)969 }970 set session "???"971 if { [info exists env(SESSION)] } {972 set session $env(SESSION)973 }974 lappend info "hub" [exec hostname]975 lappend info "client" "vtkstreamlinesviewer"976 lappend info "user" $user977 lappend info "session" $session978 SendCmd "clientinfo [list $info]"979 }980 980 set _width $w 981 981 set _height $h -
trunk/gui/scripts/vtkviewer.tcl
r3571 r3592 707 707 set result [VisViewer::Connect $_hosts] 708 708 if { $result } { 709 set w [winfo width $itk_component(view)]710 set h [winfo height $itk_component(view)]711 EventuallyResize $w $h712 }713 return $result714 }715 716 #717 # isconnected --718 #719 # Indicates if we are currently connected to the visualization server.720 #721 itcl::body Rappture::VtkViewer::isconnected {} {722 return [VisViewer::IsConnected]723 }724 725 #726 # disconnect --727 #728 itcl::body Rappture::VtkViewer::disconnect {} {729 Disconnect730 set _reset 1731 }732 733 #734 # Disconnect --735 #736 # Clients use this method to disconnect from the current rendering737 # server.738 #739 itcl::body Rappture::VtkViewer::Disconnect {} {740 VisViewer::Disconnect741 742 # disconnected -- no more data sitting on server743 array unset _datasets744 array unset _data745 array unset _colormaps746 }747 748 # ----------------------------------------------------------------------749 # USAGE: ReceiveImage -bytes <size> -type <type> -token <token>750 #751 # Invoked automatically whenever the "image" command comes in from752 # the rendering server. Indicates that binary image data with the753 # specified <size> will follow.754 # ----------------------------------------------------------------------755 itcl::body Rappture::VtkViewer::ReceiveImage { args } {756 array set info {757 -token "???"758 -bytes 0759 -type image760 }761 array set info $args762 set bytes [ReceiveBytes $info(-bytes)]763 if { $info(-type) == "image" } {764 if 0 {765 set f [open "last.ppm" "w"]766 puts $f $bytes767 close $f768 }769 $_image(plot) configure -data $bytes770 set time [clock seconds]771 set date [clock format $time]772 if { $_start > 0 } {773 set finish [clock clicks -milliseconds]774 set _start 0775 }776 } elseif { $info(type) == "print" } {777 set tag $this-print-$info(-token)778 set _hardcopy($tag) $bytes779 }780 }781 782 #783 # ReceiveDataset --784 #785 itcl::body Rappture::VtkViewer::ReceiveDataset { args } {786 if { ![isconnected] } {787 return788 }789 set option [lindex $args 0]790 switch -- $option {791 "scalar" {792 set option [lindex $args 1]793 switch -- $option {794 "world" {795 foreach { x y z value tag } [lrange $args 2 end] break796 }797 "pixel" {798 foreach { x y value tag } [lrange $args 2 end] break799 }800 }801 }802 "vector" {803 set option [lindex $args 1]804 switch -- $option {805 "world" {806 foreach { x y z vx vy vz tag } [lrange $args 2 end] break807 }808 "pixel" {809 foreach { x y vx vy vz tag } [lrange $args 2 end] break810 }811 }812 }813 "names" {814 foreach { name } [lindex $args 1] {815 #puts stderr "Dataset: $name"816 }817 }818 default {819 error "unknown dataset option \"$option\" from server"820 }821 }822 }823 824 # ----------------------------------------------------------------------825 # USAGE: Rebuild826 #827 # Called automatically whenever something changes that affects the828 # data in the widget. Clears any existing data and rebuilds the829 # widget to display new data.830 # ----------------------------------------------------------------------831 itcl::body Rappture::VtkViewer::Rebuild {} {832 833 set w [winfo width $itk_component(view)]834 set h [winfo height $itk_component(view)]835 if { $w < 2 || $h < 2 } {836 $_dispatcher event -idle !rebuild837 return838 }839 840 # Turn on buffering of commands to the server. We don't want to841 # be preempted by a server disconnect/reconnect (which automatically842 # generates a new call to Rebuild).843 StartBufferingCommands844 845 if { $_reset } {846 709 if { $_reportClientInfo } { 847 # Tell the server the name of the tool, the version, and dataset 848 # that we are rendering. Have to do it here because we don't know 849 # what data objects are using the renderer until be get here. 710 # Tell the server the viewer, hub, user and session. 711 # Do this immediately on connect before buffing any commands 850 712 global env 851 713 … … 866 728 } 867 729 730 set w [winfo width $itk_component(view)] 731 set h [winfo height $itk_component(view)] 732 EventuallyResize $w $h 733 } 734 return $result 735 } 736 737 # 738 # isconnected -- 739 # 740 # Indicates if we are currently connected to the visualization server. 741 # 742 itcl::body Rappture::VtkViewer::isconnected {} { 743 return [VisViewer::IsConnected] 744 } 745 746 # 747 # disconnect -- 748 # 749 itcl::body Rappture::VtkViewer::disconnect {} { 750 Disconnect 751 set _reset 1 752 } 753 754 # 755 # Disconnect -- 756 # 757 # Clients use this method to disconnect from the current rendering 758 # server. 759 # 760 itcl::body Rappture::VtkViewer::Disconnect {} { 761 VisViewer::Disconnect 762 763 # disconnected -- no more data sitting on server 764 array unset _datasets 765 array unset _data 766 array unset _colormaps 767 } 768 769 # ---------------------------------------------------------------------- 770 # USAGE: ReceiveImage -bytes <size> -type <type> -token <token> 771 # 772 # Invoked automatically whenever the "image" command comes in from 773 # the rendering server. Indicates that binary image data with the 774 # specified <size> will follow. 775 # ---------------------------------------------------------------------- 776 itcl::body Rappture::VtkViewer::ReceiveImage { args } { 777 array set info { 778 -token "???" 779 -bytes 0 780 -type image 781 } 782 array set info $args 783 set bytes [ReceiveBytes $info(-bytes)] 784 if { $info(-type) == "image" } { 785 if 0 { 786 set f [open "last.ppm" "w"] 787 puts $f $bytes 788 close $f 789 } 790 $_image(plot) configure -data $bytes 791 set time [clock seconds] 792 set date [clock format $time] 793 if { $_start > 0 } { 794 set finish [clock clicks -milliseconds] 795 set _start 0 796 } 797 } elseif { $info(type) == "print" } { 798 set tag $this-print-$info(-token) 799 set _hardcopy($tag) $bytes 800 } 801 } 802 803 # 804 # ReceiveDataset -- 805 # 806 itcl::body Rappture::VtkViewer::ReceiveDataset { args } { 807 if { ![isconnected] } { 808 return 809 } 810 set option [lindex $args 0] 811 switch -- $option { 812 "scalar" { 813 set option [lindex $args 1] 814 switch -- $option { 815 "world" { 816 foreach { x y z value tag } [lrange $args 2 end] break 817 } 818 "pixel" { 819 foreach { x y value tag } [lrange $args 2 end] break 820 } 821 } 822 } 823 "vector" { 824 set option [lindex $args 1] 825 switch -- $option { 826 "world" { 827 foreach { x y z vx vy vz tag } [lrange $args 2 end] break 828 } 829 "pixel" { 830 foreach { x y vx vy vz tag } [lrange $args 2 end] break 831 } 832 } 833 } 834 "names" { 835 foreach { name } [lindex $args 1] { 836 #puts stderr "Dataset: $name" 837 } 838 } 839 default { 840 error "unknown dataset option \"$option\" from server" 841 } 842 } 843 } 844 845 # ---------------------------------------------------------------------- 846 # USAGE: Rebuild 847 # 848 # Called automatically whenever something changes that affects the 849 # data in the widget. Clears any existing data and rebuilds the 850 # widget to display new data. 851 # ---------------------------------------------------------------------- 852 itcl::body Rappture::VtkViewer::Rebuild {} { 853 854 set w [winfo width $itk_component(view)] 855 set h [winfo height $itk_component(view)] 856 if { $w < 2 || $h < 2 } { 857 $_dispatcher event -idle !rebuild 858 return 859 } 860 861 # Turn on buffering of commands to the server. We don't want to 862 # be preempted by a server disconnect/reconnect (which automatically 863 # generates a new call to Rebuild). 864 StartBufferingCommands 865 866 if { $_reset } { 868 867 set _width $w 869 868 set _height $h -
trunk/gui/scripts/vtkvolumeviewer.tcl
r3571 r3592 773 773 set result [VisViewer::Connect $_hosts] 774 774 if { $result } { 775 if { $_reportClientInfo } { 776 # Tell the server the viewer, hub, user and session. 777 # Do this immediately on connect before buffing any commands 778 global env 779 780 set info {} 781 set user "???" 782 if { [info exists env(USER)] } { 783 set user $env(USER) 784 } 785 set session "???" 786 if { [info exists env(SESSION)] } { 787 set session $env(SESSION) 788 } 789 lappend info "hub" [exec hostname] 790 lappend info "client" "vtkvolumeviewer" 791 lappend info "user" $user 792 lappend info "session" $session 793 SendCmd "clientinfo [list $info]" 794 } 795 775 796 set w [winfo width $itk_component(view)] 776 797 set h [winfo height $itk_component(view)] … … 930 951 931 952 if { $_reset } { 932 if { $_reportClientInfo } {933 # Tell the server the name of the tool, the version, and dataset934 # that we are rendering. Have to do it here because we don't know935 # what data objects are using the renderer until be get here.936 global env937 938 set info {}939 set user "???"940 if { [info exists env(USER)] } {941 set user $env(USER)942 }943 set session "???"944 if { [info exists env(SESSION)] } {945 set session $env(SESSION)946 }947 lappend info "hub" [exec hostname]948 lappend info "client" "vtkvolumeviewer"949 lappend info "user" $user950 lappend info "session" $session951 SendCmd "clientinfo [list $info]"952 }953 954 953 set _width $w 955 954 set _height $h
Note: See TracChangeset
for help on using the changeset viewer.