Ignore:
Timestamp:
Mar 4, 2013, 7:18:28 AM (12 years ago)
Author:
gah
Message:

misc cleanup vtkvolumeviewer

File:
1 edited

Legend:

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

    r3438 r3441  
    5858    public method get {args}
    5959    public method isconnected {}
    60     public method limits { colormap }
    6160    public method parameters {title args} {
    6261        # do nothing
     
    8988    private method BuildVolumeTab {}
    9089    private method ConvertToVtkData { dataobj comp }
    91     private method DrawLegend { title }
     90    private method DrawLegend {}
    9291    private method Combo { option }
    9392    private method EnterLegend { x y }
     
    143142    private variable _legendPending 0
    144143    private variable _outline
    145     private variable _vectorFields
    146     private variable _scalarFields
    147144    private variable _fields
    148     private variable _currentField ""
    149     private variable _field      ""
    150     private variable _numSeeds 200
     145    private variable _curFldName ""
     146    private variable _curFldLabel ""
    151147    private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
    152148}
     
    230226    $_arcball quaternion $q
    231227
    232     set _limits(zmin) 0.0
    233     set _limits(zmax) 1.0
    234 
    235     array set _settings [subst {
     228    array set _settings {
    236229        axis-xgrid              0
    237230        axis-ygrid              0
     
    243236        axis-yposition          0
    244237        axis-zposition          0
    245         axis-visible            1
    246         axis-labels             1
    247         cutplane-edges          0
     238        axesVisible             1
     239        axisLabels              1
     240        cutplaneEdges           0
    248241        cutplane-xvisible       0
    249242        cutplane-yvisible       0
     
    252245        cutplane-yposition      50
    253246        cutplane-zposition      50
    254         cutplane-visible        1
    255         cutplane-lighting       1
    256         cutplane-wireframe      0
     247        cutplaneVisible         1
     248        cutplaneLighting        1
     249        cutplaneWireframe       0
    257250        cutplane-opacity        100
    258         volume-lighting         1
     251        volumeLighting          1
    259252        volume-material         80
    260253        volume-opacity          40
    261254        volume-quality          50
    262         volume-visible          1
    263         legend-visible          1
    264     }]
     255        volumeVisible           1
     256        legendVisible           1
     257    }
    265258
    266259    itk_component add view {
     
    340333            -onimage [Rappture::icon volume-on] \
    341334            -offimage [Rappture::icon volume-off] \
    342             -variable [itcl::scope _settings(volume-visible)] \
    343             -command [itcl::code $this AdjustSetting volume-visible]
     335            -variable [itcl::scope _settings(volumeVisible)] \
     336            -command [itcl::code $this AdjustSetting volumeVisible]
    344337    }
    345338    $itk_component(volume) select
     
    352345            -onimage [Rappture::icon cutbutton] \
    353346            -offimage [Rappture::icon cutbutton] \
    354             -variable [itcl::scope _settings(cutplane-visible)] \
    355             -command [itcl::code $this AdjustSetting cutplane-visible]
     347            -variable [itcl::scope _settings(cutplaneVisible)] \
     348            -command [itcl::code $this AdjustSetting cutplaneVisible]
    356349    }
    357350    $itk_component(cutplane) select
     
    677670itcl::body Rappture::VtkVolumeViewer::scale {args} {
    678671    foreach dataobj $args {
    679         set string [limits $dataobj]
    680         if { $string == "" } {
    681             continue
    682         }
    683         array set bounds $string
    684         if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} {
    685             set _limits(xmin) $bounds(xmin)
    686         }
    687         if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} {
    688             set _limits(xmax) $bounds(xmax)
    689         }
    690 
    691         if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} {
    692             set _limits(ymin) $bounds(ymin)
    693         }
    694         if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} {
    695             set _limits(ymax) $bounds(ymax)
    696         }
    697 
    698         if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} {
    699             set _limits(zmin) $bounds(zmin)
    700         }
    701         if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} {
    702             set _limits(zmax) $bounds(zmax)
     672        foreach axis { x y z } {
     673            set lim [$dataobj limits $axis]
     674            if { ![info exists _limits($axis)] } {
     675                set _limits($axis) $lim
     676                continue
     677            }
     678            foreach {min max} $lim break
     679            foreach {amin amax} $_limits($axis) break
     680            if { $amin > $min } {
     681                set amin $min
     682            }
     683            if { $amax < $max } {
     684                set amax $max
     685            }
     686            set _limits($axis) [list $amin $amax]
     687        }
     688        foreach { fname lim } [$dataobj fieldlimits] {
     689            if { ![info exists _limits($fname)] } {
     690                set _limits($fname) $lim
     691                continue
     692            }
     693            foreach {min max} $lim break
     694            foreach {fmin fmax} $_limits($fname) break
     695            if { $fmin > $min } {
     696                set fmin $min
     697            }
     698            if { $fmax < $max } {
     699                set fmax $max
     700            }
     701            set _limits($fname) [list $fmin $fmax]
    703702        }
    704703    }
     
    969968        }
    970969        DoRotate
    971         InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
    972             axis-visible axis-labels
     970        InitSettings axis-xgrid axis-ygrid axis-zgrid axisFlyMode \
     971            axesVisible axisLabels
    973972        PanCamera
    974973    }
     
    976975
    977976    SendCmd "imgflush"
    978     set _limits(zmin) ""
    979     set _limits(zmax) ""
    980977    set _first ""
    981978
     
    10311028            }
    10321029        }
    1033         array unset _scalarFields
    1034         array unset _vectorFields
    1035         set _currentField [$_first hints default]
    1036         $itk_component(field) choices delete 0 end
    1037         $itk_component(fieldmenu) delete 0 end
    1038         array unset _fields
    1039         foreach { name title units } [$_first hints vectors] {
    1040             set _vectorFields($title) $name
    1041             $itk_component(field) choices insert end "$name" "$title"
    1042             $itk_component(fieldmenu) add radiobutton -label "$title" \
    1043                 -value $title -variable [itcl::scope _currentField] \
    1044                 -selectcolor red \
    1045                 -activebackground black \
    1046                 -activeforeground white \
    1047                 -font "Arial 8" \
    1048                 -command [itcl::code $this Combo invoke]
    1049             set _fields($name) [list $title $units]
    1050         }
    1051         foreach { name title units } [$_first hints scalars] {
    1052             set _scalarFields($title) $name
    1053             $itk_component(field) choices insert end "$name" "$title"
    1054             $itk_component(fieldmenu) add radiobutton -label "$title" \
    1055                 -value $title -variable [itcl::scope _currentField] \
    1056                 -selectcolor red \
    1057                 -activebackground black \
    1058                 -activeforeground white \
    1059                 -font "Arial 8" \
    1060                 -command [itcl::code $this Combo invoke]
    1061             set _fields($name) [list $title $units]
    1062         }
    1063         foreach { name title units } { default Default ??? } {
    1064             set _scalarFields($title) $name
    1065             $itk_component(field) choices insert end "$name" "$title"
    1066             $itk_component(fieldmenu) add radiobutton -label "$title" \
    1067                 -value $title -variable [itcl::scope _currentField] \
    1068                 -selectcolor red \
    1069                 -activebackground black \
    1070                 -activeforeground white \
    1071                 -font "Arial 8" \
    1072                 -command [itcl::code $this Combo invoke]
    1073             set _fields($name) [list $title $units]
    1074         }
    1075         $itk_component(field) value $_currentField
    1076     }
    1077 
    1078     InitSettings volume-palette volume-material volume-quality volume-visible \
    1079         cutplane-visible \
     1030        $itk_component(field) choices delete 0 end
     1031        $itk_component(fieldmenu) delete 0 end
     1032        array unset _fields
     1033        set _curFldName ""
     1034        foreach cname [$_first components] {
     1035            foreach fname [$_first fieldnames $cname] {
     1036                if { [info exists _fields($fname)] } {
     1037                    continue
     1038                }
     1039                foreach { label units components } \
     1040                    [$_first fieldinfo $fname] break
     1041                $itk_component(field) choices insert end "$fname" "$label"
     1042                $itk_component(fieldmenu) add radiobutton -label "$label" \
     1043                    -value $label -variable [itcl::scope _curFldLabel] \
     1044                    -selectcolor red \
     1045                    -activebackground $itk_option(-plotbackground) \
     1046                    -activeforeground $itk_option(-plotforeground) \
     1047                    -font "Arial 8" \
     1048                    -command [itcl::code $this Combo invoke]
     1049                set _fields($fname) [list $label $units $components]
     1050                if { $_curFldName == "" } {
     1051                    set _curFldName $fname
     1052                    set _curFldLabel $label
     1053                }
     1054            }
     1055        }
     1056        $itk_component(field) value $_curFldLabel
     1057    }
     1058
     1059    InitSettings volume-palette volume-material volume-quality volumeVisible \
     1060        cutplaneVisible \
    10801061        cutplane-xposition cutplane-yposition cutplane-zposition \
    10811062        cutplane-xvisible cutplane-yvisible cutplane-zvisible
    10821063
    10831064    if { $_reset } {
    1084         InitSettings volume-lighting
     1065        InitSettings volumeLighting
    10851066        Zoom reset
    10861067        set _reset 0
     
    13261307    }
    13271308    switch -- $what {
    1328         "volume-visible" {
    1329             set bool $_settings(volume-visible)
     1309        "volumeVisible" {
     1310            set bool $_settings(volumeVisible)
    13301311            foreach dataset [CurrentDatasets -visible] {
    13311312                SendCmd "volume visible $bool $dataset"
     
    13501331            }
    13511332        }
    1352         "volume-lighting" {
    1353             set bool $_settings(volume-lighting)
     1333        "volumeLighting" {
     1334            set bool $_settings(volumeLighting)
    13541335            foreach dataset [CurrentDatasets -visible] {
    13551336                SendCmd "volume lighting $bool $dataset"
     
    13631344            }
    13641345        }
    1365         "axis-visible" {
    1366             set bool $_settings(axis-visible)
     1346        "axesVisible" {
     1347            set bool $_settings(axesVisible)
    13671348            SendCmd "axis visible all $bool"
    13681349        }
    1369         "axis-labels" {
    1370             set bool $_settings(axis-labels)
     1350        "axisLabels" {
     1351            set bool $_settings(axisLabels)
    13711352            SendCmd "axis labels all $bool"
    13721353        }
     
    13761357            SendCmd "axis grid $axis $bool"
    13771358        }
    1378         "axis-mode" {
     1359        "axisFlyMode" {
    13791360            set mode [$itk_component(axismode) value]
    13801361            set mode [$itk_component(axismode) translate $mode]
     
    13821363            SendCmd "axis flymode $mode"
    13831364        }
    1384         "cutplane-edges" {
     1365        "cutplaneEdges" {
    13851366            set bool $_settings($what)
    13861367            foreach dataset [CurrentDatasets -visible] {
     
    13881369            }
    13891370        }
    1390         "cutplane-visible" {
     1371        "cutplaneVisible" {
    13911372            set bool $_settings($what)
    13921373            foreach dataset [CurrentDatasets -visible] {
     
    13941375            }
    13951376        }
    1396         "cutplane-wireframe" {
     1377        "cutplaneWireframe" {
    13971378            set bool $_settings($what)
    13981379            foreach dataset [CurrentDatasets -visible] {
     
    14001381            }
    14011382        }
    1402         "cutplane-lighting" {
     1383        "cutplaneLighting" {
    14031384            set bool $_settings($what)
    14041385            foreach dataset [CurrentDatasets -visible] {
     
    14531434            set _legendPending 1
    14541435        }
    1455         "volume-field" {
    1456             set new [$itk_component(field) value]
    1457             set value [$itk_component(field) translate $new]
    1458             set _settings(volume-field) $value
    1459             if { [info exists _scalarFields($new)] } {
    1460                 set name $_scalarFields($new)
    1461                 set _colorMode scalar
    1462                 set _currentField $new
    1463             } elseif { [info exists _vectorFields($new)] } {
    1464                 set name $_vectorFields($new)
    1465                 set _colorMode vmag
    1466                 set _currentField $new
     1436        "field" {
     1437            set label [$itk_component(field) value]
     1438            set fname [$itk_component(field) translate $label]
     1439            set _settings(field) $fname
     1440            if { [info exists _fields($fname)] } {
     1441                foreach { label units components } $_fields($fname) break
     1442                if { $components > 1 } {
     1443                    set _colorMode vmag
     1444                } else {
     1445                    set _colorMode scalar
     1446                }
     1447                set _curFldName $fname
     1448                set _curFldLabel $label
    14671449            } else {
    1468                 puts stderr "unknown field \"$new\""
     1450                puts stderr "unknown field \"$fname\""
    14691451                return
    14701452            }
    1471             foreach dataset [CurrentDatasets -visible] {
    1472                 #puts stderr "volume colormode $_colorMode ${name} $dataset"
    1473                 puts stderr "cutplane colormode $_colorMode ${name} $dataset"
    1474                 #SendCmd "volume colormode $_colorMode ${name} $dataset"
    1475                 SendCmd "cutplane colormode $_colorMode ${name} $dataset"
    1476             }
    1477             set _legendPending 1
     1453            # Get the new limits because the field changed.
     1454            SendCmd "volume colormode $_colorMode ${name} $dataset"
     1455            SendCmd "cutplane colormode $_colorMode ${name} $dataset"
     1456            #SendCmd "dataset scalar $_curFldName"
     1457            SendCmd "camera reset"
     1458            DrawLegend
    14781459        }
    14791460        default {
     
    14991480        return
    15001481    }
    1501     if { [info exists _scalarFields($_currentField)] } {
    1502         set name $_scalarFields($_currentField)
    1503     } elseif { [info exists _vectorFields($_currentField)] } {
    1504         set name $_vectorFields($_currentField)
    1505     } else {
    1506         return
    1507     }
    15081482    # Set the legend on the first volume dataset.
    15091483    foreach dataset [CurrentDatasets -visible $_first] {
     
    15111485        if { [info exists _dataset2style($dataset)] } {
    15121486            SendCmdNoWait \
    1513                 "legend $_dataset2style($dataset) $_colorMode $name {} $w $h 0"
     1487                "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0"
    15141488            break;
    15151489        }
     
    16111585}
    16121586
    1613 itcl::body Rappture::VtkVolumeViewer::limits { dataobj } {
    1614     return
    1615     array unset _limits $dataobj-*
    1616     foreach comp [$dataobj components] {
    1617         set tag $dataobj-$comp
    1618         if { ![info exists _limits($tag)] } {
    1619             set data [$dataobj blob $comp]
    1620             set tmpfile file[pid].vtk
    1621             set f [open "$tmpfile" "w"]
    1622             fconfigure $f -translation binary -encoding binary
    1623             puts $f $data
    1624             close $f
    1625             set reader [vtkDataSetReader $tag-xvtkDataSetReader]
    1626             $reader SetFileName $tmpfile
    1627             $reader ReadAllScalarsOn
    1628             $reader ReadAllVectorsOn
    1629             $reader ReadAllFieldsOn
    1630             $reader Update
    1631             set output [$reader GetOutput]
    1632             set _limits($tag) [$output GetBounds]
    1633             set pointData [$output GetPointData]
    1634             puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]"
    1635             puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]"
    1636             puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]"
    1637             set fieldData [$output GetFieldData]
    1638             set pointData [$output GetPointData]
    1639             puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]"
    1640             for { set i 0 } { $i < [$fieldData GetNumberOfArrays] } { incr i } {
    1641                 puts stderr [$fieldData GetArrayName $i]
    1642             }
    1643             puts stderr "point \#arrays=[$pointData GetNumberOfArrays]"
    1644             for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } {
    1645                 set name [$pointData GetArrayName $i]
    1646                 if { ![info exists _fields($name)] } {
    1647                     $itk_component(field) choices insert end "$name" "$name"
    1648                     set _fields($name) 1
    1649                 }
    1650             }
    1651             puts stderr "field \#components=[$fieldData GetNumberOfComponents]"
    1652             puts stderr "point \#components=[$pointData GetNumberOfComponents]"
    1653             puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]"
    1654             puts stderr "point \#tuples=[$pointData GetNumberOfTuples]"
    1655             puts stderr "point \#scalars=[$pointData GetScalars]"
    1656             puts stderr vectors=[$pointData GetVectors]
    1657             rename $output ""
    1658             rename $reader ""
    1659             file delete $tmpfile
    1660         }
    1661         foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break
    1662         if {![info exists limits(xmin)] || $limits(xmin) > $xMin} {
    1663             set limits(xmin) $xMin
    1664         }
    1665         if {![info exists limits(xmax)] || $limits(xmax) < $xMax} {
    1666             set limits(xmax) $xMax
    1667         }
    1668         if {![info exists limits(ymin)] || $limits(ymin) > $yMin} {
    1669             set limits(ymin) $xMin
    1670         }
    1671         if {![info exists limits(ymax)] || $limits(ymax) < $yMax} {
    1672             set limits(ymax) $yMax
    1673         }
    1674         if {![info exists limits(zmin)] || $limits(zmin) > $zMin} {
    1675             set limits(zmin) $zMin
    1676         }
    1677         if {![info exists limits(zmax)] || $limits(zmax) < $zMax} {
    1678             set limits(zmax) $zMax
    1679         }
    1680     }
    1681     return [array get limits]
    1682 }
    1683 
    16841587itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} {
    16851588
     
    16941597    checkbutton $inner.volume \
    16951598        -text "Show Volume" \
    1696         -variable [itcl::scope _settings(volume-visible)] \
    1697         -command [itcl::code $this AdjustSetting volume-visible] \
     1599        -variable [itcl::scope _settings(volumeVisible)] \
     1600        -command [itcl::code $this AdjustSetting volumeVisible] \
    16981601        -font "Arial 9"
    16991602
    17001603    checkbutton $inner.lighting \
    17011604        -text "Enable Lighting" \
    1702         -variable [itcl::scope _settings(volume-lighting)] \
    1703         -command [itcl::code $this AdjustSetting volume-lighting] \
     1605        -variable [itcl::scope _settings(volumeLighting)] \
     1606        -command [itcl::code $this AdjustSetting volumeLighting] \
    17041607        -font "Arial 9"
    17051608
     
    17241627        -showvalue off -command [itcl::code $this AdjustSetting volume-quality]
    17251628
    1726     label $inner.field_l -text "Field" -font "Arial 9"
     1629    itk_component add field_l {
     1630        label $inner.field_l -text "Field" -font "Arial 9"
     1631    } {
     1632        ignore -font
     1633    }
    17271634    itk_component add field {
    17281635        Rappture::Combobox $inner.field -width 10 -editable no
    17291636    }
    17301637    bind $inner.field <<Value>> \
    1731         [itcl::code $this AdjustSetting volume-field]
     1638        [itcl::code $this AdjustSetting field]
    17321639
    17331640    label $inner.palette_l -text "Palette" -font "Arial 9"
     
    17581665
    17591666    blt::table $inner \
    1760         0,0 $inner.volume    -anchor w -pady 2 -cspan 4 \
     1667        0,0 $inner.field_l   -anchor w -pady 2  \
     1668        0,1 $inner.field     -anchor w -pady 2 -cspan 2 \
     1669        1,0 $inner.volume    -anchor w -pady 2 -cspan 4 \
    17611670        2,0 $inner.lighting  -anchor w -pady 2 -cspan 4 \
    17621671        3,0 $inner.dim_l     -anchor e -pady 2 \
     
    17651674        4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \
    17661675        5,0 $inner.quality   -fill x   -pady 2 -cspan 2 \
    1767         6,0 $inner.field_l   -anchor w -pady 2  \
    1768         6,1 $inner.field     -anchor w -pady 2 -cspan 2 \
    17691676        7,0 $inner.palette_l -anchor w -pady 2  \
    17701677        7,1 $inner.palette   -anchor w -pady 2 -cspan 2 \
    17711678
    17721679    blt::table configure $inner r* c* -resize none
    1773     blt::table configure $inner r8 c3 -resize expand
     1680    blt::table configure $inner r8 -resize expand
    17741681}
    17751682
     
    17861693    checkbutton $inner.visible \
    17871694        -text "Show Axes" \
    1788         -variable [itcl::scope _settings(axis-visible)] \
    1789         -command [itcl::code $this AdjustSetting axis-visible] \
     1695        -variable [itcl::scope _settings(axesVisible)] \
     1696        -command [itcl::code $this AdjustSetting axesVisible] \
    17901697        -font "Arial 9"
    17911698
    17921699    checkbutton $inner.labels \
    17931700        -text "Show Axis Labels" \
    1794         -variable [itcl::scope _settings(axis-labels)] \
    1795         -command [itcl::code $this AdjustSetting axis-labels] \
     1701        -variable [itcl::scope _settings(axisLabels)] \
     1702        -command [itcl::code $this AdjustSetting axisLabels] \
    17961703        -font "Arial 9"
    17971704
     
    18231730        "outer_edges"     "outer"         
    18241731    $itk_component(axismode) value "static"
    1825     bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis-mode]
     1732    bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode]
    18261733
    18271734    blt::table $inner \
     
    18651772        -font "Arial 9"
    18661773    blt::table $inner \
    1867             $row,0 $inner.ortho -columnspan 2 -anchor w -pady 2
     1774            $row,0 $inner.ortho -cspan 2 -anchor w -pady 2
    18681775    blt::table configure $inner r$row -resize none
    18691776    incr row
     
    18861793    checkbutton $inner.visible \
    18871794        -text "Show Cutplanes" \
    1888         -variable [itcl::scope _settings(cutplane-visible)] \
    1889         -command [itcl::code $this AdjustSetting cutplane-visible] \
     1795        -variable [itcl::scope _settings(cutplaneVisible)] \
     1796        -command [itcl::code $this AdjustSetting cutplaneVisible] \
    18901797        -font "Arial 9"
    18911798
    18921799    checkbutton $inner.wireframe \
    18931800        -text "Show Wireframe" \
    1894         -variable [itcl::scope _settings(cutplane-wireframe)] \
    1895         -command [itcl::code $this AdjustSetting cutplane-wireframe] \
     1801        -variable [itcl::scope _settings(cutplaneWireframe)] \
     1802        -command [itcl::code $this AdjustSetting cutplaneWireframe] \
    18961803        -font "Arial 9"
    18971804
    18981805    checkbutton $inner.lighting \
    18991806        -text "Enable Lighting" \
    1900         -variable [itcl::scope _settings(cutplane-lighting)] \
    1901         -command [itcl::code $this AdjustSetting cutplane-lighting] \
     1807        -variable [itcl::scope _settings(cutplaneLighting)] \
     1808        -command [itcl::code $this AdjustSetting cutplaneLighting] \
    19021809        -font "Arial 9"
    19031810
    19041811    checkbutton $inner.edges \
    19051812        -text "Show Edges" \
    1906         -variable [itcl::scope _settings(cutplane-edges)] \
    1907         -command [itcl::code $this AdjustSetting cutplane-edges] \
     1813        -variable [itcl::scope _settings(cutplaneEdges)] \
     1814        -command [itcl::code $this AdjustSetting cutplaneEdges] \
    19081815        -font "Arial 9"
    19091816
     
    21712078
    21722079    SendCmd "volume lighting $settings(-lighting) $tag"
    2173     set _settings(volume-lighting) $settings(-lighting)
     2080    set _settings(volumeLighting) $settings(-lighting)
    21742081    SetColormap $dataobj $comp
    21752082}
     
    21922099    set _legendPending 0
    21932100    puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size"
    2194     set _limits(vmin) $vmin
    2195     set _limits(vmax) $vmax
    2196     set _title $title
    2197     regsub {\(mag\)} $title "" _title
    21982101    if { [IsConnected] } {
    21992102        set bytes [ReceiveBytes $size]
     
    22032106        $_image(legend) configure -data $bytes
    22042107        #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>"
    2205         if { [catch {DrawLegend $_title} errs] != 0 } {
     2108        if { [catch {DrawLegend} errs] != 0 } {
    22062109            puts stderr errs=$errs
    22072110        }
     
    22152118#       of the contour plot area.
    22162119#
    2217 itcl::body Rappture::VtkVolumeViewer::DrawLegend { name } {
     2120itcl::body Rappture::VtkVolumeViewer::DrawLegend { } {
     2121    set fname $_curFldName
    22182122    set c $itk_component(view)
    22192123    set w [winfo width $c]
     
    22222126    set lineht [font metrics $font -linespace]
    22232127   
    2224     if { [info exists _fields($name)] } {
    2225         foreach { title units } $_fields($name) break
     2128    if { [info exists _fields($fname)] } {
     2129        foreach { title units } $_fields($fname) break
    22262130        if { $units != "" } {
    22272131            set title [format "%s (%s)" $title $units]
    22282132        }
    22292133    } else {
    2230         set title $name
    2231     }
    2232     if { $_settings(legend-visible) } {
     2134        set title $fname
     2135    }
     2136    if { $_settings(legendVisible) } {
    22332137        set x [expr $w - 2]
    22342138        if { [$c find withtag "legend"] == "" } {
     
    22602164        # Reset the item coordinates according the current size of the plot.
    22612165        $c itemconfigure title -text $title
    2262         if { $_limits(vmin) != "" } {
    2263             $c itemconfigure vmin -text [format %g $_limits(vmin)]
    2264         }
    2265         if { $_limits(vmax) != "" } {
    2266             $c itemconfigure vmax -text [format %g $_limits(vmax)]
     2166        if { [info exists _limits($_curFldName)] } {
     2167            foreach { vmin vmax } $_limits($_curFldName) break
     2168            $c itemconfigure vmin -text [format %g $vmin]
     2169            $c itemconfigure vmax -text [format %g $vmax]
    22672170        }
    22682171        set y 2
     
    23372240
    23382241    # Compute the value of the point
    2339     if { [info exists _limits(vmax)] && [info exists _limits(vmin)] } {
     2242    if { [info exists _limits($_curFldName)] } {
     2243        foreach { vmin vmax } $_limits($_curFldName) break
    23402244        set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
    2341         set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
     2245        set value [expr $t * ($vmax - $vmin) + $vmin]
    23422246    } else {
    23432247        set value 0.0
     
    24112315        }
    24122316        invoke {
    2413             $itk_component(field) value $_currentField
    2414             AdjustSetting volume-field
     2317            $itk_component(field) value _curFldLabel
     2318            AdjustSetting field
    24152319        }
    24162320        default {
Note: See TracChangeset for help on using the changeset viewer.