Changeset 3366 for trunk/gui/scripts/nanovisviewer.tcl
- Timestamp:
- Feb 26, 2013, 3:33:21 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/nanovisviewer.tcl
r3365 r3366 90 90 protected method DoResize {} 91 91 protected method FixLegend {} 92 protected method FixSettings {what {value ""}} 92 protected method AdjustSetting {what} 93 protected method InitSettings { args } 93 94 protected method Pan {option x y} 94 95 protected method Rebuild {} … … 109 110 private method BuildViewTab {} 110 111 private method BuildVolumeTab {} 112 private method ColorsToColormap { colors } 113 private method ResetColormap { color } 111 114 private method ComputeTransferFunc { tf } 112 115 private method EventuallyResize { w h } … … 290 293 -onimage [Rappture::icon volume-on] \ 291 294 -offimage [Rappture::icon volume-off] \ 292 -command [itcl::code $this FixSettingsvolume] \295 -command [itcl::code $this AdjustSetting volume] \ 293 296 -variable [itcl::scope _settings($this-volume)] 294 297 } … … 836 839 } 837 840 838 puts stderr "Received volume info: '$args'"839 840 841 # Arguments from server are name value pairs. Stuff them in an array. 841 842 array set info $args … … 889 890 } 890 891 891 set w [winfo width $itk_component(3dview)] 892 set h [winfo height $itk_component(3dview)] 893 $_arcball resize $w $h 894 EventuallyResize $w $h 892 set _width [winfo width $itk_component(3dview)] 893 set _height [winfo height $itk_component(3dview)] 894 DoResize 895 895 896 896 foreach dataobj [get] { … … 936 936 PanCamera 937 937 SendCmd "camera zoom $_view(zoom)" 938 FixSettings light2side 939 FixSettings light 940 FixSettings transp 941 FixSettings isosurface 942 FixSettings grid 943 FixSettings axes 944 FixSettings outline 938 InitSettings light2side light transp isosurface grid axes outline 945 939 946 940 foreach axis {x y z} { … … 1239 1233 1240 1234 # ---------------------------------------------------------------------- 1241 # USAGE: FixSettings<what> ?<value>?1235 # USAGE: AdjustSetting <what> ?<value>? 1242 1236 # 1243 1237 # Used internally to update rendering settings whenever parameters … … 1245 1239 # to the back end. 1246 1240 # ---------------------------------------------------------------------- 1247 itcl::body Rappture::NanovisViewer::FixSettings {what {value ""}} { 1241 itcl::body Rappture::NanovisViewer::InitSettings { args } { 1242 foreach arg $args { 1243 AdjustSetting $arg 1244 } 1245 } 1246 1247 # ---------------------------------------------------------------------- 1248 # USAGE: AdjustSetting <what> ?<value>? 1249 # 1250 # Used internally to update rendering settings whenever parameters 1251 # change in the popup settings panel. Sends the new settings off 1252 # to the back end. 1253 # ---------------------------------------------------------------------- 1254 itcl::body Rappture::NanovisViewer::AdjustSetting {what} { 1248 1255 switch -- $what { 1249 1256 light { … … 1306 1313 } 1307 1314 } 1315 "colormap" { 1316 set color [$itk_component(colormap) value] 1317 set _settings(colormap) $color 1318 #ResetColormap $color 1319 } 1308 1320 "grid" { 1309 1321 if { [isconnected] } { … … 1396 1408 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } { 1397 1409 array set style { 1398 -color rainbow1410 -color nanovis 1399 1411 -levels 6 1400 1412 -opacity 1.0 … … 1409 1421 } 1410 1422 1423 1424 itcl::body Rappture::NanovisViewer::ColorsToColormap { colors } { 1425 switch -- $colors { 1426 "grey-to-blue" { 1427 return { 1428 0.0 0.200 0.200 0.200 1429 0.14285714285714285 0.400 0.400 0.400 1430 0.2857142857142857 0.600 0.600 0.600 1431 0.42857142857142855 0.900 0.900 0.900 1432 0.5714285714285714 0.800 1.000 1.000 1433 0.7142857142857143 0.600 1.000 1.000 1434 0.8571428571428571 0.400 0.900 1.000 1435 1.0 0.000 0.600 0.800 1436 } 1437 } 1438 "blue-to-grey" { 1439 return { 1440 0.0 0.000 0.600 0.800 1441 0.14285714285714285 0.400 0.900 1.000 1442 0.2857142857142857 0.600 1.000 1.000 1443 0.42857142857142855 0.800 1.000 1.000 1444 0.5714285714285714 0.900 0.900 0.900 1445 0.7142857142857143 0.600 0.600 0.600 1446 0.8571428571428571 0.400 0.400 0.400 1447 1.0 0.200 0.200 0.200 1448 } 1449 } 1450 "blue" { 1451 return { 1452 0.0 0.900 1.000 1.000 1453 0.1111111111111111 0.800 0.983 1.000 1454 0.2222222222222222 0.700 0.950 1.000 1455 0.3333333333333333 0.600 0.900 1.000 1456 0.4444444444444444 0.500 0.833 1.000 1457 0.5555555555555556 0.400 0.750 1.000 1458 0.6666666666666666 0.300 0.650 1.000 1459 0.7777777777777778 0.200 0.533 1.000 1460 0.8888888888888888 0.100 0.400 1.000 1461 1.0 0.000 0.250 1.000 1462 } 1463 } 1464 "brown-to-blue" { 1465 return { 1466 0.0 0.200 0.100 0.000 1467 0.09090909090909091 0.400 0.187 0.000 1468 0.18181818181818182 0.600 0.379 0.210 1469 0.2727272727272727 0.800 0.608 0.480 1470 0.36363636363636365 0.850 0.688 0.595 1471 0.45454545454545453 0.950 0.855 0.808 1472 0.5454545454545454 0.800 0.993 1.000 1473 0.6363636363636364 0.600 0.973 1.000 1474 0.7272727272727273 0.400 0.940 1.000 1475 0.8181818181818182 0.200 0.893 1.000 1476 0.9090909090909091 0.000 0.667 0.800 1477 1.0 0.000 0.480 0.600 1478 } 1479 } 1480 "blue-to-brown" { 1481 return { 1482 0.0 0.000 0.480 0.600 1483 0.09090909090909091 0.000 0.667 0.800 1484 0.18181818181818182 0.200 0.893 1.000 1485 0.2727272727272727 0.400 0.940 1.000 1486 0.36363636363636365 0.600 0.973 1.000 1487 0.45454545454545453 0.800 0.993 1.000 1488 0.5454545454545454 0.950 0.855 0.808 1489 0.6363636363636364 0.850 0.688 0.595 1490 0.7272727272727273 0.800 0.608 0.480 1491 0.8181818181818182 0.600 0.379 0.210 1492 0.9090909090909091 0.400 0.187 0.000 1493 1.0 0.200 0.100 0.000 1494 } 1495 } 1496 "blue-to-orange" { 1497 return { 1498 0.0 0.000 0.167 1.000 1499 0.09090909090909091 0.100 0.400 1.000 1500 0.18181818181818182 0.200 0.600 1.000 1501 0.2727272727272727 0.400 0.800 1.000 1502 0.36363636363636365 0.600 0.933 1.000 1503 0.45454545454545453 0.800 1.000 1.000 1504 0.5454545454545454 1.000 1.000 0.800 1505 0.6363636363636364 1.000 0.933 0.600 1506 0.7272727272727273 1.000 0.800 0.400 1507 0.8181818181818182 1.000 0.600 0.200 1508 0.9090909090909091 1.000 0.400 0.100 1509 1.0 1.000 0.167 0.000 1510 } 1511 } 1512 "orange-to-blue" { 1513 return { 1514 0.0 1.000 0.167 0.000 1515 0.09090909090909091 1.000 0.400 0.100 1516 0.18181818181818182 1.000 0.600 0.200 1517 0.2727272727272727 1.000 0.800 0.400 1518 0.36363636363636365 1.000 0.933 0.600 1519 0.45454545454545453 1.000 1.000 0.800 1520 0.5454545454545454 0.800 1.000 1.000 1521 0.6363636363636364 0.600 0.933 1.000 1522 0.7272727272727273 0.400 0.800 1.000 1523 0.8181818181818182 0.200 0.600 1.000 1524 0.9090909090909091 0.100 0.400 1.000 1525 1.0 0.000 0.167 1.000 1526 } 1527 } 1528 "rainbow" { 1529 set clist { 1530 "#EE82EE" 1531 "#4B0082" 1532 "blue" 1533 "#008000" 1534 "yellow" 1535 "#FFA500" 1536 "red" 1537 } 1538 } 1539 "BGYOR" { 1540 set clist { 1541 "blue" 1542 "#008000" 1543 "yellow" 1544 "#FFA500" 1545 "red" 1546 } 1547 } 1548 "ROYGB" { 1549 set clist { 1550 "red" 1551 "#FFA500" 1552 "yellow" 1553 "#008000" 1554 "blue" 1555 } 1556 } 1557 "RYGCB" { 1558 set clist { 1559 "red" 1560 "yellow" 1561 "green" 1562 "cyan" 1563 "blue" 1564 } 1565 } 1566 "BCGYR" { 1567 set clist { 1568 "blue" 1569 "cyan" 1570 "green" 1571 "yellow" 1572 "red" 1573 } 1574 } 1575 "spectral" { 1576 return { 1577 0.0 0.150 0.300 1.000 1578 0.1 0.250 0.630 1.000 1579 0.2 0.450 0.850 1.000 1580 0.3 0.670 0.970 1.000 1581 0.4 0.880 1.000 1.000 1582 0.5 1.000 1.000 0.750 1583 0.6 1.000 0.880 0.600 1584 0.7 1.000 0.680 0.450 1585 0.8 0.970 0.430 0.370 1586 0.9 0.850 0.150 0.196 1587 1.0 0.650 0.000 0.130 1588 } 1589 } 1590 "green-to-magenta" { 1591 return { 1592 0.0 0.000 0.316 0.000 1593 0.06666666666666667 0.000 0.526 0.000 1594 0.13333333333333333 0.000 0.737 0.000 1595 0.2 0.000 0.947 0.000 1596 0.26666666666666666 0.316 1.000 0.316 1597 0.3333333333333333 0.526 1.000 0.526 1598 0.4 0.737 1.000 0.737 1599 0.4666666666666667 1.000 1.000 1.000 1600 0.5333333333333333 1.000 0.947 1.000 1601 0.6 1.000 0.737 1.000 1602 0.6666666666666666 1.000 0.526 1.000 1603 0.7333333333333333 1.000 0.316 1.000 1604 0.8 0.947 0.000 0.947 1605 0.8666666666666667 0.737 0.000 0.737 1606 0.9333333333333333 0.526 0.000 0.526 1607 1.0 0.316 0.000 0.316 1608 } 1609 } 1610 "greyscale" { 1611 return { 1612 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1613 } 1614 } 1615 "nanohub" { 1616 set clist "white yellow green cyan blue magenta" 1617 } 1618 default { 1619 set clist $colors 1620 } 1621 } 1622 set cmap {} 1623 if { [llength $clist] == 1 } { 1624 set rgb [Color2RGB $clist] 1625 append cmap "0.0 $rgb 1.0 $rgb" 1626 } else { 1627 for {set i 0} {$i < [llength $clist]} {incr i} { 1628 set x [expr {double($i)/([llength $clist]-1)}] 1629 set color [lindex $clist $i] 1630 append cmap "$x [Color2RGB $color] " 1631 } 1632 } 1633 return $cmap 1634 } 1635 1411 1636 # 1412 1637 # ComputeTransferFunc -- … … 1427 1652 foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break 1428 1653 array set style [lindex [$dataobj components -style $cname] 0] 1429 1430 puts stderr "$tf: $style(-color), $style(-levels), $style(-opacity), $style(-markers)"1431 1654 1432 1655 # We have to parse the style attributes for a volume using this … … 1448 1671 [llength $style(-markers)] > 0 } { 1449 1672 ParseMarkersOption $tf $style(-markers) 1450 puts stderr "Found markers option"1451 1673 } else { 1452 1674 ParseLevelsOption $tf $style(-levels) 1453 1675 } 1454 1676 } 1455 if {$style(-color) == "rainbow"} { 1456 set style(-color) "white:yellow:green:cyan:blue:magenta" 1457 } 1458 set clist [split $style(-color) :] 1459 if {[llength $clist] == 1} { 1460 lappend clist [lindex $clist 0] 1461 } 1462 for {set i 0} {$i < [llength $clist]} {incr i} { 1463 set x [expr {double($i)/([llength $clist]-1)}] 1464 set color [lindex $clist $i] 1465 append cmap "$x [Color2RGB $color] " 1466 } 1467 1677 set cmap [ColorsToColormap $style(-color)] 1468 1678 set tag $this-$tf 1469 1679 if { ![info exists _settings($tag-opacity)] } { … … 1720 1930 grid 0 1721 1931 axes 1 1722 outline 11932 outline 0 1723 1933 volume 1 1724 1934 legend 1 … … 1741 1951 -text "Isosurface shading" \ 1742 1952 -variable [itcl::scope _settings($this-isosurface)] \ 1743 -command [itcl::code $this FixSettingsisosurface] \1953 -command [itcl::code $this AdjustSetting isosurface] \ 1744 1954 -font "Arial 9" 1745 1955 … … 1747 1957 -text "Axes" \ 1748 1958 -variable [itcl::scope _settings($this-axes)] \ 1749 -command [itcl::code $this FixSettingsaxes] \1959 -command [itcl::code $this AdjustSetting axes] \ 1750 1960 -font "Arial 9" 1751 1961 … … 1753 1963 -text "Grid" \ 1754 1964 -variable [itcl::scope _settings($this-grid)] \ 1755 -command [itcl::code $this FixSettingsgrid] \1965 -command [itcl::code $this AdjustSetting grid] \ 1756 1966 -font "Arial 9" 1757 1967 … … 1759 1969 -text "Outline" \ 1760 1970 -variable [itcl::scope _settings($this-outline)] \ 1761 -command [itcl::code $this FixSettingsoutline] \1971 -command [itcl::code $this AdjustSetting outline] \ 1762 1972 -font "Arial 9" 1763 1973 … … 1765 1975 -text "Legend" \ 1766 1976 -variable [itcl::scope _settings($this-legend)] \ 1767 -command [itcl::code $this FixSettingslegend] \1977 -command [itcl::code $this AdjustSetting legend] \ 1768 1978 -font "Arial 9" 1769 1979 … … 1771 1981 -text "Volume" \ 1772 1982 -variable [itcl::scope _settings($this-volume)] \ 1773 -command [itcl::code $this FixSettingsvolume] \1983 -command [itcl::code $this AdjustSetting volume] \ 1774 1984 -font "Arial 9" 1775 1985 … … 1809 2019 checkbutton $inner.vol -text "Show volume" -font $fg \ 1810 2020 -variable [itcl::scope _settings($this-volume)] \ 1811 -command [itcl::code $this FixSettingsvolume]2021 -command [itcl::code $this AdjustSetting volume] 1812 2022 label $inner.shading -text "Shading:" -font $fg 1813 2023 1814 2024 checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ 1815 2025 -variable [itcl::scope _settings($this-light2side)] \ 1816 -command [itcl::code $this FixSettingslight2side]2026 -command [itcl::code $this AdjustSetting light2side] 1817 2027 1818 2028 label $inner.dim -text "Glow" -font $fg … … 1820 2030 -variable [itcl::scope _settings($this-light)] \ 1821 2031 -width 10 \ 1822 -showvalue off -command [itcl::code $this FixSettingslight]2032 -showvalue off -command [itcl::code $this AdjustSetting light] 1823 2033 label $inner.bright -text "Surface" -font $fg 1824 2034 … … 1827 2037 -variable [itcl::scope _settings($this-transp)] \ 1828 2038 -width 10 \ 1829 -showvalue off -command [itcl::code $this FixSettingstransp]2039 -showvalue off -command [itcl::code $this AdjustSetting transp] 1830 2040 label $inner.plastic -text "Opaque" -font $fg 1831 2041 … … 1834 2044 -variable [itcl::scope _settings($this-opacity)] \ 1835 2045 -width 10 \ 1836 -showvalue off -command [itcl::code $this FixSettingsopacity]2046 -showvalue off -command [itcl::code $this AdjustSetting opacity] 1837 2047 label $inner.opaque -text "Opaque" -font $fg 1838 2048 … … 1841 2051 -variable [itcl::scope _settings($this-thickness)] \ 1842 2052 -width 10 \ 1843 -showvalue off -command [itcl::code $this FixSettingsthickness]2053 -showvalue off -command [itcl::code $this AdjustSetting thickness] 1844 2054 label $inner.thick -text "Thick" -font $fg 1845 2055 2056 label $inner.colormap_l -text "Colormap" -font "Arial 9" 2057 itk_component add colormap { 2058 Rappture::Combobox $inner.colormap -width 10 -editable no 2059 } 2060 2061 $inner.colormap choices insert end \ 2062 "BCGYR" "BCGYR" \ 2063 "BGYOR" "BGYOR" \ 2064 "blue" "blue" \ 2065 "blue-to-brown" "blue-to-brown" \ 2066 "blue-to-orange" "blue-to-orange" \ 2067 "blue-to-grey" "blue-to-grey" \ 2068 "green-to-magenta" "green-to-magenta" \ 2069 "greyscale" "greyscale" \ 2070 "nanohub" "nanohub" \ 2071 "rainbow" "rainbow" \ 2072 "spectral" "spectral" \ 2073 "ROYGB" "ROYGB" \ 2074 "RYGCB" "RYGCB" \ 2075 "brown-to-blue" "brown-to-blue" \ 2076 "grey-to-blue" "grey-to-blue" \ 2077 "orange-to-blue" "orange-to-blue" \ 2078 "none" "none" 2079 2080 $itk_component(colormap) value "BCGYR" 2081 bind $inner.colormap <<Value>> \ 2082 [itcl::code $this AdjustSetting colormap] 2083 1846 2084 blt::table $inner \ 1847 0,0 $inner.vol -c olumnspan 4 -anchor w -pady 2 \2085 0,0 $inner.vol -cspan 4 -anchor w -pady 2 \ 1848 2086 1,0 $inner.shading -columnspan 4 -anchor w -pady {10 2} \ 1849 2087 2,0 $inner.light2side -columnspan 4 -anchor w -pady 2 \ … … 1878 2116 -onimage [Rappture::icon x-cutplane] \ 1879 2117 -offimage [Rappture::icon x-cutplane] \ 1880 -command [itcl::code $this FixSettingsxcutplane] \2118 -command [itcl::code $this AdjustSetting xcutplane] \ 1881 2119 -variable [itcl::scope _settings($this-xcutplane)] 1882 2120 } … … 1905 2143 -onimage [Rappture::icon y-cutplane] \ 1906 2144 -offimage [Rappture::icon y-cutplane] \ 1907 -command [itcl::code $this FixSettingsycutplane] \2145 -command [itcl::code $this AdjustSetting ycutplane] \ 1908 2146 -variable [itcl::scope _settings($this-ycutplane)] 1909 2147 } … … 1932 2170 -onimage [Rappture::icon z-cutplane] \ 1933 2171 -offimage [Rappture::icon z-cutplane] \ 1934 -command [itcl::code $this FixSettingszcutplane] \2172 -command [itcl::code $this AdjustSetting zcutplane] \ 1935 2173 -variable [itcl::scope _settings($this-zcutplane)] 1936 2174 } … … 2195 2433 SendCmd "camera angle $xyz" 2196 2434 } 2435
Note: See TracChangeset
for help on using the changeset viewer.