Changeset 3623 for trunk/gui/scripts/vtkheightmapviewer.tcl
- Timestamp:
- Apr 3, 2013 1:06:20 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkheightmapviewer.tcl
r3593 r3623 107 107 private method ResetAxes {} 108 108 private method SetOrientation { side } 109 private method UpdateContourList {} 109 110 110 111 private variable _arcball "" … … 120 121 # The name of the current colormap used. The colormap is global to all 121 122 # heightmaps displayed. 122 private variable _currentColormap "" ;123 private variable _currentNumIsolines "" ;124 private variable _currentOpacity "" ;123 private variable _currentColormap "" 124 private variable _currentNumIsolines -1 125 private variable _currentOpacity "" 125 126 126 127 private variable _click ; # info used for rotate operations … … 139 140 private variable _start 0 140 141 private variable _isolines 142 private variable _contourList "" 141 143 142 144 common _downloadPopup; # download options from popup … … 1057 1059 PanCamera 1058 1060 InitSettings axisXGrid axisYGrid axisZGrid \ 1059 axisVisible axisLabels 1060 InitSettings heightmapScale field isHeightmap1061 axisVisible axisLabels heightmapScale field isHeightmap \ 1062 numIsolines 1061 1063 if { [array size _fields] < 2 } { 1062 1064 blt::table forget $itk_component(field) $itk_component(field_l) … … 1367 1369 SetCurrentColormap $color 1368 1370 if {$_settings(colormapDiscrete)} { 1369 set numColors [expr $_settings(numIsolines) -1]1371 set numColors [expr $_settings(numIsolines) + 1] 1370 1372 SendCmd "colormap res $numColors $color" 1371 1373 } … … 1380 1382 "colormapDiscrete" { 1381 1383 set bool $_settings($what) 1382 set numColors [expr $_settings(numIsolines) -1]1384 set numColors [expr $_settings(numIsolines) + 1] 1383 1385 StartBufferingCommands 1384 1386 if {$bool} { … … 1440 1442 SendCmd "heightmap colormode scalar $_curFldName" 1441 1443 SendCmd "camera reset" 1444 UpdateContourList 1442 1445 DrawLegend 1443 1446 } … … 1569 1572 } 1570 1573 "numIsolines" { 1571 set _changed(numIsolines) 11572 1574 set _settings(numIsolines) [$itk_component(numisolines) value] 1573 1575 set _currentNumIsolines $_settings(numIsolines) 1574 SendCmd "heightmap numcontours $_settings(numIsolines)" 1576 UpdateContourList 1577 set _changed(numIsolines) 1 1578 SendCmd "heightmap contourlist [list $_contourList]" 1575 1579 if {$_settings(colormapDiscrete)} { 1576 set numColors [expr $_settings(numIsolines) -1]1580 set numColors [expr $_settings(numIsolines) + 1] 1577 1581 SendCmd "colormap res $numColors" 1578 1582 EventuallyRequestLegend … … 1961 1965 itk_component add numisolines { 1962 1966 Rappture::Spinint $inner.numisolines \ 1963 -min 2-max 50 -font "arial 9"1967 -min 1 -max 50 -font "arial 9" 1964 1968 } 1965 1969 $itk_component(numisolines) value $_settings(numIsolines) … … 2273 2277 set _settings(numIsolines) $_currentNumIsolines 2274 2278 $itk_component(numisolines) value $_currentNumIsolines 2279 UpdateContourList 2275 2280 DrawLegend 2276 2281 } … … 2279 2284 SendCmd "outline visible $_settings(outline) $tag" 2280 2285 set scale [GetHeightmapScale] 2281 SendCmd " heightmap add numcontours $_currentNumIsolines $scale $tag"2286 SendCmd "[list heightmap add contourlist $_contourList $scale $tag]" 2282 2287 set _comp2scale($tag) $_settings(heightmapScale) 2283 2288 SendCmd "heightmap edges $_settings(edges) $tag" … … 2384 2389 if { $color != "none" && [info exists _limits($_curFldName)] && 2385 2390 $_settings(isolinesVisible) && $_currentNumIsolines > 0 } { 2386 set pixels [blt::vector create \#auto] 2387 set values [blt::vector create \#auto] 2388 set range [image height $_image(legend)] 2389 # Order of pixels is max to min (max is at top of legend). 2390 $pixels seq $ih 0 $_currentNumIsolines 2391 2391 2392 foreach { vmin vmax } $_limits($_curFldName) break 2393 set range [expr double($vmax - $vmin)] 2394 if { $range <= 0.0 } { 2395 set range 1.0; # Min is greater or equal to max. 2396 } 2397 set tags "isoline legend" 2392 2398 set offset [expr 2 + $lineht] 2393 # If there's a legend title, increase the offset by the line height.2394 2399 if { $title != "" } { 2395 2400 incr offset $lineht 2396 2401 } 2397 $pixels expr {round($pixels + $offset)} 2398 # Order of values is min to max. 2399 foreach { vmin vmax } $_limits($_curFldName) break 2400 $values seq $vmin $vmax $_currentNumIsolines 2401 set tags "isoline legend" 2402 array unset _isolines 2403 foreach pos [$pixels range 0 end] value [$values range end 0] { 2404 set y1 [expr int($pos)] 2402 foreach value $_contourList { 2403 set norm [expr 1.0 - (($value - $vmin) / $range)] 2404 set y1 [expr int(round(($norm * $ih) + $offset))] 2405 2405 for { set off 0 } { $off < 3 } { incr off } { 2406 2406 set _isolines([expr $y1 + $off]) $value 2407 2407 set _isolines([expr $y1 - $off]) $value 2408 2408 } 2409 set id [$c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags]2409 $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags 2410 2410 } 2411 blt::vector destroy $pixels $values2412 2411 } 2413 2412 … … 2595 2594 set _view(zoom) 1.0 2596 2595 } 2596 2597 itcl::body Rappture::VtkHeightmapViewer::UpdateContourList {} { 2598 if { ![info exists _limits($_curFldName)] } { 2599 return 2600 } 2601 foreach { vmin vmax } $_limits($_curFldName) break 2602 set v [blt::vector create \#auto] 2603 $v seq $vmin $vmax [expr $_currentNumIsolines+2] 2604 $v delete end 0 2605 set _contourList [$v range 0 end] 2606 blt::vector destroy $v 2607 }
Note: See TracChangeset
for help on using the changeset viewer.