Changeset 2587 for trunk/gui/scripts
- Timestamp:
- Sep 29, 2011, 1:32:40 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkstreamlinesviewer.tcl
r2586 r2587 102 102 private method MotionLegend { x y } 103 103 private method PanCamera {} 104 private method RequestLegend { {mode "vmag"}}104 private method RequestLegend {} 105 105 private method SetColormap { dataobj comp } 106 106 private method ChangeColormap { dataobj comp color } … … 151 151 private variable _outline 152 152 private variable _fields 153 private variable _colorMode "vmag";# Mode of colormap (vmag or scalar) 153 154 } 154 155 … … 236 237 }] 237 238 array set _cutplane [subst { 239 edges 0 238 240 xvisible 0 239 241 yvisible 0 … … 243 245 zposition 0 244 246 visible 1 247 wireframe 0 248 opacity 1 245 249 }] 246 250 array set _volume [subst { … … 255 259 visible 1 256 260 opacity 100 257 seeddensity 40261 seeddensity 200 258 262 lighting 1 259 263 scale 1 … … 441 445 eval itk_initialize $args 442 446 Connect 447 update 443 448 } 444 449 … … 926 931 itcl::body Rappture::VtkStreamlinesViewer::Rebuild {} { 927 932 update 928 929 933 set w [winfo width $itk_component(view)] 930 934 set h [winfo height $itk_component(view)] … … 1314 1318 SendCmd "axis flymode $mode" 1315 1319 } 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 } 1316 1351 "xcutplane-visible" - "ycutplane-visible" - "zcutplane-visible" { 1317 1352 set axis [string range $what 0 0] … … 1325 1360 } 1326 1361 SendCmd "cutplane axis $axis $bool" 1327 SendCmd "cutplane colormode vmag"1362 SendCmd "cutplane colormode $_colorMode" 1328 1363 } 1329 1364 "xcutplane-position" - "ycutplane-position" - "zcutplane-position" { … … 1340 1375 } 1341 1376 "streamlines-seeddensity" { 1342 set density [expr int($_streamlines(seeddensity) * 5.0)]1377 set density $_streamlines(seeddensity) 1343 1378 foreach dataset [CurrentDatasets -visible $_first] { 1379 foreach {dataobj comp} [split $dataset -] break 1344 1380 # 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 } 1346 1389 } 1347 1390 } … … 1367 1410 } 1368 1411 "ribbons" { 1369 SendCmd "streamlines ribbons 10 $dataset"1412 SendCmd "streamlines ribbons 3 0 $dataset" 1370 1413 } 1371 1414 "tubes" { 1372 SendCmd "streamlines tubes 5 1$dataset"1415 SendCmd "streamlines tubes 5 3 $dataset" 1373 1416 } 1374 1417 } … … 1381 1424 ChangeColormap $dataobj $comp $palette 1382 1425 } 1426 RequestLegend 1383 1427 } 1384 1428 "streamlines-opacity" { … … 1404 1448 "streamlines-field" { 1405 1449 set field [$itk_component(field) value] 1406 set mode scalar1450 set _colorMode scalar 1407 1451 if { $field == "U" } { 1408 set mode vmag1452 set _colorMode vmag 1409 1453 } 1410 1454 foreach dataset [CurrentDatasets -visible $_first] { 1411 1455 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" 1415 1458 } 1416 RequestLegend $mode1459 RequestLegend 1417 1460 } 1418 1461 default { … … 1429 1472 # to be vertical when drawn. 1430 1473 # 1431 itcl::body Rappture::VtkStreamlinesViewer::RequestLegend { {mode vmag}} {1432 #puts stderr "RequestLegend _first=$_first"1474 itcl::body Rappture::VtkStreamlinesViewer::RequestLegend {} { 1475 puts stderr "RequestLegend _first=$_first" 1433 1476 #puts stderr "RequestLegend width=$_width height=$_height" 1434 1477 set font "Arial 8" … … 1444 1487 foreach {dataobj comp} [split $dataset -] break 1445 1488 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" 1448 1491 break; 1449 1492 } … … 1456 1499 itcl::body Rappture::VtkStreamlinesViewer::ChangeColormap {dataobj comp color} { 1457 1500 set tag $dataobj-$comp 1458 if { ![info exist _style s($tag)] } {1501 if { ![info exist _style($tag)] } { 1459 1502 error "no initial colormap" 1460 1503 } 1461 set _style(-color) $color 1504 array set style $_style($tag) 1505 set style(-color) $color 1506 set _style($tag) [array get style] 1462 1507 SetColormap $dataobj $comp 1463 1508 } … … 1468 1513 itcl::body Rappture::VtkStreamlinesViewer::SetColormap { dataobj comp } { 1469 1514 array set style { 1470 -color rainbow1515 -color BGYOR 1471 1516 -levels 6 1472 1517 -opacity 1.0 … … 1494 1539 if { ![info exists _dataset2style($tag)] || 1495 1540 $_dataset2style($tag) != $name } { 1541 puts stderr "streamlines colormap $name $tag" 1542 puts stderr "cutplane colormap $name $tag" 1496 1543 SendCmd "streamlines colormap $name $tag" 1497 1544 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 1500 1561 1501 1562 itcl::body Rappture::VtkStreamlinesViewer::ColorsToColormap { colors } { 1502 1563 switch -- $colors { 1503 " blue-to-gray" {1564 "grey-to-blue" { 1504 1565 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 1513 1586 } 1514 1587 } 1515 1588 "blue" { 1516 1589 return { 1517 0.0 1518 0.1111111111111111 1519 0.2222222222222222 1520 0.3333333333333333 1521 0.4444444444444444 1522 0.5555555555555556 1523 0.6666666666666666 1524 0.7777777777777778 1525 0.8888888888888888 1526 1.0 1527 } 1528 } 1529 "b lue-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" { 1530 1603 return { 1531 1604 0.0 0.200 0.100 0.000 … … 1541 1614 0.9090909090909091 0.000 0.667 0.800 1542 1615 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 1543 1632 } 1544 1633 } … … 1559 1648 } 1560 1649 } 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 } 1561 1666 "rainbow" { 1562 1667 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" { 1567 1678 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 1569 1728 } 1570 1729 } … … 1798 1957 -command [itcl::code $this AdjustSetting streamlines-opacity] 1799 1958 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 \ 1802 1961 -variable [itcl::scope _streamlines(seeddensity)] \ 1803 1962 -width 10 \ 1804 -showvalue o ff\1963 -showvalue on \ 1805 1964 -command [itcl::code $this AdjustSetting streamlines-seeddensity] 1806 1965 … … 1819 1978 [itcl::code $this AdjustSetting streamlines-field] 1820 1979 1821 label $inner.palette_l -text " ColorPalette" -font "Arial 9"1980 label $inner.palette_l -text "Palette" -font "Arial 9" 1822 1981 itk_component add palette { 1823 1982 Rappture::Combobox $inner.palette -width 10 -editable no 1824 1983 } 1825 1984 $inner.palette choices insert end \ 1826 " blue-to-gray" "blue-to-gray"\1985 "BGYOR" "BGYOR" \ 1827 1986 "blue" "blue" \ 1828 1987 "blue-to-brown" "blue-to-brown" \ 1829 1988 "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" \ 1830 1993 "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" 1835 2001 bind $inner.palette <<Value>> \ 1836 2002 [itcl::code $this AdjustSetting streamlines-palette] … … 1961 2127 1962 2128 set inner [$itk_component(main) insert end \ 1963 -title "Cutplane Along Axis" \2129 -title "Cutplane Settings" \ 1964 2130 -icon [Rappture::icon cutbutton]] 1965 2131 1966 2132 $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) 1967 2165 1968 2166 # X-value slicer... … … 2048 2246 2049 2247 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 \ 2056 2260 2057 2261 blt::table configure $inner r* c* -resize none 2058 blt::table configure $inner r 1c3 -resize expand2262 blt::table configure $inner r7 c3 -resize expand 2059 2263 } 2060 2264 … … 2214 2418 } 2215 2419 SendCmd "cutplane add $tag" 2216 SendCmd "cutplane colormode vmag$tag"2420 SendCmd "cutplane colormode $_colorMode $tag" 2217 2421 SendCmd "cutplane edges 0 $tag" 2218 2422 SendCmd "cutplane wireframe 0 $tag" … … 2222 2426 #puts stderr "cutplane axis $axis $bool" 2223 2427 #SendCmd "cutplane visible $tag" 2224 SendCmd "cutplane colormode vmag $tag"2225 2428 foreach axis { x y z } { 2226 2429 SendCmd "cutplane slice $axis 1.0 $tag"
Note: See TracChangeset
for help on using the changeset viewer.