Ignore:
Timestamp:
Feb 25, 2013 6:38:40 AM (11 years ago)
Author:
gah
Message:

fix nanovis Rebuild (too much in reset)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/nanovisviewer.tcl

    r3330 r3339  
    8686
    8787    protected method Connect {}
    88     protected method CurrentVolumes {{what -all}}
     88    protected method CurrentDatasets {{what -all}}
    8989    protected method Disconnect {}
    9090    protected method DoResize {}
     
    125125    private variable _allDataObjs
    126126    private variable _obj2ovride   ;# maps dataobj => style override
    127     private variable _serverVols   ;# contains all the dataobj-component
     127    private variable _serverDatasets   ;# contains all the dataobj-component
    128128                                   ;# to volumes in the server
    129129    private variable _serverTfs    ;# contains all the transfer functions
    130130                                   ;# in the server.
    131     private variable _recvdVols    ;# list of data objs to send to server
     131    private variable _recvdDatasets    ;# list of data objs to send to server
    132132    private variable _vol2style    ;# maps dataobj-component to transfunc
    133     private variable _style2vols   ;# maps tf back to list of
     133    private variable _style2datasets   ;# maps tf back to list of
    134134                                    # dataobj-components using the tf.
    135135
     
    139139    private variable _view         ;# view params for 3D view
    140140    private variable _isomarkers    ;# array of isosurface level values 0..1
    141     private common   _settings
     141    private variable  _settings
    142142    # Array of transfer functions in server.  If 0 the transfer has been
    143143    # defined but not loaded.  If 1 the transfer function has been named
     
    628628    # disconnected -- no more data sitting on server
    629629    set _outbuf ""
    630     array unset _serverVols
     630    array unset _serverDatasets
    631631}
    632632
     
    672672    set thickness [expr {double($_settings($this-thickness)) * 0.0001}]
    673673
    674     foreach vol [CurrentVolumes] {
    675         if { ![info exists _serverVols($vol)] || !$_serverVols($vol) } {
     674    foreach tag [CurrentDatasets] {
     675        if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } {
    676676            # The volume hasn't reached the server yet.  How did we get
    677677            # here?
    678678            continue
    679679        }
    680         if { ![info exists _vol2style($vol)] } {
    681             puts stderr "unknown volume $vol"
     680        if { ![info exists _vol2style($tag)] } {
     681            puts stderr "unknown volume $tag"
    682682            continue;                        # How does this happen?
    683683        }
    684         set tf $_vol2style($vol)
     684        set tf $_vol2style($tag)
    685685        set _settings($this-$tf-opacity) $opacity
    686686        set _settings($this-$tf-thickness) $thickness
     
    693693            set _activeTfs($tf) 1
    694694        }
    695         SendCmd "volume shading transfunc $tf $vol"
     695        SendCmd "volume shading transfunc $tf $tag"
    696696    }
    697697    FixLegend
     
    776776
    777777    # 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"
    780780
    781781    # Adjust the cutplane for only the first component in the topmost volume
    782782    # (i.e. the first volume designated in the field).
    783     set vol [lindex $vols 0]
     783    set tag [lindex $datasets 0]
    784784    foreach axis {x y z} {
    785785        # Turn off cutplanes for all volumes
     
    787787        if { $_settings($this-${axis}cutplane) } {
    788788            # 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"
    790790            set pos [expr {0.01*$_settings($this-${axis}cutposition)}]
    791             SendCmd "cutplane position $pos $axis $vol"
     791            SendCmd "cutplane position $pos $axis $tag"
    792792        }
    793793    }
     
    803803#       doesn't parse 3D data formats, we rely on the server (nanovis) to
    804804#       tell us what the limits are.  Once we've received the limits to all
    805 #       the data we've sent (tracked by _recvdVols) we can then determine
     805#       the data we've sent (tracked by _recvdDatasets) we can then determine
    806806#       what the transfer functions are for these volumes.
    807807#
     
    829829    #
    830830    set dataobj [lindex $parts 0]
    831     set _serverVols($tag) 1
     831    set _serverDatasets($tag) 1
    832832    if { $_settings($this-volume) && $dataobj == $_first } {
    833833        SendCmd "volume state 1 $tag"
     
    838838    set _limits(vmax)      $info(vmax); # Overall maximum value.
    839839
    840     unset _recvdVols($tag)
    841     if { [array size _recvdVols] == 0 } {
     840    unset _recvdDatasets($tag)
     841    if { [array size _recvdDatasets] == 0 } {
    842842        # The active transfer function is by default the first component of
    843843        # the first data object.  This assumes that the data is always
     
    875875
    876876    foreach dataobj [get] {
    877         foreach comp [$dataobj components] {
    878             set vol $dataobj-$comp
    879             if { ![info exists _serverVols($vol)] } {
     877        foreach cname [$dataobj components] {
     878            set tag $dataobj-$cname
     879            if { ![info exists _serverDatasets($tag)] } {
    880880                # Send the data as one huge base64-encoded mess -- yuck!
    881                 set data [$dataobj values $comp]
     881                set data [$dataobj values $cname]
    882882                set nbytes [string length $data]
    883                 append _outbuf "volume data follows $nbytes $vol\n"
     883                append _outbuf "volume data follows $nbytes $tag\n"
    884884                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]
    891892    if { $_reset } {
    892893        #
     
    912913        FixSettings outline
    913914       
    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        }
    917919        if {"" != $_first} {
    918920            set axis [$_first hints updir]
     
    924926                array set _view $location
    925927            }
    926             set vols [array names _serverVols $_first-*]
    927             if { $vols != "" } {
    928                 SendCmd "volume state 1 $vols"
    929             }
    930928            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.
    934933                global env
    935934
     
    949948                SendCmd "clientinfo [list $out]"
    950949            }
    951 
    952             foreach axis {x y z} {
    953                 # Turn off cutplanes for all volumes
    954                 SendCmd "cutplane state 0 $axis"
    955             }
    956            
    957             # If the first volume already exists on the server, then make sure
    958             # we display the proper transfer function in the legend.
    959             set comp [lindex [$_first components] 0]
    960             if { [info exists _serverVols($_first-$comp)] } {
    961                 updatetransferfuncs
    962             }
    963950        }
     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        }
    964965    }
    965966    set _buffering 0;                        # Turn off buffering.
     
    974975
    975976# ----------------------------------------------------------------------
    976 # USAGE: CurrentVolumes ?-cutplanes?
     977# USAGE: CurrentDatasets ?-cutplanes?
    977978#
    978979# Returns a list of volume server IDs for the current volume being
     
    980981# of IDs if the current data object has multiple components.
    981982# ----------------------------------------------------------------------
    982 itcl::body Rappture::NanovisViewer::CurrentVolumes {{what -all}} {
     983itcl::body Rappture::NanovisViewer::CurrentDatasets {{what -all}} {
    983984    set rlist ""
    984985    if { $_first == "" } {
    985986        return
    986987    }
    987     foreach comp [$_first components] {
    988         set vol $_first-$comp
    989         if { [info exists _serverVols($vol)] && $_serverVols($vol) } {
     988    foreach cname [$_first components] {
     989        set tag $_first-$cname
     990        if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } {
    990991            array set style {
    991992                -cutplanes 1
    992993            }
    993             array set style [lindex [$_first components -style $comp] 0]
     994            array set style [lindex [$_first components -style $cname] 0]
    994995            if { $what != "-cutplanes" || $style(-cutplanes) } {
    995                 lappend rlist $vol
     996                lappend rlist $tag
    996997            }
    997998        }
     
    12611262        "volume" {
    12621263            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"
    12651266            }
    12661267        }
     
    12691270            set bool $_settings($this-$what)
    12701271            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"
    12741275            }
    12751276            if { $bool } {
     
    13001301    set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
    13011302    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"
    13051306        }
    13061307    } else {
     
    13271328#              now.
    13281329#
    1329 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj comp } {
     1330itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } {
    13301331    array set style {
    13311332        -color rainbow
     
    13331334        -opacity 1.0
    13341335    }
    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]
    13361338    set tf "$style(-color):$style(-levels):$style(-opacity)"
    1337     set _vol2style($dataobj-$comp) $tf
    1338     lappend _style2vols($tf) $dataobj-$comp
     1339    set _vol2style($tag) $tf
     1340    lappend _style2datasets($tf) $tag
    13391341    return $tf
    13401342}
     
    13551357        -opacity 1.0
    13561358    }
    1357     foreach {dataobj comp} [split [lindex $_style2vols($tf) 0] -] break
    1358     array set style [lindex [$dataobj components -style $comp] 0]
     1359    foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break
     1360    array set style [lindex [$dataobj components -style $cname] 0]
    13591361
    13601362
     
    15601562        error "active transfer function isn't set"
    15611563    }
    1562     set vol [lindex [CurrentVolumes] 0]
    1563     set tf $_vol2style($vol)
     1564    set tag [lindex [CurrentDatasets] 0]
     1565    set tf $_vol2style($tag)
    15641566    set c $itk_component(legend)
    15651567    set m [Rappture::IsoMarker \#auto $c $this $tf]
     
    16141616    set _limits(min) 0.0
    16151617    set _limits(max) 1.0
    1616     if { ![info exists _style2vols($tf)] } {
     1618    if { ![info exists _style2datasets($tf)] } {
    16171619        return [array get _limits]
    16181620    }
    16191621    set min ""; set max ""
    1620     foreach vol $_style2vols($tf) {
    1621         if { ![info exists _serverVols($vol)] } {
     1622    foreach tag $_style2datasets($tf) {
     1623        if { ![info exists _serverDatasets($tag)] } {
    16221624            continue
    16231625        }
    1624         if { ![info exists _limits($vol-min)] } {
     1626        if { ![info exists _limits($tag-min)] } {
    16251627            continue
    16261628        }
    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)
    16321634        }
    16331635    }
     
    19451947
    19461948            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"
    19501952        }
    19511953        default {
Note: See TracChangeset for help on using the changeset viewer.