Changeset 5270


Ignore:
Timestamp:
Apr 18, 2015, 1:51:06 AM (5 years ago)
Author:
ldelgass
Message:

Bringing flowvis viewer more in line with nanovis viewer

File:
1 edited

Legend:

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

    r5258 r5270  
    8484    private method BuildVolumeComponents {}
    8585    private method BuildVolumeTab {}
    86     private method ComputeTransferFunc { tf }
     86    private method ComputeTransferFunction { tf }
    8787    private method Connect {}
    8888    private method CurrentVolumeIds {{what -all}}
    8989    private method Disconnect {}
     90    private method DrawLegend { tf }
    9091    private method EventuallyResize { w h }
    9192    private method EventuallyGoto { nSteps }
     
    9697    private method GetPngImage { widget width height }
    9798    private method InitSettings { args }
    98     private method NameTransferFunc { dataobj comp }
     99    private method NameTransferFunction { dataobj comp }
    99100    private method Pan {option x y}
    100101    private method PanCamera {}
     
    112113    private method Rotate {option x y}
    113114    private method SendFlowCmd { dataobj comp nbytes extents }
    114     private method SendTransferFuncs {}
     115    private method SendTransferFunctions {}
    115116    private method SetOrientation { side }
    116117    private method Slice {option args}
     
    129130
    130131    private variable _arcball ""
    131     private variable _dlist ""     ;# list of data objects
    132     private variable _allDataObjs
    133     private variable _obj2ovride   ;# maps dataobj => style override
    134     private variable _serverObjs   ;# maps dataobj-component to volume ID
    135                                     # in the server
    136     private variable _recvObjs     ;# list of data objs to send to server
    137     private variable _obj2style    ;# maps dataobj-component to transfunc
    138     private variable _style2objs   ;# maps tf back to list of
    139                                     # dataobj-components using the tf.
    140     private variable _obj2flow;     # Maps dataobj-component to a flow.
    141 
    142     private variable _reset 1      ;# Connection to server has been reset
    143     private variable _click        ;# info used for rotate operations
    144     private variable _limits       ;# autoscale min/max for all axes
    145     private variable _view         ;# view params for 3D view
    146     private variable _isomarkers   ;# array of isosurface level values 0..1
     132    private variable _dlist ""         ;# list of data objects
     133    private variable _obj2ovride       ;# maps dataobj => style override
     134    private variable _serverDatasets   ;# maps dataobj-component to volume ID
     135                                        # in the server
     136    private variable _recvdDatasets    ;# list of data objs to send to server
     137    private variable _dataset2style    ;# maps dataobj-component to transfunc
     138    private variable _style2datasets   ;# maps tf back to list of
     139                                        # dataobj-components using the tf.
     140    private variable _dataset2flow     ;# Maps dataobj-component to a flow.
     141
     142    private variable _reset 1          ;# Connection to server has been reset
     143    private variable _click            ;# info used for rotate operations
     144    private variable _limits           ;# Autoscale min/max for all axes
     145    private variable _view             ;# View params for 3D view
     146    private variable _isomarkers       ;# array of isosurface level values 0..1
    147147    private common   _settings
    148     private variable _activeTf ""  ;# The currently active transfer function.
    149     private variable _first ""     ;# This is the topmost volume.
    150     private variable _volcomponents   ;# Array of components found
    151     private variable _componentsList  ;# Array of components found
     148    private variable _activeTf ""      ;# The currently active transfer function.
     149    private variable _first ""         ;# This is the topmost volume.
     150    private variable _volcomponents    ;# Array of components found
     151    private variable _componentsList   ;# Array of components found
    152152    private variable _nextToken 0
    153153    private variable _icon 0
    154154    private variable _flow
    155     private common _downloadPopup          ;# download options from popup
    156 
     155
     156    private common _downloadPopup      ;# download options from popup
    157157    private common _hardcopy
    158158    private variable _width 0
     
    181181    $_dispatcher register !send_transfunc
    182182    $_dispatcher dispatch $this !send_transfunc \
    183         "[itcl::code $this SendTransferFuncs]; list"
     183        "[itcl::code $this SendTransferFunctions]; list"
    184184
    185185    # Rebuild event.
     
    230230
    231231    array set _settings [subst {
    232         $this-qw                $_view(-qw)
    233         $this-qx                $_view(-qx)
    234         $this-qy                $_view(-qy)
    235         $this-qz                $_view(-qz)
    236         $this-zoom              $_view(-zoom)
    237         $this-xpan              $_view(-xpan)
    238         $this-ypan              $_view(-ypan)
     232        -qw                     $_view(-qw)
     233        -qx                     $_view(-qx)
     234        -qy                     $_view(-qy)
     235        -qz                     $_view(-qz)
     236        -zoom                   $_view(-zoom)
     237        -xpan                   $_view(-xpan)
     238        -ypan                   $_view(-ypan)
    239239        $this-arrows            0
    240240        $this-currenttime       0
     
    609609            continue
    610610        }
    611         set _obj2flow($dataobj-$comp) $flowobj
     611        set _dataset2flow($dataobj-$comp) $flowobj
    612612    }
    613613    set pos [lsearch -exact $_dlist $dataobj]
    614614    if {$pos < 0} {
    615615        lappend _dlist $dataobj
    616         set _allDataObjs($dataobj) 1
    617616        set _obj2ovride($dataobj-color) $params(-color)
    618617        set _obj2ovride($dataobj-width) $params(-width)
     
    698697            set _dlist [lreplace $_dlist $pos $pos]
    699698            array unset _obj2ovride $dataobj-*
    700             array unset _obj2flow $dataobj-*
    701             array unset _serverObjs $dataobj-*
    702             array unset _obj2style $dataobj-*
     699            array unset _dataset2flow $dataobj-*
     700            array unset _serverDatasets $dataobj-*
     701            array unset _dataset2style $dataobj-*
    703702            set changed 1
    704703        }
     
    707706    if {$changed} {
    708707        # Repair the reverse lookup
    709         foreach tf [array names _style2objs] {
     708        foreach tf [array names _style2datasets] {
    710709            set list {}
    711             foreach {dataobj comp} $_style2objs($tf) break
    712             if { [info exists _serverObjs($dataobj-$comp)] } {
     710            foreach {dataobj comp} $_style2datasets($tf) break
     711            if { [info exists _serverDatasets($dataobj-$comp)] } {
    713712                lappend list $dataobj $comp
    714713            }
    715714            if { $list == "" } {
    716                 array unset _style2objs $tf
     715                array unset _style2datasets $tf
    717716            } else {
    718                 set _style2objs($tf) $list
     717                set _style2datasets($tf) $list
    719718            }
    720719        }
     
    944943
    945944    # disconnected -- no more data sitting on server
    946     array unset _serverObjs
    947 }
    948 
    949 # ----------------------------------------------------------------------
    950 # USAGE: SendTransferFuncs
    951 # ----------------------------------------------------------------------
    952 itcl::body Rappture::FlowvisViewer::SendTransferFuncs {} {
     945    array unset _serverDatasets
     946}
     947
     948# ----------------------------------------------------------------------
     949# USAGE: SendTransferFunctions
     950# ----------------------------------------------------------------------
     951itcl::body Rappture::FlowvisViewer::SendTransferFunctions {} {
    953952    if { $_activeTf == "" } {
    954953        puts stderr "no active tf"
     
    970969    set _settings($this-$tf-thickness) $thickness
    971970
    972     foreach key [array names _obj2style $_first-*] {
    973         if { [info exists _obj2style($key)] } {
    974             foreach tf $_obj2style($key) {
    975                 ComputeTransferFunc $tf
     971    foreach key [array names _dataset2style $_first-*] {
     972        if { [info exists _dataset2style($key)] } {
     973            foreach tf $_dataset2style($key) {
     974                ComputeTransferFunction $tf
    976975            }
    977976        }
     
    10161015
    10171016#
    1018 # ReceiveLegend --
    1019 #
    1020 #       The procedure is the response from the render server to each "legend"
    1021 #       command.  The server sends back a "legend" command invoked our
    1022 #       the slave interpreter.  The purpose is to collect data of the image
    1023 #       representing the legend in the canvas.  In addition, the isomarkers
    1024 #       of the active transfer function are displayed.
    1025 #
    1026 #       I don't know is this is the right place to display the isomarkers.
    1027 #       I don't know all the different paths used to draw the plot. There's
    1028 #       "Rebuild", "add", etc.
    1029 #
    1030 itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } {
    1031     if { ![isconnected] } {
    1032         return
    1033     }
    1034     #puts stderr "receive legend $tag $vmin $vmax $size"
    1035     set bytes [ReceiveBytes $size]
    1036     $_image(legend) configure -data $bytes
    1037     ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    1038 
     1017# DrawLegend --
     1018#
     1019itcl::body Rappture::FlowvisViewer::DrawLegend { tag } {
    10391020    set c $itk_component(legend)
    10401021    set w [winfo width $c]
     
    10521033        $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y]
    10531034    }
    1054     # Display the markers used by the active transfer function.
    1055     set tf $_obj2style($tag)
     1035
     1036    # Display the markers used by the current transfer function.
     1037    set tf $_dataset2style($tag)
    10561038    foreach {vmin vmax} [limits $tf] break
    10571039    $c itemconfigure vmin -text [format %g $vmin]
     
    10661048        }
    10671049    }
     1050}
     1051
     1052#
     1053# ReceiveLegend --
     1054#
     1055#       The procedure is the response from the render server to each "legend"
     1056#       command.  The server sends back a "legend" command invoked our
     1057#       the slave interpreter.  The purpose is to collect data of the image
     1058#       representing the legend in the canvas.  In addition, the
     1059#       active transfer function is displayed.
     1060#
     1061itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } {
     1062    if { ![isconnected] } {
     1063        return
     1064    }
     1065    #puts stderr "receive legend $tag $vmin $vmax $size"
     1066    set bytes [ReceiveBytes $size]
     1067    $_image(legend) configure -data $bytes
     1068    ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
     1069
     1070    DrawLegend $tag
    10681071}
    10691072
     
    10771080#       doesn't parse 3D data formats, we rely on the server (flowvis) to
    10781081#       tell us what the limits are.  Once we've received the limits to all
    1079 #       the data we've sent (tracked by _recvObjs) we can then determine
     1082#       the data we've sent (tracked by _recvdDatasets) we can then determine
    10801083#       what the transfer functions are for these # volumes.
    10811084#
     
    10971100    set parts [split $tag -]
    10981101    set dataobj [lindex $parts 0]
    1099     set _serverObjs($tag) 0
     1102    set _serverDatasets($tag) 0
    11001103    set _limits($tag) [list $values(min) $values(max)]
    1101     unset _recvObjs($tag)
    1102     if { [array size _recvObjs] == 0 } {
     1104    unset _recvdDatasets($tag)
     1105    if { [array size _recvdDatasets] == 0 } {
    11031106        updateTransferFunctions
    11041107    }
     
    11791182            }
    11801183            SendData $data
    1181             NameTransferFunc $dataobj $comp
    1182             set _recvObjs($tag) 1
     1184            NameTransferFunction $dataobj $comp
     1185            set _recvdDatasets($tag) 1
    11831186        }
    11841187    }
     
    12081211
    12091212    }
    1210     set _settings($this-qw)    $_view(-qw)
    1211     set _settings($this-qx)    $_view(-qx)
    1212     set _settings($this-qy)    $_view(-qy)
    1213     set _settings($this-qz)    $_view(-qz)
    1214     set _settings($this-xpan)  $_view(-xpan)
    1215     set _settings($this-ypan)  $_view(-ypan)
    1216     set _settings($this-zoom)  $_view(-zoom)
     1213    set _settings(-qw)    $_view(-qw)
     1214    set _settings(-qx)    $_view(-qx)
     1215    set _settings(-qy)    $_view(-qy)
     1216    set _settings(-qz)    $_view(-qz)
     1217    set _settings(-xpan)  $_view(-xpan)
     1218    set _settings(-ypan)  $_view(-ypan)
     1219    set _settings(-zoom)  $_view(-zoom)
    12171220
    12181221    set q [ViewToQuaternion]
     
    12251228    foreach dataobj [get] {
    12261229        foreach comp [$dataobj components] {
    1227             NameTransferFunc $dataobj $comp
     1230            NameTransferFunction $dataobj $comp
    12281231        }
    12291232    }
     
    12411244        }
    12421245        set comp [lindex [$_first components] 0]
    1243         set _activeTf [lindex $_obj2style($_first-$comp) 0]
     1246        set _activeTf [lindex $_dataset2style($_first-$comp) 0]
    12441247    }
    12451248
     
    12741277        return
    12751278    }
    1276     foreach key [array names _serverObjs *-*] {
     1279    foreach key [array names _serverDatasets *-*] {
    12771280        if {[string match $_first-* $key]} {
    12781281            array set style {
     
    12821285            array set style [lindex [$dataobj components -style $comp] 0]
    12831286            if {$what != "-cutplanes" || $style(-cutplanes)} {
    1284                 lappend rlist $_serverObjs($key)
     1287                lappend rlist $_serverDatasets($key)
    12851288            }
    12861289        }
     
    13011304        "in" {
    13021305            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1303             set _settings($this-zoom) $_view(-zoom)
     1306            set _settings(-zoom) $_view(-zoom)
    13041307            SendCmd "camera zoom $_view(-zoom)"
    13051308        }
    13061309        "out" {
    13071310            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1308             set _settings($this-zoom) $_view(-zoom)
     1311            set _settings(-zoom) $_view(-zoom)
    13091312            SendCmd "camera zoom $_view(-zoom)"
    13101313        }
     
    13291332            SendCmd "camera orient $q"
    13301333            SendCmd "camera reset"
    1331             set _settings($this-qw)    $_view(-qw)
    1332             set _settings($this-qx)    $_view(-qx)
    1333             set _settings($this-qy)    $_view(-qy)
    1334             set _settings($this-qz)    $_view(-qz)
    1335             set _settings($this-xpan)  $_view(-xpan)
    1336             set _settings($this-ypan)  $_view(-ypan)
    1337             set _settings($this-zoom)  $_view(-zoom)
     1334            set _settings(-qw)    $_view(-qw)
     1335            set _settings(-qx)    $_view(-qx)
     1336            set _settings(-qy)    $_view(-qy)
     1337            set _settings(-qz)    $_view(-qz)
     1338            set _settings(-xpan)  $_view(-xpan)
     1339            set _settings(-ypan)  $_view(-ypan)
     1340            set _settings(-zoom)  $_view(-zoom)
    13381341        }
    13391342    }
     
    13811384                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    13821385                QuaternionToView $q
    1383                 set _settings($this-qw) $_view(-qw)
    1384                 set _settings($this-qx) $_view(-qx)
    1385                 set _settings($this-qy) $_view(-qy)
    1386                 set _settings($this-qz) $_view(-qz)
     1386                set _settings(-qw) $_view(-qw)
     1387                set _settings(-qx) $_view(-qx)
     1388                set _settings(-qy) $_view(-qy)
     1389                set _settings(-qz) $_view(-qz)
    13871390                SendCmd "camera orient $q"
    13881391
     
    14201423        set _view(-ypan) [expr $_view(-ypan) + $y]
    14211424        PanCamera
    1422         set _settings($this-xpan) $_view(-xpan)
    1423         set _settings($this-ypan) $_view(-ypan)
     1425        set _settings(-xpan) $_view(-xpan)
     1426        set _settings(-ypan) $_view(-ypan)
    14241427        return
    14251428    }
     
    14371440        set _view(-ypan) [expr $_view(-ypan) - $dy]
    14381441        PanCamera
    1439         set _settings($this-xpan) $_view(-xpan)
    1440         set _settings($this-ypan) $_view(-ypan)
     1442        set _settings(-xpan) $_view(-xpan)
     1443        set _settings(-ypan) $_view(-ypan)
    14411444    }
    14421445    if { $option == "release" } {
     
    17171720    set comp [lindex [$_first components] 0]
    17181721    set tag $_first-$comp
    1719     #set _activeTf [lindex $_obj2style($tag) 0]
     1722    #set _activeTf [lindex $_dataset2style($tag) 0]
    17201723    if {$w > 0 && $h > 0 && "" != $_activeTf} {
    17211724        #SendCmd "legend $_activeTf $w $h"
     
    17301733
    17311734#
    1732 # NameTransferFunc --
     1735# NameTransferFunction --
    17331736#
    17341737#       Creates a transfer function name based on the <style> settings in the
     
    17441747#              now.
    17451748#
    1746 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } {
     1749itcl::body Rappture::FlowvisViewer::NameTransferFunction { dataobj cname } {
    17471750    array set style {
    17481751        -color BCGYR
     
    17521755    array set style [lindex [$dataobj components -style $cname] 0]
    17531756    set _settings($this-opacity) [expr $style(-opacity) * 100]
    1754     set _obj2style($dataobj-$cname) $cname
    1755     lappend _style2objs($cname) $dataobj $cname
     1757    set _dataset2style($dataobj-$cname) $cname
     1758    lappend _style2datasets($cname) $dataobj $cname
    17561759    return $cname
    17571760}
    17581761
    17591762#
    1760 # ComputeTransferFunc --
     1763# ComputeTransferFunction --
    17611764#
    17621765#   Computes and sends the transfer function to the render server.  It's
     
    17661769#   the alpha map of the transfer function.
    17671770#
    1768 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {
     1771itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } {
    17691772    array set style {
    17701773        -color BCGYR
     
    17731776    }
    17741777    set dataobj ""; set comp ""
    1775     foreach {dataobj comp} $_style2objs($tf) break
     1778    foreach {dataobj comp} $_style2datasets($tf) break
    17761779    if { $dataobj == "" } {
    17771780        return 0
     
    19811984
    19821985# ----------------------------------------------------------------------
    1983 # USAGE: UpdateTransferFuncs
     1986# USAGE: UpdateTransferFunctions
    19841987# ----------------------------------------------------------------------
    19851988itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} {
     
    20442047itcl::body Rappture::FlowvisViewer::limits { cname } {
    20452048    set _limits(v) [list 0.0 1.0]
    2046     if { ![info exists _style2objs($cname)] } {
    2047         puts stderr "no style2objs for $cname cname=($cname)"
     2049    if { ![info exists _style2datasets($cname)] } {
     2050        puts stderr "no _style2datasets for $cname cname=($cname)"
    20482051        return [array get _limits]
    20492052    }
    20502053    set min ""; set max ""
    20512054    foreach tag [GetDatasetsWithComponent $cname] {
    2052         if { ![info exists _serverObjs($tag)] } {
     2055        if { ![info exists _serverDatasets($tag)] } {
    20532056            puts stderr "$tag not in serverObjs?"
    20542057            continue
     
    23782381        label $inner.${tag}label -text $tag -font "Arial 9"
    23792382        entry $inner.${tag} -font "Arial 9"  -bg white \
    2380             -textvariable [itcl::scope _settings($this-$tag)]
     2383            -textvariable [itcl::scope _settings(-$tag)]
    23812384        bind $inner.${tag} <Return> \
    23822385            [itcl::code $this camera set -${tag}]
     
    23972400itcl::body Rappture::FlowvisViewer::GetFlowInfo { w } {
    23982401    set flowobj ""
    2399     foreach key [array names _obj2flow] {
    2400         set flowobj $_obj2flow($key)
     2402    foreach key [array names _dataset2flow] {
     2403        set flowobj $_dataset2flow($key)
    24012404        break
    24022405    }
     
    26132616itcl::body Rappture::FlowvisViewer::SendFlowCmd { dataobj comp nbytes extents } {
    26142617    set tag "$dataobj-$comp"
    2615     if { ![info exists _obj2flow($tag)] } {
     2618    if { ![info exists _dataset2flow($tag)] } {
    26162619        SendCmd "flow add $tag"
    26172620        SendCmd "$tag data follows $nbytes $extents"
    26182621        return 0
    26192622    }
    2620     set flowobj $_obj2flow($tag)
     2623    set flowobj $_dataset2flow($tag)
    26212624    if { $flowobj == "" } {
    26222625        puts stderr "no flowobj"
     
    29973000    set _view(-ypan) 0.0
    29983001    set _view(-zoom) 1.0
    2999     set _settings($this-xpan) $_view(-xpan)
    3000     set _settings($this-ypan) $_view(-ypan)
    3001     set _settings($this-zoom) $_view(-zoom)
     3002    set _settings(-xpan) $_view(-xpan)
     3003    set _settings(-ypan) $_view(-ypan)
     3004    set _settings(-zoom) $_view(-zoom)
    30023005}
    30033006
     
    30193022    set list ""
    30203023    foreach tag $_volcomponents($cname) {
    3021         if { ![info exists _serverObjs($tag)] } {
     3024        if { ![info exists _serverDatasets($tag)] } {
    30223025            continue
    30233026        }
Note: See TracChangeset for help on using the changeset viewer.