Changeset 3538


Ignore:
Timestamp:
Mar 19, 2013, 10:00:11 AM (11 years ago)
Author:
gah
Message:

change isosurfaceviewer to compute values for contour list rather than asking for some number of isosurfaces

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/vtkisosurfaceviewer.tcl

    r3536 r3538  
    106106    private method SetCurrentColormap { color }
    107107    private method SetOrientation { side }
     108    private method UpdateContourList {}
    108109
    109110    private variable _arcball ""
     
    119120    # heightmaps displayed.
    120121    private variable _currentColormap "" ;   
    121     private variable _currentNumContours "" ;   
     122    private variable _currentNumContours -1;   
    122123    private variable _currentOpacity "" ;   
    123124
     
    138139    private variable _title ""
    139140    private variable _isolines
     141    private variable _contourList ""
    140142
    141143    common _downloadPopup;              # download options from popup
     
    10471049            cutplaneXPosition cutplaneYPosition cutplaneZPosition \
    10481050            cutplaneXVisible cutplaneYVisible cutplaneZVisible \
    1049             cutplanePreinterp
     1051            cutplanePreinterp numContours
    10501052
    10511053        Zoom reset
     
    14101412        }
    14111413        "numContours" {
    1412             set _changed(numContours) 1
    14131414            set _settings(numContours) [$itk_component(numcontours) value]
    14141415            set _currentNumContours $_settings(numContours)
    1415             SendCmd "contour3d numcontours $_settings(numContours)"
     1416            UpdateContourList
     1417            set _changed(numContours) 1
     1418            SendCmd "contour3d contourlist [list $_contourList]"
    14161419            DrawLegend
    14171420        }
     
    14751478            SendCmd "cutplane colormode $_colorMode $_curFldName"
    14761479            SendCmd "camera reset"
     1480            UpdateContourList
    14771481            DrawLegend
    14781482        }
     
    17021706    itk_component add numcontours {
    17031707        Rappture::Spinint $inner.numcontours \
    1704             -min 2 -max 50 -font "arial 9"
     1708            -min 1 -max 50 -font "arial 9"
    17051709    }
    17061710    $itk_component(numcontours) value $_settings(numContours)
     
    21682172        set _settings(numContours) $_currentNumContours
    21692173        $itk_component(numcontours) value $_currentNumContours
     2174        UpdateContourList
    21702175        DrawLegend
    21712176    }
    2172     SendCmd "contour3d add numcontours $_currentNumContours $tag"
     2177    SendCmd [list contour3d add contourlist $_contourList $tag]
    21732178    SendCmd "contour3d edges $style(-edges) $tag"
    21742179    SendCmd "dataset outline $style(-outline) $tag"
     
    24112416    if { $color != "none"  && [info exists _limits($_curFldName)] &&
    24122417         $_settings(numContours) > 0 } {
    2413         set pixels [blt::vector create \#auto]
    2414         set values [blt::vector create \#auto]
    2415         set range [image height $_image(legend)]
    2416         # Order of pixels is max to min (max is at top of legend).
    2417         $pixels seq $ih 0 $_settings(numContours)
     2418
     2419        foreach { vmin vmax } $_limits($_curFldName) break
     2420        set range [expr double($vmax - $vmin)]
     2421        if { $range <= 0.0 } {
     2422            set range 1.0;              # Min is greater or equal to max.
     2423        }
     2424        set tags "isoline legend"
    24182425        set offset [expr 2 + $lineht]
    2419         # If there's a legend title, increase the offset by the line height.
    24202426        if { $title != "" } {
    24212427            incr offset $lineht
    24222428        }
    2423         # Order of values is min to max.
    2424         $pixels expr {round($pixels + $offset)}
    2425         foreach { vmin vmax } $_limits($_curFldName) break
    2426         $values seq $vmin $vmax $_settings(numContours)
    2427         set tags "isoline legend"
    2428         foreach pos [$pixels range 0 end] value [$values range end 0] {
    2429             set y1 [expr int($pos)]
     2429        foreach value $_contourList {
     2430            set norm [expr ($value - $vmin) / $range]
     2431            set y1 [expr int(round(($norm * $ih) + $offset))]
    24302432            for { set off 0 } { $off < 3 } { incr off } {
    24312433                set _isolines([expr $y1 + $off]) $value
    24322434                set _isolines([expr $y1 - $off]) $value
    24332435            }
    2434             set id [$c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags]
    2435         }
    2436         blt::vector destroy $pixels $values
     2436            $c create line $x1 $y1 $x2 $y1 -fill $color -tags $tags
     2437        }
    24372438    }
    24382439
     
    25472548    set _view(zoom) 1.0
    25482549}
     2550
     2551itcl::body Rappture::VtkIsosurfaceViewer::UpdateContourList {} {
     2552    if { ![info exists _limits($_curFldName)] } {
     2553        return
     2554    }
     2555    foreach { vmin vmax } $_limits($_curFldName) break
     2556    set v [blt::vector create \#auto]
     2557    $v seq $vmin $vmax [expr $_currentNumContours+2]
     2558    $v delete end 0
     2559    set _contourList [$v range 0 end]
     2560    blt::vector destroy $v
     2561}
Note: See TracChangeset for help on using the changeset viewer.