Ignore:
Timestamp:
Sep 27, 2013 3:05:18 AM (11 years ago)
Author:
ldelgass
Message:

Bring vtk volume viewer UI closer in line with new nanovis viewer, add settings
for blendmode, opacity. Note that some controls only work with certain volume
mappers in VTK (right now this is selected when the server is built).

File:
1 edited

Legend:

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

    r3923 r3963  
    143143    private variable _curFldName ""
    144144    private variable _curFldLabel ""
    145     private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
     145    private variable _colorMode "scalar";#  Mode of colormap (vmag or scalar)
    146146}
    147147
     
    232232        cutplaneWireframe       0
    233233        cutplane-opacity        100
     234        volume-blendmode        composite
    234235        volumeLighting          1
    235         volume-material         80
    236         volume-opacity          40
     236        volume-ambient          40
     237        volume-diffuse          60
     238        volume-specularLevel    30
     239        volume-specularExponent 90
     240        volume-opacity          50
    237241        volume-quality          50
    238242        volumeVisible           1
     
    10331037    }
    10341038
    1035     InitSettings volume-palette volume-material volume-quality volumeVisible \
     1039    InitSettings volume-palette \
     1040        volume-ambient volume-diffuse volume-specularLevel volume-specularExponent \
     1041        volume-opacity volume-quality volumeVisible \
    10361042        cutplaneVisible \
    10371043        cutplane-xposition cutplane-yposition cutplane-zposition \
     
    12961302            }
    12971303        }
    1298         "volume-material" {
    1299             set val $_settings(volume-material)
     1304        "volume-blendmode" {
     1305            set val [$itk_component(blendmode) value]
     1306            set mode [$itk_component(blendmode) translate $val]
     1307            set _settings(volume-blendmode) $mode
     1308            foreach dataset [CurrentDatasets -visible] {
     1309                SendCmd "volume blendmode $mode $dataset"
     1310            }
     1311        }
     1312        "volume-ambient" {
     1313            set val $_settings(volume-ambient)
     1314            set ambient [expr {0.01*$val}]
     1315            foreach dataset [CurrentDatasets -visible] {
     1316                SendCmd "volume shading ambient $ambient $dataset"
     1317            }
     1318        }
     1319        "volume-diffuse" {
     1320            set val $_settings(volume-diffuse)
    13001321            set diffuse [expr {0.01*$val}]
    1301             set specular [expr {0.01*$val}]
    1302             #set power [expr {sqrt(160*$val+1.0)}]
    1303             set power [expr {$val+1.0}]
    13041322            foreach dataset [CurrentDatasets -visible] {
    13051323                SendCmd "volume shading diffuse $diffuse $dataset"
    1306                 SendCmd "volume shading specular $specular $power $dataset"
     1324            }
     1325        }
     1326        "volume-specularLevel" - "volume-specularExponent" {
     1327            set val $_settings(volume-specularLevel)
     1328            set specularLevel [expr {0.01*$val}]
     1329            set specularExponent $_settings(volume-specularExponent)
     1330            foreach dataset [CurrentDatasets -visible] {
     1331                SendCmd "volume shading specular $specularLevel $specularExponent $dataset"
    13071332            }
    13081333        }
     
    13111336            foreach dataset [CurrentDatasets -visible] {
    13121337                SendCmd "volume lighting $bool $dataset"
     1338            }
     1339        }
     1340        "volume-opacity" {
     1341            set val $_settings(volume-opacity)
     1342            set val [expr {0.01*$val}]
     1343            foreach dataset [CurrentDatasets -visible] {
     1344                SendCmd "volume opacity $val $dataset"
    13131345            }
    13141346        }
     
    13911423            }
    13921424            set _cutplanePending 0
    1393         }
    1394         "volume-palette" {
    1395             set palette [$itk_component(palette) value]
    1396             set _settings(volume-palette) $palette
    1397             foreach dataset [CurrentDatasets -visible $_first] {
    1398                 foreach {dataobj comp} [split $dataset -] break
    1399                 ChangeColormap $dataobj $comp $palette
    1400             }
    1401             set _legendPending 1
    14021425        }
    14031426        "volume-palette" {
     
    15621585
    15631586itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} {
    1564 
    1565     set fg [option get $itk_component(hull) font Font]
    1566     #set bfg [option get $itk_component(hull) boldFont Font]
     1587    set font [option get $itk_component(hull) font Font]
     1588    #set bfont [option get $itk_component(hull) boldFont Font]
    15671589
    15681590    set inner [$itk_component(main) insert end \
     
    15711593    $inner configure -borderwidth 4
    15721594
    1573     checkbutton $inner.volume \
    1574         -text "Show Volume" \
     1595    checkbutton $inner.visibility \
     1596        -text "Visible" \
     1597        -font $font \
    15751598        -variable [itcl::scope _settings(volumeVisible)] \
    1576         -command [itcl::code $this AdjustSetting volumeVisible] \
    1577         -font "Arial 9"
     1599        -command [itcl::code $this AdjustSetting volumeVisible]
     1600
     1601    label $inner.lighting_l \
     1602        -text "Lighting / Material Properties" \
     1603        -font "Arial 9 bold"
    15781604
    15791605    checkbutton $inner.lighting \
    15801606        -text "Enable Lighting" \
     1607        -font $font \
    15811608        -variable [itcl::scope _settings(volumeLighting)] \
    1582         -command [itcl::code $this AdjustSetting volumeLighting] \
    1583         -font "Arial 9"
    1584 
    1585     label $inner.dim_l -text "Dim" -font "Arial 9"
    1586     ::scale $inner.material -from 0 -to 100 -orient horizontal \
    1587         -variable [itcl::scope _settings(volume-material)] \
    1588         -width 10 \
    1589         -showvalue off -command [itcl::code $this AdjustSetting volume-material]
    1590     label $inner.bright_l -text "Bright" -font "Arial 9"
    1591 
    1592     label $inner.opacity_l -text "Opacity" -font "Arial 9"
     1609        -command [itcl::code $this AdjustSetting volumeLighting]
     1610
     1611    label $inner.ambient_l \
     1612        -text "Ambient" \
     1613        -font $font
     1614    ::scale $inner.ambient -from 0 -to 100 -orient horizontal \
     1615        -variable [itcl::scope _settings(volume-ambient)] \
     1616        -showvalue off -command [itcl::code $this AdjustSetting volume-ambient] \
     1617        -troughcolor grey92
     1618
     1619    label $inner.diffuse_l -text "Diffuse" -font $font
     1620    ::scale $inner.diffuse -from 0 -to 100 -orient horizontal \
     1621        -variable [itcl::scope _settings(volume-diffuse)] \
     1622        -showvalue off -command [itcl::code $this AdjustSetting volume-diffuse] \
     1623        -troughcolor grey92
     1624
     1625    label $inner.specularLevel_l -text "Specular" -font $font
     1626    ::scale $inner.specularLevel -from 0 -to 100 -orient horizontal \
     1627        -variable [itcl::scope _settings(volume-specularLevel)] \
     1628        -showvalue off -command [itcl::code $this AdjustSetting volume-specularLevel] \
     1629        -troughcolor grey92
     1630
     1631    label $inner.specularExponent_l -text "Shininess" -font $font
     1632    ::scale $inner.specularExponent -from 10 -to 128 -orient horizontal \
     1633        -variable [itcl::scope _settings(volume-specularExponent)] \
     1634        -showvalue off -command [itcl::code $this AdjustSetting volume-specularExponent] \
     1635        -troughcolor grey92
     1636
     1637    label $inner.opacity_l -text "Opacity" -font $font
    15931638    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    15941639        -variable [itcl::scope _settings(volume-opacity)] \
    1595         -width 10 \
    1596         -showvalue off \
    1597         -command [itcl::code $this AdjustSetting volume-opacity]
    1598 
    1599     label $inner.quality_l -text "Quality" -font "Arial 9"
     1640        -showvalue off -command [itcl::code $this AdjustSetting volume-opacity] \
     1641        -troughcolor grey92
     1642
     1643    label $inner.quality_l -text "Quality" -font $font
    16001644    ::scale $inner.quality -from 0 -to 100 -orient horizontal \
    16011645        -variable [itcl::scope _settings(volume-quality)] \
    1602         -width 10 \
    1603         -showvalue off -command [itcl::code $this AdjustSetting volume-quality]
    1604 
    1605     itk_component add field_l {
    1606         label $inner.field_l -text "Field" -font "Arial 9"
    1607     } {
    1608         ignore -font
    1609     }
     1646        -showvalue off -command [itcl::code $this AdjustSetting volume-quality] \
     1647        -troughcolor grey92
     1648
     1649    label $inner.field_l -text "Field" -font $font
    16101650    itk_component add field {
    1611         Rappture::Combobox $inner.field -width 10 -editable no
     1651        Rappture::Combobox $inner.field -editable no
    16121652    }
    16131653    bind $inner.field <<Value>> \
    16141654        [itcl::code $this AdjustSetting field]
    16151655
    1616     label $inner.palette_l -text "Palette" -font "Arial 9"
     1656    label $inner.transferfunction_l \
     1657        -text "Transfer Function" -font "Arial 9 bold"
     1658
     1659    label $inner.palette_l -text "Colormap" -font $font
    16171660    itk_component add palette {
    16181661        Rappture::Combobox $inner.palette -width 10 -editable no
     
    16401683        [itcl::code $this AdjustSetting volume-palette]
    16411684
     1685    label $inner.blendmode_l -text "Blend Mode" -font "Arial 9"
     1686    itk_component add blendmode {
     1687        Rappture::Combobox $inner.blendmode -editable no
     1688    }
     1689    $inner.blendmode choices insert end \
     1690        "composite"          "Composite"         \
     1691        "max_intensity"      "Maximum Intensity" \
     1692        "additive"           "Additive"
     1693
     1694    $itk_component(blendmode) value "composite"
     1695    bind $inner.blendmode <<Value>> \
     1696        [itcl::code $this AdjustSetting volume-blendmode]
     1697
    16421698    blt::table $inner \
    1643         0,0 $inner.field_l   -anchor w -pady 2  \
    1644         0,1 $inner.field     -anchor w -pady 2 -cspan 2 \
    1645         1,0 $inner.volume    -anchor w -pady 2 -cspan 4 \
    1646         2,0 $inner.lighting  -anchor w -pady 2 -cspan 4 \
    1647         3,0 $inner.dim_l     -anchor e -pady 2 \
    1648         3,1 $inner.material  -fill x   -pady 2 \
    1649         3,2 $inner.bright_l  -anchor w -pady 2 \
    1650         4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \
    1651         5,0 $inner.quality   -fill x   -pady 2 -cspan 2 \
    1652         7,0 $inner.palette_l -anchor w -pady 2  \
    1653         7,1 $inner.palette   -anchor w -pady 2 -cspan 2 \
     1699        0,0 $inner.field_l   -anchor e -cspan 2  \
     1700        0,2 $inner.field               -cspan 3 -fill x \
     1701        1,1 $inner.lighting_l -anchor w -cspan 4 \
     1702        2,1 $inner.lighting   -anchor w -cspan 3 \
     1703        3,1 $inner.ambient_l       -anchor e -pady 2 \
     1704        3,2 $inner.ambient                   -cspan 3 -fill x \
     1705        4,1 $inner.diffuse_l       -anchor e -pady 2 \
     1706        4,2 $inner.diffuse                   -cspan 3 -fill x \
     1707        5,1 $inner.specularLevel_l -anchor e -pady 2 \
     1708        5,2 $inner.specularLevel             -cspan 3 -fill x \
     1709        6,1 $inner.specularExponent_l -anchor e -pady 2 \
     1710        6,2 $inner.specularExponent          -cspan 3 -fill x \
     1711        7,1 $inner.visibility    -anchor w -cspan 3 \
     1712        8,1 $inner.quality_l -anchor e -pady 2 \
     1713        8,2 $inner.quality                     -cspan 3 -fill x \
     1714        9,1 $inner.transferfunction_l -anchor w              -cspan 4 \
     1715        10,1 $inner.opacity_l -anchor e -pady 2 \
     1716        10,2 $inner.opacity                    -cspan 3 -fill x \
     1717        11,1 $inner.palette_l -anchor e  \
     1718        11,2 $inner.palette                 -padx 2 -cspan 3 -fill x \
     1719        12,1 $inner.blendmode_l -anchor e  \
     1720        12,2 $inner.blendmode               -padx 2 -cspan 3 -fill x \
    16541721
    16551722    blt::table configure $inner r* c* -resize none
    1656     blt::table configure $inner r8 -resize expand
     1723    blt::table configure $inner r* -pady { 2 0 }
     1724    blt::table configure $inner c2 c3 r13 -resize expand
     1725    blt::table configure $inner c0 -width .1i
    16571726}
    16581727
Note: See TracChangeset for help on using the changeset viewer.