Changeset 3236


Ignore:
Timestamp:
Jan 4, 2013, 12:07:59 PM (12 years ago)
Author:
gah
Message:

fix heightscale when switching between heightmap/contour modes, also removed cutplane controls.

Location:
branches/Rappture 1.2/gui/scripts
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/Rappture 1.2/gui/scripts/mesh.tcl

    r3226 r3236  
    7474    private variable _zv        ""
    7575    private variable _bltmesh   ""
     76    private variable _xValues   "";     # For the blt contour only
     77    private variable _yValues   "";     # For the blt contour only
    7678   
    7779    private method ReadCloud { xmlobj path }
  • branches/Rappture 1.2/gui/scripts/vtkheightmapviewer.tcl

    r3227 r3236  
    8888    private method BuildColormap { name colors }
    8989    private method BuildContourTab {}
    90     private method BuildCutplaneTab {}
    9190    private method BuildDownloadPopup { widget command }
    9291    private method BuildViewTab {}
     
    10099    private method EventuallyResize { w h }
    101100    private method EventuallyRotate { q }
    102     private method EventuallySetCutplane { axis args }
    103101    private method GetImage { args }
    104102    private method GetVtkData { args }
     
    111109    private method SetLegendTip { x y }
    112110    private method SetObjectStyle { dataobj comp }
    113     private method Slice {option args}
    114111    private method GetHeightmapScale {}
    115112    private method EnterIsoline { x y value }
     
    157154    private variable _contourPending 0
    158155    private variable _rotatePending 0
    159     private variable _cutplanePending 0
    160156    private variable _legendPending 0
    161157    private variable _outline
     
    200196    $_dispatcher register !legend
    201197    $_dispatcher dispatch $this !legend "[itcl::code $this RequestLegend]; list"
    202 
    203     # X-Cutplane event
    204     $_dispatcher register !xcutplane
    205     $_dispatcher dispatch $this !xcutplane \
    206         "[itcl::code $this AdjustSetting cutplane-xposition]; list"
    207 
    208     # Y-Cutplane event
    209     $_dispatcher register !ycutplane
    210     $_dispatcher dispatch $this !ycutplane \
    211         "[itcl::code $this AdjustSetting cutplane-yposition]; list"
    212 
    213     # Z-Cutplane event
    214     $_dispatcher register !zcutplane
    215     $_dispatcher dispatch $this !zcutplane \
    216         "[itcl::code $this AdjustSetting cutplane-zposition]; list"
    217198
    218199    #
     
    250231        axis-labels             1
    251232        axis-visible            1
    252         axis-xcutplane          0
    253233        axis-xgrid              0
    254234        axis-xposition          0
    255         axis-ycutplane          0
    256235        axis-ygrid              0
    257236        axis-yposition          0
    258         axis-zcutplane          0
    259237        axis-zgrid              0
    260238        axis-zposition          0
     
    266244        contour-visible         1
    267245        contour-wireframe       0
    268         cutplane-edges          0
    269         cutplane-opacity        100
    270         cutplane-visible        1
    271         cutplane-wireframe      0
    272         cutplane-xposition      50
    273         cutplane-xvisible       0
    274         cutplane-yposition      50
    275         cutplane-yvisible       0
    276         cutplane-zposition      50
    277         cutplane-zvisible       0
    278246        heightmap-mode          0
    279         heightmap-scale         0
     247        heightmap-scale         50
    280248        legend-visible          1
    281249    }]
     
    353321    Rappture::Tooltip::for $itk_component(zoomout) "Zoom out"
    354322
    355     itk_component add surface {
    356         Rappture::PushButton $f.surface \
    357             -onimage [Rappture::icon volume-on] \
    358             -offimage [Rappture::icon volume-off] \
    359             -variable [itcl::scope _settings(contour-visible)] \
    360             -command [itcl::code $this AdjustSetting contour-visible]
    361     }
    362     $itk_component(surface) select
    363     Rappture::Tooltip::for $itk_component(surface) \
    364         "Don't display the surface"
    365     pack $itk_component(surface) -padx 2 -pady 2
    366 
    367323    itk_component add mode {
    368324        Rappture::PushButton $f.mode \
     
    379335        BuildViewTab
    380336        BuildContourTab
    381         BuildCutplaneTab
    382337        BuildAxisTab
    383338        BuildCameraTab
     
    512467}
    513468
    514 itcl::body Rappture::VtkHeightmapViewer::EventuallySetCutplane { axis args } {
    515     if { !$_cutplanePending } {
    516         set _cutplanePending 1
    517         $_dispatcher event -after 100 !${axis}cutplane
    518     }
    519 }
    520 
    521469# ----------------------------------------------------------------------
    522470# USAGE: add <dataobj> ?<settings>?
     
    811759    $_dispatcher cancel !contour
    812760    $_dispatcher cancel !rotate
    813     $_dispatcher cancel !xcutplane
    814     $_dispatcher cancel !ycutplane
    815     $_dispatcher cancel !zcutplane
    816761    $_dispatcher cancel !legend
    817762    # disconnected -- no more data sitting on server
     
    829774itcl::body Rappture::VtkHeightmapViewer::sendto { bytes } {
    830775    SendBytes "$bytes\n"
    831     StartWaiting
    832776}
    833777
     
    844788    } else {
    845789        SendBytes "$string\n"
    846         StartWaiting
    847790    }
    848791}
     
    878821    array set info $args
    879822    set bytes [ReceiveBytes $info(-bytes)]
    880     StopWaiting
    881823    if { $info(-type) == "image" } {
    882824        if 0 {
     
    977919        #
    978920        SendCmd "axis color [Color2RGB $itk_option(-plotforeground)]"
    979         #SendCmd "dataset maprange 0"
     921        SendCmd "dataset maprange all"
    980922        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    981923        $_arcball quaternion $q
    982924        if {$_settings(heightmap-mode) } {
     925            SendCmd "camera reset all"
    983926            if { $_view(ortho)} {
    984927                SendCmd "camera mode ortho"
     
    10961039
    10971040    if { $_reset } {
     1041        SendCmd "axis tickpos outside"
     1042        foreach axis { x y z } {
     1043            SendCmd "axis lformat $axis %g"
     1044        }
    10981045        foreach axis { x y } {
    10991046            set label [$_first hints ${axis}label]
    11001047            if { $label != "" } {
    1101                 SendCmd "axis name $axis $label"
     1048                # May be a space in the axis label.
     1049                SendCmd [list axis name $axis $label]
    11021050            }
    11031051            set units [$_first hints ${axis}units]
    11041052            if { $units != "" } {
    1105                 SendCmd "axis units $axis $units"
     1053                # May be a space in the axis units.
     1054                SendCmd [list axis units $axis $units]
    11061055            }
    11071056        }
     1057        #
     1058        # Reset the camera and other view parameters
     1059        #
     1060        SendCmd "axis color [Color2RGB $itk_option(-plotforeground)]"
     1061        SendCmd "dataset maprange all"
     1062        set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
     1063        $_arcball quaternion $q
     1064        if {$_settings(heightmap-mode) } {
     1065            SendCmd "camera reset all"
     1066            if { $_view(ortho)} {
     1067                SendCmd "camera mode ortho"
     1068            } else {
     1069                SendCmd "camera mode persp"
     1070            }
     1071        }           
     1072        DoRotate
     1073        PanCamera
    11081074        InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
    11091075            axis-visible axis-labels
    1110        
    11111076        InitSettings contour-opacity \
    11121077            heightmap-scale contour-lighting \
     
    14141379            set _settings($what) $mode
    14151380            SendCmd "axis flymode $mode"
    1416         }
    1417         "cutplane-edges" {
    1418             set bool $_settings($what)
    1419             foreach dataset [CurrentDatasets -visible] {
    1420                 #SendCmd "cutplane edges $bool $dataset"
    1421             }
    1422         }
    1423         "cutplane-visible" {
    1424             set bool $_settings($what)
    1425             foreach dataset [CurrentDatasets -visible] {
    1426                 #SendCmd "cutplane visible $bool $dataset"
    1427             }
    1428         }
    1429         "cutplane-wireframe" {
    1430             set bool $_settings($what)
    1431             foreach dataset [CurrentDatasets -visible] {
    1432                 #SendCmd "cutplane wireframe $bool $dataset"
    1433             }
    1434         }
    1435         "cutplane-lighting" {
    1436             set bool $_settings($what)
    1437             foreach dataset [CurrentDatasets -visible] {
    1438                 #SendCmd "cutplane lighting $bool $dataset"
    1439             }
    1440         }
    1441         "cutplane-opacity" {
    1442             set val $_settings($what)
    1443             set sval [expr { 0.01 * double($val) }]
    1444             foreach dataset [CurrentDatasets -visible] {
    1445                 #SendCmd "cutplane opacity $sval $dataset"
    1446             }
    1447         }
    1448         "cutplane-xvisible" - "cutplane-yvisible" - "cutplane-zvisible" {
    1449             set axis [string range $what 9 9]
    1450             set bool $_settings($what)
    1451             if { $bool } {
    1452                 $itk_component(${axis}CutScale) configure -state normal \
    1453                     -troughcolor white
    1454             } else {
    1455                 $itk_component(${axis}CutScale) configure -state disabled \
    1456                     -troughcolor grey82
    1457             }
    1458             #SendCmd "cutplane axis $axis $bool"
    1459         }
    1460         "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" {
    1461             set axis [string range $what 9 9]
    1462             set pos [expr $_settings($what) * 0.01]
    1463             SendCmd "heightmap slice ${axis} ${pos}"
    1464             set _cutplanePending 0
    14651381        }
    14661382        "contour-isolines" {
     
    15471463                return
    15481464            }
    1549             foreach dataset [CurrentDatasets -visible] {
    1550                 #SendCmd "cutplane colormode $_colorMode ${name} $dataset"
    1551             }
    15521465            set _legendPending 1
    15531466        }
    15541467        "heightmap-mode" {
    15551468            if {[isconnected]} {
    1556                 set c $itk_component(view)
    15571469                set bool $_settings(heightmap-mode)
     1470                # Fix heightmap scale: 0 for contours, 1 for heightmaps.
    15581471                if { $bool } {
    15591472                    set _settings(heightmap-scale) 50
     1473                } else {
     1474                    set _settings(heightmap-scale) 50
     1475                }
     1476                set scale [GetHeightmapScale]
     1477                foreach dataset [CurrentDatasets -all] {
     1478                    SendCmd "heightmap heightscale $scale $dataset"
     1479                    set _comp2scale($dataset) $scale
     1480                }
     1481                # Fix the mouse bindings for rotation/panning and the
     1482                # camera mode. Ideally we'd create a bindtag for these.
     1483                set c $itk_component(view)
     1484                if { $bool } {
    15601485                    # Bindings for rotation via mouse
    15611486                    bind $c <ButtonPress-1> \
     
    15801505                    SendCmd "camera mode image"
    15811506                }
    1582                 set scale [GetHeightmapScale]
    1583                 foreach dataset [CurrentDatasets -all] {
    1584                     SendCmd "heightmap heightscale $scale $dataset"
    1585                     set _comp2scale($dataset) $scale
    1586                 }
    15871507            }
    15881508        }       
     
    19811901        -font "Arial 9"
    19821902
    1983     checkbutton $inner.cutplane \
    1984         -text "Cutplanes" \
    1985         -variable [itcl::scope _settings(cutplane-visible)] \
    1986         -command [itcl::code $this AdjustSetting cutplane-visible] \
    1987         -font "Arial 9"
    1988 
    19891903    label $inner.background_l -text "Background" -font "Arial 9"
    19901904    itk_component add background {
     
    20091923        1,0 $inner.legend    -anchor w -pady 2 -cspan 2 \
    20101924        2,0 $inner.axes      -anchor w -pady 2 -cspan 2 \
    2011         3,0 $inner.cutplane  -anchor w -pady 2 -cspan 2 \
    20121925        5,0 $inner.contour   -anchor w -pady 2 -cspan 2 \
    20131926        6,0 $inner.heightmap -anchor w -pady 2 -cspan 2 \
     
    22402153    blt::table configure $inner r$row -resize expand
    22412154}
    2242 
    2243 itcl::body Rappture::VtkHeightmapViewer::BuildCutplaneTab {} {
    2244 
    2245     set fg [option get $itk_component(hull) font Font]
    2246    
    2247     set inner [$itk_component(main) insert end \
    2248         -title "Cutplane Settings" \
    2249         -icon [Rappture::icon cutbutton]]
    2250 
    2251     $inner configure -borderwidth 4
    2252 
    2253     checkbutton $inner.visible \
    2254         -text "Show Cutplanes" \
    2255         -variable [itcl::scope _settings(cutplane-visible)] \
    2256         -command [itcl::code $this AdjustSetting cutplane-visible] \
    2257         -font "Arial 9"
    2258 
    2259     checkbutton $inner.wireframe \
    2260         -text "Show Wireframe" \
    2261         -variable [itcl::scope _settings(cutplane-wireframe)] \
    2262         -command [itcl::code $this AdjustSetting cutplane-wireframe] \
    2263         -font "Arial 9"
    2264 
    2265     checkbutton $inner.lighting \
    2266         -text "Enable Lighting" \
    2267         -variable [itcl::scope _settings(cutplane-lighting)] \
    2268         -command [itcl::code $this AdjustSetting cutplane-lighting] \
    2269         -font "Arial 9"
    2270 
    2271     checkbutton $inner.edges \
    2272         -text "Show Edges" \
    2273         -variable [itcl::scope _settings(cutplane-edges)] \
    2274         -command [itcl::code $this AdjustSetting cutplane-edges] \
    2275         -font "Arial 9"
    2276 
    2277     label $inner.opacity_l -text "Opacity" -font "Arial 9"
    2278     ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
    2279         -variable [itcl::scope _settings(cutplane-opacity)] \
    2280         -width 10 \
    2281         -showvalue off \
    2282         -command [itcl::code $this AdjustSetting cutplane-opacity]
    2283     $inner.opacity set $_settings(cutplane-opacity)
    2284 
    2285     # X-value slicer...
    2286     itk_component add xCutButton {
    2287         Rappture::PushButton $inner.xbutton \
    2288             -onimage [Rappture::icon x-cutplane] \
    2289             -offimage [Rappture::icon x-cutplane] \
    2290             -command [itcl::code $this AdjustSetting cutplane-xvisible] \
    2291             -variable [itcl::scope _settings(cutplane-xvisible)]
    2292     }
    2293     Rappture::Tooltip::for $itk_component(xCutButton) \
    2294         "Toggle the X-axis cutplane on/off"
    2295 
    2296     itk_component add xCutScale {
    2297         ::scale $inner.xval -from 100 -to 1 \
    2298             -width 10 -orient vertical -showvalue yes \
    2299             -borderwidth 1 -highlightthickness 0 \
    2300             -command [itcl::code $this EventuallySetCutplane x] \
    2301             -variable [itcl::scope _settings(cutplane-xposition)]
    2302     } {
    2303         usual
    2304         ignore -borderwidth -highlightthickness
    2305     }
    2306     # Set the default cutplane value before disabling the scale.
    2307     $itk_component(xCutScale) set 50
    2308     $itk_component(xCutScale) configure -state disabled
    2309     Rappture::Tooltip::for $itk_component(xCutScale) \
    2310         "@[itcl::code $this Slice tooltip x]"
    2311 
    2312     # Y-value slicer...
    2313     itk_component add yCutButton {
    2314         Rappture::PushButton $inner.ybutton \
    2315             -onimage [Rappture::icon y-cutplane] \
    2316             -offimage [Rappture::icon y-cutplane] \
    2317             -command [itcl::code $this AdjustSetting cutplane-yvisible] \
    2318             -variable [itcl::scope _settings(cutplane-yvisible)]
    2319     }
    2320     Rappture::Tooltip::for $itk_component(yCutButton) \
    2321         "Toggle the Y-axis cutplane on/off"
    2322 
    2323     itk_component add yCutScale {
    2324         ::scale $inner.yval -from 100 -to 1 \
    2325             -width 10 -orient vertical -showvalue yes \
    2326             -borderwidth 1 -highlightthickness 0 \
    2327             -command [itcl::code $this EventuallySetCutplane y] \
    2328             -variable [itcl::scope _settings(cutplane-yposition)]
    2329     } {
    2330         usual
    2331         ignore -borderwidth -highlightthickness
    2332     }
    2333     Rappture::Tooltip::for $itk_component(yCutScale) \
    2334         "@[itcl::code $this Slice tooltip y]"
    2335     # Set the default cutplane value before disabling the scale.
    2336     $itk_component(yCutScale) set 50
    2337     $itk_component(yCutScale) configure -state disabled
    2338 
    2339     # Z-value slicer...
    2340     itk_component add zCutButton {
    2341         Rappture::PushButton $inner.zbutton \
    2342             -onimage [Rappture::icon z-cutplane] \
    2343             -offimage [Rappture::icon z-cutplane] \
    2344             -command [itcl::code $this AdjustSetting cutplane-zvisible] \
    2345             -variable [itcl::scope _settings(cutplane-zvisible)]
    2346     }
    2347     Rappture::Tooltip::for $itk_component(zCutButton) \
    2348         "Toggle the Z-axis cutplane on/off"
    2349 
    2350     itk_component add zCutScale {
    2351         ::scale $inner.zval -from 100 -to 1 \
    2352             -width 10 -orient vertical -showvalue yes \
    2353             -borderwidth 1 -highlightthickness 0 \
    2354             -command [itcl::code $this EventuallySetCutplane z] \
    2355             -variable [itcl::scope _settings(cutplane-zposition)]
    2356     } {
    2357         usual
    2358         ignore -borderwidth -highlightthickness
    2359     }
    2360     $itk_component(zCutScale) set 50
    2361     $itk_component(zCutScale) configure -state disabled
    2362     #$itk_component(zCutScale) configure -state disabled
    2363     Rappture::Tooltip::for $itk_component(zCutScale) \
    2364         "@[itcl::code $this Slice tooltip z]"
    2365 
    2366     blt::table $inner \
    2367         0,0 $inner.visible              -anchor w -pady 2 -cspan 4 \
    2368         1,0 $inner.lighting             -anchor w -pady 2 -cspan 4 \
    2369         2,0 $inner.wireframe            -anchor w -pady 2 -cspan 4 \
    2370         3,0 $inner.edges                -anchor w -pady 2 -cspan 4 \
    2371         4,0 $inner.opacity_l            -anchor w -pady 2 -cspan 3 \
    2372         5,0 $inner.opacity              -fill x   -pady 2 -cspan 3 \
    2373         6,0 $itk_component(xCutButton)  -anchor e -padx 2 -pady 2 \
    2374         7,0 $itk_component(xCutScale)   -fill y \
    2375         6,1 $itk_component(yCutButton)  -anchor e -padx 2 -pady 2 \
    2376         7,1 $itk_component(yCutScale)   -fill y \
    2377         6,2 $itk_component(zCutButton)  -anchor e -padx 2 -pady 2 \
    2378         7,2 $itk_component(zCutScale)   -fill y \
    2379 
    2380     blt::table configure $inner r* c* -resize none
    2381     blt::table configure $inner r7 c3 -resize expand
    2382 }
    2383 
    2384 
    23852155
    23862156#
     
    25152285    $itk_component(isolinecolor) value $settings(-isolinecolor)
    25162286    set _numContours $settings(-levels)
    2517     puts stderr "SetObjectStyle _numContours=$_numContours"
    25182287    set scale [GetHeightmapScale]
    25192288    SendCmd "heightmap add numcontours $settings(-levels) $scale $tag"
     
    27792548}
    27802549
    2781 
    2782 # ----------------------------------------------------------------------
    2783 # USAGE: Slice move x|y|z <newval>
    2784 #
    2785 # Called automatically when the user drags the slider to move the
    2786 # cut plane that slices 3D data.  Gets the current value from the
    2787 # slider and moves the cut plane to the appropriate point in the
    2788 # data set.
    2789 # ----------------------------------------------------------------------
    2790 itcl::body Rappture::VtkHeightmapViewer::Slice {option args} {
    2791     switch -- $option {
    2792         "move" {
    2793             set axis [lindex $args 0]
    2794             set oldval $_settings(axis-${axis}position)
    2795             set newval [lindex $args 1]
    2796             if {[llength $args] != 2} {
    2797                 error "wrong # args: should be \"Slice move x|y|z newval\""
    2798             }
    2799             set newpos [expr {0.01*$newval}]
    2800             SendCmd "heightmap slice $axis $newpos"
    2801         }
    2802         "tooltip" {
    2803             set axis [lindex $args 0]
    2804             set val [$itk_component(${axis}CutScale) get]
    2805             return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
    2806         }
    2807         default {
    2808             error "bad option \"$option\": should be axis, move, or tooltip"
    2809         }
    2810     }
    2811 }
    2812 
    2813 
    28142550# ----------------------------------------------------------------------
    28152551# USAGE: _dropdown post
  • branches/Rappture 1.2/gui/scripts/xyresult.tcl

    r3186 r3236  
    433433    catch {unset _limits}
    434434    foreach dataobj $args {
    435         # find the axes for this dataobj (e.g., {x y2})
     435        # Find the axes for this dataobj (e.g., {x y2})
    436436        foreach {map(x) map(y)} [GetAxes $dataobj] break
    437437        foreach axis {x y} {
    438             # get defaults for both linear and log scales
     438            # Get defaults for both linear and log scales
    439439            foreach type {lin log} {
    440440                # store results -- ex: _limits(x2log-min)
Note: See TracChangeset for help on using the changeset viewer.