Changeset 5451 for branches


Ignore:
Timestamp:
May 6, 2015 8:22:12 PM (9 years ago)
Author:
ldelgass
Message:

Merge r5376:5381 from trunk

Location:
branches/1.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4

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

    r5449 r5451  
    8080    private method ComputeTransferFunction { tf }
    8181    private method Connect {}
    82     private method CurrentVolumeIds {{what -all}}
     82    private method CurrentDatasets {{what -all}}
    8383    private method Disconnect {}
     84    private method DoResize {}
    8485    private method DrawLegend { tf }
     86    private method EventuallyGoto { nSteps }
     87    private method EventuallyRedrawLegend { }
    8588    private method EventuallyResize { w h }
    86     private method EventuallyGoto { nSteps }
    87     private method EventuallyResizeLegend { }
     89    private method FixLegend {}
    8890    private method GetDatasetsWithComponent { cname }
    8991    private method GetFlowInfo { widget }
     
    103105    private method ReceiveImage { args }
    104106    private method ReceiveLegend { tf vmin vmax size }
    105     private method Resize {}
    106     private method ResizeLegend {}
    107107    private method Rotate {option x y}
    108108    private method SendFlowCmd { dataobj comp nbytes extents }
     
    126126    private variable _dlist ""         ;# list of data objects
    127127    private variable _obj2ovride       ;# maps dataobj => style override
    128     private variable _serverDatasets   ;# maps dataobj-component to volume ID
    129                                         # in the server
     128    private variable _serverDatasets   ;# contains all the dataobj-component
     129                                       ;# to volumes in the server
    130130    private variable _recvdDatasets    ;# list of data objs to send to server
    131131    private variable _dataset2style    ;# maps dataobj-component to transfunc
    132132    private variable _style2datasets   ;# maps tf back to list of
    133                                         # dataobj-components using the tf.
     133                                       ;# dataobj-components using the tf.
    134134    private variable _dataset2flow     ;# Maps dataobj-component to a flow.
    135135
     
    140140    private variable _isomarkers       ;# array of isosurface level values 0..1
    141141    private variable _settings
    142     private variable _activeTf ""      ;# The currently active transfer function
     142    private variable _activeTf ""      ;# Currently active transfer function
    143143    private variable _first ""         ;# This is the topmost volume.
    144     private variable _volcomponents    ;# Array of components found
    145     private variable _componentsList   ;# Array of components found
     144    private variable _volcomponents    ;# Maps component name to list of
     145                                       ;# dataobj-component tags
     146    private variable _componentsList   ;# List of components found
    146147    private variable _nextToken 0
    147148    private variable _icon 0
     
    165166# CONSTRUCTOR
    166167# ----------------------------------------------------------------------
    167 itcl::body Rappture::FlowvisViewer::constructor { hostlist args } {
     168itcl::body Rappture::FlowvisViewer::constructor {hostlist args} {
    168169    set _serverType "nanovis"
    169170
    170171    # Draw legend event
    171172    $_dispatcher register !legend
    172     $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list"
    173 
    174     # Send transferfunctions event
     173    $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list"
     174
     175    # Send transfer functions event
    175176    $_dispatcher register !send_transfunc
    176177    $_dispatcher dispatch $this !send_transfunc \
    177178        "[itcl::code $this SendTransferFunctions]; list"
    178179
    179     # Rebuild event.
     180    # Rebuild event
    180181    $_dispatcher register !rebuild
    181182    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
    182183
    183     # Resize event.
     184    # Resize event
    184185    $_dispatcher register !resize
    185     $_dispatcher dispatch $this !resize "[itcl::code $this Resize]; list"
     186    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
    186187
    187188    $_dispatcher register !play
     
    224225    array set _settings [subst {
    225226        -arrows                 0
    226         -axes                   0
     227        -axesvisible            0
     228        -background             black
    227229        -colormap               BCGYR
    228230        -currenttime            0
    229         -cutplanesVisible       0
     231        -cutplanesvisible       0
    230232        -duration               1:00
    231         -grid                   0
    232         -isosurface             0
    233         -legend                 1
     233        -gridvisible            0
     234        -isosurfaceshading      0
     235        -legendvisible          1
    234236        -lic                    1
    235237        -light                  40
     
    237239        -loop                   0
    238240        -opacity                50
    239         -outline                1
     241        -outlinevisible         1
    240242        -particles              1
    241243        -play                   0
     
    249251        -thickness              350
    250252        -volume                 1
    251         -xcutplane              1
    252         -xcutposition           0
     253        -xcutplaneposition      50
     254        -xcutplanevisible       1
    253255        -xpan                   $_view(-xpan)
    254         -ycutplane              1
    255         -ycutposition           0
     256        -ycutplaneposition      50
     257        -ycutplanevisible       1
    256258        -ypan                   $_view(-ypan)
    257         -zcutplane              1
    258         -zcutposition           0
     259        -zcutplaneposition      50
     260        -zcutplanevisible       1
    259261        -zoom                   $_view(-zoom)
    260262    }]
     
    323325            -onimage [Rappture::icon cutbutton] \
    324326            -offimage [Rappture::icon cutbutton] \
    325             -variable [itcl::scope _settings(-cutplanesVisible)] \
    326             -command [itcl::code $this AdjustSetting -cutplanesVisible]
     327            -variable [itcl::scope _settings(-cutplanesvisible)] \
     328            -command [itcl::code $this AdjustSetting -cutplanesvisible]
    327329    }
    328330    Rappture::Tooltip::for $itk_component(cutplane) \
     
    340342    }
    341343
    342     bind $itk_component(3dview) <Configure> \
    343         [itcl::code $this EventuallyResize %w %h]
    344 
    345344    # Legend
    346345    set _image(legend) [image create photo]
     
    353352    }
    354353    bind $itk_component(legend) <Configure> \
    355         [itcl::code $this EventuallyResizeLegend]
     354        [itcl::code $this EventuallyRedrawLegend]
    356355
    357356    # Hack around the Tk panewindow.  The problem is that the requested
     
    364363        1,0 $itk_component(legend) -fill x
    365364    blt::table configure $itk_component(plotarea) r1 -resize none
     365
    366366    # Create flow controls...
    367 
    368367    itk_component add flowcontrols {
    369368        frame $itk_interior.flowcontrols
     
    572571    $_dispatcher cancel !rebuild
    573572    $_dispatcher cancel !send_transfunc
     573    $_dispatcher cancel !resize
    574574    image delete $_image(plot)
    575575    image delete $_image(legend)
     
    597597    }
    598598    array set params $settings
     599
    599600    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    600601        # can't handle -autocolors yet
    601602        set params(-color) black
    602603    }
    603     foreach comp [$dataobj components] {
    604         set flowobj [$dataobj flowhints $comp]
     604    foreach cname [$dataobj components] {
     605        set flowobj [$dataobj flowhints $cname]
    605606        if { $flowobj == "" } {
    606             puts stderr "no flowhints $dataobj-$comp"
     607            puts stderr "no flowhints $dataobj-$cname"
    607608            continue
    608609        }
    609         set _dataset2flow($dataobj-$comp) $flowobj
     610        set _dataset2flow($dataobj-$cname) $flowobj
    610611    }
    611612    set pos [lsearch -exact $_dlist $dataobj]
     
    637638            # put the dataobj list in order according to -raise options
    638639            set dlist $_dlist
    639             foreach obj $dlist {
    640                 if {[info exists _obj2ovride($obj-raise)] &&
    641                     $_obj2ovride($obj-raise)} {
    642                     set i [lsearch -exact $dlist $obj]
     640            foreach dataobj $dlist {
     641                if {[info exists _obj2ovride($dataobj-raise)] &&
     642                    $_obj2ovride($dataobj-raise)} {
     643                    set i [lsearch -exact $dlist $dataobj]
    643644                    if {$i >= 0} {
    644645                        set dlist [lreplace $dlist $i $i]
    645                         lappend dlist $obj
     646                        lappend dlist $dataobj
    646647                    }
    647648                }
     
    690691        set pos [lsearch -exact $_dlist $dataobj]
    691692        if { $pos >= 0 } {
    692             foreach comp [$dataobj components] {
    693                 array unset _limits $dataobj-$comp-*
    694             }
    695693            set _dlist [lreplace $_dlist $pos $pos]
     694            array unset _limits $dataobj-*
    696695            array unset _obj2ovride $dataobj-*
    697696            array unset _dataset2flow $dataobj-*
     
    706705        foreach tf [array names _style2datasets] {
    707706            set list {}
    708             foreach {dataobj comp} $_style2datasets($tf) break
    709             if { [info exists _serverDatasets($dataobj-$comp)] } {
    710                 lappend list $dataobj $comp
     707            foreach {dataobj cname} $_style2datasets($tf) break
     708            if { [info exists _serverDatasets($dataobj-$cname)] } {
     709                lappend list $dataobj $cname
    711710            }
    712711            if { $list == "" } {
     
    731730itcl::body Rappture::FlowvisViewer::scale {args} {
    732731    array set style {
    733         -color BCGYR
    734         -levels 6
    735         -markers ""
    736         -opacity 0.5
     732        -color    BCGYR
     733        -levels   6
     734        -markers  ""
    737735    }
    738736    array unset _limits
     
    954952    set tf $_activeTf
    955953    if { $_first == "" } {
    956         puts stderr "no first"
     954        puts stderr "first not set"
    957955        return
    958956    }
    959957
    960958    # Ensure that the global thickness setting (in the slider
    961     # settings widget) is used for the active transfer-function. Update
    962     # the values in the _settings varible.
    963 
    964     set value $_settings(-thickness)
     959    # settings widget) is used for the active transfer-function.  Update
     960    # the value in the _settings variable.
     961
    965962    # Scale values between 0.00001 and 0.01000
    966     set thickness [expr {double($value) * 0.0001}]
     963    set thickness [expr {double($_settings(-thickness)) * 0.0001}]
    967964    set _settings($tf-thickness) $thickness
    968965
    969     foreach key [array names _dataset2style $_first-*] {
    970         if { [info exists _dataset2style($key)] } {
    971             foreach tf $_dataset2style($key) {
     966    foreach tag [array names _dataset2style $_first-*] {
     967        if { [info exists _dataset2style($tag)] } {
     968            foreach tf $_dataset2style($tag) {
    972969                ComputeTransferFunction $tf
    973970            }
    974971        }
    975972    }
    976     EventuallyResizeLegend
    977 }
    978 
    979 # ----------------------------------------------------------------------
    980 # USAGE: ReceiveImage -bytes $size -type $type -token $token
     973    EventuallyRedrawLegend
     974}
     975
     976# ----------------------------------------------------------------------
     977# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
    981978#
    982979# Invoked automatically whenever the "image" command comes in from
     
    10251022            -image $_image(legend) -tags colorbar
    10261023        $c create text $lx $ly -anchor sw \
    1027             -fill $itk_option(-plotforeground) -tags "limits vmin"
     1024            -fill $itk_option(-plotforeground) -tags "limits labels vmin"
    10281025        $c create text [expr {$w-$lx}] $ly -anchor se \
    1029             -fill $itk_option(-plotforeground) -tags "limits vmax"
     1026            -fill $itk_option(-plotforeground) -tags "limits labels vmax"
    10301027        $c lower colorbar
    10311028        $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y]
     
    10341031    # Display the markers used by the current transfer function.
    10351032    set tf $_dataset2style($tag)
    1036     foreach {vmin vmax} [limits $tf] break
    1037     $c itemconfigure vmin -text [format %g $vmin]
     1033    foreach {min max} [limits $tf] break
     1034    $c itemconfigure vmin -text [format %g $min]
    10381035    $c coords vmin $lx $ly
    10391036
    1040     $c itemconfigure vmax -text [format %g $vmax]
     1037    $c itemconfigure vmax -text [format %g $max]
    10411038    $c coords vmax [expr {$w-$lx}] $ly
    10421039
     
    10611058        return
    10621059    }
    1063     #puts stderr "receive legend $tag $vmin $vmax $size"
    10641060    set bytes [ReceiveBytes $size]
    10651061    $_image(legend) configure -data $bytes
     
    10941090        return
    10951091    }
     1092
    10961093    # Arguments from server are name value pairs. Stuff them in an array.
    1097     array set values $args
    1098     set tag $values(tag)
     1094    array set info $args
     1095
     1096    set tag $info(tag)
    10991097    set parts [split $tag -]
     1098
     1099    #
     1100    # Volumes don't exist until we're told about them.
     1101    #
    11001102    set dataobj [lindex $parts 0]
    11011103    set _serverDatasets($tag) 0
    1102     set _limits($tag) [list $values(min) $values(max)]
     1104    set _limits($tag) [list $info(min) $info(max)]
     1105
    11031106    unset _recvdDatasets($tag)
    11041107    if { [array size _recvdDatasets] == 0 } {
     
    11071110}
    11081111
    1109 #
    1110 # Rebuild --
    1111 #
    1112 # Called automatically whenever something changes that affects the data
    1113 # in the widget.  Clears any existing data and rebuilds the widget to
    1114 # display new data.
    1115 #
     1112# ----------------------------------------------------------------------
     1113# USAGE: Rebuild
     1114#
     1115# Called automatically whenever something changes that affects the
     1116# data in the widget.  Clears any existing data and rebuilds the
     1117# widget to display new data.
     1118# ----------------------------------------------------------------------
    11161119itcl::body Rappture::FlowvisViewer::Rebuild {} {
    11171120    set w [winfo width $itk_component(3dview)]
     
    11411144        set _height $h
    11421145        $_arcball resize $w $h
    1143         Resize
     1146        DoResize
    11441147    }
    11451148
    11461149    set _first ""
    11471150    foreach dataobj [get] {
    1148         foreach comp [$dataobj components] {
    1149             set tag $dataobj-$comp
     1151        foreach cname [$dataobj components] {
     1152            set tag $dataobj-$cname
    11501153            set isvtk 0
    11511154            # FIXME: Would like to use the type method of the dataobj
     
    11531156            if {[catch {
    11541157                # Send the data as one huge base64-encoded mess -- yuck!
    1155                 set data [$dataobj blob $comp]
     1158                set data [$dataobj blob $cname]
    11561159            }]} {
    1157                 set data [$dataobj vtkdata $comp]
     1160                set data [$dataobj vtkdata $cname]
    11581161                set isvtk 1
    11591162            }
     
    11711174                SendCmd "clientinfo [list $info]"
    11721175            }
    1173             set extents [$dataobj extents $comp]
     1176            set extents [$dataobj extents $cname]
    11741177            # I have a field. Is a vector field or a volume field?
    11751178            if { !$isvtk && $extents == 1 } {
    11761179                SendCmd "volume data follows $nbytes $tag"
    11771180            } else {
    1178                 if {[SendFlowCmd $dataobj $comp $nbytes $extents] < 0} {
     1181                if {[SendFlowCmd $dataobj $cname $nbytes $extents] < 0} {
    11791182                    continue
    11801183                }
    11811184            }
    11821185            SendData $data
    1183             NameTransferFunction $dataobj $comp
     1186            NameTransferFunction $dataobj $cname
    11841187            set _recvdDatasets($tag) 1
    11851188        }
     
    11941197
    11951198    # Reset the camera and other view parameters
    1196     InitSettings -light2side -light \
    1197         -opacity -isosurface -grid -axes -volume -outline \
    1198         -cutplanesVisible -xcutplane -ycutplane -zcutplane
     1199    InitSettings -axesvisible -gridvisible \
     1200        -opacity -light2side -isosurfaceshading \
     1201        -light \
     1202        -volume -outlinevisible -cutplanesvisible \
     1203        -xcutplanevisible -ycutplanevisible -zcutplanevisible \
     1204        -xcutplaneposition -ycutplaneposition -zcutplaneposition
    11991205
    12001206    # nothing to send -- activate the proper volume
     
    12251231
    12261232    foreach dataobj [get] {
    1227         foreach comp [$dataobj components] {
    1228             NameTransferFunction $dataobj $comp
     1233        foreach cname [$dataobj components] {
     1234            NameTransferFunction $dataobj $cname
    12291235        }
    12301236    }
     
    12411247            array set _view $location
    12421248        }
    1243         set comp [lindex [$_first components] 0]
    1244         set _activeTf [lindex $_dataset2style($_first-$comp) 0]
     1249        set cname [lindex [$_first components] 0]
     1250        set _activeTf [lindex $_dataset2style($_first-$cname) 0]
    12451251    }
    12461252
    12471253    # sync the state of slicers
    1248     set vols [CurrentVolumeIds -cutplanes]
     1254    set vols [CurrentDatasets -cutplanes]
    12491255    foreach axis {x y z} {
    1250         set pos [expr {0.01*$_settings(-${axis}cutposition)}]
     1256        set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}]
    12511257        SendCmd "cutplane position $pos $axis $vols"
    12521258    }
    12531259    SendCmd "volume data state $_settings(-volume)"
    1254     EventuallyResizeLegend
     1260    EventuallyRedrawLegend
    12551261
    12561262    # Actually write the commands to the server socket.  If it fails, we don't
     
    12631269
    12641270# ----------------------------------------------------------------------
    1265 # USAGE: CurrentVolumeIds ?-cutplanes?
     1271# USAGE: CurrentDatasets ?-cutplanes?
    12661272#
    12671273# Returns a list of volume server IDs for the current volume being
     
    12691275# of IDs if the current data object has multiple components.
    12701276# ----------------------------------------------------------------------
    1271 itcl::body Rappture::FlowvisViewer::CurrentVolumeIds {{what -all}} {
     1277itcl::body Rappture::FlowvisViewer::CurrentDatasets {{what -all}} {
    12721278    return ""
    12731279    if { $_first == "" } {
    12741280        return
    12751281    }
    1276     foreach key [array names _serverDatasets *-*] {
    1277         if {[string match $_first-* $key]} {
     1282    foreach tag [array names _serverDatasets *-*] {
     1283        if {[string match $_first-* $tag]} {
    12781284            array set style {
    12791285                -cutplanes 1
    12801286            }
    1281             foreach {dataobj comp} [split $key -] break
    1282             array set style [lindex [$dataobj components -style $comp] 0]
     1287            foreach {dataobj cname} [split $tag -] break
     1288            array set style [lindex [$dataobj components -style $cname] 0]
    12831289            if {$what != "-cutplanes" || $style(-cutplanes)} {
    1284                 lappend rlist $_serverDatasets($key)
     1290                lappend rlist $_serverDatasets($tag)
    12851291            }
    12861292        }
     
    14661472# ----------------------------------------------------------------------
    14671473itcl::body Rappture::FlowvisViewer::AdjustSetting {what {value ""}} {
     1474    if {![isconnected]} {
     1475        return
     1476    }
    14681477    switch -- $what {
     1478        "-axesvisible" {
     1479            SendCmd "axis visible $_settings($what)"
     1480        }
     1481        "-background" {
     1482            set bgcolor [$itk_component(background) value]
     1483            array set fgcolors {
     1484                "black" "white"
     1485                "white" "black"
     1486                "grey"  "black"
     1487            }
     1488            configure -plotbackground $bgcolor \
     1489                -plotforeground $fgcolors($bgcolor)
     1490            if { $_first != "" } {
     1491                set comp [lindex [$_first components] 0]
     1492                set tag $_first-$comp
     1493                DrawLegend $tag
     1494            }
     1495        }
    14691496        "-colormap" {
    14701497            set color [$itk_component(colormap) value]
    14711498            set _settings($what) $color
    14721499            #ResetColormap $color
     1500        }
     1501        "-cutplanesvisible" {
     1502            set bool $_settings($what)
     1503            set datasets [CurrentDatasets -cutplanes]
     1504            set tag [lindex $datasets 0]
     1505            SendCmd "cutplane visible $bool $tag"
     1506        }
     1507        "-gridvisible" {
     1508            SendCmd "grid visible $_settings($what)"
     1509        }
     1510        "-isosurfaceshading" {
     1511            if { $_first != "" } {
     1512                set comp [lindex [$_first components] 0]
     1513                set tag $_first-$comp
     1514                set val $_settings($what)
     1515                # This flag isn't implemented in the server
     1516                #SendCmd "$tag configure -isosurface $val"
     1517            }
     1518        }
     1519        "-legendvisible" {
     1520            if { $_settings($what) } {
     1521                blt::table $itk_component(plotarea) \
     1522                    0,0 $itk_component(3dview) -fill both \
     1523                    1,0 $itk_component(legend) -fill x
     1524                blt::table configure $itk_component(plotarea) r1 -resize none
     1525            } else {
     1526                blt::table forget $itk_component(legend)
     1527            }
    14731528        }
    14741529        "-light" {
     
    14991554            }
    15001555        }
     1556        "-outlinevisible" {
     1557            if { $_first != "" } {
     1558                set comp [lindex [$_first components] 0]
     1559                set tag $_first-$comp
     1560                SendCmd "$tag configure -outline $_settings($what)"
     1561            }
     1562        }
    15011563        "-thickness" {
    15021564            if { $_first != "" && $_activeTf != "" } {
     
    15091571            }
    15101572        }
    1511         "-outline" {
    1512             if { $_first != "" } {
    1513                 set comp [lindex [$_first components] 0]
    1514                 set tag $_first-$comp
    1515                 SendCmd "$tag configure -outline $_settings($what)"
    1516             }
    1517         }
    1518         "-isosurface" {
    1519             if { [isconnected] } {
    1520                 SendCmd "volume shading isosurface $_settings($what)"
    1521             }
    1522         }
    1523         "-grid" {
    1524             if { [isconnected] } {
    1525                 SendCmd "grid visible $_settings($what)"
    1526             }
    1527         }
    1528         "-axes" {
    1529             if { [isconnected] } {
    1530                 SendCmd "axis visible $_settings($what)"
    1531             }
    1532         }
    1533         "-legend" {
    1534             if { $_settings($what) } {
    1535                 blt::table $itk_component(plotarea) \
    1536                     0,0 $itk_component(3dview) -fill both \
    1537                     1,0 $itk_component(legend) -fill x
    1538                 blt::table configure $itk_component(plotarea) r1 -resize none
    1539             } else {
    1540                 blt::table forget $itk_component(legend)
    1541             }
    1542         }
    15431573        "-volume" {
    15441574            if { $_first != "" } {
     
    15481578            }
    15491579        }
    1550         "-cutplanesVisible" {
    1551             set bool $_settings($what)
    1552             set datasets [CurrentVolumeIds -cutplanes]
     1580        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
     1581            set axis [string range $what 1 1]
     1582            set pos [expr $_settings($what) * 0.01]
     1583            # We only set cutplanes on the first dataset.
     1584            set datasets [CurrentDatasets -cutplanes]
    15531585            set tag [lindex $datasets 0]
    1554             SendCmd "cutplane visible $bool $tag"
    1555         }
    1556         "-xcutplane" - "-ycutplane" - "-zcutplane" {
     1586            SendCmd "cutplane position $pos $axis $tag"
     1587        }
     1588        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
    15571589            set axis [string range $what 1 1]
    15581590            set bool $_settings($what)
    1559             if { [isconnected] } {
    1560                 set vols [CurrentVolumeIds -cutplanes]
    1561                 SendCmd "cutplane state $bool $axis $vols"
    1562             }
     1591            # We only set cutplanes on the first dataset.
     1592            set datasets [CurrentDatasets -cutplanes]
     1593            set tag [lindex $datasets 0]
     1594            SendCmd "cutplane state $bool $axis $tag"
    15631595            if { $bool } {
    15641596                $itk_component(${axis}CutScale) configure -state normal \
     
    15761608
    15771609# ----------------------------------------------------------------------
    1578 # USAGE: ResizeLegend
     1610# USAGE: FixLegend
    15791611#
    15801612# Used internally to update the legend area whenever it changes size
     
    15821614# for the current field.
    15831615# ----------------------------------------------------------------------
    1584 itcl::body Rappture::FlowvisViewer::ResizeLegend {} {
     1616itcl::body Rappture::FlowvisViewer::FixLegend {} {
    15851617    set _resizeLegendPending 0
    15861618    set lineht [font metrics $itk_option(-font) -linespace]
     
    15971629        #SendCmd "legend $_activeTf $w $h"
    15981630        SendCmd "$tag legend $w $h"
    1599     } else {
    1600     # Can't do this as this will remove the items associated with the
    1601     # isomarkers.
    1602 
    1603     #$itk_component(legend) delete all
    16041631    }
    16051632}
     
    16211648    }
    16221649    array set style [lindex [$dataobj components -style $cname] 0]
     1650    # Some tools erroneously set -opacity to 1 in style, so
     1651    # override the requested opacity for now
     1652    set style(-opacity) 0.5
    16231653    set _settings(-opacity) [expr $style(-opacity) * 100]
    16241654    set _dataset2style($dataobj-$cname) $cname
     
    16301660# ComputeTransferFunction --
    16311661#
    1632 #   Computes and sends the transfer function to the render server.  It's
    1633 #   assumed that the volume data limits are known and that the global
    1634 #   transfer-functions slider values have be setup.  Both parts are
    1635 #   needed to compute the relative value (location) of the marker, and
    1636 #   the alpha map of the transfer function.
     1662#       Computes and sends the transfer function to the render server.  It's
     1663#       assumed that the volume data limits are known and that the global
     1664#       transfer-functions slider values have been set up.  Both parts are
     1665#       needed to compute the relative value (location) of the marker, and
     1666#       the alpha map of the transfer function.
    16371667#
    16381668itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } {
     
    16421672        -opacity 0.5
    16431673    }
    1644     set dataobj ""; set comp ""
    1645     foreach {dataobj comp} $_style2datasets($tf) break
     1674    set dataobj ""; set cname ""
     1675    foreach {dataobj cname} $_style2datasets($tf) break
    16461676    if { $dataobj == "" } {
    16471677        return 0
    16481678    }
    1649     array set style [lindex [$dataobj components -style $comp] 0]
     1679    array set style [lindex [$dataobj components -style $cname] 0]
     1680    # Some tools erroneously set -opacity to 1 in style, so
     1681    # override the requested opacity for now
     1682    set style(-opacity) 0.5
    16501683
    16511684    # We have to parse the style attributes for a volume using this
     
    17361769    }
    17371770    SendCmd "transfunc define $tf { $cmap } { $amap }"
    1738     return [SendCmd "$dataobj-$comp configure -transferfunction $tf"]
     1771    return [SendCmd "$dataobj-$cname configure -transferfunction $tf"]
    17391772}
    17401773
     
    19431976    $inner configure -borderwidth 4
    19441977
    1945     checkbutton $inner.isosurface \
    1946         -text "Isosurface shading" \
    1947         -variable [itcl::scope _settings(-isosurface)] \
    1948         -command [itcl::code $this AdjustSetting -isosurface] \
    1949         -font "Arial 9"
    1950 
     1978    # General options
    19511979    checkbutton $inner.axes \
    19521980        -text "Axes" \
    1953         -variable [itcl::scope _settings(-axes)] \
    1954         -command [itcl::code $this AdjustSetting -axes] \
     1981        -variable [itcl::scope _settings(-axesvisible)] \
     1982        -command [itcl::code $this AdjustSetting -axesvisible] \
    19551983        -font "Arial 9"
    19561984
    19571985    checkbutton $inner.grid \
    19581986        -text "Grid" \
    1959         -variable [itcl::scope _settings(-grid)] \
    1960         -command [itcl::code $this AdjustSetting -grid] \
     1987        -variable [itcl::scope _settings(-gridvisible)] \
     1988        -command [itcl::code $this AdjustSetting -gridvisible] \
    19611989        -font "Arial 9"
     1990
     1991    checkbutton $inner.legend \
     1992        -text "Legend" \
     1993        -variable [itcl::scope _settings(-legendvisible)] \
     1994        -command [itcl::code $this AdjustSetting -legendvisible] \
     1995        -font "Arial 9"
     1996
     1997    label $inner.background_l -text "Background" -font "Arial 9"
     1998    itk_component add background {
     1999        Rappture::Combobox $inner.background -width 10 -editable no
     2000    }
     2001    $inner.background choices insert end \
     2002        "black" "black" \
     2003        "white" "white" \
     2004        "grey"  "grey"
     2005
     2006    $itk_component(background) value $_settings(-background)
     2007    bind $inner.background <<Value>> \
     2008        [itcl::code $this AdjustSetting -background]
     2009
     2010    # Dataset options
     2011    label $inner.flow_l -text "Flow" -font "Arial 9 bold"
    19622012
    19632013    checkbutton $inner.outline \
    19642014        -text "Outline" \
    1965         -variable [itcl::scope _settings(-outline)] \
    1966         -command [itcl::code $this AdjustSetting -outline] \
    1967         -font "Arial 9"
    1968 
    1969     checkbutton $inner.legend \
    1970         -text "Legend" \
    1971         -variable [itcl::scope _settings(-legend)] \
    1972         -command [itcl::code $this AdjustSetting -legend] \
     2015        -variable [itcl::scope _settings(-outlinevisible)] \
     2016        -command [itcl::code $this AdjustSetting -outlinevisible] \
    19732017        -font "Arial 9"
    19742018
     
    19792023        -font "Arial 9"
    19802024
    1981     checkbutton $inner.particles \
    1982         -text "Particles" \
    1983         -variable [itcl::scope _settings(-particles)] \
    1984         -command [itcl::code $this AdjustSetting -particles] \
    1985         -font "Arial 9"
    1986 
    1987     checkbutton $inner.lic \
    1988         -text "Lic" \
    1989         -variable [itcl::scope _settings(-lic)] \
    1990         -command [itcl::code $this AdjustSetting -lic] \
    1991         -font "Arial 9"
    1992 
    19932025    frame $inner.frame
    19942026
    19952027    blt::table $inner \
    1996         0,0 $inner.axes  -cspan 2 -anchor w \
    1997         1,0 $inner.grid  -cspan 2 -anchor w \
    1998         2,0 $inner.outline  -cspan 2 -anchor w \
    1999         3,0 $inner.volume  -cspan 2 -anchor w \
    2000         4,0 $inner.legend  -cspan 2 -anchor w
     2028        0,0 $inner.axes -cspan 2 -anchor w \
     2029        1,0 $inner.grid -cspan 2 -anchor w \
     2030        2,0 $inner.legend -cspan 2 -anchor w \
     2031        3,0 $inner.background_l -anchor e -pady 2 \
     2032        3,1 $inner.background -fill x \
     2033        4,0 $inner.flow_l -anchor w \
     2034        5,0 $inner.outline -cspan 2 -anchor w \
     2035        6,0 $inner.volume -cspan 2 -anchor w \
    20012036
    20022037    bind $inner <Map> [itcl::code $this GetFlowInfo $inner]
    20032038
    2004     blt::table configure $inner r* -resize none
    2005     blt::table configure $inner r5 -resize expand
     2039    blt::table configure $inner c* r* -resize none
     2040    blt::table configure $inner c2 r7 -resize expand
    20062041}
    20072042
     
    20212056        -font "Arial 9"
    20222057
    2023     label $inner.shading -text "Shading:" -font $fg
     2058    label $inner.lighting_l \
     2059        -text "Lighting / Material Properties" \
     2060        -font "Arial 9 bold"
     2061
     2062    checkbutton $inner.isosurface -text "Isosurface shading" -font $fg \
     2063        -variable [itcl::scope _settings(-isosurfaceshading)] \
     2064        -command [itcl::code $this AdjustSetting -isosurfaceshading]
    20242065
    20252066    checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \
     
    20342075    label $inner.bright -text "Surface" -font $fg
    20352076
    2036     label $inner.clear -text "Clear" -font $fg
     2077    # Opacity
     2078    label $inner.opacity_l -text "Opacity" -font $fg
    20372079    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    20382080        -variable [itcl::scope _settings(-opacity)] \
    20392081        -width 10 \
    20402082        -showvalue off -command [itcl::code $this AdjustSetting -opacity]
    2041     label $inner.opaque -text "Opaque" -font $fg
    2042 
     2083
     2084    label $inner.transferfunction_l \
     2085        -text "Transfer Function" -font "Arial 9 bold"
     2086
     2087    # Tooth thickness
    20432088    label $inner.thin -text "Thin" -font $fg
    20442089    ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \
     
    20482093    label $inner.thick -text "Thick" -font $fg
    20492094
    2050     label $inner.colormap_l -text "Colormap" -font "Arial 9"
     2095    # Colormap
     2096    label $inner.colormap_l -text "Colormap" -font $fg
    20512097    itk_component add colormap {
    20522098        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    20542100
    20552101    $inner.colormap choices insert end [GetColormapList -includeNone]
    2056     $itk_component(colormap) value "BCGYR"
    20572102    bind $inner.colormap <<Value>> \
    20582103        [itcl::code $this AdjustSetting -colormap]
     2104    $itk_component(colormap) value "BCGYR"
     2105    set _settings(-colormap) "BCGYR"
    20592106
    20602107    blt::table $inner \
    20612108        0,0 $inner.vol -cspan 4 -anchor w -pady 2 \
    2062         1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \
     2109        1,0 $inner.lighting_l -cspan 4 -anchor w -pady {10 2} \
    20632110        2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \
    20642111        3,0 $inner.dim -anchor e -pady 2 \
    20652112        3,1 $inner.light -cspan 2 -pady 2 -fill x \
    20662113        3,3 $inner.bright -anchor w -pady 2 \
    2067         4,0 $inner.clear -anchor e -pady 2 \
    2068         4,1 $inner.opacity -cspan 2 -pady 2 -fill x \
    2069         4,3 $inner.opaque -anchor w -pady 2 \
     2114        4,0 $inner.opacity_l -anchor e -pady 2 \
     2115        4,1 $inner.opacity -cspan 3 -pady 2 -fill x \
    20702116        5,0 $inner.thin -anchor e -pady 2 \
    2071         5,1 $inner.thickness -cspan 2 -pady 2 -fill x\
     2117        5,1 $inner.thickness -cspan 2 -pady 2 -fill x \
    20722118        5,3 $inner.thick -anchor w -pady 2
    20732119
     
    20822128    $inner configure -borderwidth 4
    20832129
     2130    checkbutton $inner.visible \
     2131        -text "Show Cutplanes" \
     2132        -variable [itcl::scope _settings(-cutplanesvisible)] \
     2133        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
     2134        -font "Arial 9"
     2135
    20842136    # X-value slicer...
    20852137    itk_component add xCutButton {
     
    20872139            -onimage [Rappture::icon x-cutplane] \
    20882140            -offimage [Rappture::icon x-cutplane] \
    2089             -command [itcl::code $this AdjustSetting -xcutplane] \
    2090             -variable [itcl::scope _settings(-xcutplane)]
     2141            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
     2142            -variable [itcl::scope _settings(-xcutplanevisible)]
    20912143    }
    20922144    Rappture::Tooltip::for $itk_component(xCutButton) \
     
    20992151            -borderwidth 1 -highlightthickness 0 \
    21002152            -command [itcl::code $this Slice move x] \
    2101             -variable [itcl::scope _settings(-xcutposition)]
     2153            -variable [itcl::scope _settings(-xcutplaneposition)]
    21022154    } {
    21032155        usual
     
    21152167            -onimage [Rappture::icon y-cutplane] \
    21162168            -offimage [Rappture::icon y-cutplane] \
    2117             -command [itcl::code $this AdjustSetting -ycutplane] \
    2118             -variable [itcl::scope _settings(-ycutplane)]
     2169            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
     2170            -variable [itcl::scope _settings(-ycutplanevisible)]
    21192171    }
    21202172    Rappture::Tooltip::for $itk_component(yCutButton) \
     
    21272179            -borderwidth 1 -highlightthickness 0 \
    21282180            -command [itcl::code $this Slice move y] \
    2129             -variable [itcl::scope _settings(-ycutposition)]
     2181            -variable [itcl::scope _settings(-ycutplaneposition)]
    21302182    } {
    21312183        usual
     
    21432195            -onimage [Rappture::icon z-cutplane] \
    21442196            -offimage [Rappture::icon z-cutplane] \
    2145             -command [itcl::code $this AdjustSetting -zcutplane] \
    2146             -variable [itcl::scope _settings(-zcutplane)]
     2197            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
     2198            -variable [itcl::scope _settings(-zcutplanevisible)]
    21472199    }
    21482200    Rappture::Tooltip::for $itk_component(zCutButton) \
     
    21552207            -borderwidth 1 -highlightthickness 0 \
    21562208            -command [itcl::code $this Slice move z] \
    2157             -variable [itcl::scope _settings(-zcutposition)]
     2209            -variable [itcl::scope _settings(-zcutplaneposition)]
    21582210    } {
    21592211        usual
     
    21622214    $itk_component(zCutScale) set 50
    21632215    $itk_component(zCutScale) configure -state disabled
    2164     #$itk_component(zCutScale) configure -state disabled
    21652216    Rappture::Tooltip::for $itk_component(zCutScale) \
    21662217        "@[itcl::code $this SlicerTip z]"
    21672218
    21682219    blt::table $inner \
    2169         1,1 $itk_component(xCutButton) \
    2170         1,2 $itk_component(yCutButton) \
    2171         1,3 $itk_component(zCutButton) \
    2172         0,1 $itk_component(xCutScale) \
    2173         0,2 $itk_component(yCutScale) \
    2174         0,3 $itk_component(zCutScale) \
    2175 
    2176     blt::table configure $inner r0 r1 c* -resize none
    2177     blt::table configure $inner r2 c4 -resize expand
     2220        0,1 $inner.visible -anchor w -pady 2 -cspan 4 \
     2221        1,1 $itk_component(xCutScale) \
     2222        1,2 $itk_component(yCutScale) \
     2223        1,3 $itk_component(zCutScale) \
     2224        2,1 $itk_component(xCutButton) \
     2225        2,2 $itk_component(yCutButton) \
     2226        2,3 $itk_component(zCutButton)
     2227
     2228    blt::table configure $inner r0 r1 r2 c* -resize none
     2229    blt::table configure $inner r3 c4 -resize expand
    21782230    blt::table configure $inner c0 -width 2
    21792231    blt::table configure $inner c1 c2 c3 -padx 2
     
    22362288    set inner [frame $w.frame]
    22372289    blt::table $w \
    2238         5,0 $inner -fill both -cspan 2 -anchor nw
     2290        7,0 $inner -fill both -cspan 2 -anchor nw
    22392291    array set hints [$flowobj hints]
    22402292    checkbutton $inner.showstreams -text "Streams Plane" \
     
    23492401            set axis [lindex $args 0]
    23502402            set newval [lindex $args 1]
     2403
    23512404            set newpos [expr {0.01*$newval}]
    2352 
    2353             # show the current value in the readout
    2354 
    2355             set ids [CurrentVolumeIds -cutplanes]
    2356             SendCmd "cutplane position $newpos $axis $ids"
     2405            set datasets [CurrentDatasets -cutplanes]
     2406            set tag [lindex $datasets 0]
     2407            SendCmd "cutplane position $newpos $axis $tag"
    23572408        }
    23582409        default {
     
    23732424}
    23742425
    2375 itcl::body Rappture::FlowvisViewer::Resize {} {
     2426itcl::body Rappture::FlowvisViewer::DoResize {} {
    23762427    $_arcball resize $_width $_height
    23772428    SendCmd "screen size $_width $_height"
     
    23892440}
    23902441
    2391 itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} {
     2442itcl::body Rappture::FlowvisViewer::EventuallyRedrawLegend {} {
    23922443    if { !$_resizeLegendPending } {
    23932444        $_dispatcher event -after 100 !legend
     
    24052456
    24062457#  camera --
     2458#
    24072459itcl::body Rappture::FlowvisViewer::camera {option args} {
    24082460    switch -- $option {
     
    24122464        "set" {
    24132465            set what [lindex $args 0]
    2414             set x $_settings(${this}${what})
     2466            set x $_settings($what)
    24152467            set code [catch { string is double $x } result]
    24162468            if { $code != 0 || !$result } {
    2417                 set _settings(${this}${what}) $_view($what)
     2469                set _settings($what) $_view($what)
    24182470                return
    24192471            }
    24202472            switch -- $what {
    24212473                "-xpan" - "-ypan" {
    2422                     set _view($what) $_settings(${this}${what})
     2474                    set _view($what) $_settings($what)
    24232475                    PanCamera
    24242476                }
    24252477                "-qx" - "-qy" - "-qz" - "-qw" {
    2426                     set _view($what) $_settings(${this}${what})
     2478                    set _view($what) $_settings($what)
    24272479                    set q [ViewToQuaternion]
    24282480                    $_arcball quaternion $q
     
    24302482                }
    24312483                "-zoom" {
    2432                     set _view($what) $_settings(${this}${what})
     2484                    set _view($what) $_settings($what)
    24332485                    SendCmd "camera zoom $_view($what)"
    24342486                }
     
    24512503    }
    24522504    SendCmd "if {\[flow exists $tag\]} {flow delete $tag}"
    2453     array set info  [$flowobj hints]
     2505    array set info [$flowobj hints]
    24542506    set _settings(-volume) $info(volume)
    2455     set _settings(-outline) $info(outline)
     2507    set _settings(-outlinevisible) $info(outline)
    24562508    set _settings(-arrows) $info(arrows)
    24572509    set _settings(-duration) $info(duration)
     
    26212673}
    26222674
    2623 itcl::body Rappture::FlowvisViewer::WaitIcon  { option widget } {
     2675itcl::body Rappture::FlowvisViewer::WaitIcon { option widget } {
    26242676    switch -- $option {
    26252677        "start" {
     
    28202872    SendCmd "camera orient $q"
    28212873    SendCmd "camera reset"
    2822     set _view(-xpan) 0.0
    2823     set _view(-ypan) 0.0
     2874    set _view(-xpan) 0
     2875    set _view(-ypan) 0
    28242876    set _view(-zoom) 1.0
    28252877    set _settings(-xpan) $_view(-xpan)
     
    28282880}
    28292881
    2830 # Reset global settings from dataset's settings.
     2882#
     2883# BuildVolumeComponents --
     2884#
     2885#    This is called from the "scale" method which is called when a new
     2886#    dataset is added or deleted.  It repopulates the dropdown menu of
     2887#    volume component names.  It sets the current component to the first
     2888#    component in the list (of components found).  Finally, if there is
     2889#    only one component, don't display the label or the combobox in the
     2890#    volume settings tab.
     2891#
    28312892itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} {
    28322893    $itk_component(volcomponents) choices delete 0 end
     
    28382899}
    28392900
    2840 # Reset global settings from dataset's settings.
     2901#
     2902# GetDatasetsWithComponents --
     2903#
     2904#    Returns a list of all the datasets (known by the combination of their
     2905#    data object and component name) that match the given component name.
     2906#    For example, this is used where we want to change the settings of
     2907#    volumes that have the current component.
     2908#
    28412909itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } {
    28422910    if { ![info exists _volcomponents($cname)] } {
Note: See TracChangeset for help on using the changeset viewer.