Changeset 3454 for trunk/gui/scripts/vtkheightmapviewer.tcl
- Timestamp:
- Mar 5, 2013, 3:22:29 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkheightmapviewer.tcl
r3447 r3454 84 84 private method BuildAxisTab {} 85 85 private method BuildCameraTab {} 86 private method BuildColormap { name colors } 87 private method ResetColormap { color } 86 private method BuildColormap { name } 88 87 private method BuildContourTab {} 89 88 private method BuildDownloadPopup { widget command } … … 102 101 private method PanCamera {} 103 102 private method RequestLegend {} 104 private method SetCurrentColormap { stylelist}103 private method SetCurrentColormap { color } 105 104 private method SetLegendTip { x y } 106 105 private method SetObjectStyle { dataobj comp } … … 121 120 # heightmaps displayed. 122 121 private variable _currentColormap "" ; 122 private variable _currentNumIsolines "" ; 123 private variable _currentOpacity "" ; 123 124 124 125 private variable _click ; # info used for rotate operations … … 127 128 private variable _view ; # view params for 3D view 128 129 private variable _settings 130 private variable _changed 129 131 private variable _initialStyle ""; # First found style in dataobjects. 130 132 private variable _reset 1; # Indicates if camera needs to be reset … … 144 146 private variable _legendHeight 0 145 147 private variable _resizePending 0 146 private variable _numIsolinesPending 0147 148 private variable _rotatePending 0 148 149 private variable _legendPending 0 … … 165 166 set _serverType "vtkvis" 166 167 168 EnableWaitDialog 1000 167 169 # Rebuild event 168 170 $_dispatcher register !rebuild … … 187 189 $_parser alias dataset [itcl::code $this ReceiveDataset] 188 190 $_parser alias legend [itcl::code $this ReceiveLegend] 189 $_parser alias viserror [itcl::code $this ReceiveError]190 191 191 192 # Initialize the view to some default parameters. … … 204 205 $_arcball quaternion $q 205 206 206 array set _settings [subst{207 array set _settings { 207 208 axisFlymode "static" 208 209 axisMinorTicks 1 … … 228 229 wireframe 0 229 230 saveOpacity 100 230 }] 231 231 } 232 array set _changed { 233 opacity 0 234 colormap 0 235 numIsolines 0 236 } 232 237 itk_component add view { 233 238 canvas $itk_component(plotarea).view \ … … 986 991 $itk_component(field) value $_curFldLabel 987 992 } 988 InitSettings stretchToFit 993 InitSettings stretchToFit 989 994 990 995 if { $_reset } { … … 1040 1045 InitSettings axisXGrid axisYGrid axisZGrid \ 1041 1046 axisVisible axisLabels 1042 InitSettings opacity heightmapScale lighting edges wireframe \ 1043 colormap field outline isHeightmap 1047 InitSettings heightmapScale field isHeightmap 1044 1048 if { [array size _fields] < 2 } { 1045 1049 blt::table forget $itk_component(field) $itk_component(field_l) … … 1331 1335 } 1332 1336 "colormap" { 1337 set _changed(colormap) 1 1333 1338 StartBufferingCommands 1334 1339 set color [$itk_component(colormap) value] … … 1344 1349 set _settings(colormapVisible) 1 1345 1350 } 1346 ResetColormap $color 1347 SendCmd "heightmap colormap $_currentColormap" 1351 SetCurrentColormap $color 1348 1352 } 1349 1353 #SendCmd "heightmap colormode scalar $_curFldName" … … 1524 1528 } 1525 1529 "numIsolines" { 1530 set _changed(numIsolines) 1 1526 1531 set _settings(numIsolines) [$itk_component(numisolines) value] 1532 set _currentNumIsolines $_settings(numIsolines) 1527 1533 SendCmd "heightmap numcontours $_settings(numIsolines)" 1528 1534 DrawLegend 1529 1535 } 1530 1536 "opacity" { 1537 set _changed(opacity) 1 1531 1538 if { $_settings(isHeightmap) } { 1532 1539 set _settings(saveOpacity) $_settings(opacity) … … 1654 1661 # SetCurrentColormap -- 1655 1662 # 1656 itcl::body Rappture::VtkHeightmapViewer::SetCurrentColormap { stylelist } { 1657 array set style { 1658 -color BCGYR 1659 -levels 10 1660 -opacity 1.0 1661 } 1662 array set style $stylelist 1663 1664 set name "$style(-color):$style(-levels):$style(-opacity)" 1663 itcl::body Rappture::VtkHeightmapViewer::SetCurrentColormap { name } { 1664 # Keep track of the colormaps that we build. 1665 1665 if { ![info exists _colormaps($name)] } { 1666 set stylelist [array get style] 1667 BuildColormap $name $stylelist 1668 set _colormaps($name) $stylelist 1666 BuildColormap $name 1667 set _colormaps($name) 1 1669 1668 } 1670 1669 set _currentColormap $name 1670 SendCmd "heightmap colormap $_currentColormap" 1671 1671 } 1672 1672 … … 1675 1675 # BuildColormap -- 1676 1676 # 1677 itcl::body Rappture::VtkHeightmapViewer::BuildColormap { name stylelist } { 1678 array set style $stylelist 1679 set cmap [ColorsToColormap $style(-color)] 1677 # Build the designated colormap on the server. 1678 # 1679 itcl::body Rappture::VtkHeightmapViewer::BuildColormap { name } { 1680 set cmap [ColorsToColormap $name] 1680 1681 if { [llength $cmap] == 0 } { 1681 1682 set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0" 1682 1683 } 1683 if { ![info exists _settings(opacity)] } {1684 set _settings(opacity) $style(-opacity)1685 }1686 set max $_settings(opacity)1687 1688 1684 set wmap "0.0 1.0 1.0 1.0" 1689 1685 SendCmd "colormap add $name { $cmap } { $wmap }" … … 2010 2006 entry $inner.${tag} -font "Arial 9" -bg white \ 2011 2007 -textvariable [itcl::scope _view($tag)] 2012 bind $inner.${tag} <KeyPress-Return> \ 2008 bind $inner.${tag} <Return> \ 2009 [itcl::code $this camera set ${tag}] 2010 bind $inner.${tag} <KP_Enter> \ 2013 2011 [itcl::code $this camera set ${tag}] 2014 2012 blt::table $inner \ … … 2137 2135 } 2138 2136 2137 # 2138 # SetObjectStyle -- 2139 # 2140 # Set the style of the heightmap/contour object. This gets calls 2141 # for each dataset once as it is loaded. It can overridden by 2142 # the user controls. 2143 # 2144 # 2139 2145 itcl::body Rappture::VtkHeightmapViewer::SetObjectStyle { dataobj comp } { 2140 2146 # Parse style string. … … 2142 2148 array set style { 2143 2149 -color BCGYR 2144 -edges 0 2145 -edgecolor black 2146 -linewidth 1.0 2150 -opacity 100 2147 2151 -levels 10 2148 -visible 1 2152 } 2153 set stylelist [$dataobj style $comp] 2154 if { $stylelist != "" } { 2155 array set style $stylelist 2156 } 2157 # This is too complicated. We want to set the colormap, number of 2158 # isolines and opacity for the object. They can be the default values, 2159 # the style hints set with the dataset, or set by user controls. As 2160 # datasets get loaded, they first use the defaults that are overidden 2161 # by the style hints. If the user changes the global controls, then that 2162 # overrides everything else. I don't know what it means when global 2163 # controls are specified as style hints by each dataset. It complicates 2164 # the code to handle aberrant cases. 2165 2166 if { $_changed(opacity) } { 2167 set style(-opacity) $_settings(opacity) 2168 } 2169 if { $_changed(numIsolines) } { 2170 set style(-levels) $_settings(numIsolines) 2171 } 2172 if { $_changed(colormap) } { 2173 set style(-color) $_settings(colormap) 2149 2174 } 2150 2175 if { $_currentColormap == "" } { 2151 set stylelist [$dataobj style $comp] 2152 if { $stylelist != "" } { 2153 array set style $stylelist 2154 set stylelist [array get style] 2155 SetCurrentColormap $stylelist 2156 } 2157 $itk_component(colormap) value $style(-color) 2176 $itk_component(colormap) value $style(-color) 2177 } 2178 set _currentOpacity $style(-opacity) 2179 if { $_currentNumIsolines != $style(-levels) } { 2180 set _currentNumIsolines $style(-levels) 2181 DrawLegend 2158 2182 } 2159 2183 SendCmd "dataset outline $_settings(outline) $tag" 2160 2184 SendCmd "dataset color [Color2RGB $itk_option(-plotforeground)] $tag" 2161 set _settings(numIsolines) $style(-levels)2162 2185 set scale [GetHeightmapScale] 2163 SendCmd "heightmap add numcontours $_ settings(numIsolines)$scale $tag"2186 SendCmd "heightmap add numcontours $_currentNumIsolines $scale $tag" 2164 2187 set _comp2scale($tag) $_settings(heightmapScale) 2165 2188 SendCmd "heightmap edges $_settings(edges) $tag" 2166 2189 SendCmd "heightmap wireframe $_settings(wireframe) $tag" 2167 Se ndCmd "heightmap colormap $_currentColormap $tag"2190 SetCurrentColormap $style(-color) 2168 2191 set color [$itk_component(isolinecolor) value] 2169 2192 SendCmd "heightmap isolinecolor [Color2RGB $color] $tag" … … 2266 2289 # Draw the isolines on the legend. 2267 2290 if { $color != "none" && [info exists _limits($_curFldName)] && 2268 $_settings(isolinesVisible) && $_ settings(numIsolines)> 0 } {2291 $_settings(isolinesVisible) && $_currentNumIsolines > 0 } { 2269 2292 set pixels [blt::vector create \#auto] 2270 2293 set values [blt::vector create \#auto] 2271 2294 set range [image height $_image(legend)] 2272 2295 # Order of pixels is max to min (max is at top of legend). 2273 $pixels seq $ih 0 $_ settings(numIsolines)2296 $pixels seq $ih 0 $_currentNumIsolines 2274 2297 2275 2298 set offset [expr 2 + $lineht] … … 2281 2304 # Order of values is min to max. 2282 2305 foreach { vmin vmax } $_limits($_curFldName) break 2283 $values seq $vmin $vmax $_ settings(numIsolines)2306 $values seq $vmin $vmax $_currentNumIsolines 2284 2307 set tags "isoline legend" 2285 2308 array unset _isolines … … 2291 2314 } 2292 2315 set id [$c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags] 2293 #$c bind $id <B1-Enter> [itcl::code $this EnterIsoline %x %y $value]2294 #$c bind $id <Leave> [itcl::code $this LeaveIsoline]2295 2316 } 2296 2317 blt::vector destroy $pixels $values … … 2460 2481 } 2461 2482 2462 itcl::body Rappture::VtkHeightmapViewer::ResetColormap { color } { 2463 array set style { 2464 -color BCGYR 2465 -levels 10 2466 -opacity 1.0 2467 } 2468 if { [info exists _colormap($_currentColormap)] } { 2469 array set style $_colormap($_currentColormap) 2470 } 2471 set style(-color) $color 2472 SetCurrentColormap [array get style] 2473 } 2474 2483 2484 2485
Note: See TracChangeset
for help on using the changeset viewer.