Changeset 3340 for branches/nanovis2
- Timestamp:
- Feb 25, 2013, 10:41:03 AM (12 years ago)
- Location:
- branches/nanovis2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/nanovis2
-
branches/nanovis2/gui/scripts/nanovisviewer.tcl
r3334 r3340 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 {} … … 127 127 private variable _allDataObjs 128 128 private variable _obj2ovride ;# maps dataobj => style override 129 private variable _server Vols ;# contains all the dataobj-component129 private variable _serverDatasets ;# contains all the dataobj-component 130 130 ;# to volumes in the server 131 131 private variable _serverTfs ;# contains all the transfer functions 132 132 ;# in the server. 133 private variable _recvd Vols ;# list of data objs to send to server134 private variable _ vol2style ;# maps dataobj-component to transfunc135 private variable _style2 vols ;# maps tf back to list of133 private variable _recvdDatasets ;# list of data objs to send to server 134 private variable _dataset2style ;# maps dataobj-component to transfunc 135 private variable _style2datasets ;# maps tf back to list of 136 136 # dataobj-components using the tf. 137 137 … … 141 141 private variable _view ;# view params for 3D view 142 142 private variable _isomarkers ;# array of isosurface level values 0..1 143 private common_settings143 private variable _settings 144 144 # Array of transfer functions in server. If 0 the transfer has been 145 145 # defined but not loaded. If 1 the transfer function has been named … … 506 506 array unset _limits $dataobj* 507 507 array unset _obj2ovride $dataobj-* 508 array unset _ vol2style $dataobj-*508 array unset _dataset2style $dataobj-* 509 509 set changed 1 510 510 } … … 643 643 # disconnected -- no more data sitting on server 644 644 set _outbuf "" 645 array unset _server Vols645 array unset _serverDatasets 646 646 } 647 647 … … 687 687 set thickness [expr {double($_settings($this-thickness)) * 0.0001}] 688 688 689 foreach vol [CurrentVolumes] {690 if { ![info exists _server Vols($vol)] || !$_serverVols($vol) } {689 foreach tag [CurrentDatasets] { 690 if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } { 691 691 # The volume hasn't reached the server yet. How did we get 692 692 # here? … … 694 694 continue 695 695 } 696 if { ![info exists _ vol2style($vol)] } {697 puts stderr "Don't have style for volume $ vol"696 if { ![info exists _dataset2style($tag)] } { 697 puts stderr "Don't have style for volume $tag" 698 698 continue; # How does this happen? 699 699 } 700 set tf $_ vol2style($vol)700 set tf $_dataset2style($tag) 701 701 set _settings($this-$tf-opacity) $opacity 702 702 set _settings($this-$tf-thickness) $thickness … … 709 709 set _activeTfs($tf) 1 710 710 } 711 SendCmd "volume shading transfunc $tf $ vol"711 SendCmd "volume shading transfunc $tf $tag" 712 712 } 713 713 FixLegend … … 792 792 793 793 # The colormap may have changed. Resync the slicers with the colormap. 794 set vols [CurrentVolumes -cutplanes]795 SendCmd "volume data state $_settings($this-volume) $ vols"794 set datasets [CurrentDatasets -cutplanes] 795 SendCmd "volume data state $_settings($this-volume) $datasets" 796 796 797 797 # Adjust the cutplane for only the first component in the topmost volume 798 798 # (i.e. the first volume designated in the field). 799 set vol [lindex $vols 0]799 set tag [lindex $datasets 0] 800 800 foreach axis {x y z} { 801 801 # Turn off cutplanes for all volumes … … 803 803 if { $_settings($this-${axis}cutplane) } { 804 804 # Turn on cutplane for this particular volume and set the position 805 SendCmd "cutplane state 1 $axis $ vol"805 SendCmd "cutplane state 1 $axis $tag" 806 806 set pos [expr {0.01*$_settings($this-${axis}cutposition)}] 807 SendCmd "cutplane position $pos $axis $ vol"807 SendCmd "cutplane position $pos $axis $tag" 808 808 } 809 809 } … … 819 819 # doesn't parse 3D data formats, we rely on the server (nanovis) to 820 820 # tell us what the limits are. Once we've received the limits to all 821 # the data we've sent (tracked by _recvd Vols) we can then determine821 # the data we've sent (tracked by _recvdDatasets) we can then determine 822 822 # what the transfer functions are for these volumes. 823 823 # … … 848 848 # 849 849 set dataobj [lindex $parts 0] 850 set _server Vols($tag) 1850 set _serverDatasets($tag) 1 851 851 if { $_settings($this-volume) && $dataobj == $_first } { 852 852 SendCmd "volume state 1 $tag" … … 857 857 set _limits(vmax) $info(vmax); # Overall maximum value. 858 858 859 unset _recvd Vols($tag)860 if { [array size _recvd Vols] == 0 } {859 unset _recvdDatasets($tag) 860 if { [array size _recvdDatasets] == 0 } { 861 861 # The active transfer function is by default the first component of 862 862 # the first data object. This assumes that the data is always … … 895 895 896 896 foreach dataobj [get] { 897 foreach c omp[$dataobj components] {898 set vol $dataobj-$comp899 if { ![info exists _server Vols($vol)] } {897 foreach cname [$dataobj components] { 898 set tag $dataobj-$cname 899 if { ![info exists _serverDatasets($tag)] } { 900 900 # Send the data as one huge base64-encoded mess -- yuck! 901 set data [$dataobj values $c omp]901 set data [$dataobj values $cname] 902 902 set nbytes [string length $data] 903 append _outbuf "volume data follows $nbytes $ vol\n"903 append _outbuf "volume data follows $nbytes $tag\n" 904 904 append _outbuf $data 905 set _recvdVols($vol) 1 906 set _serverVols($vol) 0 907 } 908 NameTransferFunc $dataobj $comp 909 } 910 } 905 set _recvdDatasets($tag) 1 906 set _serverDatasets($tag) 0 907 } 908 NameTransferFunc $dataobj $cname 909 } 910 } 911 set _first [lindex [get] 0] 911 912 if { $_reset } { 912 913 # … … 943 944 FixSettings outline 944 945 945 # nothing to send -- activate the proper ivol 946 SendCmd "volume state 0" 947 set _first [lindex [get] 0] 946 foreach axis {x y z} { 947 # Turn off cutplanes for all volumes 948 SendCmd "cutplane state 0 $axis" 949 } 948 950 if {"" != $_first} { 949 951 set axis [$_first hints updir] … … 955 957 array set _view $location 956 958 } 957 set vols [array names _serverVols $_first-*]958 if { $vols != "" } {959 SendCmd "volume state 1 $vols"960 }961 959 if 1 { 962 # Tell the server the name of the tool, the version, and dataset 963 # that we are rendering. Have to do it here because we don't know 964 # what data objects are using the renderer until be get here. 960 # Tell the server the name of the tool, the version, and 961 # dataset that we are rendering. Have to do it here because 962 # we don't know what data objects are using the renderer until 963 # be get here. 965 964 global env 966 965 … … 980 979 SendCmd "clientinfo [list $out]" 981 980 } 982 983 foreach axis {x y z} {984 # Turn off cutplanes for all volumes985 SendCmd "cutplane state 0 $axis"986 }987 988 # If the first volume already exists on the server, then make sure989 # we display the proper transfer function in the legend.990 set comp [lindex [$_first components] 0]991 if { [info exists _serverVols($_first-$comp)] } {992 updatetransferfuncs993 }994 981 } 982 } 983 # nothing to send -- activate the proper ivol 984 SendCmd "volume state 0" 985 if {"" != $_first} { 986 set datasets [array names _serverDatasets $_first-*] 987 if { $datasets != "" } { 988 SendCmd "volume state 1 $datasets" 989 } 990 # If the first volume already exists on the server, then make sure 991 # we display the proper transfer function in the legend. 992 set cname [lindex [$_first components] 0] 993 if { [info exists _serverDatasets($_first-$cname)] } { 994 updatetransferfuncs 995 } 995 996 } 996 997 set _buffering 0; # Turn off buffering. … … 1005 1006 1006 1007 # ---------------------------------------------------------------------- 1007 # USAGE: Current Volumes ?-cutplanes?1008 # USAGE: CurrentDatasets ?-cutplanes? 1008 1009 # 1009 1010 # Returns a list of volume server IDs for the current volume being … … 1011 1012 # of IDs if the current data object has multiple components. 1012 1013 # ---------------------------------------------------------------------- 1013 itcl::body Rappture::NanovisViewer::Current Volumes {{what -all}} {1014 itcl::body Rappture::NanovisViewer::CurrentDatasets {{what -all}} { 1014 1015 set rlist "" 1015 1016 if { $_first == "" } { 1016 1017 return 1017 1018 } 1018 foreach c omp[$_first components] {1019 set vol $_first-$comp1020 if { [info exists _server Vols($vol)] && $_serverVols($vol) } {1019 foreach cname [$_first components] { 1020 set tag $_first-$cname 1021 if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } { 1021 1022 array set style { 1022 1023 -cutplanes 1 1023 1024 } 1024 array set style [lindex [$_first components -style $c omp] 0]1025 array set style [lindex [$_first components -style $cname] 0] 1025 1026 if { $what != "-cutplanes" || $style(-cutplanes) } { 1026 lappend rlist $ vol1027 lappend rlist $tag 1027 1028 } 1028 1029 } … … 1327 1328 "volume" { 1328 1329 if { [isconnected] } { 1329 set vols [CurrentVolumes -cutplanes]1330 SendCmd "volume data state $_settings($this-volume) $ vols"1330 set datasets [CurrentDatasets -cutplanes] 1331 SendCmd "volume data state $_settings($this-volume) $datasets" 1331 1332 } 1332 1333 } … … 1335 1336 set bool $_settings($this-$what) 1336 1337 if { [isconnected] } { 1337 set vols [CurrentVolumes -cutplanes]1338 set vol [lindex $vols 0]1339 SendCmd "cutplane state $bool $axis $ vol"1338 set datasets [CurrentDatasets -cutplanes] 1339 set tag [lindex $datasets 0] 1340 SendCmd "cutplane state $bool $axis $tag" 1340 1341 } 1341 1342 if { $bool } { … … 1366 1367 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 1367 1368 if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } { 1368 set vol [lindex [CurrentVolumes] 0]1369 if { [info exists _ vol2style($vol)] } {1370 SendCmd "legend $_ vol2style($vol) $w $h"1369 set tag [lindex [CurrentDatasets] 0] 1370 if { [info exists _dataset2style($tag)] } { 1371 SendCmd "legend $_dataset2style($tag) $w $h" 1371 1372 } 1372 1373 } else { … … 1393 1394 # now. 1394 1395 # 1395 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj c omp} {1396 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } { 1396 1397 array set style { 1397 1398 -color rainbow … … 1400 1401 -markers "" 1401 1402 } 1402 array set style [lindex [$dataobj components -style $comp] 0] 1403 set tag $dataobj-$cname 1404 array set style [lindex [$dataobj components -style $cname] 0] 1403 1405 set tf "$style(-color):$style(-levels):$style(-opacity)" 1404 set _ vol2style($dataobj-$comp) $tf1405 lappend _style2 vols($tf) $dataobj-$comp1406 set _dataset2style($tag) $tf 1407 lappend _style2datasets($tf) $tag 1406 1408 return $tf 1407 1409 } … … 1423 1425 -markers "" 1424 1426 } 1425 foreach {dataobj c omp} [split [lindex $_style2vols($tf) 0] -] break1426 array set style [lindex [$dataobj components -style $c omp] 0]1427 foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break 1428 array set style [lindex [$dataobj components -style $cname] 0] 1427 1429 1428 1430 puts stderr "$tf: $style(-color), $style(-levels), $style(-opacity), $style(-markers)" … … 1632 1634 error "active transfer function isn't set" 1633 1635 } 1634 set vol [lindex [CurrentVolumes] 0]1635 set tf $_ vol2style($vol)1636 set tag [lindex [CurrentDatasets] 0] 1637 set tf $_dataset2style($tag) 1636 1638 set c $itk_component(legend) 1637 1639 set m [Rappture::IsoMarker \#auto $c $this $tf] … … 1686 1688 set _limits(min) 0.0 1687 1689 set _limits(max) 1.0 1688 if { ![info exists _style2 vols($tf)] } {1690 if { ![info exists _style2datasets($tf)] } { 1689 1691 return [array get _limits] 1690 1692 } 1691 1693 set min ""; set max "" 1692 foreach vol $_style2vols($tf) {1693 if { ![info exists _server Vols($vol)] } {1694 foreach tag $_style2datasets($tf) { 1695 if { ![info exists _serverDatasets($tag)] } { 1694 1696 continue 1695 1697 } 1696 if { ![info exists _limits($ vol-min)] } {1698 if { ![info exists _limits($tag-min)] } { 1697 1699 continue 1698 1700 } 1699 if { $min == "" || $min > $_limits($ vol-min) } {1700 set min $_limits($ vol-min)1701 } 1702 if { $max == "" || $max < $_limits($ vol-max) } {1703 set max $_limits($ vol-max)1701 if { $min == "" || $min > $_limits($tag-min) } { 1702 set min $_limits($tag-min) 1703 } 1704 if { $max == "" || $max < $_limits($tag-max) } { 1705 set max $_limits($tag-max) 1704 1706 } 1705 1707 } … … 2029 2031 2030 2032 set newpos [expr {0.01*$newval}] 2031 set vols [CurrentVolumes -cutplanes]2032 set vol [lindex $vols 0]2033 SendCmd "cutplane position $newpos $axis $ vol"2033 set datasets [CurrentDatasets -cutplanes] 2034 set tag [lindex $datasets 0] 2035 SendCmd "cutplane position $newpos $axis $tag" 2034 2036 } 2035 2037 default {
Note: See TracChangeset
for help on using the changeset viewer.