Changeset 5272


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

merge r5270 from trunk

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

    • Property svn:mergeinfo changed
      /trunkmerged: 5270
  • branches/1.3/gui/scripts/flowvisviewer.tcl

    r5257 r5272  
    8383    private method BuildViewTab {}
    8484    private method BuildVolumeTab {}
    85     private method ComputeTransferFunc { tf }
     85    private method ComputeTransferFunction { tf }
    8686    private method Connect {}
    8787    private method CurrentVolumeIds {{what -all}}
    8888    private method Disconnect {}
     89    private method DrawLegend { tf }
    8990    private method EventuallyResize { w h }
    9091    private method EventuallyGoto { nSteps }
     
    9495    private method GetPngImage { widget width height }
    9596    private method InitSettings { args }
    96     private method NameTransferFunc { dataobj comp }
     97    private method NameTransferFunction { dataobj comp }
    9798    private method Pan {option x y}
    9899    private method PanCamera {}
     
    111112    private method SendDataObjs {}
    112113    private method SendFlowCmd { dataobj comp nbytes extents }
    113     private method SendTransferFuncs {}
     114    private method SendTransferFunctions {}
    114115    private method SetOrientation { side }
    115116    private method Slice {option args}
     
    128129
    129130    private variable _arcball ""
    130     private variable _dlist ""     ;# list of data objects
    131     private variable _allDataObjs
    132     private variable _obj2ovride   ;# maps dataobj => style override
    133     private variable _serverObjs   ;# maps dataobj-component to volume ID
    134                                     # in the server
    135     private variable _sendobjs ""  ;# list of data objs to send to 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
     131    private variable _dlist ""         ;# list of data objects
     132    private variable _obj2ovride       ;# maps dataobj => style override
     133    private variable _serverDatasets   ;# maps dataobj-component to volume ID
     134                                        # in the server
     135    private variable _sendobjs ""      ;# list of data objs to send to 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.
     148    private variable _activeTf ""      ;# The currently active transfer function
     149    private variable _first ""         ;# This is the topmost volume.
    150150    private variable _nextToken 0
    151151    private variable _icon 0
    152152    private variable _flow
    153     private common _downloadPopup          ;# download options from popup
    154 
     153
     154    private common _downloadPopup      ;# download options from popup
    155155    private common _hardcopy
    156156    private variable _width 0
     
    184184    $_dispatcher register !send_transfunc
    185185    $_dispatcher dispatch $this !send_transfunc \
    186         "[itcl::code $this SendTransferFuncs]; list"
     186        "[itcl::code $this SendTransferFunctions]; list"
    187187
    188188    # Rebuild event.
     
    234234
    235235    array set _settings [subst {
    236         $this-qw                $_view(-qw)
    237         $this-qx                $_view(-qx)
    238         $this-qy                $_view(-qy)
    239         $this-qz                $_view(-qz)
    240         $this-zoom              $_view(-zoom)
    241         $this-xpan              $_view(-xpan)
    242         $this-ypan              $_view(-ypan)
     236        -qw                     $_view(-qw)
     237        -qx                     $_view(-qx)
     238        -qy                     $_view(-qy)
     239        -qz                     $_view(-qz)
     240        -zoom                   $_view(-zoom)
     241        -xpan                   $_view(-xpan)
     242        -ypan                   $_view(-ypan)
    243243        $this-arrows            0
    244244        $this-currenttime       0
     
    597597            continue
    598598        }
    599         set _obj2flow($dataobj-$comp) $flowobj
     599        set _dataset2flow($dataobj-$comp) $flowobj
    600600    }
    601601    set pos [lsearch -exact $_dlist $dataobj]
    602602    if {$pos < 0} {
    603603        lappend _dlist $dataobj
    604         set _allDataObjs($dataobj) 1
    605604        set _obj2ovride($dataobj-color) $params(-color)
    606605        set _obj2ovride($dataobj-width) $params(-width)
     
    686685            set _dlist [lreplace $_dlist $pos $pos]
    687686            array unset _obj2ovride $dataobj-*
    688             array unset _obj2flow $dataobj-*
    689             array unset _serverObjs $dataobj-*
    690             array unset _obj2style $dataobj-*
     687            array unset _dataset2flow $dataobj-*
     688            array unset _serverDatasets $dataobj-*
     689            array unset _dataset2style $dataobj-*
    691690            set changed 1
    692691        }
     
    695694    if {$changed} {
    696695        # Repair the reverse lookup
    697         foreach tf [array names _style2objs] {
     696        foreach tf [array names _style2datasets] {
    698697            set list {}
    699             foreach {dataobj comp} $_style2objs($tf) break
    700             if { [info exists _serverObjs($dataobj-$comp)] } {
     698            foreach {dataobj comp} $_style2datasets($tf) break
     699            if { [info exists _serverDatasets($dataobj-$comp)] } {
    701700                lappend list $dataobj $comp
    702701            }
    703702            if { $list == "" } {
    704                 array unset _style2objs $tf
     703                array unset _style2datasets $tf
    705704            } else {
    706                 set _style2objs($tf) $list
     705                set _style2datasets($tf) $list
    707706            }
    708707        }
     
    912911
    913912    # disconnected -- no more data sitting on server
    914     array unset _serverObjs
     913    array unset _serverDatasets
    915914    set _sendobjs ""
    916915}
     
    950949                return
    951950            }
    952             NameTransferFunc $dataobj $comp
    953             set _recvObjs($dataobj-$comp) 1
     951            NameTransferFunction $dataobj $comp
     952            set _recvdDatasets($dataobj-$comp) 1
    954953        }
    955954    }
     
    975974            array set _view $location
    976975        }
    977         set _settings($this-qw)    $_view(-qw)
    978         set _settings($this-qx)    $_view(-qx)
    979         set _settings($this-qy)    $_view(-qy)
    980         set _settings($this-qz)    $_view(-qz)
    981         set _settings($this-xpan)  $_view(-xpan)
    982         set _settings($this-ypan)  $_view(-ypan)
    983         set _settings($this-zoom)  $_view(-zoom)
     976        set _settings(-qw)    $_view(-qw)
     977        set _settings(-qx)    $_view(-qx)
     978        set _settings(-qy)    $_view(-qy)
     979        set _settings(-qz)    $_view(-qz)
     980        set _settings(-xpan)  $_view(-xpan)
     981        set _settings(-ypan)  $_view(-ypan)
     982        set _settings(-zoom)  $_view(-zoom)
    984983        set q [ViewToQuaternion]
    985984        $_arcball quaternion $q
     
    993992        # successfully transferred.
    994993        set comp [lindex [$_first components] 0]
    995         set _activeTf [lindex $_obj2style($_first-$comp) 0]
     994        set _activeTf [lindex $_dataset2style($_first-$comp) 0]
    996995    }
    997996
     
    10011000
    10021001# ----------------------------------------------------------------------
    1003 # USAGE: SendTransferFuncs
    1004 # ----------------------------------------------------------------------
    1005 itcl::body Rappture::FlowvisViewer::SendTransferFuncs {} {
     1002# USAGE: SendTransferFunctions
     1003# ----------------------------------------------------------------------
     1004itcl::body Rappture::FlowvisViewer::SendTransferFunctions {} {
    10061005    if { $_activeTf == "" } {
    10071006        puts stderr "no active tf"
     
    10251024    set _settings($this-$tf-thickness) $thickness
    10261025
    1027     foreach key [array names _obj2style $_first-*] {
    1028         if { [info exists _obj2style($key)] } {
    1029             foreach tf $_obj2style($key) {
    1030                 ComputeTransferFunc $tf
     1026    foreach key [array names _dataset2style $_first-*] {
     1027        if { [info exists _dataset2style($key)] } {
     1028            foreach tf $_dataset2style($key) {
     1029                ComputeTransferFunction $tf
    10311030            }
    10321031        }
     
    10711070
    10721071#
    1073 # ReceiveLegend --
    1074 #
    1075 #       The procedure is the response from the render server to each "legend"
    1076 #       command.  The server sends back a "legend" command invoked our
    1077 #       the slave interpreter.  The purpose is to collect data of the image
    1078 #       representing the legend in the canvas.  In addition, the isomarkers
    1079 #       of the active transfer function are displayed.
    1080 #
    1081 #       I don't know is this is the right place to display the isomarkers.
    1082 #       I don't know all the different paths used to draw the plot. There's
    1083 #       "Rebuild", "add", etc.
    1084 #
    1085 itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } {
    1086     if { ![isconnected] } {
    1087         return
    1088     }
    1089     #puts stderr "receive legend $tag $vmin $vmax $size"
    1090     set bytes [ReceiveBytes $size]
    1091     $_image(legend) configure -data $bytes
    1092     ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    1093 
     1072# DrawLegend --
     1073#
     1074itcl::body Rappture::FlowvisViewer::DrawLegend { tag } {
    10941075    set c $itk_component(legend)
    10951076    set w [winfo width $c]
     
    11131094            [itcl::code $this AddIsoMarker %x %y]
    11141095    }
    1115     # Display the markers used by the active transfer function.
    1116     set tf $_obj2style($tag)
     1096
     1097    # Display the markers used by the current transfer function.
     1098    set tf $_dataset2style($tag)
    11171099    array set limits [limits $tf]
    11181100    $c itemconfigure vmin -text [format %.2g $limits(vmin)]
     
    11271109        }
    11281110    }
     1111}
     1112
     1113#
     1114# ReceiveLegend --
     1115#
     1116#       The procedure is the response from the render server to each "legend"
     1117#       command.  The server sends back a "legend" command invoked our
     1118#       the slave interpreter.  The purpose is to collect data of the image
     1119#       representing the legend in the canvas.  In addition, the
     1120#       active transfer function is displayed.
     1121#
     1122itcl::body Rappture::FlowvisViewer::ReceiveLegend { tag vmin vmax size } {
     1123    if { ![isconnected] } {
     1124        return
     1125    }
     1126    #puts stderr "receive legend $tag $vmin $vmax $size"
     1127    set bytes [ReceiveBytes $size]
     1128    $_image(legend) configure -data $bytes
     1129    ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
     1130
     1131    DrawLegend $tag
    11291132}
    11301133
     
    11381141#       doesn't parse 3D data formats, we rely on the server (flowvis) to
    11391142#       tell us what the limits are.  Once we've received the limits to all
    1140 #       the data we've sent (tracked by _recvObjs) we can then determine
     1143#       the data we've sent (tracked by _recvdDatasets) we can then determine
    11411144#       what the transfer functions are for these # volumes.
    11421145#
     
    11581161    set parts [split $tag -]
    11591162    set dataobj [lindex $parts 0]
    1160     set _serverObjs($tag) 0
     1163    set _serverDatasets($tag) 0
    11611164    set _limits($tag-min)  $values(min);  # Minimum value of the volume.
    11621165    set _limits($tag-max)  $values(max);  # Maximum value of the volume.
    1163     unset _recvObjs($tag)
    1164     if { [array size _recvObjs] == 0 } {
     1166    unset _recvdDatasets($tag)
     1167    if { [array size _recvdDatasets] == 0 } {
    11651168        updateTransferFunctions
    11661169    }
     
    12331236            }
    12341237            SendData $data
    1235             NameTransferFunc $dataobj $comp
    1236             set _recvObjs($tag) 1
     1238            NameTransferFunction $dataobj $comp
     1239            set _recvdDatasets($tag) 1
    12371240        }
    12381241    }
     
    12571260
    12581261    }
    1259     set _settings($this-qw)    $_view(-qw)
    1260     set _settings($this-qx)    $_view(-qx)
    1261     set _settings($this-qy)    $_view(-qy)
    1262     set _settings($this-qz)    $_view(-qz)
    1263     set _settings($this-xpan)  $_view(-xpan)
    1264     set _settings($this-ypan)  $_view(-ypan)
    1265     set _settings($this-zoom)  $_view(-zoom)
     1262    set _settings(-qw)    $_view(-qw)
     1263    set _settings(-qx)    $_view(-qx)
     1264    set _settings(-qy)    $_view(-qy)
     1265    set _settings(-qz)    $_view(-qz)
     1266    set _settings(-xpan)  $_view(-xpan)
     1267    set _settings(-ypan)  $_view(-ypan)
     1268    set _settings(-zoom)  $_view(-zoom)
    12661269
    12671270    set q [ViewToQuaternion]
     
    12741277    foreach dataobj [get] {
    12751278        foreach comp [$dataobj components] {
    1276             NameTransferFunc $dataobj $comp
     1279            NameTransferFunction $dataobj $comp
    12771280        }
    12781281    }
     
    12901293        }
    12911294        set comp [lindex [$_first components] 0]
    1292         set _activeTf [lindex $_obj2style($_first-$comp) 0]
     1295        set _activeTf [lindex $_dataset2style($_first-$comp) 0]
    12931296    }
    12941297
     
    13241327        return
    13251328    }
    1326     foreach key [array names _serverObjs *-*] {
     1329    foreach key [array names _serverDatasets *-*] {
    13271330        if {[string match $_first-* $key]} {
    13281331            array set style {
     
    13321335            array set style [lindex [$dataobj components -style $comp] 0]
    13331336            if {$what != "-cutplanes" || $style(-cutplanes)} {
    1334                 lappend rlist $_serverObjs($key)
     1337                lappend rlist $_serverDatasets($key)
    13351338            }
    13361339        }
     
    13511354        "in" {
    13521355            set _view(-zoom) [expr {$_view(-zoom)*1.25}]
    1353             set _settings($this-zoom) $_view(-zoom)
     1356            set _settings(-zoom) $_view(-zoom)
    13541357            SendCmd "camera zoom $_view(-zoom)"
    13551358        }
    13561359        "out" {
    13571360            set _view(-zoom) [expr {$_view(-zoom)*0.8}]
    1358             set _settings($this-zoom) $_view(-zoom)
     1361            set _settings(-zoom) $_view(-zoom)
    13591362            SendCmd "camera zoom $_view(-zoom)"
    13601363        }
     
    13791382            SendCmd "camera orient $q"
    13801383            SendCmd "camera reset"
    1381             set _settings($this-qw)    $_view(-qw)
    1382             set _settings($this-qx)    $_view(-qx)
    1383             set _settings($this-qy)    $_view(-qy)
    1384             set _settings($this-qz)    $_view(-qz)
    1385             set _settings($this-xpan)  $_view(-xpan)
    1386             set _settings($this-ypan)  $_view(-ypan)
    1387             set _settings($this-zoom)  $_view(-zoom)
     1384            set _settings(-qw)    $_view(-qw)
     1385            set _settings(-qx)    $_view(-qx)
     1386            set _settings(-qy)    $_view(-qy)
     1387            set _settings(-qz)    $_view(-qz)
     1388            set _settings(-xpan)  $_view(-xpan)
     1389            set _settings(-ypan)  $_view(-ypan)
     1390            set _settings(-zoom)  $_view(-zoom)
    13881391        }
    13891392    }
     
    14311434                set q [$_arcball rotate $x $y $_click(x) $_click(y)]
    14321435                QuaternionToView $q
    1433                 set _settings($this-qw) $_view(-qw)
    1434                 set _settings($this-qx) $_view(-qx)
    1435                 set _settings($this-qy) $_view(-qy)
    1436                 set _settings($this-qz) $_view(-qz)
     1436                set _settings(-qw) $_view(-qw)
     1437                set _settings(-qx) $_view(-qx)
     1438                set _settings(-qy) $_view(-qy)
     1439                set _settings(-qz) $_view(-qz)
    14371440                SendCmd "camera orient $q"
    14381441
     
    14701473        set _view(-ypan) [expr $_view(-ypan) + $y]
    14711474        PanCamera
    1472         set _settings($this-xpan) $_view(-xpan)
    1473         set _settings($this-ypan) $_view(-ypan)
     1475        set _settings(-xpan) $_view(-xpan)
     1476        set _settings(-ypan) $_view(-ypan)
    14741477        return
    14751478    }
     
    14871490        set _view(-ypan) [expr $_view(-ypan) - $dy]
    14881491        PanCamera
    1489         set _settings($this-xpan) $_view(-xpan)
    1490         set _settings($this-ypan) $_view(-ypan)
     1492        set _settings(-xpan) $_view(-xpan)
     1493        set _settings(-ypan) $_view(-ypan)
    14911494    }
    14921495    if { $option == "release" } {
     
    17461749    set comp [lindex [$_first components] 0]
    17471750    set tag $_first-$comp
    1748     #set _activeTf [lindex $_obj2style($tag) 0]
     1751    #set _activeTf [lindex $_dataset2style($tag) 0]
    17491752    if {$w > 0 && $h > 0 && "" != $_activeTf} {
    17501753        #SendCmd "legend $_activeTf $w $h"
     
    17591762
    17601763#
    1761 # NameTransferFunc --
     1764# NameTransferFunction --
    17621765#
    17631766#       Creates a transfer function name based on the <style> settings in the
     
    17731776#              now.
    17741777#
    1775 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj comp } {
     1778itcl::body Rappture::FlowvisViewer::NameTransferFunction { dataobj cname } {
    17761779    array set style {
    17771780        -color BCGYR
     
    17811784        -transp 50
    17821785    }
    1783     array set style [lindex [$dataobj components -style $comp] 0]
     1786    array set style [lindex [$dataobj components -style $cname] 0]
    17841787    set _settings($this-light) $style(-light)
    17851788    set _settings($this-transp) $style(-transp)
    17861789    set _settings($this-opacity) [expr $style(-opacity) * 100]
    17871790    set tf "$style(-color):$style(-levels):$style(-opacity)"
    1788     set _obj2style($dataobj-$comp) $tf
    1789     lappend _style2objs($tf) $dataobj $comp
     1791    set _dataset2style($dataobj-$cname) $tf
     1792    lappend _style2datasets($tf) $dataobj $cname
    17901793    return $tf
    17911794}
    17921795
    17931796#
    1794 # ComputeTransferFunc --
     1797# ComputeTransferFunction --
    17951798#
    17961799#   Computes and sends the transfer function to the render server.  It's
     
    18001803#   the alpha map of the transfer function.
    18011804#
    1802 itcl::body Rappture::FlowvisViewer::ComputeTransferFunc { tf } {
     1805itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } {
    18031806    array set style {
    18041807        -color BCGYR
     
    18091812    }
    18101813    set dataobj ""; set comp ""
    1811     foreach {dataobj comp} $_style2objs($tf) break
     1814    foreach {dataobj comp} $_style2datasets($tf) break
    18121815    if { $dataobj == "" } {
    18131816        return 0
     
    20082011
    20092012# ----------------------------------------------------------------------
    2010 # USAGE: UpdateTransferFuncs
     2013# USAGE: UpdateTransferFunctions
    20112014# ----------------------------------------------------------------------
    20122015itcl::body Rappture::FlowvisViewer::updateTransferFunctions {} {
     
    20712074    set _limits(vmin) 0.0
    20722075    set _limits(vmax) 1.0
    2073     if { ![info exists _style2objs($tf)] } {
    2074         puts stderr "no style2objs for $tf tf=($tf)"
     2076    if { ![info exists _style2datasets($tf)] } {
     2077        puts stderr "no _style2datasets for $tf tf=($tf)"
    20752078        return [array get _limits]
    20762079    }
     
    20782081    foreach {dataobj comp} $_style2objs($tf) {
    20792082        set tag $dataobj-$comp
    2080         if { ![info exists _serverObjs($tag)] } {
     2083        if { ![info exists _serverDatasets($tag)] } {
    20812084            puts stderr "$tag not in serverObjs?"
    20822085            continue
     
    24002403        label $inner.${tag}label -text $tag -font "Arial 9"
    24012404        entry $inner.${tag} -font "Arial 9"  -bg white \
    2402             -textvariable [itcl::scope _settings($this-$tag)]
     2405            -textvariable [itcl::scope _settings(-$tag)]
    24032406        bind $inner.${tag} <Return> \
    24042407            [itcl::code $this camera set -${tag}]
     
    24192422itcl::body Rappture::FlowvisViewer::GetFlowInfo { w } {
    24202423    set flowobj ""
    2421     foreach key [array names _obj2flow] {
    2422         set flowobj $_obj2flow($key)
     2424    foreach key [array names _dataset2flow] {
     2425        set flowobj $_dataset2flow($key)
    24232426        break
    24242427    }
     
    26352638itcl::body Rappture::FlowvisViewer::SendFlowCmd { dataobj comp nbytes extents } {
    26362639    set tag "$dataobj-$comp"
    2637     if { ![info exists _obj2flow($tag)] } {
     2640    if { ![info exists _dataset2flow($tag)] } {
    26382641        SendCmd "flow add $tag"
    26392642        SendCmd "$tag data follows $nbytes $extents"
    26402643        return 0
    26412644    }
    2642     set flowobj $_obj2flow($tag)
     2645    set flowobj $_dataset2flow($tag)
    26432646    if { $flowobj == "" } {
    26442647        puts stderr "no flowobj"
     
    30193022    set _view(-ypan) 0.0
    30203023    set _view(-zoom) 1.0
    3021     set _settings($this-xpan) $_view(-xpan)
    3022     set _settings($this-ypan) $_view(-ypan)
    3023     set _settings($this-zoom) $_view(-zoom)
    3024 }
     3024    set _settings(-xpan) $_view(-xpan)
     3025    set _settings(-ypan) $_view(-ypan)
     3026    set _settings(-zoom) $_view(-zoom)
     3027}
Note: See TracChangeset for help on using the changeset viewer.