Ignore:
Timestamp:
Apr 3, 2013 1:06:20 PM (11 years ago)
Author:
ldelgass
Message:

Use contour list in heightmap viewer to remove min/max isolines.

File:
1 edited

Legend:

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

    r3593 r3623  
    107107    private method ResetAxes {}
    108108    private method SetOrientation { side }
     109    private method UpdateContourList {}
    109110
    110111    private variable _arcball ""
     
    120121    # The name of the current colormap used.  The colormap is global to all
    121122    # 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 ""
    125126
    126127    private variable _click        ;    # info used for rotate operations
     
    139140    private variable _start 0
    140141    private variable _isolines
     142    private variable _contourList ""
    141143
    142144    common _downloadPopup;              # download options from popup
     
    10571059        PanCamera
    10581060        InitSettings axisXGrid axisYGrid axisZGrid \
    1059             axisVisible axisLabels
    1060         InitSettings heightmapScale field isHeightmap
     1061            axisVisible axisLabels heightmapScale field isHeightmap \
     1062            numIsolines
    10611063        if { [array size _fields] < 2 } {
    10621064            blt::table forget $itk_component(field) $itk_component(field_l)
     
    13671369                SetCurrentColormap $color
    13681370                if {$_settings(colormapDiscrete)} {
    1369                     set numColors [expr $_settings(numIsolines) - 1]
     1371                    set numColors [expr $_settings(numIsolines) + 1]
    13701372                    SendCmd "colormap res $numColors $color"
    13711373                }
     
    13801382        "colormapDiscrete" {
    13811383            set bool $_settings($what)
    1382             set numColors [expr $_settings(numIsolines) - 1]
     1384            set numColors [expr $_settings(numIsolines) + 1]
    13831385            StartBufferingCommands
    13841386            if {$bool} {
     
    14401442            SendCmd "heightmap colormode scalar $_curFldName"
    14411443            SendCmd "camera reset"
     1444            UpdateContourList
    14421445            DrawLegend
    14431446        }
     
    15691572        }
    15701573        "numIsolines" {
    1571             set _changed(numIsolines) 1
    15721574            set _settings(numIsolines) [$itk_component(numisolines) value]
    15731575            set _currentNumIsolines $_settings(numIsolines)
    1574             SendCmd "heightmap numcontours $_settings(numIsolines)"
     1576            UpdateContourList
     1577            set _changed(numIsolines) 1
     1578            SendCmd "heightmap contourlist [list $_contourList]"
    15751579            if {$_settings(colormapDiscrete)} {
    1576                 set numColors [expr $_settings(numIsolines) - 1]
     1580                set numColors [expr $_settings(numIsolines) + 1]
    15771581                SendCmd "colormap res $numColors"
    15781582                EventuallyRequestLegend
     
    19611965    itk_component add numisolines {
    19621966        Rappture::Spinint $inner.numisolines \
    1963             -min 2 -max 50 -font "arial 9"
     1967            -min 1 -max 50 -font "arial 9"
    19641968    }
    19651969    $itk_component(numisolines) value $_settings(numIsolines)
     
    22732277        set _settings(numIsolines) $_currentNumIsolines
    22742278        $itk_component(numisolines) value $_currentNumIsolines
     2279        UpdateContourList
    22752280        DrawLegend
    22762281    }
     
    22792284    SendCmd "outline visible $_settings(outline) $tag"
    22802285    set scale [GetHeightmapScale]
    2281     SendCmd "heightmap add numcontours $_currentNumIsolines $scale $tag"
     2286    SendCmd "[list heightmap add contourlist $_contourList $scale $tag]"
    22822287    set _comp2scale($tag) $_settings(heightmapScale)
    22832288    SendCmd "heightmap edges $_settings(edges) $tag"
     
    23842389    if { $color != "none"  && [info exists _limits($_curFldName)] &&
    23852390         $_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"
    23922398        set offset [expr 2 + $lineht]
    2393         # If there's a legend title, increase the offset by the line height.
    23942399        if { $title != "" } {
    23952400            incr offset $lineht
    23962401        }
    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))]
    24052405            for { set off 0 } { $off < 3 } { incr off } {
    24062406                set _isolines([expr $y1 + $off]) $value
    24072407                set _isolines([expr $y1 - $off]) $value
    24082408            }
    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
    24102410        }
    2411         blt::vector destroy $pixels $values
    24122411    }
    24132412
     
    25952594    set _view(zoom) 1.0
    25962595}
     2596
     2597itcl::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.