Changeset 3514


Ignore:
Timestamp:
Mar 16, 2013 2:15:14 PM (11 years ago)
Author:
gah
Message:

rearrange controls in isosurfaceviewer, add number of isosurfaces control, fix for cutplane visibility?, add binding Control-F1 for text window in debug console

Location:
trunk/gui/scripts
Files:
3 edited

Legend:

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

    r3454 r3514  
    701701    bind $f.send.e <Return> [itcl::code $this SendDebugCommand]
    702702    bind $f.send.e <KP_Enter> [itcl::code $this SendDebugCommand]
    703    
    704703    scrollbar $f.sb -orient vertical -command "$f.comm yview"
    705704    pack $f.sb -side right -fill y
     
    710709    }
    711710    pack $f.comm -expand yes -fill both
     711    bind $f.comm <Control-F1> [itcl::code $this ToggleConsole]
    712712
    713713    $itk_component(trace) tag configure error -foreground red \
  • trunk/gui/scripts/vtkheightmapviewer.tcl

    r3498 r3514  
    913913        }           
    914914        PanCamera
     915        StopBufferingCommands
    915916        SendCmd "imgflush"
     917        StartBufferingCommands
    916918    }
    917919
     
    13571359                }
    13581360            }
    1359             #SendCmd "heightmap colormode scalar $_curFldName"
    1360             #SendCmd "dataset scalar $_curFldName"
    13611361            StopBufferingCommands
    13621362            EventuallyRequestLegend
  • trunk/gui/scripts/vtkisosurfaceviewer.tcl

    r3486 r3514  
    8383    private method BuildAxisTab {}
    8484    private method BuildCameraTab {}
    85     private method BuildColormap { name colors }
     85    private method BuildColormap { name }
    8686    private method BuildCutplaneTab {}
    8787    private method BuildDownloadPopup { widget command }
     
    104104    private method SetObjectStyle { dataobj comp }
    105105    private method Slice {option args}
    106     private method ResetColormap { color }
    107     private method SetCurrentColormap { stylelist }
     106    private method SetCurrentColormap { color }
    108107
    109108    private variable _arcball ""
     
    119118    # heightmaps displayed.
    120119    private variable _currentColormap "" ;   
    121 
     120    private variable _currentNumContours "" ;   
     121    private variable _currentOpacity "" ;   
    122122
    123123    private variable _dataset2style    ;# maps dataobj-component to transfunc
     
    128128    private variable _settings
    129129    private variable _style;            # Array of current component styles.
     130    private variable _changed
    130131    private variable _initialStyle;     # Array of initial component styles.
    131132    private variable _reset 1;          # indicates if camera needs to be reset
     
    151152    private variable _curFldName ""
    152153    private variable _curFldLabel ""
    153     private variable _numContours 10
    154154}
    155155
     
    221221    array set _settings [subst {
    222222        background              black
    223         colormapPalette         BCGYR
     223        colormap                BCGYR
    224224        colormapVisible         1
    225225        field                   "Default"
     
    244244        isosurfaceLighting      1
    245245        isosurfaceOpacity       60
     246        saveIsosurfaceOpacity   60
    246247        isosurfaceOutline       0
    247248        isosurfaceVisible       1
    248249        isosurfaceWireframe     0
    249250        legendVisible           1
     251        numContours             10
    250252    }]
     253    array set _changed {
     254        isosurfaceOpacity       0
     255        colormap                0
     256        numContours             0
     257    }
    251258
    252259    itk_component add view {
     
    959966            SendCmd "axis lformat $axis %g"
    960967        }
     968        StopBufferingCommands
    961969        SendCmd "imgflush"
     970        StartBufferingCommands
    962971    }
    963972    set _first ""
     
    10021011        }
    10031012    }
     1013    # FIXME: Why do I have to reassert the cutplane visibility?
     1014    InitSettings cutplaneVisible
     1015
    10041016    if { $_first != "" } {
    10051017        $itk_component(field) choices delete 0 end
     
    10311043        $itk_component(field) value $_curFldLabel
    10321044    }
    1033     InitSettings isosurfaceVisible colormapPalette isosurfaceVisible
    10341045
    10351046    if { $_reset } {
     
    10411052            isosurfaceWireframe isosurfaceOutline \
    10421053            cutplaneXPosition cutplaneYPosition cutplaneZPosition \
    1043             cutplaneXVisible cutplaneYVisible cutplaneZVisible \
    1044             cutplaneVisible
     1054            cutplaneXVisible cutplaneYVisible cutplaneZVisible
     1055
    10451056        Zoom reset
    10461057        foreach axis { x y z } {
     
    10631074            SendCmd [list axis name $axis $label]
    10641075        }
     1076        if { [array size _fields] < 2 } {
     1077            blt::table forget $itk_component(field) $itk_component(field_l)
     1078        }
    10651079        set _reset 0
    10661080    }
     
    13061320    }
    13071321    switch -- $what {
    1308         "isosurfaceOpacity" {
    1309             set val $_settings(isosurfaceOpacity)
    1310             set sval [expr { 0.01 * double($val) }]
    1311             SendCmd "contour3d opacity $sval"
    1312         }
    1313         "isosurfaceWireframe" {
    1314             set bool $_settings(isosurfaceWireframe)
    1315             SendCmd "contour3d wireframe $bool"
    1316         }
    1317         "isosurfaceVisible" {
    1318             set bool $_settings(isosurfaceVisible)
    1319             SendCmd "contour3d visible $bool"
    1320             if { $bool } {
    1321                 Rappture::Tooltip::for $itk_component(contour) \
    1322                     "Hide the isosurface"
    1323             } else {
    1324                 Rappture::Tooltip::for $itk_component(contour) \
    1325                     "Show the isosurface"
    1326             }
    1327         }
    1328         "isosurfaceLighting" {
    1329             set bool $_settings(isosurfaceLighting)
    1330             SendCmd "contour3d lighting $bool"
    1331         }
    1332         "isosurfaceEdges" {
    1333             set bool $_settings(isosurfaceEdges)
    1334             SendCmd "contour3d edges $bool"
    1335         }
    1336         "isosurfaceOutline" {
    1337             set bool $_settings(isosurfaceOutline)
    1338             SendCmd "dataset outline $bool"
    1339         }
    13401322        "background" {
    13411323            set bgcolor [$itk_component(background) value]
     
    13711353        "cutplaneEdges" {
    13721354            set bool $_settings($what)
    1373             foreach dataset [CurrentDatasets -visible] {
    1374                 SendCmd "cutplane edges $bool $dataset"
    1375             }
     1355            SendCmd "cutplane edges $bool"
    13761356        }
    13771357        "cutplaneVisible" {
    13781358            set bool $_settings($what)
    1379             foreach dataset [CurrentDatasets -visible] {
    1380                 SendCmd "cutplane visible $bool $dataset"
    1381             }
     1359            puts stderr "cutplane visible $bool"
     1360            SendCmd "cutplane visible $bool"
    13821361        }
    13831362        "cutplaneWireframe" {
    13841363            set bool $_settings($what)
    1385             foreach dataset [CurrentDatasets -visible] {
    1386                 SendCmd "cutplane wireframe $bool $dataset"
    1387             }
     1364            SendCmd "cutplane wireframe $bool"
    13881365        }
    13891366        "cutplaneLighting" {
    13901367            set bool $_settings($what)
    1391             foreach dataset [CurrentDatasets -visible] {
    1392                 SendCmd "cutplane lighting $bool $dataset"
    1393             }
     1368            SendCmd "cutplane lighting $bool"
    13941369        }
    13951370        "cutplaneOpacity" {
    13961371            set val $_settings($what)
    13971372            set sval [expr { 0.01 * double($val) }]
    1398             foreach dataset [CurrentDatasets -visible] {
    1399                 SendCmd "cutplane opacity $sval $dataset"
    1400             }
     1373            SendCmd "cutplane opacity $sval"
    14011374        }
    14021375        "cutplaneXVisible" - "cutplaneYVisible" - "cutplaneZVisible" {
     
    14151388            set axis [string tolower [string range $what 8 8]]
    14161389            set pos [expr $_settings($what) * 0.01]
    1417             foreach dataset [CurrentDatasets -visible] {
    1418                 SendCmd "cutplane slice ${axis} ${pos} $dataset"
    1419             }
     1390            SendCmd "cutplane slice ${axis} ${pos}"
    14201391            set _cutplanePending 0
    14211392        }
    1422         "isosurfaceVisible" {
    1423             set bool $_settings($what)
    1424             foreach dataset [CurrentDatasets -visible] {
    1425                 SendCmd "contour3d visible $bool $dataset"
    1426             }
    1427             set _settings(isosurfaceVisible) $bool
    1428             if { $bool } {
    1429                 Rappture::Tooltip::for $itk_component(contour) \
    1430                     "Hide the isosurface"
    1431             } else {
    1432                 Rappture::Tooltip::for $itk_component(contour) \
    1433                     "Show the isosurface"
    1434             }
    1435             DrawLegend
    1436         }
    1437         "colormapPalette" {
    1438             set color [$itk_component(palette) value]
    1439             set _settings(colormapPalette) $color
     1393        "colormap" {
     1394            set _changed(colormap) 1
     1395            StartBufferingCommands
     1396            set color [$itk_component(colormap) value]
     1397            set _settings(colormap) $color
    14401398            if { $color == "none" } {
    14411399                if { $_settings(colormapVisible) } {
     
    14481406                    set _settings(colormapVisible) 1
    14491407                }
    1450                 ResetColormap $color
    1451                 SendCmd "contour3d colormap $_currentColormap"
    1452                 SendCmd "cutplane colormap $_currentColormap"
     1408                SetCurrentColormap $color
    14531409            }
     1410            StopBufferingCommands
    14541411            EventuallyRequestLegend
     1412        }
     1413        "numContours" {
     1414            set _changed(numContours) 1
     1415            set _settings(numContours) [$itk_component(numcontours) value]
     1416            set _currentNumContours $_settings(numContours)
     1417            SendCmd "contour3d numcontours [expr $_settings(numContours) + 1]"
     1418            DrawLegend
     1419        }
     1420        "isosurfaceWireframe" {
     1421            set bool $_settings(isosurfaceWireframe)
     1422            SendCmd "contour3d wireframe $bool"
     1423        }
     1424        "isosurfaceVisible" {
     1425            set bool $_settings(isosurfaceVisible)
     1426            SendCmd "contour3d visible $bool"
     1427            if { $bool } {
     1428                Rappture::Tooltip::for $itk_component(contour) \
     1429                    "Hide the isosurface"
     1430            } else {
     1431                Rappture::Tooltip::for $itk_component(contour) \
     1432                    "Show the isosurface"
     1433            }
     1434            DrawLegend
     1435        }
     1436        "isosurfaceLighting" {
     1437            set bool $_settings(isosurfaceLighting)
     1438            SendCmd "contour3d lighting $bool"
     1439        }
     1440        "isosurfaceEdges" {
     1441            set bool $_settings(isosurfaceEdges)
     1442            SendCmd "contour3d edges $bool"
     1443        }
     1444        "isosurfaceOutline" {
     1445            set bool $_settings(isosurfaceOutline)
     1446            SendCmd "dataset outline $bool"
    14551447        }
    14561448        "isolineColor" {
     
    14621454            set val $_settings(isosurfaceOpacity)
    14631455            set sval [expr { 0.01 * double($val) }]
    1464             foreach dataset [CurrentDatasets -visible $_first] {
    1465                 SendCmd "contour3d opacity $sval $dataset"
    1466             }
    1467         }
    1468         "isosurfaceLighting" {
    1469             set bool $_settings(isosurfaceLighting)
    1470             foreach dataset [CurrentDatasets -visible $_first] {
    1471                 SendCmd "contour3d lighting $bool $dataset"
    1472             }
     1456            SendCmd "contour3d opacity $sval"
    14731457        }
    14741458        "field" {
     
    15581542}
    15591543
    1560 #
    1561 # BuildColormap --
    1562 #
    1563 itcl::body Rappture::VtkIsosurfaceViewer::BuildColormap { name stylelist } {
    1564     array set style $stylelist
    1565     set cmap [ColorsToColormap $style(-color)]
    1566     if { [llength $cmap] == 0 } {
    1567         set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    1568     }
    1569     if { ![info exists _settings(contour-opacity)] } {
    1570         set _settings(contour-opacity) $style(-opacity)
    1571     }
    1572     set max $_settings(contour-opacity)
    1573 
    1574     set wmap "0.0 1.0 1.0 1.0"
    1575     SendCmd "colormap add $name { $cmap } { $wmap }"
    1576 }
    1577 
    15781544# ----------------------------------------------------------------------
    15791545# CONFIGURATION OPTION: -plotbackground
     
    16981664        -command [itcl::code $this AdjustSetting contour-scale]
    16991665
    1700     label $inner.field_l -text "Field" -font "Arial 9"
     1666    itk_component add field_l {
     1667        label $inner.field_l -text "Field" -font "Arial 9"
     1668    } {
     1669        ignore -font
     1670    }
    17011671    itk_component add field {
    17021672        Rappture::Combobox $inner.field -width 10 -editable no
     
    17051675        [itcl::code $this AdjustSetting field]
    17061676
    1707     label $inner.palette_l -text "Palette" -font "Arial 9"
    1708     itk_component add palette {
    1709         Rappture::Combobox $inner.palette -width 10 -editable no
    1710     }
    1711     $inner.palette choices insert end \
     1677    label $inner.colormap_l -text "Colormap" -font "Arial 9"
     1678    itk_component add colormap {
     1679        Rappture::Combobox $inner.colormap -width 10 -editable no
     1680    }
     1681    $inner.colormap choices insert end \
    17121682        "BCGYR"              "BCGYR"            \
    17131683        "BGYOR"              "BGYOR"            \
     
    17271697        "orange-to-blue"     "orange-to-blue"   
    17281698
    1729     $itk_component(palette) value "BCGYR"
    1730     bind $inner.palette <<Value>> \
    1731         [itcl::code $this AdjustSetting colormapPalette]
     1699    $itk_component(colormap) value "BCGYR"
     1700    bind $inner.colormap <<Value>> \
     1701        [itcl::code $this AdjustSetting colormap]
     1702
     1703    label $inner.numcontours_l -text "Number of Isosurfaces" -font "Arial 9"
     1704    itk_component add numcontours {
     1705        Rappture::Spinint $inner.numcontours \
     1706            -min 2 -max 50 -font "arial 9"
     1707    }
     1708    $itk_component(numcontours) value $_settings(numContours)
     1709    bind $itk_component(numcontours) <<Value>> \
     1710        [itcl::code $this AdjustSetting numContours]
    17321711
    17331712    blt::table $inner \
    1734         0,0 $inner.palette_l -anchor w -pady 2  \
    1735         0,1 $inner.palette   -anchor w -pady 2  -fill x \
    1736         1,0 $inner.linecolor_l  -anchor w -pady 2  \
    1737         1,1 $inner.linecolor    -anchor w -pady 2 -fill x  \
    1738         2,0 $inner.background_l -anchor w -pady 2 \
    1739         2,1 $inner.background -anchor w -pady 2  -fill x \
    1740         3,0 $inner.contour   -anchor w -pady 2 -cspan 2 \
    1741         4,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \
    1742         5,0 $inner.lighting  -anchor w -pady 2 -cspan 2 \
    1743         6,0 $inner.edges     -anchor w -pady 2 -cspan 2 \
    1744         7,0 $inner.outline   -anchor w -pady 2 -cspan 2 \
    1745         8,0 $inner.legend    -anchor w -pady 2 \
    1746         9,0 $inner.opacity_l -anchor w -pady 2 \
    1747         9,1 $inner.opacity   -fill x   -pady 2 -fill x \
    1748         10,0 $inner.field_l   -anchor w -pady 2  \
    1749         10,1 $inner.field     -anchor w -pady 2  -fill x \
     1713        0,0 $inner.field_l   -anchor w -pady 2  \
     1714        0,1 $inner.field     -anchor w -pady 2  -fill x \
     1715        1,0 $inner.colormap_l -anchor w -pady 2  \
     1716        1,1 $inner.colormap   -anchor w -pady 2  -fill x \
     1717        2,0 $inner.linecolor_l  -anchor w -pady 2  \
     1718        2,1 $inner.linecolor    -anchor w -pady 2 -fill x  \
     1719        3,0 $inner.background_l -anchor w -pady 2 \
     1720        3,1 $inner.background -anchor w -pady 2  -fill x \
     1721        4,0 $inner.numcontours_l -anchor w -pady 2 \
     1722        4,1 $inner.numcontours -anchor w -pady 2 \
     1723        5,0 $inner.wireframe -anchor w -pady 2 -cspan 2 \
     1724        6,0 $inner.lighting  -anchor w -pady 2 -cspan 2 \
     1725        7,0 $inner.edges     -anchor w -pady 2 -cspan 2 \
     1726        8,0 $inner.outline   -anchor w -pady 2 -cspan 2 \
     1727        9,0 $inner.legend    -anchor w -pady 2 \
     1728        10,0 $inner.opacity_l -anchor w -pady 2 \
     1729        10,1 $inner.opacity   -fill x   -pady 2 -fill x \
    17501730
    17511731    blt::table configure $inner r* c* -resize none
     
    21332113            SetCurrentColormap $stylelist
    21342114        }
    2135         $itk_component(palette) value $style(-color)
     2115        $itk_component(colormap) value $style(-color)
    21362116    }
    21372117    SendCmd "cutplane add $tag"
     
    21412121    SendCmd "cutplane linewidth 1 $tag"
    21422122
    2143     #SendCmd "cutplane linecolor 1 1 1 $tag"
    2144     #SendCmd "cutplane visible $tag"
    21452123    foreach axis { x y z } {
    21462124        SendCmd "cutplane slice $axis 0.5 $tag"
    21472125        SendCmd "cutplane axis $axis 0 $tag"
    21482126    }
    2149     set _numContours $style(-levels)
    2150     SendCmd "contour3d add numcontours $_numContours $tag"
     2127    # This is too complicated.  We want to set the colormap, number of
     2128    # isolines and opacity for the dataset.  They can be the default values,
     2129    # the style hints loaded with the dataset, or set by user controls.  As
     2130    # datasets get loaded, they first use the defaults that are overidden
     2131    # by the style hints.  If the user changes the global controls, then that
     2132    # overrides everything else.  I don't know what it means when global
     2133    # controls are specified as style hints by each dataset.  It complicates
     2134    # the code to handle aberrant cases.
     2135
     2136    if { $_changed(isosurfaceOpacity) } {
     2137        set style(-opacity) $_settings(isosurfaceOpacity)
     2138    }
     2139    if { $_changed(numContours) } {
     2140        set style(-levels) $_settings(numContours)
     2141    }
     2142    if { $_changed(colormap) } {
     2143        set style(-color) $_settings(colormap)
     2144    }
     2145    if { $_currentColormap == "" } {
     2146        $itk_component(colormap) value $style(-color)
     2147    }
     2148    set _currentOpacity $style(-opacity)
     2149    if { $_currentNumContours != $style(-levels) } {
     2150        set _currentNumContours $style(-levels)
     2151        set _settings(numContours) $_currentNumContours
     2152        $itk_component(numcontours) value $_currentNumContours
     2153        DrawLegend
     2154    }
     2155    SendCmd "contour3d add numcontours [expr $_currentNumContours+1] $tag"
    21512156    SendCmd "contour3d edges $style(-edges) $tag"
    21522157    SendCmd "dataset outline $style(-outline) $tag"
     
    21592164    SendCmd "contour3d linecolor [Color2RGB $style(-edgecolor)] $tag"
    21602165    SendCmd "contour3d linewidth $style(-linewidth) $tag"
    2161     SendCmd "contour3d opacity $style(-opacity) $tag"
     2166    SendCmd "contour3d opacity $_currentOpacity $tag"
    21622167    set _settings(isosurfaceOpacity) $style(-opacity)
     2168    SetCurrentColormap $style(-color)
    21632169    SendCmd "contour3d wireframe $style(-wireframe) $tag"
    21642170    set _settings(isosurfaceWireframe) $style(-wireframe)
     
    23872393    array unset _isolines
    23882394    if { $color != "none"  && [info exists _limits($_curFldName)] &&
    2389          $_numContours > 0 } {
     2395         $_settings(numContours) > 0 } {
    23902396        set pixels [blt::vector create \#auto]
    23912397        set values [blt::vector create \#auto]
    23922398        set range [image height $_image(legend)]
    23932399        # Order of pixels is max to min (max is at top of legend).
    2394         $pixels seq $ih 0 $_numContours
     2400        $pixels seq $ih 0 $_settings(numContours)
    23952401        set offset [expr 2 + $lineht]
    23962402        # If there's a legend title, increase the offset by the line height.
     
    24012407        $pixels expr {round($pixels + $offset)}
    24022408        foreach { vmin vmax } $_limits($_curFldName) break
    2403         $values seq $vmin $vmax $_numContours
     2409        $values seq $vmin $vmax $_settings(numContours)
    24042410        set tags "isoline legend"
    24052411        foreach pos [$pixels range 0 end] value [$values range end 0] {
     
    24802486# SetCurrentColormap --
    24812487#
    2482 itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentColormap { stylelist } {
    2483     array set style {
    2484         -color BCGYR
    2485         -levels 10
    2486         -opacity 1.0
    2487     }
    2488     array set style $stylelist
    2489 
    2490     set name "$style(-color):$style(-levels):$style(-opacity)"
     2488itcl::body Rappture::VtkIsosurfaceViewer::SetCurrentColormap { name } {
     2489    # Keep track of the colormaps that we build.
    24912490    if { ![info exists _colormaps($name)] } {
    2492         set stylelist [array get style]
    2493         BuildColormap $name $stylelist
    2494         set _colormaps($name) $stylelist
     2491        BuildColormap $name
     2492        set _colormaps($name) 1
    24952493    }
    24962494    set _currentColormap $name
     2495    SendCmd "contour3d colormap $_currentColormap"
    24972496}
    24982497
     
    25002499# BuildColormap --
    25012500#
    2502 itcl::body Rappture::VtkIsosurfaceViewer::BuildColormap { name stylelist } {
    2503     array set style $stylelist
    2504     set cmap [ColorsToColormap $style(-color)]
     2501#       Build the designated colormap on the server.
     2502#
     2503itcl::body Rappture::VtkIsosurfaceViewer::BuildColormap { name } {
     2504    set cmap [ColorsToColormap $name]
    25052505    if { [llength $cmap] == 0 } {
    25062506        set cmap "0.0 0.0 0.0 0.0 1.0 1.0 1.0 1.0"
    25072507    }
    2508     if { ![info exists _settings(isosurfaceOpacity)] } {
    2509         set _settings(isosurfaceOpacity) $style(-opacity)
    2510     }
    2511     set max $_settings(isosurfaceOpacity)
    2512 
    25132508    set wmap "0.0 1.0 1.0 1.0"
    25142509    SendCmd "colormap add $name { $cmap } { $wmap }"
    25152510}
    25162511
    2517 itcl::body Rappture::VtkIsosurfaceViewer::ResetColormap { color } {
    2518     array set style {
    2519         -color BCGYR
    2520         -levels 10
    2521         -opacity 1.0
    2522     }
    2523     if { [info exists _colormap($_currentColormap)] } {
    2524         array set style $_colormap($_currentColormap)
    2525     }
    2526     set style(-color) $color
    2527     SetCurrentColormap [array get style]
    2528 }
     2512
     2513
Note: See TracChangeset for help on using the changeset viewer.