- Timestamp:
- Jul 15, 2012, 11:23:02 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkviewer.tcl
r3090 r3093 84 84 private method BuildAxisTab {} 85 85 private method BuildCameraTab {} 86 private method BuildColormap { colormap dataobj comp}86 private method BuildColormap { name styles } 87 87 private method BuildCutawayTab {} 88 88 private method BuildDownloadPopup { widget command } … … 101 101 private method RequestLegend {} 102 102 private method SetColormap { dataobj comp } 103 private method ChangeColormap { dataobj comp color } 104 private method ColorsToColormap { color } 103 105 private method SetLegendTip { x y } 104 106 private method SetObjectStyle { dataobj comp } … … 106 108 107 109 private variable _arcball "" 108 private variable _outbuf ;# buffer for outgoing commands109 110 private variable _dlist "" ;# list of data objects110 private variable _outbuf; # buffer for outgoing commands 111 112 private variable _dlist ""; # list of data objects 111 113 private variable _allDataObjs 112 114 private variable _obj2datasets 113 private variable _obj2ovride ;# maps dataobj => style override 114 private variable _datasets ;# contains all the dataobj-component 115 ;# datasets in the server 116 private variable _colormaps ;# contains all the colormaps 117 ;# in the server. 118 private variable _dataset2style ;# maps dataobj-component to transfunc 119 private variable _style2datasets ;# maps tf back to list of 120 # dataobj-components using the tf. 121 122 private variable _click ;# info used for rotate operations 123 private variable _limits ;# autoscale min/max for all axes 124 private variable _view ;# view params for 3D view 115 private variable _obj2ovride; # maps dataobj => style override 116 private variable _datasets; # contains all the dataobj-component 117 # datasets in the server 118 private variable _colormaps; # contains all the colormaps 119 # in the server. 120 private variable _dataset2style; # maps dataobj-component to transfunc 121 private variable _style2datasets; # maps tf back to list of 122 # dataobj-components using the tf. 123 private variable _click ; # info used for rotate operations 124 private variable _limits ; # autoscale min/max for all axes 125 private variable _view ; # view params for 3D view 125 126 private variable _settings 127 private variable _style; # Array of current component styles. 128 private variable _initialStyle; # Array of initial component styles. 126 129 private variable _volume 127 130 private variable _axis … … 221 224 }] 222 225 array set _volume [subst { 223 edges 1226 edges 0 224 227 lighting 1 225 228 opacity 40 226 229 visible 1 227 230 wireframe 0 231 palette rainbow 228 232 }] 229 233 array set _settings [subst { … … 269 273 } 270 274 pack $itk_component(reset) -side top -padx 2 -pady 2 271 Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" 275 Rappture::Tooltip::for $itk_component(reset) \ 276 "Reset the view to the default zoom level" 272 277 273 278 itk_component add zoomin { … … 295 300 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 296 301 297 BuildVolumeTab 302 puts stderr "BuildVolumeTab" 303 if { [catch { BuildVolumeTab } errs ] != 0 } { 304 puts stderr "errs=$errs" 305 } 298 306 BuildAxisTab 299 307 BuildCutawayTab … … 1172 1180 foreach { dataobj comp } [split $dataset -] break 1173 1181 set type [$dataobj type $comp] 1174 if { $type != "" } {1182 if { $type != "" && $type != "glyphs" } { 1175 1183 SendCmd "$type opacity $sval $dataset" 1176 1184 } … … 1216 1224 } 1217 1225 } 1226 } 1227 "volume-palette" { 1228 set palette [$itk_component(palette) value] 1229 set _settings(volume-palette) $palette 1230 foreach dataset [CurrentDatasets -visible $_first] { 1231 foreach {dataobj comp} [split $dataset -] break 1232 ChangeColormap $dataobj $comp $palette 1233 } 1234 set _legendPending 1 1218 1235 } 1219 1236 "axis-visible" { … … 1297 1314 1298 1315 # 1316 # ChangeColormap -- 1317 # 1318 itcl::body Rappture::VtkViewer::ChangeColormap {dataobj comp color} { 1319 set tag $dataobj-$comp 1320 if { ![info exist _style($tag)] } { 1321 error "no initial colormap" 1322 } 1323 array set style $_style($tag) 1324 set style(-color) $color 1325 set _style($tag) [array get style] 1326 SetColormap $dataobj $comp 1327 } 1328 1329 # 1299 1330 # SetColormap -- 1300 1331 # 1301 1332 itcl::body Rappture::VtkViewer::SetColormap { dataobj comp } { 1302 1333 array set style { 1303 -color rainbow1334 -color BCGYR 1304 1335 -levels 6 1305 1336 -opacity 1.0 1306 1337 } 1307 1338 set tag $dataobj-$comp 1308 array set style [$dataobj style $comp] 1309 set colormap "$style(-color):$style(-levels):$style(-opacity)" 1310 if { [info exists _colormaps($colormap)] } { 1311 return $colormap 1312 } 1313 if { ![info exists _dataset2style($tag)] } { 1314 set _dataset2style($tag) $colormap 1315 lappend _style2datasets($colormap) $tag 1316 } 1317 if { ![info exists _colormaps($colormap)] } { 1318 # Build the pseudo colormap if it doesn't exist. 1319 BuildColormap $colormap $dataobj $comp 1320 set _colormaps($colormap) 1 1321 } 1322 switch -- [$dataobj type $comp] { 1323 "polygon" { 1324 SendCmd "pseudocolor colormap $colormap $tag" 1325 } 1326 "glyphs" { 1327 #SendCmd "glyphs colormap $colormap $tag" 1328 } 1329 "molecule" { 1330 #SendCmd "glyphs colormap $colormap $tag" 1331 } 1332 } 1333 return $colormap 1334 } 1335 1336 # 1337 # BuildColormap -- 1338 # 1339 itcl::body Rappture::VtkViewer::BuildColormap { colormap dataobj comp } { 1340 array set style { 1341 -color rainbow 1342 -levels 6 1343 -opacity 1.0 1344 } 1345 array set style [$dataobj style $comp] 1346 if {$style(-color) == "rainbow"} { 1347 set style(-color) "white:yellow:green:cyan:blue:magenta" 1348 } 1349 set clist [split $style(-color) :] 1339 if { ![info exists _initialStyle($tag)] } { 1340 # Save the initial component style. 1341 set _initialStyle($tag) [$dataobj style $comp] 1342 } 1343 1344 # Override defaults with initial style defined in xml. 1345 array set style $_initialStyle($tag) 1346 1347 if { ![info exists _style($tag)] } { 1348 set _style($tag) [array get style] 1349 } 1350 # Override initial style with current style. 1351 array set style $_style($tag) 1352 1353 set name "$style(-color):$style(-levels):$style(-opacity)" 1354 if { ![info exists _colormaps($name)] } { 1355 BuildColormap $name [array get style] 1356 set _colormaps($name) 1 1357 } 1358 if { ![info exists _dataset2style($tag)] || 1359 $_dataset2style($tag) != $name } { 1360 SendCmd "cutplane colormap $name $tag" 1361 set _dataset2style($tag) $name 1362 switch -- [$dataobj type $comp] { 1363 "polygon" { 1364 SendCmd "pseudocolor colormap $name $tag" 1365 } 1366 "glyphs" { 1367 SendCmd "glyphs colormap $name $tag" 1368 } 1369 "molecule" { 1370 #SendCmd "molecule colormap $name $tag" 1371 } 1372 } 1373 } 1374 } 1375 1376 itcl::body Rappture::VtkViewer::ColorsToColormap { colors } { 1377 switch -- $colors { 1378 "grey-to-blue" { 1379 return { 1380 0.0 0.200 0.200 0.200 1381 0.14285714285714285 0.400 0.400 0.400 1382 0.2857142857142857 0.600 0.600 0.600 1383 0.42857142857142855 0.900 0.900 0.900 1384 0.5714285714285714 0.800 1.000 1.000 1385 0.7142857142857143 0.600 1.000 1.000 1386 0.8571428571428571 0.400 0.900 1.000 1387 1.0 0.000 0.600 0.800 1388 } 1389 } 1390 "blue-to-grey" { 1391 return { 1392 0.0 0.000 0.600 0.800 1393 0.14285714285714285 0.400 0.900 1.000 1394 0.2857142857142857 0.600 1.000 1.000 1395 0.42857142857142855 0.800 1.000 1.000 1396 0.5714285714285714 0.900 0.900 0.900 1397 0.7142857142857143 0.600 0.600 0.600 1398 0.8571428571428571 0.400 0.400 0.400 1399 1.0 0.200 0.200 0.200 1400 } 1401 } 1402 "blue" { 1403 return { 1404 0.0 0.900 1.000 1.000 1405 0.1111111111111111 0.800 0.983 1.000 1406 0.2222222222222222 0.700 0.950 1.000 1407 0.3333333333333333 0.600 0.900 1.000 1408 0.4444444444444444 0.500 0.833 1.000 1409 0.5555555555555556 0.400 0.750 1.000 1410 0.6666666666666666 0.300 0.650 1.000 1411 0.7777777777777778 0.200 0.533 1.000 1412 0.8888888888888888 0.100 0.400 1.000 1413 1.0 0.000 0.250 1.000 1414 } 1415 } 1416 "brown-to-blue" { 1417 return { 1418 0.0 0.200 0.100 0.000 1419 0.09090909090909091 0.400 0.187 0.000 1420 0.18181818181818182 0.600 0.379 0.210 1421 0.2727272727272727 0.800 0.608 0.480 1422 0.36363636363636365 0.850 0.688 0.595 1423 0.45454545454545453 0.950 0.855 0.808 1424 0.5454545454545454 0.800 0.993 1.000 1425 0.6363636363636364 0.600 0.973 1.000 1426 0.7272727272727273 0.400 0.940 1.000 1427 0.8181818181818182 0.200 0.893 1.000 1428 0.9090909090909091 0.000 0.667 0.800 1429 1.0 0.000 0.480 0.600 1430 } 1431 } 1432 "blue-to-brown" { 1433 return { 1434 0.0 0.000 0.480 0.600 1435 0.09090909090909091 0.000 0.667 0.800 1436 0.18181818181818182 0.200 0.893 1.000 1437 0.2727272727272727 0.400 0.940 1.000 1438 0.36363636363636365 0.600 0.973 1.000 1439 0.45454545454545453 0.800 0.993 1.000 1440 0.5454545454545454 0.950 0.855 0.808 1441 0.6363636363636364 0.850 0.688 0.595 1442 0.7272727272727273 0.800 0.608 0.480 1443 0.8181818181818182 0.600 0.379 0.210 1444 0.9090909090909091 0.400 0.187 0.000 1445 1.0 0.200 0.100 0.000 1446 } 1447 } 1448 "blue-to-orange" { 1449 return { 1450 0.0 0.000 0.167 1.000 1451 0.09090909090909091 0.100 0.400 1.000 1452 0.18181818181818182 0.200 0.600 1.000 1453 0.2727272727272727 0.400 0.800 1.000 1454 0.36363636363636365 0.600 0.933 1.000 1455 0.45454545454545453 0.800 1.000 1.000 1456 0.5454545454545454 1.000 1.000 0.800 1457 0.6363636363636364 1.000 0.933 0.600 1458 0.7272727272727273 1.000 0.800 0.400 1459 0.8181818181818182 1.000 0.600 0.200 1460 0.9090909090909091 1.000 0.400 0.100 1461 1.0 1.000 0.167 0.000 1462 } 1463 } 1464 "orange-to-blue" { 1465 return { 1466 0.0 1.000 0.167 0.000 1467 0.09090909090909091 1.000 0.400 0.100 1468 0.18181818181818182 1.000 0.600 0.200 1469 0.2727272727272727 1.000 0.800 0.400 1470 0.36363636363636365 1.000 0.933 0.600 1471 0.45454545454545453 1.000 1.000 0.800 1472 0.5454545454545454 0.800 1.000 1.000 1473 0.6363636363636364 0.600 0.933 1.000 1474 0.7272727272727273 0.400 0.800 1.000 1475 0.8181818181818182 0.200 0.600 1.000 1476 0.9090909090909091 0.100 0.400 1.000 1477 1.0 0.000 0.167 1.000 1478 } 1479 } 1480 "rainbow" { 1481 set clist { 1482 "#EE82EE" 1483 "#4B0082" 1484 "blue" 1485 "#008000" 1486 "yellow" 1487 "#FFA500" 1488 "red" 1489 } 1490 } 1491 "BGYOR" { 1492 set clist { 1493 "blue" 1494 "#008000" 1495 "yellow" 1496 "#FFA500" 1497 "red" 1498 } 1499 } 1500 "ROYGB" { 1501 set clist { 1502 "red" 1503 "#FFA500" 1504 "yellow" 1505 "#008000" 1506 "blue" 1507 } 1508 } 1509 "RYGCB" { 1510 set clist { 1511 "red" 1512 "yellow" 1513 "green" 1514 "cyan" 1515 "blue" 1516 } 1517 } 1518 "BCGYR" { 1519 set clist { 1520 "blue" 1521 "cyan" 1522 "green" 1523 "yellow" 1524 "red" 1525 } 1526 } 1527 "spectral" { 1528 return { 1529 0.0 0.150 0.300 1.000 1530 0.1 0.250 0.630 1.000 1531 0.2 0.450 0.850 1.000 1532 0.3 0.670 0.970 1.000 1533 0.4 0.880 1.000 1.000 1534 0.5 1.000 1.000 0.750 1535 0.6 1.000 0.880 0.600 1536 0.7 1.000 0.680 0.450 1537 0.8 0.970 0.430 0.370 1538 0.9 0.850 0.150 0.196 1539 1.0 0.650 0.000 0.130 1540 } 1541 } 1542 "green-to-magenta" { 1543 return { 1544 0.0 0.000 0.316 0.000 1545 0.06666666666666667 0.000 0.526 0.000 1546 0.13333333333333333 0.000 0.737 0.000 1547 0.2 0.000 0.947 0.000 1548 0.26666666666666666 0.316 1.000 0.316 1549 0.3333333333333333 0.526 1.000 0.526 1550 0.4 0.737 1.000 0.737 1551 0.4666666666666667 1.000 1.000 1.000 1552 0.5333333333333333 1.000 0.947 1.000 1553 0.6 1.000 0.737 1.000 1554 0.6666666666666666 1.000 0.526 1.000 1555 0.7333333333333333 1.000 0.316 1.000 1556 0.8 0.947 0.000 0.947 1557 0.8666666666666667 0.737 0.000 0.737 1558 0.9333333333333333 0.526 0.000 0.526 1559 1.0 0.316 0.000 0.316 1560 } 1561 } 1562 "greyscale" { 1563 return { 1564 0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0 1565 } 1566 } 1567 "nanohub" { 1568 set clist "white yellow green cyan blue magenta" 1569 } 1570 default { 1571 set clist $colors 1572 } 1573 } 1350 1574 set cmap {} 1351 1575 set numColors [llength $clist] 1352 1576 for {set i 0} {$i < $numColors} {incr i} { 1353 set x 01354 1577 if { $numColors > 1 } { 1355 1578 set x [expr {double($i)/($numColors-1)}] 1579 } else { 1580 set x [expr double($i)] 1356 1581 } 1357 1582 set color [lindex $clist $i] 1358 1583 append cmap "$x [Color2RGB $color] " 1359 1584 } 1585 return $cmap 1586 } 1587 1588 # 1589 # BuildColormap -- 1590 # 1591 itcl::body Rappture::VtkViewer::BuildColormap { name styles } { 1592 array set style $styles 1593 set cmap [ColorsToColormap $style(-color)] 1360 1594 if { [llength $cmap] == 0 } { 1361 1595 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1362 1596 } 1363 if { ![info exists _ volume(opacity)] } {1364 set _ volume(opacity) $style(-opacity)1365 } 1366 set max $_ volume(opacity)1597 if { ![info exists _settings(volume-opacity)] } { 1598 set _settings(volume-opacity) $style(-opacity) 1599 } 1600 set max $_settings(volume-opacity) 1367 1601 1368 1602 set wmap "0.0 1.0 1.0 1.0" 1369 SendCmd "colormap add $colormap { $cmap } { $wmap }" 1370 } 1603 SendCmd "colormap add $name { $cmap } { $wmap }" 1604 } 1605 1371 1606 1372 1607 # ---------------------------------------------------------------------- … … 1491 1726 -font "Arial 9" 1492 1727 1728 label $inner.palette_l -text "Palette" -font "Arial 9" 1729 itk_component add palette { 1730 Rappture::Combobox $inner.palette -width 10 -editable no 1731 } 1732 $inner.palette choices insert end \ 1733 "BCGYR" "BCGYR" \ 1734 "BGYOR" "BGYOR" \ 1735 "blue" "blue" \ 1736 "blue-to-brown" "blue-to-brown" \ 1737 "blue-to-orange" "blue-to-orange" \ 1738 "blue-to-grey" "blue-to-grey" \ 1739 "green-to-magenta" "green-to-magenta" \ 1740 "greyscale" "greyscale" \ 1741 "nanohub" "nanohub" \ 1742 "rainbow" "rainbow" \ 1743 "spectral" "spectral" \ 1744 "ROYGB" "ROYGB" \ 1745 "RYGCB" "RYGCB" \ 1746 "brown-to-blue" "brown-to-blue" \ 1747 "grey-to-blue" "grey-to-blue" \ 1748 "orange-to-blue" "orange-to-blue" 1749 1750 $itk_component(palette) value "BCGYR" 1751 bind $inner.palette <<Value>> \ 1752 [itcl::code $this AdjustSetting volume-palette] 1753 1493 1754 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1494 1755 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ … … 1499 1760 1500 1761 blt::table $inner \ 1501 0,0 $inner.volume - anchor w -pady 2 \1502 1,0 $inner.wireframe - anchor w -pady 2 \1503 2,0 $inner.lighting - anchor w -pady 2 \1504 3,0 $inner.edges - anchor w -pady 2 \1762 0,0 $inner.volume -cspan 2 -anchor w -pady 2 \ 1763 1,0 $inner.wireframe -cspan 2 -anchor w -pady 2 \ 1764 2,0 $inner.lighting -cspan 2 -anchor w -pady 2 \ 1765 3,0 $inner.edges -cspan 2 -anchor w -pady 2 \ 1505 1766 4,0 $inner.opacity_l -anchor w -pady 2 \ 1506 5,0 $inner.opacity -fill x -pady 2 1767 4,1 $inner.opacity -fill x -pady 2 \ 1768 5,0 $inner.palette_l -anchor w -pady 2 \ 1769 5,1 $inner.palette -fill x -pady 2 1507 1770 1508 1771 blt::table configure $inner r* c* -resize none 1509 blt::table configure $inner r 6c1 -resize expand1772 blt::table configure $inner r7 c1 -resize expand 1510 1773 } 1511 1774
Note: See TracChangeset
for help on using the changeset viewer.