Changeset 3514
- Timestamp:
- Mar 16, 2013 2:15:14 PM (11 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/visviewer.tcl
r3454 r3514 701 701 bind $f.send.e <Return> [itcl::code $this SendDebugCommand] 702 702 bind $f.send.e <KP_Enter> [itcl::code $this SendDebugCommand] 703 704 703 scrollbar $f.sb -orient vertical -command "$f.comm yview" 705 704 pack $f.sb -side right -fill y … … 710 709 } 711 710 pack $f.comm -expand yes -fill both 711 bind $f.comm <Control-F1> [itcl::code $this ToggleConsole] 712 712 713 713 $itk_component(trace) tag configure error -foreground red \ -
trunk/gui/scripts/vtkheightmapviewer.tcl
r3498 r3514 913 913 } 914 914 PanCamera 915 StopBufferingCommands 915 916 SendCmd "imgflush" 917 StartBufferingCommands 916 918 } 917 919 … … 1357 1359 } 1358 1360 } 1359 #SendCmd "heightmap colormode scalar $_curFldName"1360 #SendCmd "dataset scalar $_curFldName"1361 1361 StopBufferingCommands 1362 1362 EventuallyRequestLegend -
trunk/gui/scripts/vtkisosurfaceviewer.tcl
r3486 r3514 83 83 private method BuildAxisTab {} 84 84 private method BuildCameraTab {} 85 private method BuildColormap { name colors}85 private method BuildColormap { name } 86 86 private method BuildCutplaneTab {} 87 87 private method BuildDownloadPopup { widget command } … … 104 104 private method SetObjectStyle { dataobj comp } 105 105 private method Slice {option args} 106 private method ResetColormap { color } 107 private method SetCurrentColormap { stylelist } 106 private method SetCurrentColormap { color } 108 107 109 108 private variable _arcball "" … … 119 118 # heightmaps displayed. 120 119 private variable _currentColormap "" ; 121 120 private variable _currentNumContours "" ; 121 private variable _currentOpacity "" ; 122 122 123 123 private variable _dataset2style ;# maps dataobj-component to transfunc … … 128 128 private variable _settings 129 129 private variable _style; # Array of current component styles. 130 private variable _changed 130 131 private variable _initialStyle; # Array of initial component styles. 131 132 private variable _reset 1; # indicates if camera needs to be reset … … 151 152 private variable _curFldName "" 152 153 private variable _curFldLabel "" 153 private variable _numContours 10154 154 } 155 155 … … 221 221 array set _settings [subst { 222 222 background black 223 colormap PaletteBCGYR223 colormap BCGYR 224 224 colormapVisible 1 225 225 field "Default" … … 244 244 isosurfaceLighting 1 245 245 isosurfaceOpacity 60 246 saveIsosurfaceOpacity 60 246 247 isosurfaceOutline 0 247 248 isosurfaceVisible 1 248 249 isosurfaceWireframe 0 249 250 legendVisible 1 251 numContours 10 250 252 }] 253 array set _changed { 254 isosurfaceOpacity 0 255 colormap 0 256 numContours 0 257 } 251 258 252 259 itk_component add view { … … 959 966 SendCmd "axis lformat $axis %g" 960 967 } 968 StopBufferingCommands 961 969 SendCmd "imgflush" 970 StartBufferingCommands 962 971 } 963 972 set _first "" … … 1002 1011 } 1003 1012 } 1013 # FIXME: Why do I have to reassert the cutplane visibility? 1014 InitSettings cutplaneVisible 1015 1004 1016 if { $_first != "" } { 1005 1017 $itk_component(field) choices delete 0 end … … 1031 1043 $itk_component(field) value $_curFldLabel 1032 1044 } 1033 InitSettings isosurfaceVisible colormapPalette isosurfaceVisible1034 1045 1035 1046 if { $_reset } { … … 1041 1052 isosurfaceWireframe isosurfaceOutline \ 1042 1053 cutplaneXPosition cutplaneYPosition cutplaneZPosition \ 1043 cutplaneXVisible cutplaneYVisible cutplaneZVisible \1044 cutplaneVisible 1054 cutplaneXVisible cutplaneYVisible cutplaneZVisible 1055 1045 1056 Zoom reset 1046 1057 foreach axis { x y z } { … … 1063 1074 SendCmd [list axis name $axis $label] 1064 1075 } 1076 if { [array size _fields] < 2 } { 1077 blt::table forget $itk_component(field) $itk_component(field_l) 1078 } 1065 1079 set _reset 0 1066 1080 } … … 1306 1320 } 1307 1321 switch -- $what { 1308 "isosurfaceOpacity" {1309 set val $_settings(isosurfaceOpacity)1310 set sval [expr { 0.01 * double($val) }]1311 SendCmd "contour3d opacity $sval"1312 }1313 "isosurfaceWireframe" {1314 set bool $_settings(isosurfaceWireframe)1315 SendCmd "contour3d wireframe $bool"1316 }1317 "isosurfaceVisible" {1318 set bool $_settings(isosurfaceVisible)1319 SendCmd "contour3d visible $bool"1320 if { $bool } {1321 Rappture::Tooltip::for $itk_component(contour) \1322 "Hide the isosurface"1323 } else {1324 Rappture::Tooltip::for $itk_component(contour) \1325 "Show the isosurface"1326 }1327 }1328 "isosurfaceLighting" {1329 set bool $_settings(isosurfaceLighting)1330 SendCmd "contour3d lighting $bool"1331 }1332 "isosurfaceEdges" {1333 set bool $_settings(isosurfaceEdges)1334 SendCmd "contour3d edges $bool"1335 }1336 "isosurfaceOutline" {1337 set bool $_settings(isosurfaceOutline)1338 SendCmd "dataset outline $bool"1339 }1340 1322 "background" { 1341 1323 set bgcolor [$itk_component(background) value] … … 1371 1353 "cutplaneEdges" { 1372 1354 set bool $_settings($what) 1373 foreach dataset [CurrentDatasets -visible] { 1374 SendCmd "cutplane edges $bool $dataset" 1375 } 1355 SendCmd "cutplane edges $bool" 1376 1356 } 1377 1357 "cutplaneVisible" { 1378 1358 set bool $_settings($what) 1379 foreach dataset [CurrentDatasets -visible] { 1380 SendCmd "cutplane visible $bool $dataset" 1381 } 1359 puts stderr "cutplane visible $bool" 1360 SendCmd "cutplane visible $bool" 1382 1361 } 1383 1362 "cutplaneWireframe" { 1384 1363 set bool $_settings($what) 1385 foreach dataset [CurrentDatasets -visible] { 1386 SendCmd "cutplane wireframe $bool $dataset" 1387 } 1364 SendCmd "cutplane wireframe $bool" 1388 1365 } 1389 1366 "cutplaneLighting" { 1390 1367 set bool $_settings($what) 1391 foreach dataset [CurrentDatasets -visible] { 1392 SendCmd "cutplane lighting $bool $dataset" 1393 } 1368 SendCmd "cutplane lighting $bool" 1394 1369 } 1395 1370 "cutplaneOpacity" { 1396 1371 set val $_settings($what) 1397 1372 set sval [expr { 0.01 * double($val) }] 1398 foreach dataset [CurrentDatasets -visible] { 1399 SendCmd "cutplane opacity $sval $dataset" 1400 } 1373 SendCmd "cutplane opacity $sval" 1401 1374 } 1402 1375 "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" { … … 1415 1388 set axis [string tolower [string range $what 8 8]] 1416 1389 set pos [expr $_settings($what) * 0.01] 1417 foreach dataset [CurrentDatasets -visible] { 1418 SendCmd "cutplane slice ${axis} ${pos} $dataset" 1419 } 1390 SendCmd "cutplane slice ${axis} ${pos}" 1420 1391 set _cutplanePending 0 1421 1392 } 1422 "isosurfaceVisible" { 1423 set bool $_settings($what) 1424 foreach dataset [CurrentDatasets -visible] { 1425 SendCmd "contour3d visible $bool $dataset" 1426 } 1427 set _settings(isosurfaceVisible) $bool 1428 if { $bool } { 1429 Rappture::Tooltip::for $itk_component(contour) \ 1430 "Hide the isosurface" 1431 } else { 1432 Rappture::Tooltip::for $itk_component(contour) \ 1433 "Show the isosurface" 1434 } 1435 DrawLegend 1436 } 1437 "colormapPalette" { 1438 set color [$itk_component(palette) value] 1439 set _settings(colormapPalette) $color 1393 "colormap" { 1394 set _changed(colormap) 1 1395 StartBufferingCommands 1396 set color [$itk_component(colormap) value] 1397 set _settings(colormap) $color 1440 1398 if { $color == "none" } { 1441 1399 if { $_settings(colormapVisible) } { … … 1448 1406 set _settings(colormapVisible) 1 1449 1407 } 1450 ResetColormap $color 1451 SendCmd "contour3d colormap $_currentColormap" 1452 SendCmd "cutplane colormap $_currentColormap" 1408 SetCurrentColormap $color 1453 1409 } 1410 StopBufferingCommands 1454 1411 EventuallyRequestLegend 1412 } 1413 "numContours" { 1414 set _changed(numContours) 1 1415 set _settings(numContours) [$itk_component(numcontours) value] 1416 set _currentNumContours $_settings(numContours) 1417 SendCmd "contour3d numcontours [expr $_settings(numContours) + 1]" 1418 DrawLegend 1419 } 1420 "isosurfaceWireframe" { 1421 set bool $_settings(isosurfaceWireframe) 1422 SendCmd "contour3d wireframe $bool" 1423 } 1424 "isosurfaceVisible" { 1425 set bool $_settings(isosurfaceVisible) 1426 SendCmd "contour3d visible $bool" 1427 if { $bool } { 1428 Rappture::Tooltip::for $itk_component(contour) \ 1429 "Hide the isosurface" 1430 } else { 1431 Rappture::Tooltip::for $itk_component(contour) \ 1432 "Show the isosurface" 1433 } 1434 DrawLegend 1435 } 1436 "isosurfaceLighting" { 1437 set bool $_settings(isosurfaceLighting) 1438 SendCmd "contour3d lighting $bool" 1439 } 1440 "isosurfaceEdges" { 1441 set bool $_settings(isosurfaceEdges) 1442 SendCmd "contour3d edges $bool" 1443 } 1444 "isosurfaceOutline" { 1445 set bool $_settings(isosurfaceOutline) 1446 SendCmd "dataset outline $bool" 1455 1447 } 1456 1448 "isolineColor" { … … 1462 1454 set val $_settings(isosurfaceOpacity) 1463 1455 set sval [expr { 0.01 * double($val) }] 1464 foreach dataset [CurrentDatasets -visible $_first] { 1465 SendCmd "contour3d opacity $sval $dataset" 1466 } 1467 } 1468 "isosurfaceLighting" { 1469 set bool $_settings(isosurfaceLighting) 1470 foreach dataset [CurrentDatasets -visible $_first] { 1471 SendCmd "contour3d lighting $bool $dataset" 1472 } 1456 SendCmd "contour3d opacity $sval" 1473 1457 } 1474 1458 "field" { … … 1558 1542 } 1559 1543 1560 #1561 # BuildColormap --1562 #1563 itcl::body Rappture::VtkIsosurfaceViewer::BuildColormap { name stylelist } {1564 array set style $stylelist1565 set cmap [ColorsToColormap $style(-color)]1566 if { [llength $cmap] == 0 } {1567 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"1568 }1569 if { ![info exists _settings(contour-opacity)] } {1570 set _settings(contour-opacity) $style(-opacity)1571 }1572 set max $_settings(contour-opacity)1573 1574 set wmap "0.0 1.0 1.0 1.0"1575 SendCmd "colormap add $name { $cmap } { $wmap }"1576 }1577 1578 1544 # ---------------------------------------------------------------------- 1579 1545 # CONFIGURATION OPTION: -plotbackground … … 1698 1664 -command [itcl::code $this AdjustSetting contour-scale] 1699 1665 1700 label $inner.field_l -text "Field" -font "Arial 9" 1666 itk_component add field_l { 1667 label $inner.field_l -text "Field" -font "Arial 9" 1668 } { 1669 ignore -font 1670 } 1701 1671 itk_component add field { 1702 1672 Rappture::Combobox $inner.field -width 10 -editable no … … 1705 1675 [itcl::code $this AdjustSetting field] 1706 1676 1707 label $inner. palette_l -text "Palette" -font "Arial 9"1708 itk_component add palette{1709 Rappture::Combobox $inner. palette-width 10 -editable no1710 } 1711 $inner. palettechoices insert end \1677 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1678 itk_component add colormap { 1679 Rappture::Combobox $inner.colormap -width 10 -editable no 1680 } 1681 $inner.colormap choices insert end \ 1712 1682 "BCGYR" "BCGYR" \ 1713 1683 "BGYOR" "BGYOR" \ … … 1727 1697 "orange-to-blue" "orange-to-blue" 1728 1698 1729 $itk_component(palette) value "BCGYR" 1730 bind $inner.palette <<Value>> \ 1731 [itcl::code $this AdjustSetting colormapPalette] 1699 $itk_component(colormap) value "BCGYR" 1700 bind $inner.colormap <<Value>> \ 1701 [itcl::code $this AdjustSetting colormap] 1702 1703 label $inner.numcontours_l -text "Number of Isosurfaces" -font "Arial 9" 1704 itk_component add numcontours { 1705 Rappture::Spinint $inner.numcontours \ 1706 -min 2 -max 50 -font "arial 9" 1707 } 1708 $itk_component(numcontours) value $_settings(numContours) 1709 bind $itk_component(numcontours) <<Value>> \ 1710 [itcl::code $this AdjustSetting numContours] 1732 1711 1733 1712 blt::table $inner \ 1734 0,0 $inner.palette_l -anchor w -pady 2 \ 1735 0,1 $inner.palette -anchor w -pady 2 -fill x \ 1736 1,0 $inner.linecolor_l -anchor w -pady 2 \ 1737 1,1 $inner.linecolor -anchor w -pady 2 -fill x \ 1738 2,0 $inner.background_l -anchor w -pady 2 \ 1739 2,1 $inner.background -anchor w -pady 2 -fill x \ 1740 3,0 $inner.contour -anchor w -pady 2 -cspan 2 \ 1741 4,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \ 1742 5,0 $inner.lighting -anchor w -pady 2 -cspan 2 \ 1743 6,0 $inner.edges -anchor w -pady 2 -cspan 2 \ 1744 7,0 $inner.outline -anchor w -pady 2 -cspan 2 \ 1745 8,0 $inner.legend -anchor w -pady 2 \ 1746 9,0 $inner.opacity_l -anchor w -pady 2 \ 1747 9,1 $inner.opacity -fill x -pady 2 -fill x \ 1748 10,0 $inner.field_l -anchor w -pady 2 \ 1749 10,1 $inner.field -anchor w -pady 2 -fill x \ 1713 0,0 $inner.field_l -anchor w -pady 2 \ 1714 0,1 $inner.field -anchor w -pady 2 -fill x \ 1715 1,0 $inner.colormap_l -anchor w -pady 2 \ 1716 1,1 $inner.colormap -anchor w -pady 2 -fill x \ 1717 2,0 $inner.linecolor_l -anchor w -pady 2 \ 1718 2,1 $inner.linecolor -anchor w -pady 2 -fill x \ 1719 3,0 $inner.background_l -anchor w -pady 2 \ 1720 3,1 $inner.background -anchor w -pady 2 -fill x \ 1721 4,0 $inner.numcontours_l -anchor w -pady 2 \ 1722 4,1 $inner.numcontours -anchor w -pady 2 \ 1723 5,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \ 1724 6,0 $inner.lighting -anchor w -pady 2 -cspan 2 \ 1725 7,0 $inner.edges -anchor w -pady 2 -cspan 2 \ 1726 8,0 $inner.outline -anchor w -pady 2 -cspan 2 \ 1727 9,0 $inner.legend -anchor w -pady 2 \ 1728 10,0 $inner.opacity_l -anchor w -pady 2 \ 1729 10,1 $inner.opacity -fill x -pady 2 -fill x \ 1750 1730 1751 1731 blt::table configure $inner r* c* -resize none … … 2133 2113 SetCurrentColormap $stylelist 2134 2114 } 2135 $itk_component( palette) value $style(-color)2115 $itk_component(colormap) value $style(-color) 2136 2116 } 2137 2117 SendCmd "cutplane add $tag" … … 2141 2121 SendCmd "cutplane linewidth 1 $tag" 2142 2122 2143 #SendCmd "cutplane linecolor 1 1 1 $tag"2144 #SendCmd "cutplane visible $tag"2145 2123 foreach axis { x y z } { 2146 2124 SendCmd "cutplane slice $axis 0.5 $tag" 2147 2125 SendCmd "cutplane axis $axis 0 $tag" 2148 2126 } 2149 set _numContours $style(-levels) 2150 SendCmd "contour3d add numcontours $_numContours $tag" 2127 # This is too complicated. We want to set the colormap, number of 2128 # isolines and opacity for the dataset. They can be the default values, 2129 # the style hints loaded with the dataset, or set by user controls. As 2130 # datasets get loaded, they first use the defaults that are overidden 2131 # by the style hints. If the user changes the global controls, then that 2132 # overrides everything else. I don't know what it means when global 2133 # controls are specified as style hints by each dataset. It complicates 2134 # the code to handle aberrant cases. 2135 2136 if { $_changed(isosurfaceOpacity) } { 2137 set style(-opacity) $_settings(isosurfaceOpacity) 2138 } 2139 if { $_changed(numContours) } { 2140 set style(-levels) $_settings(numContours) 2141 } 2142 if { $_changed(colormap) } { 2143 set style(-color) $_settings(colormap) 2144 } 2145 if { $_currentColormap == "" } { 2146 $itk_component(colormap) value $style(-color) 2147 } 2148 set _currentOpacity $style(-opacity) 2149 if { $_currentNumContours != $style(-levels) } { 2150 set _currentNumContours $style(-levels) 2151 set _settings(numContours) $_currentNumContours 2152 $itk_component(numcontours) value $_currentNumContours 2153 DrawLegend 2154 } 2155 SendCmd "contour3d add numcontours [expr $_currentNumContours+1] $tag" 2151 2156 SendCmd "contour3d edges $style(-edges) $tag" 2152 2157 SendCmd "dataset outline $style(-outline) $tag" … … 2159 2164 SendCmd "contour3d linecolor [Color2RGB $style(-edgecolor)] $tag" 2160 2165 SendCmd "contour3d linewidth $style(-linewidth) $tag" 2161 SendCmd "contour3d opacity $ style(-opacity)$tag"2166 SendCmd "contour3d opacity $_currentOpacity $tag" 2162 2167 set _settings(isosurfaceOpacity) $style(-opacity) 2168 SetCurrentColormap $style(-color) 2163 2169 SendCmd "contour3d wireframe $style(-wireframe) $tag" 2164 2170 set _settings(isosurfaceWireframe) $style(-wireframe) … … 2387 2393 array unset _isolines 2388 2394 if { $color != "none" && [info exists _limits($_curFldName)] && 2389 $_ numContours> 0 } {2395 $_settings(numContours) > 0 } { 2390 2396 set pixels [blt::vector create \#auto] 2391 2397 set values [blt::vector create \#auto] 2392 2398 set range [image height $_image(legend)] 2393 2399 # Order of pixels is max to min (max is at top of legend). 2394 $pixels seq $ih 0 $_ numContours2400 $pixels seq $ih 0 $_settings(numContours) 2395 2401 set offset [expr 2 + $lineht] 2396 2402 # If there's a legend title, increase the offset by the line height. … … 2401 2407 $pixels expr {round($pixels + $offset)} 2402 2408 foreach { vmin vmax } $_limits($_curFldName) break 2403 $values seq $vmin $vmax $_ numContours2409 $values seq $vmin $vmax $_settings(numContours) 2404 2410 set tags "isoline legend" 2405 2411 foreach pos [$pixels range 0 end] value [$values range end 0] { … … 2480 2486 # SetCurrentColormap -- 2481 2487 # 2482 itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentColormap { stylelist } { 2483 array set style { 2484 -color BCGYR 2485 -levels 10 2486 -opacity 1.0 2487 } 2488 array set style $stylelist 2489 2490 set name "$style(-color):$style(-levels):$style(-opacity)" 2488 itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentColormap { name } { 2489 # Keep track of the colormaps that we build. 2491 2490 if { ![info exists _colormaps($name)] } { 2492 set stylelist [array get style] 2493 BuildColormap $name $stylelist 2494 set _colormaps($name) $stylelist 2491 BuildColormap $name 2492 set _colormaps($name) 1 2495 2493 } 2496 2494 set _currentColormap $name 2495 SendCmd "contour3d colormap $_currentColormap" 2497 2496 } 2498 2497 … … 2500 2499 # BuildColormap -- 2501 2500 # 2502 itcl::body Rappture::VtkIsosurfaceViewer::BuildColormap { name stylelist } { 2503 array set style $stylelist 2504 set cmap [ColorsToColormap $style(-color)] 2501 # Build the designated colormap on the server. 2502 # 2503 itcl::body Rappture::VtkIsosurfaceViewer::BuildColormap { name } { 2504 set cmap [ColorsToColormap $name] 2505 2505 if { [llength $cmap] == 0 } { 2506 2506 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 2507 2507 } 2508 if { ![info exists _settings(isosurfaceOpacity)] } {2509 set _settings(isosurfaceOpacity) $style(-opacity)2510 }2511 set max $_settings(isosurfaceOpacity)2512 2513 2508 set wmap "0.0 1.0 1.0 1.0" 2514 2509 SendCmd "colormap add $name { $cmap } { $wmap }" 2515 2510 } 2516 2511 2517 itcl::body Rappture::VtkIsosurfaceViewer::ResetColormap { color } { 2518 array set style { 2519 -color BCGYR 2520 -levels 10 2521 -opacity 1.0 2522 } 2523 if { [info exists _colormap($_currentColormap)] } { 2524 array set style $_colormap($_currentColormap) 2525 } 2526 set style(-color) $color 2527 SetCurrentColormap [array get style] 2528 } 2512 2513
Note: See TracChangeset
for help on using the changeset viewer.