Ignore:
Timestamp:
Sep 29, 2011, 1:32:40 PM (13 years ago)
Author:
gah
Message:

streamlines update: cutplanes, paletttes

File:
1 edited

Legend:

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

    r2586 r2587  
    102102    private method MotionLegend { x y }
    103103    private method PanCamera {}
    104     private method RequestLegend { {mode "vmag"} }
     104    private method RequestLegend {}
    105105    private method SetColormap { dataobj comp }
    106106    private method ChangeColormap { dataobj comp color }
     
    151151    private variable _outline
    152152    private variable _fields
     153    private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
    153154}
    154155
     
    236237    }]
    237238    array set _cutplane [subst {
     239        edges           0
    238240        xvisible        0
    239241        yvisible        0
     
    243245        zposition       0
    244246        visible         1
     247        wireframe       0
     248        opacity         1
    245249    }]
    246250    array set _volume [subst {
     
    255259        visible         1
    256260        opacity         100
    257         seeddensity     40
     261        seeddensity     200
    258262        lighting        1
    259263        scale           1
     
    441445    eval itk_initialize $args
    442446    Connect
     447    update
    443448}
    444449
     
    926931itcl::body Rappture::VtkStreamlinesViewer::Rebuild {} {
    927932    update
    928 
    929933    set w [winfo width $itk_component(view)]
    930934    set h [winfo height $itk_component(view)]
     
    13141318            SendCmd "axis flymode $mode"
    13151319        }
     1320        "cutplane-edges" {
     1321            set bool $_cutplane(edges)
     1322            foreach dataset [CurrentDatasets -visible $_first] {
     1323                SendCmd "cutplane edges $bool $dataset"
     1324            }
     1325        }
     1326        "cutplane-visible" {
     1327            set bool $_cutplane(visible)
     1328            foreach dataset [CurrentDatasets -visible $_first] {
     1329                SendCmd "cutplane visible $bool $dataset"
     1330            }
     1331        }
     1332        "cutplane-wireframe" {
     1333            set bool $_cutplane(wireframe)
     1334            foreach dataset [CurrentDatasets -visible $_first] {
     1335                SendCmd "cutplane wireframe $bool $dataset"
     1336            }
     1337        }
     1338        "cutplane-lighting" {
     1339            set bool $_cutplane(lighting)
     1340            foreach dataset [CurrentDatasets -visible $_first] {
     1341                SendCmd "cutplane lighting $bool $dataset"
     1342            }
     1343        }
     1344        "cutplane-opacity" {
     1345            set val $_cutplane(opacity)
     1346            set sval [expr { 0.01 * double($val) }]
     1347            foreach dataset [CurrentDatasets -visible $_first] {
     1348                SendCmd "cutplane opacity $sval $dataset"
     1349            }
     1350        }
    13161351        "xcutplane-visible" - "ycutplane-visible" - "zcutplane-visible" {
    13171352            set axis [string range $what 0 0]
     
    13251360            }
    13261361            SendCmd "cutplane axis $axis $bool"
    1327             SendCmd "cutplane colormode vmag"
     1362            SendCmd "cutplane colormode $_colorMode"
    13281363        }
    13291364        "xcutplane-position" - "ycutplane-position" - "zcutplane-position" {
     
    13401375        }
    13411376        "streamlines-seeddensity" {
    1342             set density [expr int($_streamlines(seeddensity) * 5.0)]
     1377            set density $_streamlines(seeddensity)
    13431378            foreach dataset [CurrentDatasets -visible $_first] {
     1379                foreach {dataobj comp} [split $dataset -] break
    13441380                # This command works for either random or fmesh seeds
    1345                 SendCmd "streamlines seed numpts $density $dataset"
     1381                #SendCmd "streamlines seed numpts $density $dataset"
     1382                set seeds [$dataobj hints seeds]
     1383                if { $seeds != "" } {
     1384                    set length [string length $seeds]
     1385                    SendCmd "streamlines seed fmesh $density data follows $length $dataset"
     1386                    SendCmd "$seeds"
     1387                    set _seeds($dataobj) 1
     1388                }
    13461389            }
    13471390        }
     
    13671410                    }
    13681411                    "ribbons" {
    1369                         SendCmd "streamlines ribbons 1 0 $dataset"
     1412                        SendCmd "streamlines ribbons 3 0 $dataset"
    13701413                    }
    13711414                    "tubes" {
    1372                         SendCmd "streamlines tubes 5 1 $dataset"
     1415                        SendCmd "streamlines tubes 5 3 $dataset"
    13731416                    }
    13741417                }
     
    13811424                ChangeColormap $dataobj $comp $palette
    13821425            }
     1426            RequestLegend
    13831427        }
    13841428        "streamlines-opacity" {
     
    14041448        "streamlines-field" {
    14051449            set field [$itk_component(field) value]
    1406             set mode scalar
     1450            set _colorMode scalar
    14071451            if { $field == "U" } {
    1408                 set mode vmag
     1452                set _colorMode vmag
    14091453            }
    14101454            foreach dataset [CurrentDatasets -visible $_first] {
    14111455                SendCmd "dataset scalar ${field} $dataset"
    1412                 SendCmd "streamlines colormode ${mode} $dataset"
    1413                 SendCmd "streamlines colormode ${mode} $dataset"
    1414                 #SendCmd "dataset vector ${field} $dataset"
     1456                SendCmd "streamlines colormode $_colorMode $dataset"
     1457                SendCmd "streamlines colormode $_colorMode $dataset"
    14151458            }
    1416             RequestLegend $mode
     1459            RequestLegend
    14171460        }
    14181461        default {
     
    14291472#       to be vertical when drawn.
    14301473#
    1431 itcl::body Rappture::VtkStreamlinesViewer::RequestLegend { {mode vmag} } {
    1432     #puts stderr "RequestLegend _first=$_first"
     1474itcl::body Rappture::VtkStreamlinesViewer::RequestLegend {} {
     1475    puts stderr "RequestLegend _first=$_first"
    14331476    #puts stderr "RequestLegend width=$_width height=$_height"
    14341477    set font "Arial 8"
     
    14441487        foreach {dataobj comp} [split $dataset -] break
    14451488        if { [info exists _dataset2style($dataset)] } {
    1446             #puts stderr "RequestLegend w=$w h=$h"
    1447             SendCmd "legend $_dataset2style($dataset) $mode {} $w $h 0"
     1489            puts stderr "RequestLegend w=$w h=$h"
     1490            SendCmd "legend $_dataset2style($dataset) $_colorMode {} $w $h 0"
    14481491            break;
    14491492        }
     
    14561499itcl::body Rappture::VtkStreamlinesViewer::ChangeColormap {dataobj comp color} {
    14571500    set tag $dataobj-$comp
    1458     if { ![info exist _styles($tag)] } {
     1501    if { ![info exist _style($tag)] } {
    14591502        error "no initial colormap"
    14601503    }
    1461     set _style(-color) $color
     1504    array set style $_style($tag)
     1505    set style(-color) $color
     1506    set _style($tag) [array get style]
    14621507    SetColormap $dataobj $comp
    14631508}
     
    14681513itcl::body Rappture::VtkStreamlinesViewer::SetColormap { dataobj comp } {
    14691514    array set style {
    1470         -color rainbow
     1515        -color BGYOR
    14711516        -levels 6
    14721517        -opacity 1.0
     
    14941539    if { ![info exists _dataset2style($tag)] ||
    14951540         $_dataset2style($tag) != $name } {
     1541        puts stderr "streamlines colormap $name $tag"
     1542        puts stderr "cutplane colormap $name $tag"
    14961543        SendCmd "streamlines colormap $name $tag"
    14971544        SendCmd "cutplane colormap $name $tag"
    1498     }
    1499 }
     1545        set _dataset2style($tag) $name
     1546    }
     1547}
     1548
     1549
     1550
     1551
     1552
     1553
     1554
     1555
     1556
     1557
     1558
     1559
     1560
    15001561
    15011562itcl::body Rappture::VtkStreamlinesViewer::ColorsToColormap { colors } {
    15021563    switch -- $colors {
    1503         "blue-to-gray" {
     1564        "grey-to-blue" {
    15041565            return {
    1505                 0.0 0.000 0.600 0.800
    1506                 0.14285714285714285 0.400 0.900 1.000
    1507                 0.2857142857142857 0.600 1.000 1.000
    1508                 0.42857142857142855 0.800 1.000 1.000
    1509                 0.5714285714285714 0.900 0.900 0.900
    1510                 0.7142857142857143 0.600 0.600 0.600
    1511                 0.8571428571428571 0.400 0.400 0.400
    1512                 1.0 0.200 0.200 0.200
     1566                0.0                      0.200 0.200 0.200
     1567                0.14285714285714285      0.400 0.400 0.400
     1568                0.2857142857142857       0.600 0.600 0.600
     1569                0.42857142857142855      0.900 0.900 0.900
     1570                0.5714285714285714       0.800 1.000 1.000
     1571                0.7142857142857143       0.600 1.000 1.000
     1572                0.8571428571428571       0.400 0.900 1.000
     1573                1.0                      0.000 0.600 0.800
     1574            }
     1575        }
     1576        "blue-to-grey" {
     1577            return {
     1578                0.0                     0.000 0.600 0.800
     1579                0.14285714285714285     0.400 0.900 1.000
     1580                0.2857142857142857      0.600 1.000 1.000
     1581                0.42857142857142855     0.800 1.000 1.000
     1582                0.5714285714285714      0.900 0.900 0.900
     1583                0.7142857142857143      0.600 0.600 0.600
     1584                0.8571428571428571      0.400 0.400 0.400
     1585                1.0                     0.200 0.200 0.200
    15131586            }
    15141587        }
    15151588        "blue" {
    15161589            return {
    1517                 0.0 0.900 1.000 1.000
    1518                 0.1111111111111111 0.800 0.983 1.000
    1519                 0.2222222222222222 0.700 0.950 1.000
    1520                 0.3333333333333333 0.600 0.900 1.000
    1521                 0.4444444444444444 0.500 0.833 1.000
    1522                 0.5555555555555556 0.400 0.750 1.000
    1523                 0.6666666666666666 0.300 0.650 1.000
    1524                 0.7777777777777778 0.200 0.533 1.000
    1525                 0.8888888888888888 0.100 0.400 1.000
    1526                 1.0 0.000 0.250 1.000
    1527             }
    1528         }
    1529         "blue-to-brown" {
     1590                0.0                     0.900 1.000 1.000
     1591                0.1111111111111111      0.800 0.983 1.000
     1592                0.2222222222222222      0.700 0.950 1.000
     1593                0.3333333333333333      0.600 0.900 1.000
     1594                0.4444444444444444      0.500 0.833 1.000
     1595                0.5555555555555556      0.400 0.750 1.000
     1596                0.6666666666666666      0.300 0.650 1.000
     1597                0.7777777777777778      0.200 0.533 1.000
     1598                0.8888888888888888      0.100 0.400 1.000
     1599                1.0                     0.000 0.250 1.000
     1600            }
     1601        }
     1602        "brown-to-blue" {
    15301603            return {
    15311604                0.0                             0.200   0.100   0.000
     
    15411614                0.9090909090909091              0.000   0.667   0.800
    15421615                1.0                             0.000   0.480   0.600
     1616            }
     1617        }
     1618        "blue-to-brown" {
     1619            return {
     1620                0.0                             0.000   0.480   0.600
     1621                0.09090909090909091             0.000   0.667   0.800
     1622                0.18181818181818182             0.200   0.893   1.000
     1623                0.2727272727272727              0.400   0.940   1.000
     1624                0.36363636363636365             0.600   0.973   1.000
     1625                0.45454545454545453             0.800   0.993   1.000
     1626                0.5454545454545454              0.950   0.855   0.808
     1627                0.6363636363636364              0.850   0.688   0.595
     1628                0.7272727272727273              0.800   0.608   0.480
     1629                0.8181818181818182              0.600   0.379   0.210
     1630                0.9090909090909091              0.400   0.187   0.000
     1631                1.0                             0.200   0.100   0.000
    15431632            }
    15441633        }
     
    15591648            }
    15601649        }
     1650        "orange-to-blue" {
     1651            return {
     1652                0.0                             1.000   0.167   0.000
     1653                0.09090909090909091             1.000   0.400   0.100
     1654                0.18181818181818182             1.000   0.600   0.200
     1655                0.2727272727272727              1.000   0.800   0.400
     1656                0.36363636363636365             1.000   0.933   0.600
     1657                0.45454545454545453             1.000   1.000   0.800
     1658                0.5454545454545454              0.800   1.000   1.000
     1659                0.6363636363636364              0.600   0.933   1.000
     1660                0.7272727272727273              0.400   0.800   1.000
     1661                0.8181818181818182              0.200   0.600   1.000
     1662                0.9090909090909091              0.100   0.400   1.000
     1663                1.0                             0.000   0.167   1.000
     1664            }
     1665        }
    15611666        "rainbow" {
    15621667            set clist {
    1563                 "red" "#FFA500" "yellow" "#008000" "blue" "#4B0082" "#EE82EE"
    1564             }
    1565         }
    1566         "typical" {
     1668                "#EE82EE"
     1669                "#4B0082"
     1670                "blue"
     1671                "#008000"
     1672                "yellow"
     1673                "#FFA500"
     1674                "red"
     1675            }
     1676        }
     1677        "BGYOR" {
    15671678            set clist {
    1568                 "red" "#FFA500" "yellow" "#008000" "blue"
     1679                "blue"
     1680                "#008000"
     1681                "yellow"
     1682                "#FFA500"
     1683                "red"
     1684            }
     1685        }
     1686        "ROYGB" {
     1687            set clist {
     1688                "red"
     1689                "#FFA500"
     1690                "yellow"
     1691                "#008000"
     1692                "blue"
     1693            }
     1694        }
     1695        "spectral" {
     1696            return {
     1697                0.0 0.650 0.000 0.130
     1698                0.1 0.850 0.150 0.196
     1699                0.2 0.970 0.430 0.370
     1700                0.3 1.000 0.680 0.450
     1701                0.4 1.000 0.880 0.600
     1702                0.5 1.000 1.000 0.750
     1703                0.6 0.880 1.000 1.000
     1704                0.7 0.670 0.970 1.000
     1705                0.8 0.450 0.850 1.000
     1706                0.9 0.250 0.630 1.000
     1707                1.0 0.150 0.300 1.000
     1708            }
     1709        }
     1710        "green-to-magenta" {
     1711            return {
     1712                0.0 0.000 0.316 0.000
     1713                0.06666666666666667 0.000 0.526 0.000
     1714                0.13333333333333333 0.000 0.737 0.000
     1715                0.2 0.000 0.947 0.000
     1716                0.26666666666666666 0.316 1.000 0.316
     1717                0.3333333333333333 0.526 1.000 0.526
     1718                0.4 0.737 1.000 0.737
     1719                0.4666666666666667 1.000 1.000 1.000
     1720                0.5333333333333333 1.000 0.947 1.000
     1721                0.6 1.000 0.737 1.000
     1722                0.6666666666666666 1.000 0.526 1.000
     1723                0.7333333333333333 1.000 0.316 1.000
     1724                0.8 0.947 0.000 0.947
     1725                0.8666666666666667 0.737 0.000 0.737
     1726                0.9333333333333333 0.526 0.000 0.526
     1727                1.0 0.316 0.000 0.316
    15691728            }
    15701729        }
     
    17981957        -command [itcl::code $this AdjustSetting streamlines-opacity]
    17991958
    1800     label $inner.density_l -text "Seed Density" -font "Arial 9"
    1801     ::scale $inner.density -from 1 -to 100 -orient horizontal \
     1959    label $inner.density_l -text "Number of Seeds" -font "Arial 9"
     1960    ::scale $inner.density -from 1 -to 1000 -orient horizontal \
    18021961        -variable [itcl::scope _streamlines(seeddensity)] \
    18031962        -width 10 \
    1804         -showvalue off \
     1963        -showvalue on \
    18051964        -command [itcl::code $this AdjustSetting streamlines-seeddensity]
    18061965
     
    18191978        [itcl::code $this AdjustSetting streamlines-field]
    18201979
    1821     label $inner.palette_l -text "Color Palette" -font "Arial 9"
     1980    label $inner.palette_l -text "Palette" -font "Arial 9"
    18221981    itk_component add palette {
    18231982        Rappture::Combobox $inner.palette -width 10 -editable no
    18241983    }
    18251984    $inner.palette choices insert end \
    1826         "blue-to-gray"       "blue-to-gray"     \
     1985        "BGYOR"              "BGYOR"            \
    18271986        "blue"               "blue"             \
    18281987        "blue-to-brown"      "blue-to-brown"    \
    18291988        "blue-to-orange"     "blue-to-orange"   \
     1989        "blue-to-grey"       "blue-to-grey"     \
     1990        "green-to-magenta"   "green-to-magenta" \
     1991        "greyscale"          "greyscale"        \
     1992        "nanohub"            "nanohub"          \
    18301993        "rainbow"            "rainbow"          \
    1831         "typical"            "typical"          \
    1832         "greyscale"          "greyscale"        \
    1833         "nanohub"            "nanohub"         
    1834     $itk_component(palette) value "typical"
     1994        "spectral"           "spectral"         \
     1995        "ROYGB"              "ROYGB"            \
     1996        "brown-to-blue"      "brown-to-blue"    \
     1997        "grey-to-blue"       "grey-to-blue"     \
     1998        "orange-to-blue"     "orange-to-blue"   
     1999
     2000    $itk_component(palette) value "BGYOR"
    18352001    bind $inner.palette <<Value>> \
    18362002        [itcl::code $this AdjustSetting streamlines-palette]
     
    19612127   
    19622128    set inner [$itk_component(main) insert end \
    1963         -title "Cutplane Along Axis" \
     2129        -title "Cutplane Settings" \
    19642130        -icon [Rappture::icon cutbutton]]
    19652131
    19662132    $inner configure -borderwidth 4
     2133
     2134    checkbutton $inner.visible \
     2135        -text "Show Cutplanes" \
     2136        -variable [itcl::scope _cutplane(visible)] \
     2137        -command [itcl::code $this AdjustSetting cutplane-visible] \
     2138        -font "Arial 9"
     2139
     2140    checkbutton $inner.wireframe \
     2141        -text "Show Wireframe" \
     2142        -variable [itcl::scope _cutplane(wireframe)] \
     2143        -command [itcl::code $this AdjustSetting cutplane-wireframe] \
     2144        -font "Arial 9"
     2145
     2146    checkbutton $inner.lighting \
     2147        -text "Enable Lighting" \
     2148        -variable [itcl::scope _cutplane(lighting)] \
     2149        -command [itcl::code $this AdjustSetting cutplane-lighting] \
     2150        -font "Arial 9"
     2151
     2152    checkbutton $inner.edges \
     2153        -text "Show Edges" \
     2154        -variable [itcl::scope _cutplane(edges)] \
     2155        -command [itcl::code $this AdjustSetting cutplane-edges] \
     2156        -font "Arial 9"
     2157
     2158    label $inner.opacity_l -text "Opacity" -font "Arial 9"
     2159    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
     2160        -variable [itcl::scope _cutplane(opacity)] \
     2161        -width 10 \
     2162        -showvalue off \
     2163        -command [itcl::code $this AdjustSetting cutplane-opacity]
     2164    $inner.opacity set $_cutplane(opacity)
    19672165
    19682166    # X-value slicer...
     
    20482246
    20492247    blt::table $inner \
    2050         0,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
    2051         1,0 $itk_component(xCutScale)   -fill y \
    2052         0,1 $itk_component(yCutButton)  -anchor e -padx 2 -pady 2 \
    2053         1,1 $itk_component(yCutScale)   -fill y \
    2054         0,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
    2055         1,2 $itk_component(zCutScale)   -fill y \
     2248        0,0 $inner.visible              -anchor w -pady 2 -cspan 3 \
     2249        1,0 $inner.lighting             -anchor w -pady 2 -cspan 3 \
     2250        2,0 $inner.wireframe            -anchor w -pady 2 -cspan 3 \
     2251        3,0 $inner.edges                -anchor w -pady 2 -cspan 3 \
     2252        4,0 $inner.opacity_l            -anchor w -pady 2 -cspan 3 \
     2253        5,0 $inner.opacity              -fill x   -pady 2 -cspan 3 \
     2254        6,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
     2255        7,0 $itk_component(xCutScale)   -fill y \
     2256        6,1 $itk_component(yCutButton)  -anchor e -padx 2 -pady 2 \
     2257        7,1 $itk_component(yCutScale)   -fill y \
     2258        6,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
     2259        7,2 $itk_component(zCutScale)   -fill y \
    20562260
    20572261    blt::table configure $inner r* c* -resize none
    2058     blt::table configure $inner r1 c3 -resize expand
     2262    blt::table configure $inner r7 c3 -resize expand
    20592263}
    20602264
     
    22142418    }
    22152419    SendCmd "cutplane add $tag"
    2216     SendCmd "cutplane colormode vmag $tag"
     2420    SendCmd "cutplane colormode $_colorMode $tag"
    22172421    SendCmd "cutplane edges 0 $tag"
    22182422    SendCmd "cutplane wireframe 0 $tag"
     
    22222426    #puts stderr "cutplane axis $axis $bool"
    22232427    #SendCmd "cutplane visible $tag"
    2224     SendCmd "cutplane colormode vmag $tag"
    22252428    foreach axis { x y z } {
    22262429        SendCmd "cutplane slice $axis 1.0 $tag"
Note: See TracChangeset for help on using the changeset viewer.