Changeset 5275


Ignore:
Timestamp:
Apr 18, 2015, 2:40:55 AM (5 years ago)
Author:
ldelgass
Message:

merge r5258,r5270,r5274 from trunk

Location:
branches/1.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4

  • branches/1.4/gui/scripts/flowvisviewer.tcl

    r5248 r5275  
    7777
    7878    # The following methods are only used by this class.
     79    private method AddIsoMarker { x y }
    7980    private method AdjustSetting {what {value ""}}
    80     private method AddIsoMarker { x y }
    8181    private method BuildCameraTab {}
    8282    private method BuildCutplanesTab {}
     
    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
     
    594594            continue
    595595        }
    596         set _obj2flow($dataobj-$comp) $flowobj
     596        set _dataset2flow($dataobj-$comp) $flowobj
    597597    }
    598598    set pos [lsearch -exact $_dlist $dataobj]
    599599    if {$pos < 0} {
    600600        lappend _dlist $dataobj
    601         set _allDataObjs($dataobj) 1
    602601        set _obj2ovride($dataobj-color) $params(-color)
    603602        set _obj2ovride($dataobj-width) $params(-width)
     
    683682            set _dlist [lreplace $_dlist $pos $pos]
    684683            array unset _obj2ovride $dataobj-*
    685             array unset _obj2flow $dataobj-*
    686             array unset _serverObjs $dataobj-*
    687             array unset _obj2style $dataobj-*
     684            array unset _dataset2flow $dataobj-*
     685            array unset _serverDatasets $dataobj-*
     686            array unset _dataset2style $dataobj-*
    688687            set changed 1
    689688        }
     
    692691    if {$changed} {
    693692        # Repair the reverse lookup
    694         foreach tf [array names _style2objs] {
     693        foreach tf [array names _style2datasets] {
    695694            set list {}
    696             foreach {dataobj comp} $_style2objs($tf) break
    697             if { [info exists _serverObjs($dataobj-$comp)] } {
     695            foreach {dataobj comp} $_style2datasets($tf) break
     696            if { [info exists _serverDatasets($dataobj-$comp)] } {
    698697                lappend list $dataobj $comp
    699698            }
    700699            if { $list == "" } {
    701                 array unset _style2objs $tf
     700                array unset _style2datasets $tf
    702701            } else {
    703                 set _style2objs($tf) $list
     702                set _style2datasets($tf) $list
    704703            }
    705704        }
     
    929928
    930929    # disconnected -- no more data sitting on server
    931     array unset _serverObjs
    932 }
    933 
    934 # ----------------------------------------------------------------------
    935 # USAGE: SendTransferFuncs
    936 # ----------------------------------------------------------------------
    937 itcl::body Rappture::FlowvisViewer::SendTransferFuncs {} {
     930    array unset _serverDatasets
     931}
     932
     933# ----------------------------------------------------------------------
     934# USAGE: SendTransferFunctions
     935# ----------------------------------------------------------------------
     936itcl::body Rappture::FlowvisViewer::SendTransferFunctions {} {
    938937    if { $_activeTf == "" } {
    939938        puts stderr "no active tf"
     
    955954    set _settings($this-$tf-thickness) $thickness
    956955
    957     foreach key [array names _obj2style $_first-*] {
    958         if { [info exists _obj2style($key)] } {
    959             foreach tf $_obj2style($key) {
    960                 ComputeTransferFunc $tf
     956    foreach key [array names _dataset2style $_first-*] {
     957        if { [info exists _dataset2style($key)] } {
     958            foreach tf $_dataset2style($key) {
     959                ComputeTransferFunction $tf
    961960            }
    962961        }
     
    10011000
    10021001#
    1003 # ReceiveLegend --
    1004 #
    1005 #       The procedure is the response from the render server to each "legend"
    1006 #       command.  The server sends back a "legend" command invoked our
    1007 #       the slave interpreter.  The purpose is to collect data of the image
    1008 #       representing the legend in the canvas.  In addition, the isomarkers
    1009 #       of the active transfer function are displayed.
    1010 #
    1011 #       I don't know is this is the right place to display the isomarkers.
    1012 #       I don't know all the different paths used to draw the plot. There's
    1013 #       "Rebuild", "add", etc.
    1014 #
    1015 itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } {
    1016     if { ![isconnected] } {
    1017         return
    1018     }
    1019     #puts stderr "receive legend $tag $vmin $vmax $size"
    1020     set bytes [ReceiveBytes $size]
    1021     $_image(legend) configure -data $bytes
    1022     ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    1023 
     1002# DrawLegend --
     1003#
     1004itcl::body Rappture::FlowvisViewer::DrawLegend { tag } {
    10241005    set c $itk_component(legend)
    10251006    set w [winfo width $c]
     
    10371018        $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y]
    10381019    }
    1039     # Display the markers used by the active transfer function.
    1040     set tf $_obj2style($tag)
     1020
     1021    # Display the markers used by the current transfer function.
     1022    set tf $_dataset2style($tag)
    10411023    foreach {vmin vmax} [limits $tf] break
    10421024    $c itemconfigure vmin -text [format %g $vmin]
     
    10511033        }
    10521034    }
     1035}
     1036
     1037#
     1038# ReceiveLegend --
     1039#
     1040#       The procedure is the response from the render server to each "legend"
     1041#       command.  The server sends back a "legend" command invoked our
     1042#       the slave interpreter.  The purpose is to collect data of the image
     1043#       representing the legend in the canvas.  In addition, the
     1044#       active transfer function is displayed.
     1045#
     1046itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } {
     1047    if { ![isconnected] } {
     1048        return
     1049    }
     1050    #puts stderr "receive legend $tag $vmin $vmax $size"
     1051    set bytes [ReceiveBytes $size]
     1052    $_image(legend) configure -data $bytes
     1053    ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
     1054
     1055    DrawLegend $tag
    10531056}
    10541057
     
    10621065#       doesn't parse 3D data formats, we rely on the server (flowvis) to
    10631066#       tell us what the limits are.  Once we've received the limits to all
    1064 #       the data we've sent (tracked by _recvObjs) we can then determine
     1067#       the data we've sent (tracked by _recvdDatasets) we can then determine
    10651068#       what the transfer functions are for these # volumes.
    10661069#
     
    10821085    set parts [split $tag -]
    10831086    set dataobj [lindex $parts 0]
    1084     set _serverObjs($tag) 0
     1087    set _serverDatasets($tag) 0
    10851088    set _limits($tag) [list $values(min) $values(max)]
    1086     unset _recvObjs($tag)
    1087     if { [array size _recvObjs] == 0 } {
     1089    unset _recvdDatasets($tag)
     1090    if { [array size _recvdDatasets] == 0 } {
    10881091        updateTransferFunctions
    10891092    }
     
    11641167            }
    11651168            SendData $data
    1166             NameTransferFunc $dataobj $comp
    1167             set _recvObjs($tag) 1
     1169            NameTransferFunction $dataobj $comp
     1170            set _recvdDatasets($tag) 1
    11681171        }
    11691172    }
     
    11861189
    11871190    }
    1188     set _settings($this-qw)    $_view(-qw)
    1189     set _settings($this-qx)    $_view(-qx)
    1190     set _settings($this-qy)    $_view(-qy)
    1191     set _settings($this-qz)    $_view(-qz)
    1192     set _settings($this-xpan)  $_view(-xpan)
    1193     set _settings($this-ypan)  $_view(-ypan)
    1194     set _settings($this-zoom)  $_view(-zoom)
     1191    set _settings(-qw)    $_view(-qw)
     1192    set _settings(-qx)    $_view(-qx)
     1193    set _settings(-qy)    $_view(-qy)
     1194    set _settings(-qz)    $_view(-qz)
     1195    set _settings(-xpan)  $_view(-xpan)
     1196    set _settings(-ypan)  $_view(-ypan)
     1197    set _settings(-zoom)  $_view(-zoom)
    11951198
    11961199    set q [ViewToQuaternion]
     
    12031206    foreach dataobj [get] {
    12041207        foreach comp [$dataobj components] {
    1205             NameTransferFunc $dataobj $comp
     1208            NameTransferFunction $dataobj $comp
    12061209        }
    12071210    }
     
    12191222        }
    12201223        set comp [lindex [$_first components] 0]
    1221         set _activeTf [lindex $_obj2style($_first-$comp) 0]
     1224        set _activeTf [lindex $_dataset2style($_first-$comp) 0]
    12221225    }
    12231226
     
    12531256        return
    12541257    }
    1255     foreach key [array names _serverObjs *-*] {
     1258    foreach key [array names _serverDatasets *-*] {
    12561259        if {[string match $_first-* $key]} {
    12571260            array set style {
     
    12611264            array set style [lindex [$dataobj components -style $comp] 0]
    12621265            if {$what != "-cutplanes" || $style(-cutplanes)} {
    1263                 lappend rlist $_serverObjs($key)
     1266                lappend rlist $_serverDatasets($key)
    12641267            }
    12651268        }
     
    12801283        "in" {
    12811284            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1282             set _settings($this-zoom) $_view(-zoom)
     1285            set _settings(-zoom) $_view(-zoom)
    12831286            SendCmd "camera zoom $_view(-zoom)"
    12841287        }
    12851288        "out" {
    12861289            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1287             set _settings($this-zoom) $_view(-zoom)
     1290            set _settings(-zoom) $_view(-zoom)
    12881291            SendCmd "camera zoom $_view(-zoom)"
    12891292        }
     
    12941297                -qy      0.353553
    12951298                -qz      0.146447
    1296                 -zoom    1.0
    12971299                -xpan    0
    12981300                -ypan    0
     1301                -zoom    1.0
    12991302            }
    13001303            if { $_first != "" } {
     
    13081311            SendCmd "camera orient $q"
    13091312            SendCmd "camera reset"
    1310             set _settings($this-qw)    $_view(-qw)
    1311             set _settings($this-qx)    $_view(-qx)
    1312             set _settings($this-qy)    $_view(-qy)
    1313             set _settings($this-qz)    $_view(-qz)
    1314             set _settings($this-xpan)  $_view(-xpan)
    1315             set _settings($this-ypan)  $_view(-ypan)
    1316             set _settings($this-zoom)  $_view(-zoom)
     1313            set _settings(-qw)    $_view(-qw)
     1314            set _settings(-qx)    $_view(-qx)
     1315            set _settings(-qy)    $_view(-qy)
     1316            set _settings(-qz)    $_view(-qz)
     1317            set _settings(-xpan)  $_view(-xpan)
     1318            set _settings(-ypan)  $_view(-ypan)
     1319            set _settings(-zoom)  $_view(-zoom)
    13171320        }
    13181321    }
     
    13601363                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    13611364                QuaternionToView $q
    1362                 set _settings($this-qw) $_view(-qw)
    1363                 set _settings($this-qx) $_view(-qx)
    1364                 set _settings($this-qy) $_view(-qy)
    1365                 set _settings($this-qz) $_view(-qz)
     1365                set _settings(-qw) $_view(-qw)
     1366                set _settings(-qx) $_view(-qx)
     1367                set _settings(-qy) $_view(-qy)
     1368                set _settings(-qz) $_view(-qz)
    13661369                SendCmd "camera orient $q"
    13671370
     
    13991402        set _view(-ypan) [expr $_view(-ypan) + $y]
    14001403        PanCamera
    1401         set _settings($this-xpan) $_view(-xpan)
    1402         set _settings($this-ypan) $_view(-ypan)
     1404        set _settings(-xpan) $_view(-xpan)
     1405        set _settings(-ypan) $_view(-ypan)
    14031406        return
    14041407    }
     
    14161419        set _view(-ypan) [expr $_view(-ypan) - $dy]
    14171420        PanCamera
    1418         set _settings($this-xpan) $_view(-xpan)
    1419         set _settings($this-ypan) $_view(-ypan)
     1421        set _settings(-xpan) $_view(-xpan)
     1422        set _settings(-ypan) $_view(-ypan)
    14201423    }
    14211424    if { $option == "release" } {
     
    16661669    set comp [lindex [$_first components] 0]
    16671670    set tag $_first-$comp
    1668     #set _activeTf [lindex $_obj2style($tag) 0]
     1671    #set _activeTf [lindex $_dataset2style($tag) 0]
    16691672    if {$w > 0 && $h > 0 && "" != $_activeTf} {
    16701673        #SendCmd "legend $_activeTf $w $h"
     
    16791682
    16801683#
    1681 # NameTransferFunc --
     1684# NameTransferFunction --
    16821685#
    16831686#       Creates a transfer function name based on the <style> settings in the
     
    16931696#              now.
    16941697#
    1695 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } {
     1698itcl::body Rappture::FlowvisViewer::NameTransferFunction { dataobj cname } {
    16961699    array set style {
    16971700        -color BCGYR
     
    17011704    array set style [lindex [$dataobj components -style $cname] 0]
    17021705    set _settings($this-opacity) [expr $style(-opacity) * 100]
    1703     set _obj2style($dataobj-$cname) $cname
    1704     lappend _style2objs($cname) $dataobj $cname
     1706    set _dataset2style($dataobj-$cname) $cname
     1707    lappend _style2datasets($cname) $dataobj $cname
    17051708    return $cname
    17061709}
    17071710
    17081711#
    1709 # ComputeTransferFunc --
     1712# ComputeTransferFunction --
    17101713#
    17111714#   Computes and sends the transfer function to the render server.  It's
     
    17151718#   the alpha map of the transfer function.
    17161719#
    1717 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {
     1720itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } {
    17181721    array set style {
    17191722        -color BCGYR
     
    17221725    }
    17231726    set dataobj ""; set comp ""
    1724     foreach {dataobj comp} $_style2objs($tf) break
     1727    foreach {dataobj comp} $_style2datasets($tf) break
    17251728    if { $dataobj == "" } {
    17261729        return 0
     
    19301933
    19311934# ----------------------------------------------------------------------
    1932 # USAGE: UpdateTransferFuncs
     1935# USAGE: UpdateTransferFunctions
    19331936# ----------------------------------------------------------------------
    19341937itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} {
     
    19931996itcl::body Rappture::FlowvisViewer::limits { cname } {
    19941997    set _limits(v) [list 0.0 1.0]
    1995     if { ![info exists _style2objs($cname)] } {
    1996         puts stderr "no style2objs for $cname cname=($cname)"
     1998    if { ![info exists _style2datasets($cname)] } {
     1999        puts stderr "no _style2datasets for cname=($cname)"
    19972000        return [array get _limits]
    19982001    }
    19992002    set min ""; set max ""
    20002003    foreach tag [GetDatasetsWithComponent $cname] {
    2001         if { ![info exists _serverObjs($tag)] } {
    2002             puts stderr "$tag not in serverObjs?"
     2004        if { ![info exists _serverDatasets($tag)] } {
     2005            puts stderr "$tag not in _serverDatasets?"
    20032006            continue
    20042007        }
     
    23032306        label $inner.${tag}label -text $tag -font "Arial 9"
    23042307        entry $inner.${tag} -font "Arial 9"  -bg white \
    2305             -textvariable [itcl::scope _settings($this-$tag)]
     2308            -textvariable [itcl::scope _settings(-$tag)]
    23062309        bind $inner.${tag} <Return> \
    23072310            [itcl::code $this camera set -${tag}]
     
    23222325itcl::body Rappture::FlowvisViewer::GetFlowInfo { w } {
    23232326    set flowobj ""
    2324     foreach key [array names _obj2flow] {
    2325         set flowobj $_obj2flow($key)
     2327    foreach key [array names _dataset2flow] {
     2328        set flowobj $_dataset2flow($key)
    23262329        break
    23272330    }
     
    25382541itcl::body Rappture::FlowvisViewer::SendFlowCmd { dataobj comp nbytes extents } {
    25392542    set tag "$dataobj-$comp"
    2540     if { ![info exists _obj2flow($tag)] } {
     2543    if { ![info exists _dataset2flow($tag)] } {
    25412544        SendCmd "flow add $tag"
    25422545        SendCmd "$tag data follows $nbytes $extents"
    25432546        return 0
    25442547    }
    2545     set flowobj $_obj2flow($tag)
     2548    set flowobj $_dataset2flow($tag)
    25462549    if { $flowobj == "" } {
    25472550        puts stderr "no flowobj"
     
    29222925    set _view(-ypan) 0.0
    29232926    set _view(-zoom) 1.0
    2924     set _settings($this-xpan) $_view(-xpan)
    2925     set _settings($this-ypan) $_view(-ypan)
    2926     set _settings($this-zoom) $_view(-zoom)
     2927    set _settings(-xpan) $_view(-xpan)
     2928    set _settings(-ypan) $_view(-ypan)
     2929    set _settings(-zoom) $_view(-zoom)
    29272930}
    29282931
     
    29442947    set list ""
    29452948    foreach tag $_volcomponents($cname) {
    2946         if { ![info exists _serverObjs($tag)] } {
     2949        if { ![info exists _serverDatasets($tag)] } {
    29472950            continue
    29482951        }
Note: See TracChangeset for help on using the changeset viewer.