Ignore:
Timestamp:
Mar 5, 2013 3:22:29 PM (11 years ago)
Author:
gah
Message:

add KP_Enter to Return bindings. Implement OK handler in visviewer base class. Fix setting # of isolines while running a sequence of heightmaps/contours

File:
1 edited

Legend:

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

    r3447 r3454  
    8484    private method BuildAxisTab {}
    8585    private method BuildCameraTab {}
    86     private method BuildColormap { name colors }
    87     private method ResetColormap { color }
     86    private method BuildColormap { name }
    8887    private method BuildContourTab {}
    8988    private method BuildDownloadPopup { widget command }
     
    102101    private method PanCamera {}
    103102    private method RequestLegend {}
    104     private method SetCurrentColormap { stylelist }
     103    private method SetCurrentColormap { color }
    105104    private method SetLegendTip { x y }
    106105    private method SetObjectStyle { dataobj comp }
     
    121120    # heightmaps displayed.
    122121    private variable _currentColormap "" ;   
     122    private variable _currentNumIsolines "" ;   
     123    private variable _currentOpacity "" ;   
    123124
    124125    private variable _click        ;    # info used for rotate operations
     
    127128    private variable _view         ;    # view params for 3D view
    128129    private variable _settings
     130    private variable _changed
    129131    private variable _initialStyle "";  # First found style in dataobjects.
    130132    private variable _reset 1;          # Indicates if camera needs to be reset
     
    144146    private variable _legendHeight 0
    145147    private variable _resizePending 0
    146     private variable _numIsolinesPending 0
    147148    private variable _rotatePending 0
    148149    private variable _legendPending 0
     
    165166    set _serverType "vtkvis"
    166167
     168    EnableWaitDialog 1000
    167169    # Rebuild event
    168170    $_dispatcher register !rebuild
     
    187189    $_parser alias dataset [itcl::code $this ReceiveDataset]
    188190    $_parser alias legend [itcl::code $this ReceiveLegend]
    189     $_parser alias viserror [itcl::code $this ReceiveError]
    190191
    191192    # Initialize the view to some default parameters.
     
    204205    $_arcball quaternion $q
    205206
    206     array set _settings [subst {
     207    array set _settings {
    207208        axisFlymode             "static"
    208209        axisMinorTicks          1
     
    228229        wireframe               0
    229230        saveOpacity             100
    230     }]
    231 
     231    }
     232    array set _changed {
     233        opacity                 0
     234        colormap                0
     235        numIsolines             0
     236    }
    232237    itk_component add view {
    233238        canvas $itk_component(plotarea).view \
     
    986991        $itk_component(field) value $_curFldLabel
    987992    }
    988     InitSettings stretchToFit
     993    InitSettings stretchToFit 
    989994
    990995    if { $_reset } {
     
    10401045        InitSettings axisXGrid axisYGrid axisZGrid \
    10411046            axisVisible axisLabels
    1042         InitSettings opacity heightmapScale lighting edges wireframe \
    1043             colormap field outline isHeightmap
     1047        InitSettings heightmapScale field isHeightmap
    10441048        if { [array size _fields] < 2 } {
    10451049            blt::table forget $itk_component(field) $itk_component(field_l)
     
    13311335        }
    13321336        "colormap" {
     1337            set _changed(colormap) 1
    13331338            StartBufferingCommands
    13341339            set color [$itk_component(colormap) value]
     
    13441349                    set _settings(colormapVisible) 1
    13451350                }
    1346                 ResetColormap $color
    1347                 SendCmd "heightmap colormap $_currentColormap"
     1351                SetCurrentColormap $color
    13481352            }
    13491353            #SendCmd "heightmap colormode scalar $_curFldName"
     
    15241528        }
    15251529        "numIsolines" {
     1530            set _changed(numIsolines) 1
    15261531            set _settings(numIsolines) [$itk_component(numisolines) value]
     1532            set _currentNumIsolines $_settings(numIsolines)
    15271533            SendCmd "heightmap numcontours $_settings(numIsolines)"
    15281534            DrawLegend
    15291535        }
    15301536        "opacity" {
     1537            set _changed(opacity) 1
    15311538            if { $_settings(isHeightmap) } {
    15321539                set _settings(saveOpacity) $_settings(opacity)
     
    16541661# SetCurrentColormap --
    16551662#
    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)"
     1663itcl::body Rappture::VtkHeightmapViewer::SetCurrentColormap { name } {
     1664    # Keep track of the colormaps that we build.
    16651665    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
    16691668    }
    16701669    set _currentColormap $name
     1670    SendCmd "heightmap colormap $_currentColormap"
    16711671}
    16721672
     
    16751675# BuildColormap --
    16761676#
    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#
     1679itcl::body Rappture::VtkHeightmapViewer::BuildColormap { name } {
     1680    set cmap [ColorsToColormap $name]
    16801681    if { [llength $cmap] == 0 } {
    16811682        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    16821683    }
    1683     if { ![info exists _settings(opacity)] } {
    1684         set _settings(opacity) $style(-opacity)
    1685     }
    1686     set max $_settings(opacity)
    1687 
    16881684    set wmap "0.0 1.0 1.0 1.0"
    16891685    SendCmd "colormap add $name { $cmap } { $wmap }"
     
    20102006        entry $inner.${tag} -font "Arial 9"  -bg white \
    20112007            -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> \
    20132011            [itcl::code $this camera set ${tag}]
    20142012        blt::table $inner \
     
    21372135}
    21382136
     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#
    21392145itcl::body Rappture::VtkHeightmapViewer::SetObjectStyle { dataobj comp } {
    21402146    # Parse style string.
     
    21422148    array set style {
    21432149        -color BCGYR
    2144         -edges 0
    2145         -edgecolor black
    2146         -linewidth 1.0
     2150        -opacity 100
    21472151        -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)
    21492174    }
    21502175    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
    21582182    }
    21592183    SendCmd "dataset outline $_settings(outline) $tag"
    21602184    SendCmd "dataset color [Color2RGB $itk_option(-plotforeground)] $tag"
    2161     set _settings(numIsolines) $style(-levels)
    21622185    set scale [GetHeightmapScale]
    2163     SendCmd "heightmap add numcontours $_settings(numIsolines) $scale $tag"
     2186    SendCmd "heightmap add numcontours $_currentNumIsolines $scale $tag"
    21642187    set _comp2scale($tag) $_settings(heightmapScale)
    21652188    SendCmd "heightmap edges $_settings(edges) $tag"
    21662189    SendCmd "heightmap wireframe $_settings(wireframe) $tag"
    2167     SendCmd "heightmap colormap $_currentColormap $tag"
     2190    SetCurrentColormap $style(-color)
    21682191    set color [$itk_component(isolinecolor) value]
    21692192    SendCmd "heightmap isolinecolor [Color2RGB $color] $tag"
     
    22662289    # Draw the isolines on the legend.
    22672290    if { $color != "none"  && [info exists _limits($_curFldName)] &&
    2268          $_settings(isolinesVisible) && $_settings(numIsolines) > 0 } {
     2291         $_settings(isolinesVisible) && $_currentNumIsolines > 0 } {
    22692292        set pixels [blt::vector create \#auto]
    22702293        set values [blt::vector create \#auto]
    22712294        set range [image height $_image(legend)]
    22722295        # 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
    22742297
    22752298        set offset [expr 2 + $lineht]
     
    22812304        # Order of values is min to max.
    22822305        foreach { vmin vmax } $_limits($_curFldName) break
    2283         $values seq $vmin $vmax $_settings(numIsolines)
     2306        $values seq $vmin $vmax $_currentNumIsolines
    22842307        set tags "isoline legend"
    22852308        array unset _isolines
     
    22912314            }
    22922315            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]
    22952316        }
    22962317        blt::vector destroy $pixels $values
     
    24602481}
    24612482
    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.