Changeset 3340


Ignore:
Timestamp:
Feb 25, 2013 10:41:03 AM (11 years ago)
Author:
ldelgass
Message:

Merge fix for nanovisviewer from trunk

Location:
branches/nanovis2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/nanovis2

    • Property svn:mergeinfo changed
      /trunkmerged: 3339
  • branches/nanovis2/gui/scripts/nanovisviewer.tcl

    r3334 r3340  
    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 {}
     
    127127    private variable _allDataObjs
    128128    private variable _obj2ovride   ;# maps dataobj => style override
    129     private variable _serverVols   ;# contains all the dataobj-component
     129    private variable _serverDatasets   ;# contains all the dataobj-component
    130130                                   ;# to volumes in the server
    131131    private variable _serverTfs    ;# contains all the transfer functions
    132132                                   ;# in the server.
    133     private variable _recvdVols    ;# list of data objs to send to server
    134     private variable _vol2style    ;# maps dataobj-component to transfunc
    135     private variable _style2vols   ;# maps tf back to list of
     133    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
    136136                                    # dataobj-components using the tf.
    137137
     
    141141    private variable _view         ;# view params for 3D view
    142142    private variable _isomarkers    ;# array of isosurface level values 0..1
    143     private common   _settings
     143    private variable  _settings
    144144    # Array of transfer functions in server.  If 0 the transfer has been
    145145    # defined but not loaded.  If 1 the transfer function has been named
     
    506506            array unset _limits $dataobj*
    507507            array unset _obj2ovride $dataobj-*
    508             array unset _vol2style $dataobj-*
     508            array unset _dataset2style $dataobj-*
    509509            set changed 1
    510510        }
     
    643643    # disconnected -- no more data sitting on server
    644644    set _outbuf ""
    645     array unset _serverVols
     645    array unset _serverDatasets
    646646}
    647647
     
    687687    set thickness [expr {double($_settings($this-thickness)) * 0.0001}]
    688688
    689     foreach vol [CurrentVolumes] {
    690         if { ![info exists _serverVols($vol)] || !$_serverVols($vol) } {
     689    foreach tag [CurrentDatasets] {
     690        if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } {
    691691            # The volume hasn't reached the server yet.  How did we get
    692692            # here?
     
    694694            continue
    695695        }
    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"
    698698            continue;                        # How does this happen?
    699699        }
    700         set tf $_vol2style($vol)
     700        set tf $_dataset2style($tag)
    701701        set _settings($this-$tf-opacity) $opacity
    702702        set _settings($this-$tf-thickness) $thickness
     
    709709            set _activeTfs($tf) 1
    710710        }
    711         SendCmd "volume shading transfunc $tf $vol"
     711        SendCmd "volume shading transfunc $tf $tag"
    712712    }
    713713    FixLegend
     
    792792
    793793    # 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"
    796796
    797797    # Adjust the cutplane for only the first component in the topmost volume
    798798    # (i.e. the first volume designated in the field).
    799     set vol [lindex $vols 0]
     799    set tag [lindex $datasets 0]
    800800    foreach axis {x y z} {
    801801        # Turn off cutplanes for all volumes
     
    803803        if { $_settings($this-${axis}cutplane) } {
    804804            # 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"
    806806            set pos [expr {0.01*$_settings($this-${axis}cutposition)}]
    807             SendCmd "cutplane position $pos $axis $vol"
     807            SendCmd "cutplane position $pos $axis $tag"
    808808        }
    809809    }
     
    819819#       doesn't parse 3D data formats, we rely on the server (nanovis) to
    820820#       tell us what the limits are.  Once we've received the limits to all
    821 #       the data we've sent (tracked by _recvdVols) we can then determine
     821#       the data we've sent (tracked by _recvdDatasets) we can then determine
    822822#       what the transfer functions are for these volumes.
    823823#
     
    848848    #
    849849    set dataobj [lindex $parts 0]
    850     set _serverVols($tag) 1
     850    set _serverDatasets($tag) 1
    851851    if { $_settings($this-volume) && $dataobj == $_first } {
    852852        SendCmd "volume state 1 $tag"
     
    857857    set _limits(vmax)      $info(vmax); # Overall maximum value.
    858858
    859     unset _recvdVols($tag)
    860     if { [array size _recvdVols] == 0 } {
     859    unset _recvdDatasets($tag)
     860    if { [array size _recvdDatasets] == 0 } {
    861861        # The active transfer function is by default the first component of
    862862        # the first data object.  This assumes that the data is always
     
    895895
    896896    foreach dataobj [get] {
    897         foreach comp [$dataobj components] {
    898             set vol $dataobj-$comp
    899             if { ![info exists _serverVols($vol)] } {
     897        foreach cname [$dataobj components] {
     898            set tag $dataobj-$cname
     899            if { ![info exists _serverDatasets($tag)] } {
    900900                # Send the data as one huge base64-encoded mess -- yuck!
    901                 set data [$dataobj values $comp]
     901                set data [$dataobj values $cname]
    902902                set nbytes [string length $data]
    903                 append _outbuf "volume data follows $nbytes $vol\n"
     903                append _outbuf "volume data follows $nbytes $tag\n"
    904904                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]
    911912    if { $_reset } {
    912913        #
     
    943944        FixSettings outline
    944945       
    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        }
    948950        if {"" != $_first} {
    949951            set axis [$_first hints updir]
     
    955957                array set _view $location
    956958            }
    957             set vols [array names _serverVols $_first-*]
    958             if { $vols != "" } {
    959                 SendCmd "volume state 1 $vols"
    960             }
    961959            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.
    965964                global env
    966965
     
    980979                SendCmd "clientinfo [list $out]"
    981980            }
    982 
    983             foreach axis {x y z} {
    984                 # Turn off cutplanes for all volumes
    985                 SendCmd "cutplane state 0 $axis"
    986             }
    987            
    988             # If the first volume already exists on the server, then make sure
    989             # we display the proper transfer function in the legend.
    990             set comp [lindex [$_first components] 0]
    991             if { [info exists _serverVols($_first-$comp)] } {
    992                 updatetransferfuncs
    993             }
    994981        }
     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        }
    995996    }
    996997    set _buffering 0;                        # Turn off buffering.
     
    10051006
    10061007# ----------------------------------------------------------------------
    1007 # USAGE: CurrentVolumes ?-cutplanes?
     1008# USAGE: CurrentDatasets ?-cutplanes?
    10081009#
    10091010# Returns a list of volume server IDs for the current volume being
     
    10111012# of IDs if the current data object has multiple components.
    10121013# ----------------------------------------------------------------------
    1013 itcl::body Rappture::NanovisViewer::CurrentVolumes {{what -all}} {
     1014itcl::body Rappture::NanovisViewer::CurrentDatasets {{what -all}} {
    10141015    set rlist ""
    10151016    if { $_first == "" } {
    10161017        return
    10171018    }
    1018     foreach comp [$_first components] {
    1019         set vol $_first-$comp
    1020         if { [info exists _serverVols($vol)] && $_serverVols($vol) } {
     1019    foreach cname [$_first components] {
     1020        set tag $_first-$cname
     1021        if { [info exists _serverDatasets($tag)] && $_serverDatasets($tag) } {
    10211022            array set style {
    10221023                -cutplanes 1
    10231024            }
    1024             array set style [lindex [$_first components -style $comp] 0]
     1025            array set style [lindex [$_first components -style $cname] 0]
    10251026            if { $what != "-cutplanes" || $style(-cutplanes) } {
    1026                 lappend rlist $vol
     1027                lappend rlist $tag
    10271028            }
    10281029        }
     
    13271328        "volume" {
    13281329            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"
    13311332            }
    13321333        }
     
    13351336            set bool $_settings($this-$what)
    13361337            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"
    13401341            }
    13411342            if { $bool } {
     
    13661367    set h [expr {[winfo height $itk_component(legend)]-20-$lineht}]
    13671368    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"
    13711372        }
    13721373    } else {
     
    13931394#              now.
    13941395#
    1395 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj comp } {
     1396itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } {
    13961397    array set style {
    13971398        -color rainbow
     
    14001401        -markers ""
    14011402    }
    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]
    14031405    set tf "$style(-color):$style(-levels):$style(-opacity)"
    1404     set _vol2style($dataobj-$comp) $tf
    1405     lappend _style2vols($tf) $dataobj-$comp
     1406    set _dataset2style($tag) $tf
     1407    lappend _style2datasets($tf) $tag
    14061408    return $tf
    14071409}
     
    14231425        -markers ""
    14241426    }
    1425     foreach {dataobj comp} [split [lindex $_style2vols($tf) 0] -] break
    1426     array set style [lindex [$dataobj components -style $comp] 0]
     1427    foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break
     1428    array set style [lindex [$dataobj components -style $cname] 0]
    14271429
    14281430    puts stderr "$tf: $style(-color), $style(-levels), $style(-opacity), $style(-markers)"
     
    16321634        error "active transfer function isn't set"
    16331635    }
    1634     set vol [lindex [CurrentVolumes] 0]
    1635     set tf $_vol2style($vol)
     1636    set tag [lindex [CurrentDatasets] 0]
     1637    set tf $_dataset2style($tag)
    16361638    set c $itk_component(legend)
    16371639    set m [Rappture::IsoMarker \#auto $c $this $tf]
     
    16861688    set _limits(min) 0.0
    16871689    set _limits(max) 1.0
    1688     if { ![info exists _style2vols($tf)] } {
     1690    if { ![info exists _style2datasets($tf)] } {
    16891691        return [array get _limits]
    16901692    }
    16911693    set min ""; set max ""
    1692     foreach vol $_style2vols($tf) {
    1693         if { ![info exists _serverVols($vol)] } {
     1694    foreach tag $_style2datasets($tf) {
     1695        if { ![info exists _serverDatasets($tag)] } {
    16941696            continue
    16951697        }
    1696         if { ![info exists _limits($vol-min)] } {
     1698        if { ![info exists _limits($tag-min)] } {
    16971699            continue
    16981700        }
    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)
    17041706        }
    17051707    }
     
    20292031
    20302032            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"
    20342036        }
    20352037        default {
Note: See TracChangeset for help on using the changeset viewer.