Changeset 3339 for trunk/gui/scripts/nanovisviewer.tcl
- Timestamp:
- Feb 25, 2013 6:38:40 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/nanovisviewer.tcl
r3330 r3339 86 86 87 87 protected method Connect {} 88 protected method Current Volumes {{what -all}}88 protected method CurrentDatasets {{what -all}} 89 89 protected method Disconnect {} 90 90 protected method DoResize {} … … 125 125 private variable _allDataObjs 126 126 private variable _obj2ovride ;# maps dataobj => style override 127 private variable _server Vols ;# contains all the dataobj-component127 private variable _serverDatasets ;# contains all the dataobj-component 128 128 ;# to volumes in the server 129 129 private variable _serverTfs ;# contains all the transfer functions 130 130 ;# in the server. 131 private variable _recvd Vols ;# list of data objs to send to server131 private variable _recvdDatasets ;# list of data objs to send to server 132 132 private variable _vol2style ;# maps dataobj-component to transfunc 133 private variable _style2 vols ;# maps tf back to list of133 private variable _style2datasets ;# maps tf back to list of 134 134 # dataobj-components using the tf. 135 135 … … 139 139 private variable _view ;# view params for 3D view 140 140 private variable _isomarkers ;# array of isosurface level values 0..1 141 private common_settings141 private variable _settings 142 142 # Array of transfer functions in server. If 0 the transfer has been 143 143 # defined but not loaded. If 1 the transfer function has been named … … 628 628 # disconnected -- no more data sitting on server 629 629 set _outbuf "" 630 array unset _server Vols630 array unset _serverDatasets 631 631 } 632 632 … … 672 672 set thickness [expr {double($_settings($this-thickness)) * 0.0001}] 673 673 674 foreach vol [CurrentVolumes] {675 if { ![info exists _server Vols($vol)] || !$_serverVols($vol) } {674 foreach tag [CurrentDatasets] { 675 if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } { 676 676 # The volume hasn't reached the server yet. How did we get 677 677 # here? 678 678 continue 679 679 } 680 if { ![info exists _vol2style($ vol)] } {681 puts stderr "unknown volume $ vol"680 if { ![info exists _vol2style($tag)] } { 681 puts stderr "unknown volume $tag" 682 682 continue; # How does this happen? 683 683 } 684 set tf $_vol2style($ vol)684 set tf $_vol2style($tag) 685 685 set _settings($this-$tf-opacity) $opacity 686 686 set _settings($this-$tf-thickness) $thickness … … 693 693 set _activeTfs($tf) 1 694 694 } 695 SendCmd "volume shading transfunc $tf $ vol"695 SendCmd "volume shading transfunc $tf $tag" 696 696 } 697 697 FixLegend … … 776 776 777 777 # The colormap may have changed. Resync the slicers with the colormap. 778 set vols [CurrentVolumes -cutplanes]779 SendCmd "volume data state $_settings($this-volume) $ vols"778 set datasets [CurrentDatasets -cutplanes] 779 SendCmd "volume data state $_settings($this-volume) $datasets" 780 780 781 781 # Adjust the cutplane for only the first component in the topmost volume 782 782 # (i.e. the first volume designated in the field). 783 set vol [lindex $vols 0]783 set tag [lindex $datasets 0] 784 784 foreach axis {x y z} { 785 785 # Turn off cutplanes for all volumes … … 787 787 if { $_settings($this-${axis}cutplane) } { 788 788 # Turn on cutplane for this particular volume and set the position 789 SendCmd "cutplane state 1 $axis $ vol"789 SendCmd "cutplane state 1 $axis $tag" 790 790 set pos [expr {0.01*$_settings($this-${axis}cutposition)}] 791 SendCmd "cutplane position $pos $axis $ vol"791 SendCmd "cutplane position $pos $axis $tag" 792 792 } 793 793 } … … 803 803 # doesn't parse 3D data formats, we rely on the server (nanovis) to 804 804 # tell us what the limits are. Once we've received the limits to all 805 # the data we've sent (tracked by _recvd Vols) we can then determine805 # the data we've sent (tracked by _recvdDatasets) we can then determine 806 806 # what the transfer functions are for these volumes. 807 807 # … … 829 829 # 830 830 set dataobj [lindex $parts 0] 831 set _server Vols($tag) 1831 set _serverDatasets($tag) 1 832 832 if { $_settings($this-volume) && $dataobj == $_first } { 833 833 SendCmd "volume state 1 $tag" … … 838 838 set _limits(vmax) $info(vmax); # Overall maximum value. 839 839 840 unset _recvd Vols($tag)841 if { [array size _recvd Vols] == 0 } {840 unset _recvdDatasets($tag) 841 if { [array size _recvdDatasets] == 0 } { 842 842 # The active transfer function is by default the first component of 843 843 # the first data object. This assumes that the data is always … … 875 875 876 876 foreach dataobj [get] { 877 foreach c omp[$dataobj components] {878 set vol $dataobj-$comp879 if { ![info exists _server Vols($vol)] } {877 foreach cname [$dataobj components] { 878 set tag $dataobj-$cname 879 if { ![info exists _serverDatasets($tag)] } { 880 880 # Send the data as one huge base64-encoded mess -- yuck! 881 set data [$dataobj values $c omp]881 set data [$dataobj values $cname] 882 882 set nbytes [string length $data] 883 append _outbuf "volume data follows $nbytes $ vol\n"883 append _outbuf "volume data follows $nbytes $tag\n" 884 884 append _outbuf $data 885 set _recvdVols($vol) 1 886 set _serverVols($vol) 0 887 } 888 NameTransferFunc $dataobj $comp 889 } 890 } 885 set _recvdDatasets($tag) 1 886 set _serverDatasets($tag) 0 887 } 888 NameTransferFunc $dataobj $cname 889 } 890 } 891 set _first [lindex [get] 0] 891 892 if { $_reset } { 892 893 # … … 912 913 FixSettings outline 913 914 914 # nothing to send -- activate the proper ivol 915 SendCmd "volume state 0" 916 set _first [lindex [get] 0] 915 foreach axis {x y z} { 916 # Turn off cutplanes for all volumes 917 SendCmd "cutplane state 0 $axis" 918 } 917 919 if {"" != $_first} { 918 920 set axis [$_first hints updir] … … 924 926 array set _view $location 925 927 } 926 set vols [array names _serverVols $_first-*]927 if { $vols != "" } {928 SendCmd "volume state 1 $vols"929 }930 928 if 1 { 931 # Tell the server the name of the tool, the version, and dataset 932 # that we are rendering. Have to do it here because we don't know 933 # what data objects are using the renderer until be get here. 929 # Tell the server the name of the tool, the version, and 930 # dataset that we are rendering. Have to do it here because 931 # we don't know what data objects are using the renderer until 932 # be get here. 934 933 global env 935 934 … … 949 948 SendCmd "clientinfo [list $out]" 950 949 } 951 952 foreach axis {x y z} {953 # Turn off cutplanes for all volumes954 SendCmd "cutplane state 0 $axis"955 }956 957 # If the first volume already exists on the server, then make sure958 # we display the proper transfer function in the legend.959 set comp [lindex [$_first components] 0]960 if { [info exists _serverVols($_first-$comp)] } {961 updatetransferfuncs962 }963 950 } 951 } 952 # nothing to send -- activate the proper ivol 953 SendCmd "volume state 0" 954 if {"" != $_first} { 955 set datasets [array names _serverDatasets $_first-*] 956 if { $datasets != "" } { 957 SendCmd "volume state 1 $datasets" 958 } 959 # If the first volume already exists on the server, then make sure 960 # we display the proper transfer function in the legend. 961 set cname [lindex [$_first components] 0] 962 if { [info exists _serverDatasets($_first-$cname)] } { 963 updatetransferfuncs 964 } 964 965 } 965 966 set _buffering 0; # Turn off buffering. … … 974 975 975 976 # ---------------------------------------------------------------------- 976 # USAGE: Current Volumes ?-cutplanes?977 # USAGE: CurrentDatasets ?-cutplanes? 977 978 # 978 979 # Returns a list of volume server IDs for the current volume being … … 980 981 # of IDs if the current data object has multiple components. 981 982 # ---------------------------------------------------------------------- 982 itcl::body Rappture::NanovisViewer::Current Volumes {{what -all}} {983 itcl::body Rappture::NanovisViewer::CurrentDatasets {{what -all}} { 983 984 set rlist "" 984 985 if { $_first == "" } { 985 986 return 986 987 } 987 foreach c omp[$_first components] {988 set vol $_first-$comp989 if { [info exists _server Vols($vol)] && $_serverVols($vol) } {988 foreach cname [$_first components] { 989 set tag $_first-$cname 990 if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } { 990 991 array set style { 991 992 -cutplanes 1 992 993 } 993 array set style [lindex [$_first components -style $c omp] 0]994 array set style [lindex [$_first components -style $cname] 0] 994 995 if { $what != "-cutplanes" || $style(-cutplanes) } { 995 lappend rlist $ vol996 lappend rlist $tag 996 997 } 997 998 } … … 1261 1262 "volume" { 1262 1263 if { [isconnected] } { 1263 set vols [CurrentVolumes -cutplanes]1264 SendCmd "volume data state $_settings($this-volume) $ vols"1264 set datasets [CurrentDatasets -cutplanes] 1265 SendCmd "volume data state $_settings($this-volume) $datasets" 1265 1266 } 1266 1267 } … … 1269 1270 set bool $_settings($this-$what) 1270 1271 if { [isconnected] } { 1271 set vols [CurrentVolumes -cutplanes]1272 set vol [lindex $vols 0]1273 SendCmd "cutplane state $bool $axis $ vol"1272 set datasets [CurrentDatasets -cutplanes] 1273 set tag [lindex $datasets 0] 1274 SendCmd "cutplane state $bool $axis $tag" 1274 1275 } 1275 1276 if { $bool } { … … 1300 1301 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 1301 1302 if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } { 1302 set vol [lindex [CurrentVolumes] 0]1303 if { [info exists _vol2style($ vol)] } {1304 SendCmd "legend $_vol2style($ vol) $w $h"1303 set tag [lindex [CurrentDatasets] 0] 1304 if { [info exists _vol2style($tag)] } { 1305 SendCmd "legend $_vol2style($tag) $w $h" 1305 1306 } 1306 1307 } else { … … 1327 1328 # now. 1328 1329 # 1329 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj c omp} {1330 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } { 1330 1331 array set style { 1331 1332 -color rainbow … … 1333 1334 -opacity 1.0 1334 1335 } 1335 array set style [lindex [$dataobj components -style $comp] 0] 1336 set tag $dataobj-$cname 1337 array set style [lindex [$dataobj components -style $cname] 0] 1336 1338 set tf "$style(-color):$style(-levels):$style(-opacity)" 1337 set _vol2style($ dataobj-$comp) $tf1338 lappend _style2 vols($tf) $dataobj-$comp1339 set _vol2style($tag) $tf 1340 lappend _style2datasets($tf) $tag 1339 1341 return $tf 1340 1342 } … … 1355 1357 -opacity 1.0 1356 1358 } 1357 foreach {dataobj c omp} [split [lindex $_style2vols($tf) 0] -] break1358 array set style [lindex [$dataobj components -style $c omp] 0]1359 foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break 1360 array set style [lindex [$dataobj components -style $cname] 0] 1359 1361 1360 1362 … … 1560 1562 error "active transfer function isn't set" 1561 1563 } 1562 set vol [lindex [CurrentVolumes] 0]1563 set tf $_vol2style($ vol)1564 set tag [lindex [CurrentDatasets] 0] 1565 set tf $_vol2style($tag) 1564 1566 set c $itk_component(legend) 1565 1567 set m [Rappture::IsoMarker \#auto $c $this $tf] … … 1614 1616 set _limits(min) 0.0 1615 1617 set _limits(max) 1.0 1616 if { ![info exists _style2 vols($tf)] } {1618 if { ![info exists _style2datasets($tf)] } { 1617 1619 return [array get _limits] 1618 1620 } 1619 1621 set min ""; set max "" 1620 foreach vol $_style2vols($tf) {1621 if { ![info exists _server Vols($vol)] } {1622 foreach tag $_style2datasets($tf) { 1623 if { ![info exists _serverDatasets($tag)] } { 1622 1624 continue 1623 1625 } 1624 if { ![info exists _limits($ vol-min)] } {1626 if { ![info exists _limits($tag-min)] } { 1625 1627 continue 1626 1628 } 1627 if { $min == "" || $min > $_limits($ vol-min) } {1628 set min $_limits($ vol-min)1629 } 1630 if { $max == "" || $max < $_limits($ vol-max) } {1631 set max $_limits($ vol-max)1629 if { $min == "" || $min > $_limits($tag-min) } { 1630 set min $_limits($tag-min) 1631 } 1632 if { $max == "" || $max < $_limits($tag-max) } { 1633 set max $_limits($tag-max) 1632 1634 } 1633 1635 } … … 1945 1947 1946 1948 set newpos [expr {0.01*$newval}] 1947 set vols [CurrentVolumes -cutplanes]1948 set vol [lindex $vols 0]1949 SendCmd "cutplane position $newpos $axis $ vol"1949 set datasets [CurrentDatasets -cutplanes] 1950 set tag [lindex $datasets 0] 1951 SendCmd "cutplane position $newpos $axis $tag" 1950 1952 } 1951 1953 default {
Note: See TracChangeset
for help on using the changeset viewer.