Changeset 4426 for branches/1.3


Ignore:
Timestamp:
Jun 25, 2014 10:32:46 AM (6 years ago)
Author:
gah
Message:

first attempt to fix contour levels

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl

    r4399 r4426  
    6868    protected method DoResize {}
    6969    protected method DoRotate {}
     70    protected method DoChangeContourLevels {}
    7071    protected method AdjustSetting {what {value ""}}
    7172    protected method InitSettings { args  }
     
    9091    private method EnterLegend { x y }
    9192    private method EventuallyResize { w h }
     93    private method EventuallyChangeContourLevels {}
    9294    private method EventuallyRotate { q }
    9395    private method EventuallyRequestLegend {}
     
    105107    private method SetCurrentColormap { color }
    106108    private method SetOrientation { side }
    107     private method UpdateContourList {}
     109    private method GenerateContourList {}
    108110
    109111    private variable _arcball ""
     
    138140    private variable _title ""
    139141    private variable _isolines
    140     private variable _contourList ""
     142    private variable _contourList
    141143
    142144    common _downloadPopup;              # download options from popup
     
    184186    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
    185187
     188    # Contour levels event
     189    $_dispatcher register !contours
     190    $_dispatcher dispatch $this !contours \
     191        "[itcl::code $this DoChangeContourLevels]; list"
     192
    186193    # X-Cutplane event
    187194    $_dispatcher register !xcutplane
     
    221228    $_arcball quaternion $q
    222229
     230    array set _contourList {
     231        numLevels       10
     232        reqValues       ""
     233        updatePending   0
     234        values          ""
     235    }
    223236    array set _settings {
    224237        -axesvisible                    1
     
    468481}
    469482
     483itcl::body Rappture::VtkIsosurfaceViewer::DoChangeContourLevels {} {
     484    GenerateContourList
     485    SendCmd [list contour3d contourlist $_contourList(values)]
     486    #SendCmd [list camera reset]
     487    DrawLegend
     488    set _contourList(updatePending) 0
     489}
     490
    470491itcl::body Rappture::VtkIsosurfaceViewer::DoRotate {} {
    471492    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     
    506527        set _cutplanePending 1
    507528        $_dispatcher event -after 100 !${axis}cutplane
     529    }
     530}
     531
     532itcl::body Rappture::VtkIsosurfaceViewer::EventuallyChangeContourLevels {} {
     533    set n $_contourList(numLevels)
     534    set _contourList(values) ""
     535    if { !$_contourList(updatePending) } {
     536        set _contourList(updatePending) 1
     537        global rotate_delay
     538        $_dispatcher event -after $rotate_delay !contours
    508539    }
    509540}
     
    546577    set _obj2ovride($dataobj-width) $params(-width)
    547578    set _obj2ovride($dataobj-raise) $params(-raise)
     579    EventuallyChangeContourLevels
    548580    $_dispatcher event -idle !rebuild
    549581}
     
    577609    # If anything changed, then rebuild the plot
    578610    if { $changed } {
     611        EventuallyChangeContourLevels
    579612        $_dispatcher event -idle !rebuild
    580613    }
     
    14201453        "-numcontours" {
    14211454            set _settings($what) [$itk_component(numcontours) value]
    1422             set _currentNumContours $_settings($what)
    1423             UpdateContourList
    1424             set _changed($what) 1
    1425             SendCmd "contour3d contourlist [list $_contourList]"
    1426             DrawLegend
     1455            set _contourList(numLevels) $_settings($what)
     1456            EventuallyChangeContourLevels
    14271457        }
    14281458        "-isosurfacewireframe" {
     
    14931523            if { ![info exists _limits($_curFldName)] } {
    14941524                SendCmd "dataset maprange all"
     1525                puts stderr "dataset maprange all"
    14951526            } else {
     1527                puts stderr "dataset maprange explicit $_limits($_curFldName) $_curFldName"         
    14961528                SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
    14971529            }
     
    14991531            SendCmd "contour3d colormode $_colorMode $_curFldName"
    15001532            SendCmd "camera reset"
    1501             UpdateContourList
    15021533            DrawLegend
    15031534        }
     
    21822213    }
    21832214    set _currentOpacity $style(-opacity)
    2184     if { $_currentNumContours != $style(-levels) } {
    2185         set _currentNumContours $style(-levels)
    2186         set _settings(-numcontours) $_currentNumContours
    2187         $itk_component(numcontours) value $_currentNumContours
    2188         UpdateContourList
    2189         DrawLegend
     2215    if { $_contourList(numLevels) != $style(-levels) } {
     2216        set _settings(-numcontours) $style(-levels)
     2217        $itk_component(numcontours) value $style(-levels)
     2218        set _contourList(numLevels) $style(-levels)
     2219        EventuallyChangeContourLevels
    21902220    }
    21912221    set _settings(-isosurfacevisible) $style(-isosurfacevisible)
     
    21982228    set _settings(-zcutplaneposition) $style(-zcutplaneposition)
    21992229 
    2200     SendCmd [list contour3d add contourlist $_contourList $tag]
     2230    GenerateContourList
     2231    SendCmd [list contour3d add contourlist $_contourList(values) $tag]
     2232
    22012233    SendCmd "contour3d edges $style(-edges) $tag"
    22022234    SendCmd "outline add $tag"
     
    24492481            incr offset $lineht
    24502482        }
    2451         foreach value $_contourList {
     2483        foreach value $_contourList(values) {
    24522484            set norm [expr 1.0 - (($value - $vmin) / $range)]
    24532485            set y1 [expr int(round(($norm * $ih) + $offset))]
     
    25742606}
    25752607
    2576 itcl::body Rappture::VtkIsosurfaceViewer::UpdateContourList {} {
     2608itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} {
    25772609    if { ![info exists _limits($_curFldName)] } {
    2578         return
    2579     }
    2580     if { $_currentNumContours < 1 } {
    2581         set _contourList ""
    2582         return
     2610        return ""
     2611    }
     2612    if { $_contourList(numLevels) < 1 } {
     2613        return ""
    25832614    }
    25842615    foreach { vmin vmax } $_limits($_curFldName) break
    25852616    set v [blt::vector create \#auto]
    2586     $v seq $vmin $vmax [expr $_currentNumContours+2]
     2617    $v seq $vmin $vmax [expr $_contourList(numLevels)+2]
    25872618    $v delete end 0
    2588     set _contourList [$v range 0 end]
     2619    set values [$v range 0 end]
    25892620    blt::vector destroy $v
    2590 }
    2591 
     2621    set _contourList(values) $values
     2622}
Note: See TracChangeset for help on using the changeset viewer.