Changeset 4121 for trunk/gui/scripts


Ignore:
Timestamp:
Jan 15, 2014 2:18:29 PM (10 years ago)
Author:
gah
Message:

feature: add background color controls to nanovisviewer and vtkvolumeviewer

Location:
trunk/gui/scripts
Files:
3 edited

Legend:

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

    r4088 r4121  
    217217
    218218    array set _settings [subst {
     219        background              black
    219220        $this-ambient           60
    220221        $this-colormap          default
     
    12461247            SwitchComponent $cname
    12471248        }
     1249        "background" {
     1250            set bgcolor [$itk_component(background) value]
     1251            array set fgcolors {
     1252                "black" "white"
     1253                "white" "black"
     1254                "grey"  "black"
     1255            }
     1256            configure -plotbackground $bgcolor \
     1257                -plotforeground $fgcolors($bgcolor)
     1258            DrawLegend $_current
     1259        }
    12481260        ambient {
    12491261            set val $_settings($this-ambient)
     
    16791691        -font "Arial 9"
    16801692
     1693    label $inner.background_l -text "Background" -font "Arial 9"
     1694    itk_component add background {
     1695        Rappture::Combobox $inner.background -width 10 -editable no
     1696    }
     1697    $inner.background choices insert end \
     1698        "black"              "black"            \
     1699        "white"              "white"            \
     1700        "grey"               "grey"             
     1701
     1702    $itk_component(background) value $_settings(background)
     1703    bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
     1704
    16811705    blt::table $inner \
    16821706        0,0 $inner.axes  -cspan 2 -anchor w \
     
    16841708        2,0 $inner.outline  -cspan 2 -anchor w \
    16851709        3,0 $inner.volume  -cspan 2 -anchor w \
    1686         4,0 $inner.legend  -cspan 2 -anchor w
     1710        4,0 $inner.legend  -cspan 2 -anchor w \
     1711        5,0 $inner.background_l       -anchor e -pady 2 \
     1712        5,1 $inner.background                   -fill x \
    16871713
    16881714    if 0 {
     
    16901716    }
    16911717    blt::table configure $inner r* -resize none
    1692     blt::table configure $inner r5 -resize expand
     1718    blt::table configure $inner r6 -resize expand
    16931719}
    16941720
  • trunk/gui/scripts/transferfunctioneditor.tcl

    r4088 r4121  
    127127    set _labels($name) [$_canvas create text 0 $h \
    128128                            -anchor n -fill white -font "Helvetica 8" \
    129                             -tags "$this $_name" -state $state]
     129                            -tags "labels $this $_name" -state $state]
    130130    set _id2name($_ticks($name)) $name
    131131    $_canvas bind $_ticks($name) <Enter> [itcl::code $this EnterTick $name]
  • trunk/gui/scripts/vtkvolumeviewer.tcl

    r4119 r4121  
    6464    public method updateTransferFunctions {}
    6565
     66    private method BuildViewTab {}
    6667    private method BuildVolumeComponents {}
    6768    private method ComputeAlphamap { cname }
     
    246247        axisGridZ               0
    247248        axisLabels              1
     249        background              black
    248250        cutplaneEdges           0
    249251        cutplaneLighting        1
     
    367369
    368370    if { [catch {
     371        BuildViewTab
    369372        BuildVolumeTab
    370373        BuildCutplaneTab
     
    10211024        }
    10221025        DoRotate
    1023         InitSettings axisGridX axisGridY axisGridZ axisFlyMode \
     1026        InitSettings background axisGridX axisGridY axisGridZ axisFlyMode \
    10241027            axesVisible axisLabels
    10251028        PanCamera
     
    13761379    }
    13771380    switch -- $what {
     1381        "background" {
     1382            set bgcolor [$itk_component(background) value]
     1383            array set fgcolors {
     1384                "black" "white"
     1385                "white" "black"
     1386                "grey"  "black"
     1387            }
     1388            configure -plotbackground $bgcolor \
     1389                -plotforeground $fgcolors($bgcolor)
     1390            $itk_component(view) delete "legend"
     1391            DrawLegend
     1392        }
    13781393        "volumeVisible" {
    13791394            set bool $_settings(volumeVisible)
     
    16141629itcl::configbody Rappture::VtkVolumeViewer::plotbackground {
    16151630    if { [isconnected] } {
    1616         foreach {r g b} [Color2RGB $itk_option(-plotbackground)] break
    1617         SendCmd "screen bgcolor $r $g $b"
     1631        set color $itk_option(-plotbackground)
     1632        set rgb [Color2RGB $color]
     1633        SendCmd "screen bgcolor $rgb"
     1634        $itk_component(legend) configure -background $color
    16181635    }
    16191636}
     
    16241641itcl::configbody Rappture::VtkVolumeViewer::plotforeground {
    16251642    if { [isconnected] } {
    1626         foreach {r g b} [Color2RGB $itk_option(-plotforeground)] break
    1627         #fix this!
    1628         #SendCmd "color background $r $g $b"
    1629     }
     1643        set color $itk_option(-plotforeground)
     1644        set rgb [Color2RGB $color]
     1645        SendCmd "axis color all $rgb"
     1646        SendCmd "outline color $rgb"
     1647        SendCmd "cutplane color $rgb"
     1648        $itk_component(legend) itemconfigure labels -fill $color
     1649        $itk_component(legend) itemconfigure limits -fill $color
     1650    }
     1651}
     1652
     1653itcl::body Rappture::VtkVolumeViewer::BuildViewTab {} {
     1654    foreach { key value } {
     1655        grid            0
     1656        axes            1
     1657        outline         0
     1658        volume          1
     1659        legend          1
     1660        particles       1
     1661        lic             1
     1662    } {
     1663        set _settings($this-$key) $value
     1664    }
     1665
     1666    set fg [option get $itk_component(hull) font Font]
     1667    #set bfg [option get $itk_component(hull) boldFont Font]
     1668
     1669    set inner [$itk_component(main) insert end \
     1670        -title "View Settings" \
     1671        -icon [Rappture::icon wrench]]
     1672    $inner configure -borderwidth 4
     1673
     1674    checkbutton $inner.axes \
     1675        -text "Axes" \
     1676        -variable [itcl::scope _settings(axesVisible)] \
     1677        -command [itcl::code $this AdjustSetting axesVisible] \
     1678        -font "Arial 9"
     1679
     1680    checkbutton $inner.outline \
     1681        -text "Outline" \
     1682        -variable [itcl::scope _settings(outline)] \
     1683        -command [itcl::code $this AdjustSetting outline] \
     1684        -font "Arial 9"
     1685
     1686    checkbutton $inner.legend \
     1687        -text "Legend" \
     1688        -variable [itcl::scope _settings(legendVisible)] \
     1689        -command [itcl::code $this AdjustSetting legendVisible] \
     1690        -font "Arial 9"
     1691
     1692    checkbutton $inner.volume \
     1693        -text "Volume" \
     1694        -variable [itcl::scope _settings(volumeVisible)] \
     1695        -command [itcl::code $this AdjustSetting volumeVisible] \
     1696        -font "Arial 9"
     1697
     1698    label $inner.background_l -text "Background" -font "Arial 9"
     1699    itk_component add background {
     1700        Rappture::Combobox $inner.background -width 10 -editable no
     1701    }
     1702    $inner.background choices insert end \
     1703        "black"              "black"            \
     1704        "white"              "white"            \
     1705        "grey"               "grey"             
     1706
     1707    $itk_component(background) value $_settings(background)
     1708    bind $inner.background <<Value>> [itcl::code $this AdjustSetting background]
     1709
     1710    blt::table $inner \
     1711        0,0 $inner.axes  -cspan 2 -anchor w \
     1712        1,0 $inner.outline  -cspan 2 -anchor w \
     1713        2,0 $inner.volume  -cspan 2 -anchor w \
     1714        3,0 $inner.legend  -cspan 2 -anchor w \
     1715        4,0 $inner.background_l       -anchor e -pady 2 \
     1716        4,1 $inner.background                   -fill x \
     1717
     1718    blt::table configure $inner r* -resize none
     1719    blt::table configure $inner r5 -resize expand
    16301720}
    16311721
Note: See TracChangeset for help on using the changeset viewer.