Changeset 5455 for branches/1.3


Ignore:
Timestamp:
May 7, 2015, 3:52:28 AM (10 years ago)
Author:
ldelgass
Message:

Merge r5376:5381 from trunk + sync with 1.3 branch

Location:
branches/1.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

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

    r5454 r5455  
    7676    private method BuildCutplanesTab {}
    7777    private method BuildViewTab {}
     78    private method BuildVolumeComponents {}
    7879    private method BuildVolumeTab {}
    7980    private method ComputeTransferFunction { tf }
    8081    private method Connect {}
    81     private method CurrentVolumeIds {{what -all}}
     82    private method CurrentDatasets {{what -all}}
    8283    private method Disconnect {}
     84    private method DoResize {}
    8385    private method DrawLegend { tf }
     86    private method EventuallyGoto { nSteps }
     87    private method EventuallyRedrawLegend { }
    8488    private method EventuallyResize { w h }
    85     private method EventuallyGoto { nSteps }
    86     private method EventuallyResizeLegend { }
     89    private method FixLegend {}
     90    private method GetDatasetsWithComponent { cname }
    8791    private method GetFlowInfo { widget }
    8892    private method GetMovie { widget width height }
     
    101105    private method ReceiveImage { args }
    102106    private method ReceiveLegend { tf vmin vmax size }
    103     private method Resize {}
    104     private method ResizeLegend {}
    105107    private method Rotate {option x y}
    106108    private method SendFlowCmd { dataobj comp nbytes extents }
     
    124126    private variable _dlist ""         ;# list of data objects
    125127    private variable _obj2ovride       ;# maps dataobj => style override
    126     private variable _serverDatasets   ;# maps dataobj-component to volume ID
    127                                         # in the server
     128    private variable _serverDatasets   ;# contains all the dataobj-component
     129                                       ;# to volumes in the server
    128130    private variable _recvdDatasets    ;# list of data objs to send to server
    129131    private variable _dataset2style    ;# maps dataobj-component to transfunc
    130132    private variable _style2datasets   ;# maps tf back to list of
    131                                         # dataobj-components using the tf.
     133                                       ;# dataobj-components using the tf.
    132134    private variable _dataset2flow     ;# Maps dataobj-component to a flow.
    133135
     
    138140    private variable _isomarkers       ;# array of isosurface level values 0..1
    139141    private variable _settings
    140     private variable _activeTf ""      ;# The currently active transfer function
     142    private variable _activeTf ""      ;# Currently active transfer function
    141143    private variable _first ""         ;# This is the topmost volume.
     144    private variable _volcomponents    ;# Maps component name to list of
     145                                       ;# dataobj-component tags
     146    private variable _componentsList   ;# List of components found
    142147    private variable _nextToken 0
    143148    private variable _icon 0
     
    161166# CONSTRUCTOR
    162167# ----------------------------------------------------------------------
    163 itcl::body Rappture::FlowvisViewer::constructor { hostlist args } {
     168itcl::body Rappture::FlowvisViewer::constructor {hostlist args} {
    164169    set _serverType "nanovis"
    165170
    166171    # Draw legend event
    167172    $_dispatcher register !legend
    168     $_dispatcher dispatch $this !legend "[itcl::code $this ResizeLegend]; list"
    169 
    170     # Send transferfunctions event
     173    $_dispatcher dispatch $this !legend "[itcl::code $this FixLegend]; list"
     174
     175    # Send transfer functions event
    171176    $_dispatcher register !send_transfunc
    172177    $_dispatcher dispatch $this !send_transfunc \
    173178        "[itcl::code $this SendTransferFunctions]; list"
    174179
    175     # Rebuild event.
     180    # Rebuild event
    176181    $_dispatcher register !rebuild
    177182    $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list"
    178183
    179     # Resize event.
     184    # Resize event
    180185    $_dispatcher register !resize
    181     $_dispatcher dispatch $this !resize "[itcl::code $this Resize]; list"
     186    $_dispatcher dispatch $this !resize "[itcl::code $this DoResize]; list"
    182187
    183188    $_dispatcher register !play
     
    221226    array set _settings [subst {
    222227        -arrows                 0
    223         -axes                   0
     228        -axesvisible            0
     229        -background             black
    224230        -colormap               BCGYR
    225231        -currenttime            0
    226         -cutplanesVisible       0
     232        -cutplanesvisible       0
    227233        -duration               1:00
    228         -grid                   0
    229         -isosurface             0
    230         -legend                 1
     234        -gridvisible            0
     235        -isosurfaceshading      0
     236        -legendvisible          1
    231237        -lic                    1
    232238        -light                  40
     
    234240        -loop                   0
    235241        -opacity                50
    236         -outline                1
     242        -outlinevisible         1
    237243        -particles              1
    238244        -play                   0
     
    246252        -thickness              350
    247253        -volume                 1
    248         -xcutplane              1
    249         -xcutposition           0
     254        -xcutplaneposition      50
     255        -xcutplanevisible       1
    250256        -xpan                   $_view(-xpan)
    251         -ycutplane              1
    252         -ycutposition           0
     257        -ycutplaneposition      50
     258        -ycutplanevisible       1
    253259        -ypan                   $_view(-ypan)
    254         -zcutplane              1
    255         -zcutposition           0
     260        -zcutplaneposition      50
     261        -zcutplanevisible       1
    256262        -zoom                   $_view(-zoom)
    257263    }]
     
    320326            -onimage [Rappture::icon cutbutton] \
    321327            -offimage [Rappture::icon cutbutton] \
    322             -variable [itcl::scope _settings(-cutplanesVisible)] \
    323             -command [itcl::code $this AdjustSetting -cutplanesVisible]
     328            -variable [itcl::scope _settings(-cutplanesvisible)] \
     329            -command [itcl::code $this AdjustSetting -cutplanesvisible]
    324330    }
    325331    Rappture::Tooltip::for $itk_component(cutplane) \
     
    337343    }
    338344
    339     bind $itk_component(3dview) <Configure> \
    340         [itcl::code $this EventuallyResize %w %h]
    341 
    342345    # Legend
    343346    set _image(legend) [image create photo]
     
    350353    }
    351354    bind $itk_component(legend) <Configure> \
    352         [itcl::code $this EventuallyResizeLegend]
     355        [itcl::code $this EventuallyRedrawLegend]
    353356
    354357    # Hack around the Tk panewindow.  The problem is that the requested
     
    361364        1,0 $itk_component(legend) -fill x
    362365    blt::table configure $itk_component(plotarea) r1 -resize none
     366
    363367    # Create flow controls...
    364 
    365368    itk_component add flowcontrols {
    366369        frame $itk_interior.flowcontrols
     
    569572    $_dispatcher cancel !rebuild
    570573    $_dispatcher cancel !send_transfunc
     574    $_dispatcher cancel !resize
    571575    image delete $_image(plot)
    572576    image delete $_image(legend)
     
    594598    }
    595599    array set params $settings
     600
    596601    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    597602        # can't handle -autocolors yet
    598603        set params(-color) black
    599604    }
    600     foreach comp [$dataobj components] {
    601         set flowobj [$dataobj flowhints $comp]
     605    foreach cname [$dataobj components] {
     606        set flowobj [$dataobj flowhints $cname]
    602607        if { $flowobj == "" } {
    603             puts stderr "no flowhints $dataobj-$comp"
     608            puts stderr "no flowhints $dataobj-$cname"
    604609            continue
    605610        }
    606         set _dataset2flow($dataobj-$comp) $flowobj
     611        set _dataset2flow($dataobj-$cname) $flowobj
    607612    }
    608613    set pos [lsearch -exact $_dlist $dataobj]
     
    634639            # put the dataobj list in order according to -raise options
    635640            set dlist $_dlist
    636             foreach obj $dlist {
    637                 if {[info exists _obj2ovride($obj-raise)] &&
    638                     $_obj2ovride($obj-raise)} {
    639                     set i [lsearch -exact $dlist $obj]
     641            foreach dataobj $dlist {
     642                if {[info exists _obj2ovride($dataobj-raise)] &&
     643                    $_obj2ovride($dataobj-raise)} {
     644                    set i [lsearch -exact $dlist $dataobj]
    640645                    if {$i >= 0} {
    641646                        set dlist [lreplace $dlist $i $i]
    642                         lappend dlist $obj
     647                        lappend dlist $dataobj
    643648                    }
    644649                }
     
    703708        foreach tf [array names _style2datasets] {
    704709            set list {}
    705             foreach {dataobj comp} $_style2datasets($tf) break
    706             if { [info exists _serverDatasets($dataobj-$comp)] } {
    707                 lappend list $dataobj $comp
     710            foreach {dataobj cname} $_style2datasets($tf) break
     711            if { [info exists _serverDatasets($dataobj-$cname)] } {
     712                lappend list $dataobj $cname
    708713            }
    709714            if { $list == "" } {
     
    727732# ----------------------------------------------------------------------
    728733itcl::body Rappture::FlowvisViewer::scale {args} {
    729     foreach val {xmin xmax ymin ymax vmin vmax} {
    730         set _limits($val) ""
    731     }
    732     foreach obj $args {
    733         foreach axis {x y v} {
    734             foreach { min max } [$obj limits $axis] break
     734    array set style {
     735        -color BCGYR
     736        -levels 6
     737        -markers ""
     738        -opacity 0.5
     739    }
     740    array unset _limits
     741    array unset _volcomponents
     742    foreach dataobj $args {
     743        if { ![$dataobj isvalid] } {
     744            continue;                     # Object doesn't contain valid data.
     745        }
     746        foreach cname [$dataobj components] {
     747            if { ![info exists _volcomponents($cname)] } {
     748                lappend _componentsList $cname
     749                array set style [lindex [$dataobj components -style $cname] 0]
     750                set cmap [ColorsToColormap $style(-color)]
     751                set _settings($cname-colormap) $style(-color)
     752            }
     753            lappend _volcomponents($cname) $dataobj-$cname
     754            array unset limits
     755            array set limits [$dataobj valueLimits $cname]
     756            set _limits($cname) $limits(v)
     757        }
     758        foreach axis {x y z v} {
     759            foreach { min max } [$dataobj limits $axis] break
    735760            if {"" != $min && "" != $max} {
    736                 if {"" == $_limits(${axis}min)} {
     761                if { ![info exists _limits(${axis}min)] } {
    737762                    set _limits(${axis}min) $min
    738763                    set _limits(${axis}max) $max
    739                 } else {
    740                     if {$min < $_limits(${axis}min)} {
    741                         set _limits(${axis}min) $min
    742                     }
    743                     if {$max > $_limits(${axis}max)} {
    744                         set _limits(${axis}max) $max
    745                     }
     764                    continue
    746765                }
    747             }
    748         }
    749     }
     766                if {$min < $_limits(${axis}min)} {
     767                    set _limits(${axis}min) $min
     768                }
     769                if {$max > $_limits(${axis}max)} {
     770                    set _limits(${axis}max) $max
     771                }
     772            }
     773        }
     774    }
     775    #BuildVolumeComponents
    750776}
    751777
     
    929955    set tf $_activeTf
    930956    if { $_first == "" } {
    931         puts stderr "no first"
     957        puts stderr "first not set"
    932958        return
    933959    }
    934960
    935961    # Ensure that the global thickness setting (in the slider
    936     # settings widget) is used for the active transfer-function. Update
    937     # the values in the _settings varible.
    938 
    939     set value $_settings(-thickness)
     962    # settings widget) is used for the active transfer-function.  Update
     963    # the value in the _settings variable.
     964
    940965    # Scale values between 0.00001 and 0.01000
    941     set thickness [expr {double($value) * 0.0001}]
     966    set thickness [expr {double($_settings(-thickness)) * 0.0001}]
    942967    set _settings($tf-thickness) $thickness
    943968
    944     foreach key [array names _dataset2style $_first-*] {
    945         if { [info exists _dataset2style($key)] } {
    946             foreach tf $_dataset2style($key) {
     969    foreach tag [array names _dataset2style $_first-*] {
     970        if { [info exists _dataset2style($tag)] } {
     971            foreach tf $_dataset2style($tag) {
    947972                ComputeTransferFunction $tf
    948973            }
    949974        }
    950975    }
    951     EventuallyResizeLegend
    952 }
    953 
    954 # ----------------------------------------------------------------------
    955 # USAGE: ReceiveImage -bytes $size -type $type -token $token
     976    EventuallyRedrawLegend
     977}
     978
     979# ----------------------------------------------------------------------
     980# USAGE: ReceiveImage -bytes <size> -type <type> -token <token>
    956981#
    957982# Invoked automatically whenever the "image" command comes in from
     
    10001025            -image $_image(legend) -tags colorbar
    10011026        $c create text $lx $ly -anchor sw \
    1002             -fill $itk_option(-plotforeground) -tags "limits vmin"
     1027            -fill $itk_option(-plotforeground) -tags "limits labels vmin"
    10031028        $c create text [expr {$w-$lx}] $ly -anchor se \
    1004             -fill $itk_option(-plotforeground) -tags "limits vmax"
     1029            -fill $itk_option(-plotforeground) -tags "limits labels vmax"
    10051030        $c lower colorbar
    10061031        $c bind colorbar <ButtonRelease-1> [itcl::code $this AddIsoMarker %x %y]
     
    10361061        return
    10371062    }
    1038     #puts stderr "receive legend $tag $vmin $vmax $size"
    10391063    set bytes [ReceiveBytes $size]
    10401064    $_image(legend) configure -data $bytes
     
    10691093        return
    10701094    }
     1095
    10711096    # Arguments from server are name value pairs. Stuff them in an array.
    1072     array set values $args
    1073     set tag $values(tag)
     1097    array set info $args
     1098
     1099    set tag $info(tag)
    10741100    set parts [split $tag -]
     1101
     1102    #
     1103    # Volumes don't exist until we're told about them.
     1104    #
    10751105    set dataobj [lindex $parts 0]
    10761106    set _serverDatasets($tag) 0
    10771107    set _limits($tag-min)  $values(min);  # Minimum value of the volume.
    10781108    set _limits($tag-max)  $values(max);  # Maximum value of the volume.
     1109
    10791110    unset _recvdDatasets($tag)
    10801111    if { [array size _recvdDatasets] == 0 } {
     
    10831114}
    10841115
    1085 #
    1086 # Rebuild --
    1087 #
    1088 # Called automatically whenever something changes that affects the data
    1089 # in the widget.  Clears any existing data and rebuilds the widget to
    1090 # display new data.
    1091 #
     1116# ----------------------------------------------------------------------
     1117# USAGE: Rebuild
     1118#
     1119# Called automatically whenever something changes that affects the
     1120# data in the widget.  Clears any existing data and rebuilds the
     1121# widget to display new data.
     1122# ----------------------------------------------------------------------
    10921123itcl::body Rappture::FlowvisViewer::Rebuild {} {
    10931124    set w [winfo width $itk_component(3dview)]
     
    11171148        set _height $h
    11181149        $_arcball resize $w $h
    1119         Resize
     1150        DoResize
    11201151    }
    11211152
    11221153    set _first ""
    11231154    foreach dataobj [get] {
    1124         foreach comp [$dataobj components] {
    1125             set tag $dataobj-$comp
     1155        foreach cname [$dataobj components] {
     1156            set tag $dataobj-$cname
    11261157            set isvtk 0
    11271158            # FIXME: Would like to use the type method of the dataobj
     
    11291160            if {[catch {
    11301161                # Send the data as one huge base64-encoded mess -- yuck!
    1131                 set data [$dataobj blob $comp]
     1162                set data [$dataobj blob $cname]
    11321163            }]} {
    1133                 set data [$dataobj vtkdata $comp]
     1164                set data [$dataobj vtkdata $cname]
    11341165                set isvtk 1
    11351166            }
     
    11471178                SendCmd "clientinfo [list $info]"
    11481179            }
    1149             set extents [$dataobj extents $comp]
     1180            set extents [$dataobj extents $cname]
    11501181            # I have a field. Is a vector field or a volume field?
    11511182            if { !$isvtk && $extents == 1 } {
    11521183                SendCmd "volume data follows $nbytes $tag"
    11531184            } else {
    1154                 if {[SendFlowCmd $dataobj $comp $nbytes $extents] < 0} {
     1185                if {[SendFlowCmd $dataobj $cname $nbytes $extents] < 0} {
    11551186                    continue
    11561187                }
    11571188            }
    11581189            SendData $data
    1159             NameTransferFunction $dataobj $comp
     1190            NameTransferFunction $dataobj $cname
    11601191            set _recvdDatasets($tag) 1
    11611192        }
     
    11701201
    11711202    # Reset the camera and other view parameters
    1172     InitSettings -light2side \
     1203    InitSettings -axesvisible -gridvisible \
     1204        -opacity -light2side -isosurfaceshading \
    11731205        -light \
    1174         -opacity -isosurface -grid -axes -volume -outline \
    1175         -cutplanesVisible -xcutplane -ycutplane -zcutplane
     1206        -volume -outlinevisible -cutplanesvisible \
     1207        -xcutplanevisible -ycutplanevisible -zcutplanevisible \
     1208        -xcutplaneposition -ycutplaneposition -zcutplaneposition
    11761209
    11771210    # nothing to send -- activate the proper volume
     
    12021235
    12031236    foreach dataobj [get] {
    1204         foreach comp [$dataobj components] {
    1205             NameTransferFunction $dataobj $comp
     1237        foreach cname [$dataobj components] {
     1238            NameTransferFunction $dataobj $cname
    12061239        }
    12071240    }
     
    12181251            array set _view $location
    12191252        }
    1220         set comp [lindex [$_first components] 0]
    1221         set _activeTf [lindex $_dataset2style($_first-$comp) 0]
     1253        set cname [lindex [$_first components] 0]
     1254        set _activeTf [lindex $_dataset2style($_first-$cname) 0]
    12221255    }
    12231256
    12241257    # sync the state of slicers
    1225     set vols [CurrentVolumeIds -cutplanes]
     1258    set vols [CurrentDatasets -cutplanes]
    12261259    foreach axis {x y z} {
    1227         set pos [expr {0.01*$_settings(-${axis}cutposition)}]
     1260        set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}]
    12281261        SendCmd "cutplane position $pos $axis $vols"
    12291262    }
    12301263    SendCmd "volume data state $_settings(-volume)"
    1231     EventuallyResizeLegend
     1264    EventuallyRedrawLegend
    12321265
    12331266    # Actually write the commands to the server socket.  If it fails, we don't
     
    12401273
    12411274# ----------------------------------------------------------------------
    1242 # USAGE: CurrentVolumeIds ?-cutplanes?
     1275# USAGE: CurrentDatasets ?-cutplanes?
    12431276#
    12441277# Returns a list of volume server IDs for the current volume being
     
    12461279# of IDs if the current data object has multiple components.
    12471280# ----------------------------------------------------------------------
    1248 itcl::body Rappture::FlowvisViewer::CurrentVolumeIds {{what -all}} {
     1281itcl::body Rappture::FlowvisViewer::CurrentDatasets {{what -all}} {
    12491282    return ""
    12501283    if { $_first == "" } {
    12511284        return
    12521285    }
    1253     foreach key [array names _serverDatasets *-*] {
    1254         if {[string match $_first-* $key]} {
     1286    foreach tag [array names _serverDatasets *-*] {
     1287        if {[string match $_first-* $tag]} {
    12551288            array set style {
    12561289                -cutplanes 1
    12571290            }
    1258             foreach {dataobj comp} [split $key -] break
    1259             array set style [lindex [$dataobj components -style $comp] 0]
     1291            foreach {dataobj cname} [split $tag -] break
     1292            array set style [lindex [$dataobj components -style $cname] 0]
    12601293            if {$what != "-cutplanes" || $style(-cutplanes)} {
    1261                 lappend rlist $_serverDatasets($key)
     1294                lappend rlist $_serverDatasets($tag)
    12621295            }
    12631296        }
     
    14431476# ----------------------------------------------------------------------
    14441477itcl::body Rappture::FlowvisViewer::AdjustSetting {what {value ""}} {
     1478    if {![isconnected]} {
     1479        return
     1480    }
    14451481    switch -- $what {
     1482        "-axesvisible" {
     1483            SendCmd "axis visible $_settings($what)"
     1484        }
     1485        "-background" {
     1486            set bgcolor [$itk_component(background) value]
     1487            array set fgcolors {
     1488                "black" "white"
     1489                "white" "black"
     1490                "grey"  "black"
     1491            }
     1492            configure -plotbackground $bgcolor \
     1493                -plotforeground $fgcolors($bgcolor)
     1494            if { $_first != "" } {
     1495                set comp [lindex [$_first components] 0]
     1496                set tag $_first-$comp
     1497                DrawLegend $tag
     1498            }
     1499        }
    14461500        "-colormap" {
    14471501            set color [$itk_component(colormap) value]
    14481502            set _settings($what) $color
    14491503            #ResetColormap $color
     1504        }
     1505        "-cutplanesvisible" {
     1506            set bool $_settings($what)
     1507            set datasets [CurrentDatasets -cutplanes]
     1508            set tag [lindex $datasets 0]
     1509            SendCmd "cutplane visible $bool $tag"
     1510        }
     1511        "-gridvisible" {
     1512            SendCmd "grid visible $_settings($what)"
     1513        }
     1514        "-isosurfaceshading" {
     1515            if { $_first != "" } {
     1516                set comp [lindex [$_first components] 0]
     1517                set tag $_first-$comp
     1518                set val $_settings($what)
     1519                # This flag isn't implemented in the server
     1520                #SendCmd "$tag configure -isosurface $val"
     1521            }
     1522        }
     1523        "-legendvisible" {
     1524            if { $_settings($what) } {
     1525                blt::table $itk_component(plotarea) \
     1526                    0,0 $itk_component(3dview) -fill both \
     1527                    1,0 $itk_component(legend) -fill x
     1528                blt::table configure $itk_component(plotarea) r1 -resize none
     1529            } else {
     1530                blt::table forget $itk_component(legend)
     1531            }
    14501532        }
    14511533        "-light" {
     
    14761558            }
    14771559        }
     1560        "-outlinevisible" {
     1561            if { $_first != "" } {
     1562                set comp [lindex [$_first components] 0]
     1563                set tag $_first-$comp
     1564                SendCmd "$tag configure -outline $_settings($what)"
     1565            }
     1566        }
    14781567        "-thickness" {
    14791568            if { $_first != "" && $_activeTf != "" } {
     
    14861575            }
    14871576        }
    1488         "-outline" {
    1489             if { $_first != "" } {
    1490                 set comp [lindex [$_first components] 0]
    1491                 set tag $_first-$comp
    1492                 SendCmd "$tag configure -outline $_settings($what)"
    1493             }
    1494         }
    1495         "-isosurface" {
    1496             if { [isconnected] } {
    1497                 SendCmd "volume shading isosurface $_settings($what)"
    1498             }
    1499         }
    1500         "-grid" {
    1501             if { [isconnected] } {
    1502                 SendCmd "grid visible $_settings($what)"
    1503             }
    1504         }
    1505         "-axes" {
    1506             if { [isconnected] } {
    1507                 SendCmd "axis visible $_settings($what)"
    1508             }
    1509         }
    1510         "-legend" {
    1511             if { $_settings($what) } {
    1512                 blt::table $itk_component(plotarea) \
    1513                     0,0 $itk_component(3dview) -fill both \
    1514                     1,0 $itk_component(legend) -fill x
    1515                 blt::table configure $itk_component(plotarea) r1 -resize none
    1516             } else {
    1517                 blt::table forget $itk_component(legend)
    1518             }
    1519         }
    15201577        "-volume" {
    15211578            if { $_first != "" } {
     
    15251582            }
    15261583        }
    1527         "-cutplanesVisible" {
    1528             set bool $_settings($what)
    1529             set datasets [CurrentVolumeIds -cutplanes]
     1584        "-xcutplaneposition" - "-ycutplaneposition" - "-zcutplaneposition" {
     1585            set axis [string range $what 1 1]
     1586            set pos [expr $_settings($what) * 0.01]
     1587            # We only set cutplanes on the first dataset.
     1588            set datasets [CurrentDatasets -cutplanes]
    15301589            set tag [lindex $datasets 0]
    1531             SendCmd "cutplane visible $bool $tag"
    1532         }
    1533         "-xcutplane" - "-ycutplane" - "-zcutplane" {
     1590            SendCmd "cutplane position $pos $axis $tag"
     1591        }
     1592        "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" {
    15341593            set axis [string range $what 1 1]
    15351594            set bool $_settings($what)
    1536             if { [isconnected] } {
    1537                 set vols [CurrentVolumeIds -cutplanes]
    1538                 SendCmd "cutplane state $bool $axis $vols"
    1539             }
     1595            # We only set cutplanes on the first dataset.
     1596            set datasets [CurrentDatasets -cutplanes]
     1597            set tag [lindex $datasets 0]
     1598            SendCmd "cutplane state $bool $axis $tag"
    15401599            if { $bool } {
    15411600                $itk_component(${axis}CutScale) configure -state normal \
     
    15531612
    15541613# ----------------------------------------------------------------------
    1555 # USAGE: ResizeLegend
     1614# USAGE: FixLegend
    15561615#
    15571616# Used internally to update the legend area whenever it changes size
     
    15591618# for the current field.
    15601619# ----------------------------------------------------------------------
    1561 itcl::body Rappture::FlowvisViewer::ResizeLegend {} {
     1620itcl::body Rappture::FlowvisViewer::FixLegend {} {
    15621621    set _resizeLegendPending 0
    15631622    set lineht [font metrics $itk_option(-font) -linespace]
     
    15741633        #SendCmd "legend $_activeTf $w $h"
    15751634        SendCmd "$tag legend $w $h"
    1576     } else {
    1577     # Can't do this as this will remove the items associated with the
    1578     # isomarkers.
    1579 
    1580     #$itk_component(legend) delete all
    15811635    }
    15821636}
     
    15991653    array set style [lindex [$dataobj components -style $cname] 0]
    16001654    set tf "$style(-color):$style(-levels)"
     1655    # Some tools erroneously set -opacity to 1 in style, so
     1656    # override the requested opacity for now
     1657    set style(-opacity) 0.5
    16011658    set _settings(-opacity) [expr $style(-opacity) * 100]
    16021659    set _dataset2style($dataobj-$cname) $tf
     
    16081665# ComputeTransferFunction --
    16091666#
    1610 #   Computes and sends the transfer function to the render server.  It's
    1611 #   assumed that the volume data limits are known and that the global
    1612 #   transfer-functions slider values have be setup.  Both parts are
    1613 #   needed to compute the relative value (location) of the marker, and
    1614 #   the alpha map of the transfer function.
     1667#       Computes and sends the transfer function to the render server.  It's
     1668#       assumed that the volume data limits are known and that the global
     1669#       transfer-functions slider values have been set up.  Both parts are
     1670#       needed to compute the relative value (location) of the marker, and
     1671#       the alpha map of the transfer function.
    16151672#
    16161673itcl::body Rappture::FlowvisViewer::ComputeTransferFunction { tf } {
     
    16201677        -opacity 0.5
    16211678    }
    1622     set dataobj ""; set comp ""
    1623     foreach {dataobj comp} $_style2datasets($tf) break
     1679    set dataobj ""; set cname ""
     1680    foreach {dataobj cname} $_style2datasets($tf) break
    16241681    if { $dataobj == "" } {
    16251682        return 0
    16261683    }
    1627     array set style [lindex [$dataobj components -style $comp] 0]
     1684    array set style [lindex [$dataobj components -style $cname] 0]
     1685    # Some tools erroneously set -opacity to 1 in style, so
     1686    # override the requested opacity for now
     1687    set style(-opacity) 0.5
    16281688
    16291689    # We have to parse the style attributes for a volume using this
     
    17141774    }
    17151775    SendCmd "transfunc define $tf { $cmap } { $amap }"
    1716     return [SendCmd "$dataobj-$comp configure -transferfunction $tf"]
     1776    return [SendCmd "$dataobj-$cname configure -transferfunction $tf"]
    17171777}
    17181778
     
    19241984    $inner configure -borderwidth 4
    19251985
    1926     checkbutton $inner.isosurface \
    1927         -text "Isosurface shading" \
    1928         -variable [itcl::scope _settings(-isosurface)] \
    1929         -command [itcl::code $this AdjustSetting -isosurface] \
    1930         -font "Arial 9"
    1931 
     1986    # General options
    19321987    checkbutton $inner.axes \
    19331988        -text "Axes" \
    1934         -variable [itcl::scope _settings(-axes)] \
    1935         -command [itcl::code $this AdjustSetting -axes] \
     1989        -variable [itcl::scope _settings(-axesvisible)] \
     1990        -command [itcl::code $this AdjustSetting -axesvisible] \
    19361991        -font "Arial 9"
    19371992
    19381993    checkbutton $inner.grid \
    19391994        -text "Grid" \
    1940         -variable [itcl::scope _settings(-grid)] \
    1941         -command [itcl::code $this AdjustSetting -grid] \
     1995        -variable [itcl::scope _settings(-gridvisible)] \
     1996        -command [itcl::code $this AdjustSetting -gridvisible] \
    19421997        -font "Arial 9"
     1998
     1999    checkbutton $inner.legend \
     2000        -text "Legend" \
     2001        -variable [itcl::scope _settings(-legendvisible)] \
     2002        -command [itcl::code $this AdjustSetting -legendvisible] \
     2003        -font "Arial 9"
     2004
     2005    label $inner.background_l -text "Background" -font "Arial 9"
     2006    itk_component add background {
     2007        Rappture::Combobox $inner.background -width 10 -editable no
     2008    }
     2009    $inner.background choices insert end \
     2010        "black" "black" \
     2011        "white" "white" \
     2012        "grey"  "grey"
     2013
     2014    $itk_component(background) value $_settings(-background)
     2015    bind $inner.background <<Value>> \
     2016        [itcl::code $this AdjustSetting -background]
     2017
     2018    # Dataset options
     2019    label $inner.flow_l -text "Flow" -font "Arial 9 bold"
    19432020
    19442021    checkbutton $inner.outline \
    19452022        -text "Outline" \
    1946         -variable [itcl::scope _settings(-outline)] \
    1947         -command [itcl::code $this AdjustSetting -outline] \
    1948         -font "Arial 9"
    1949 
    1950     checkbutton $inner.legend \
    1951         -text "Legend" \
    1952         -variable [itcl::scope _settings(-legend)] \
    1953         -command [itcl::code $this AdjustSetting -legend] \
     2023        -variable [itcl::scope _settings(-outlinevisible)] \
     2024        -command [itcl::code $this AdjustSetting -outlinevisible] \
    19542025        -font "Arial 9"
    19552026
     
    19602031        -font "Arial 9"
    19612032
    1962     checkbutton $inner.particles \
    1963         -text "Particles" \
    1964         -variable [itcl::scope _settings(-particles)] \
    1965         -command [itcl::code $this AdjustSetting -particles] \
    1966         -font "Arial 9"
    1967 
    1968     checkbutton $inner.lic \
    1969         -text "Lic" \
    1970         -variable [itcl::scope _settings(-lic)] \
    1971         -command [itcl::code $this AdjustSetting -lic] \
    1972         -font "Arial 9"
    1973 
    19742033    frame $inner.frame
    19752034
    19762035    blt::table $inner \
    1977         0,0 $inner.axes  -cspan 2 -anchor w \
    1978         1,0 $inner.grid  -cspan 2 -anchor w \
    1979         2,0 $inner.outline  -cspan 2 -anchor w \
    1980         3,0 $inner.volume  -cspan 2 -anchor w \
    1981         4,0 $inner.legend  -cspan 2 -anchor w
     2036        0,0 $inner.axes -cspan 2 -anchor w \
     2037        1,0 $inner.grid -cspan 2 -anchor w \
     2038        2,0 $inner.legend -cspan 2 -anchor w \
     2039        3,0 $inner.background_l -anchor e -pady 2 \
     2040        3,1 $inner.background -fill x \
     2041        4,0 $inner.flow_l -anchor w \
     2042        5,0 $inner.outline -cspan 2 -anchor w \
     2043        6,0 $inner.volume -cspan 2 -anchor w \
    19822044
    19832045    bind $inner <Map> [itcl::code $this GetFlowInfo $inner]
    19842046
    1985     blt::table configure $inner r* -resize none
    1986     blt::table configure $inner r5 -resize expand
     2047    blt::table configure $inner c* r* -resize none
     2048    blt::table configure $inner c2 r7 -resize expand
    19872049}
    19882050
     
    20022064        -font "Arial 9"
    20032065
    2004     label $inner.shading -text "Shading:" -font $fg
     2066    label $inner.lighting_l \
     2067        -text "Lighting / Material Properties" \
     2068        -font "Arial 9 bold"
     2069
     2070    checkbutton $inner.isosurface -text "Isosurface shading" -font $fg \
     2071        -variable [itcl::scope _settings(-isosurfaceshading)] \
     2072        -command [itcl::code $this AdjustSetting -isosurfaceshading]
    20052073
    20062074    checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \
     
    20152083    label $inner.bright -text "Surface" -font $fg
    20162084
    2017     label $inner.clear -text "Clear" -font $fg
     2085    # Opacity
     2086    label $inner.opacity_l -text "Opacity" -font $fg
    20182087    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    20192088        -variable [itcl::scope _settings(-opacity)] \
    20202089        -width 10 \
    20212090        -showvalue off -command [itcl::code $this AdjustSetting -opacity]
    2022     label $inner.opaque -text "Opaque" -font $fg
    2023 
     2091
     2092    label $inner.transferfunction_l \
     2093        -text "Transfer Function" -font "Arial 9 bold"
     2094
     2095    # Tooth thickness
    20242096    label $inner.thin -text "Thin" -font $fg
    20252097    ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \
     
    20292101    label $inner.thick -text "Thick" -font $fg
    20302102
    2031     label $inner.colormap_l -text "Colormap" -font "Arial 9"
     2103    # Colormap
     2104    label $inner.colormap_l -text "Colormap" -font $fg
    20322105    itk_component add colormap {
    20332106        Rappture::Combobox $inner.colormap -width 10 -editable no
     
    20352108
    20362109    $inner.colormap choices insert end [GetColormapList -includeNone]
    2037     $itk_component(colormap) value "BCGYR"
    20382110    bind $inner.colormap <<Value>> \
    20392111        [itcl::code $this AdjustSetting -colormap]
     2112    $itk_component(colormap) value "BCGYR"
     2113    set _settings(-colormap) "BCGYR"
    20402114
    20412115    blt::table $inner \
    20422116        0,0 $inner.vol -cspan 4 -anchor w -pady 2 \
    2043         1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \
     2117        1,0 $inner.lighting_l -cspan 4 -anchor w -pady {10 2} \
    20442118        2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \
    20452119        3,0 $inner.dim -anchor e -pady 2 \
    20462120        3,1 $inner.light -cspan 2 -pady 2 -fill x \
    20472121        3,3 $inner.bright -anchor w -pady 2 \
    2048         4,0 $inner.clear -anchor e -pady 2 \
    2049         4,1 $inner.opacity -cspan 2 -pady 2 -fill x \
    2050         4,3 $inner.opaque -anchor w -pady 2 \
     2122        4,0 $inner.opacity_l -anchor e -pady 2 \
     2123        4,1 $inner.opacity -cspan 3 -pady 2 -fill x \
    20512124        5,0 $inner.thin -anchor e -pady 2 \
    20522125        5,1 $inner.thickness -cspan 2 -pady 2 -fill x\
     
    20632136    $inner configure -borderwidth 4
    20642137
     2138    checkbutton $inner.visible \
     2139        -text "Show Cutplanes" \
     2140        -variable [itcl::scope _settings(-cutplanesvisible)] \
     2141        -command [itcl::code $this AdjustSetting -cutplanesvisible] \
     2142        -font "Arial 9"
     2143
    20652144    # X-value slicer...
    20662145    itk_component add xCutButton {
     
    20682147            -onimage [Rappture::icon x-cutplane] \
    20692148            -offimage [Rappture::icon x-cutplane] \
    2070             -command [itcl::code $this AdjustSetting -xcutplane] \
    2071             -variable [itcl::scope _settings(-xcutplane)]
     2149            -command [itcl::code $this AdjustSetting -xcutplanevisible] \
     2150            -variable [itcl::scope _settings(-xcutplanevisible)]
    20722151    }
    20732152    Rappture::Tooltip::for $itk_component(xCutButton) \
     
    20802159            -borderwidth 1 -highlightthickness 0 \
    20812160            -command [itcl::code $this Slice move x] \
    2082             -variable [itcl::scope _settings(-xcutposition)]
     2161            -variable [itcl::scope _settings(-xcutplaneposition)]
    20832162    } {
    20842163        usual
     
    20962175            -onimage [Rappture::icon y-cutplane] \
    20972176            -offimage [Rappture::icon y-cutplane] \
    2098             -command [itcl::code $this AdjustSetting -ycutplane] \
    2099             -variable [itcl::scope _settings(-ycutplane)]
     2177            -command [itcl::code $this AdjustSetting -ycutplanevisible] \
     2178            -variable [itcl::scope _settings(-ycutplanevisible)]
    21002179    }
    21012180    Rappture::Tooltip::for $itk_component(yCutButton) \
     
    21082187            -borderwidth 1 -highlightthickness 0 \
    21092188            -command [itcl::code $this Slice move y] \
    2110             -variable [itcl::scope _settings(-ycutposition)]
     2189            -variable [itcl::scope _settings(-ycutplaneposition)]
    21112190    } {
    21122191        usual
     
    21242203            -onimage [Rappture::icon z-cutplane] \
    21252204            -offimage [Rappture::icon z-cutplane] \
    2126             -command [itcl::code $this AdjustSetting -zcutplane] \
    2127             -variable [itcl::scope _settings(-zcutplane)]
     2205            -command [itcl::code $this AdjustSetting -zcutplanevisible] \
     2206            -variable [itcl::scope _settings(-zcutplanevisible)]
    21282207    }
    21292208    Rappture::Tooltip::for $itk_component(zCutButton) \
     
    21362215            -borderwidth 1 -highlightthickness 0 \
    21372216            -command [itcl::code $this Slice move z] \
    2138             -variable [itcl::scope _settings(-zcutposition)]
     2217            -variable [itcl::scope _settings(-zcutplaneposition)]
    21392218    } {
    21402219        usual
     
    21432222    $itk_component(zCutScale) set 50
    21442223    $itk_component(zCutScale) configure -state disabled
    2145     #$itk_component(zCutScale) configure -state disabled
    21462224    Rappture::Tooltip::for $itk_component(zCutScale) \
    21472225        "@[itcl::code $this SlicerTip z]"
    21482226
    21492227    blt::table $inner \
    2150         1,1 $itk_component(xCutButton) \
    2151         1,2 $itk_component(yCutButton) \
    2152         1,3 $itk_component(zCutButton) \
    2153         0,1 $itk_component(xCutScale) \
    2154         0,2 $itk_component(yCutScale) \
    2155         0,3 $itk_component(zCutScale) \
    2156 
    2157     blt::table configure $inner r0 r1 c* -resize none
    2158     blt::table configure $inner r2 c4 -resize expand
     2228        0,1 $inner.visible -anchor w -pady 2 -cspan 4 \
     2229        1,1 $itk_component(xCutScale) \
     2230        1,2 $itk_component(yCutScale) \
     2231        1,3 $itk_component(zCutScale) \
     2232        2,1 $itk_component(xCutButton) \
     2233        2,2 $itk_component(yCutButton) \
     2234        2,3 $itk_component(zCutButton)
     2235
     2236    blt::table configure $inner r0 r1 r2 c* -resize none
     2237    blt::table configure $inner r3 c4 -resize expand
    21592238    blt::table configure $inner c0 -width 2
    21602239    blt::table configure $inner c1 c2 c3 -padx 2
     
    22172296    set inner [frame $w.frame]
    22182297    blt::table $w \
    2219         5,0 $inner -fill both -cspan 2 -anchor nw
     2298        7,0 $inner -fill both -cspan 2 -anchor nw
    22202299    array set hints [$flowobj hints]
    22212300    checkbutton $inner.showstreams -text "Streams Plane" \
     
    23302409            set axis [lindex $args 0]
    23312410            set newval [lindex $args 1]
     2411
    23322412            set newpos [expr {0.01*$newval}]
    2333 
    2334             # show the current value in the readout
    2335 
    2336             set ids [CurrentVolumeIds -cutplanes]
    2337             SendCmd "cutplane position $newpos $axis $ids"
     2413            set datasets [CurrentDatasets -cutplanes]
     2414            set tag [lindex $datasets 0]
     2415            SendCmd "cutplane position $newpos $axis $tag"
    23382416        }
    23392417        default {
     
    23542432}
    23552433
    2356 itcl::body Rappture::FlowvisViewer::Resize {} {
     2434itcl::body Rappture::FlowvisViewer::DoResize {} {
    23572435    $_arcball resize $_width $_height
    23582436    SendCmd "screen size $_width $_height"
     
    23702448}
    23712449
    2372 itcl::body Rappture::FlowvisViewer::EventuallyResizeLegend {} {
     2450itcl::body Rappture::FlowvisViewer::EventuallyRedrawLegend {} {
    23732451    if { !$_resizeLegendPending } {
    23742452        $_dispatcher event -after 100 !legend
     
    23862464
    23872465#  camera --
     2466#
    23882467itcl::body Rappture::FlowvisViewer::camera {option args} {
    23892468    switch -- $option {
     
    23932472        "set" {
    23942473            set what [lindex $args 0]
    2395             set x $_settings(${this}${what})
     2474            set x $_settings($what)
    23962475            set code [catch { string is double $x } result]
    23972476            if { $code != 0 || !$result } {
    2398                 set _settings(${this}${what}) $_view($what)
     2477                set _settings($what) $_view($what)
    23992478                return
    24002479            }
    24012480            switch -- $what {
    24022481                "-xpan" - "-ypan" {
    2403                     set _view($what) $_settings(${this}${what})
     2482                    set _view($what) $_settings($what)
    24042483                    PanCamera
    24052484                }
    24062485                "-qx" - "-qy" - "-qz" - "-qw" {
    2407                     set _view($what) $_settings(${this}${what})
     2486                    set _view($what) $_settings($what)
    24082487                    set q [ViewToQuaternion]
    24092488                    $_arcball quaternion $q
     
    24112490                }
    24122491                "-zoom" {
    2413                     set _view($what) $_settings(${this}${what})
     2492                    set _view($what) $_settings($what)
    24142493                    SendCmd "camera zoom $_view($what)"
    24152494                }
     
    24322511    }
    24332512    SendCmd "if {\[flow exists $tag\]} {flow delete $tag}"
    2434     array set info  [$flowobj hints]
     2513    array set info [$flowobj hints]
    24352514    set _settings(-volume) $info(volume)
    2436     set _settings(-outline) $info(outline)
     2515    set _settings(-outlinevisible) $info(outline)
    24372516    set _settings(-arrows) $info(arrows)
    24382517    set _settings(-duration) $info(duration)
     
    26022681}
    26032682
    2604 itcl::body Rappture::FlowvisViewer::WaitIcon  { option widget } {
     2683itcl::body Rappture::FlowvisViewer::WaitIcon { option widget } {
    26052684    switch -- $option {
    26062685        "start" {
     
    28012880    SendCmd "camera orient $q"
    28022881    SendCmd "camera reset"
    2803     set _view(-xpan) 0.0
    2804     set _view(-ypan) 0.0
     2882    set _view(-xpan) 0
     2883    set _view(-ypan) 0
    28052884    set _view(-zoom) 1.0
    28062885    set _settings(-xpan) $_view(-xpan)
     
    28082887    set _settings(-zoom) $_view(-zoom)
    28092888}
     2889
     2890#
     2891# BuildVolumeComponents --
     2892#
     2893#    This is called from the "scale" method which is called when a new
     2894#    dataset is added or deleted.  It repopulates the dropdown menu of
     2895#    volume component names.  It sets the current component to the first
     2896#    component in the list (of components found).  Finally, if there is
     2897#    only one component, don't display the label or the combobox in the
     2898#    volume settings tab.
     2899#
     2900itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} {
     2901    $itk_component(volcomponents) choices delete 0 end
     2902    foreach name $_componentsList {
     2903        $itk_component(volcomponents) choices insert end $name $name
     2904    }
     2905    set _current [lindex $_componentsList 0]
     2906    $itk_component(volcomponents) value $_current
     2907}
     2908
     2909#
     2910# GetDatasetsWithComponents --
     2911#
     2912#    Returns a list of all the datasets (known by the combination of their
     2913#    data object and component name) that match the given component name.
     2914#    For example, this is used where we want to change the settings of
     2915#    volumes that have the current component.
     2916#
     2917itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } {
     2918    if { ![info exists _volcomponents($cname)] } {
     2919        return ""
     2920    }
     2921    set list ""
     2922    foreach tag $_volcomponents($cname) {
     2923        if { ![info exists _serverDatasets($tag)] } {
     2924            continue
     2925        }
     2926        lappend list $tag
     2927    }
     2928    return $list
     2929}
Note: See TracChangeset for help on using the changeset viewer.