Changeset 5181


Ignore:
Timestamp:
Apr 1, 2015 11:06:08 PM (9 years ago)
Author:
ldelgass
Message:

merge r5157:5158 from trunk (surfaceviewer)

Location:
branches/1.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3

  • branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl

    r5177 r5181  
    15561556                    SendCmd "contour3d visible $bool $tag"
    15571557                }
    1558             }
    1559             if { $bool } {
    15601558                Rappture::Tooltip::for $itk_component(contour) \
    15611559                    "Hide the isosurface"
  • branches/1.3/gui/scripts/vtksurfaceviewer.tcl

    r5177 r5181  
    9999    private method Rotate {option x y}
    100100    private method SetCurrentColormap { color }
     101    private method SetCurrentFieldName { dataobj }
    101102    private method SetLegendTip { x y }
    102103    private method SetObjectStyle { dataobj comp }
     
    217218        -legendvisible              1
    218219        -numcontours                10
     220        -outline                    0
    219221        -surfaceedges               0
    220222        -surfacelighting            1
    221223        -surfaceopacity             100
    222         -outline                    0
    223224        -surfacevisible             1
    224225        -surfacewireframe           0
     
    229230    array set _changed {
    230231        -colormap                0
     232        -isolinecolor            0
     233        -isolinesvisible         0
    231234        -numcontours             0
     235        -outline                 0
     236        -surfaceedges            0
     237        -surfacelighting         0
    232238        -surfaceopacity          0
     239        -surfacevisible          0
     240        -surfacewireframe        0
    233241    }
    234242
     
    918926    set _first ""
    919927    SendCmd "dataset visible 0"
     928    eval scale $_dlist
    920929    foreach dataobj [get -objects] {
    921930        if { [info exists _obj2ovride($dataobj-raise)] &&  $_first == "" } {
    922931            set _first $dataobj
     932            SetCurrentFieldName $dataobj
    923933        }
    924934        set _obj2datasets($dataobj) ""
     
    953963            lappend _obj2datasets($dataobj) $tag
    954964            if { [info exists _obj2ovride($dataobj-raise)] } {
    955                 # Setting dataset visible enables outline
    956                 # and contour2d
    957                 SendCmd "dataset visible 1 $tag"
    958             }
    959         }
    960     }
    961 
    962     if { $_first != "" } {
    963         $itk_component(field) choices delete 0 end
    964         $itk_component(fieldmenu) delete 0 end
    965         array unset _fields
    966         set _curFldName ""
    967         foreach cname [$_first components] {
    968             foreach fname [$_first fieldnames $cname] {
    969                 if { [info exists _fields($fname)] } {
    970                     continue
    971                 }
    972                 foreach { label units components } \
    973                     [$_first fieldinfo $fname] break
    974                 $itk_component(field) choices insert end "$fname" "$label"
    975                 $itk_component(fieldmenu) add radiobutton -label "$label" \
    976                     -value $label -variable [itcl::scope _curFldLabel] \
    977                     -selectcolor red \
    978                     -activebackground $itk_option(-plotbackground) \
    979                     -activeforeground $itk_option(-plotforeground) \
    980                     -font "Arial 8" \
    981                     -command [itcl::code $this Combo invoke]
    982                 set _fields($fname) [list $label $units $components]
    983                 if { $_curFldName == "" } {
    984                     set _curFldName $fname
    985                     set _curFldLabel $label
    986                 }
    987             }
    988         }
    989         $itk_component(field) value $_curFldLabel
    990     }
     965                SendCmd "polydata visible 1 $tag"
     966            }
     967        }
     968    }
     969
    991970    InitSettings -isolinesvisible -surfacevisible -outline
    992971    if { $_reset } {
     
    1016995        set _reset 0
    1017996    }
     997    # Redraw the legend even if we're using the same colormap. The position
     998    # of the isolines may have changed because the range of data changed.
     999    DrawLegend
    10181000
    10191001    # Actually write the commands to the server socket.  If it fails, we don't
     
    13571339        }
    13581340        "-isolinecolor" {
     1341            set _changed($what) 1
    13591342            set color [$itk_component(isolineColor) value]
    13601343            set _settings($what) $color
     
    13631346        }
    13641347        "-isolinesvisible" {
     1348            set _changed($what) 1
    13651349            set bool $_settings($what)
    1366             SendCmd "contour2d visible $bool"
     1350            SendCmd "contour2d visible 0"
     1351            if { $bool } {
     1352                foreach tag [CurrentDatasets -visible] {
     1353                    SendCmd "contour2d visible $bool $tag"
     1354                }
     1355            }
    13671356            DrawLegend
    13681357        }
     
    13881377        }
    13891378        "-outline" {
     1379            set _changed($what) 1
    13901380            set bool $_settings($what)
    1391             SendCmd "outline visible $bool"
     1381            SendCmd "outline visible 0"
     1382            if { $bool } {
     1383                foreach tag [CurrentDatasets -visible] {
     1384                    SendCmd "outline visible $bool $tag"
     1385                }
     1386            }
    13921387        }
    13931388        "-surfaceedges" {
     1389            set _changed($what) 1
    13941390            set bool $_settings($what)
    13951391            SendCmd "polydata edges $bool"
    13961392        }
    13971393        "-surfacelighting" {
     1394            set _changed($what) 1
    13981395            set bool $_settings($what)
    13991396            SendCmd "polydata lighting $bool"
    14001397        }
    14011398        "-surfaceopacity" {
     1399            set _changed($what) 1
    14021400            set val $_settings($what)
    14031401            set sval [expr { 0.01 * double($val) }]
     
    14051403        }
    14061404        "-surfacevisible" {
     1405            set _changed($what) 1
    14071406            set bool $_settings($what)
    1408             SendCmd "polydata visible $bool"
     1407            SendCmd "polydata visible 0"
    14091408            if { $bool } {
     1409                foreach tag [CurrentDatasets -visible] {
     1410                    SendCmd "polydata visible $bool $tag"
     1411                }
    14101412                Rappture::Tooltip::for $itk_component(surface) \
    14111413                    "Hide the surface"
     
    14171419        }
    14181420        "-surfacewireframe" {
     1421            set _changed($what) 1
    14191422            set bool $_settings($what)
    14201423            SendCmd "polydata wireframe $bool"
     
    18891892    set tag $dataobj-$comp
    18901893    array set style {
    1891         -color BCGYR
    1892         -edgecolor black
    1893         -edges 0
    1894         -isolinecolor white
     1894        -color           BCGYR
     1895        -edgecolor       black
     1896        -edges           0
     1897        -isolinecolor    white
    18951898        -isolinesvisible 0
    1896         -levels 10
    1897         -lighting 1
    1898         -linewidth 1.0
    1899         -opacity 1.0
    1900         -outline 0
    1901         -surfacevisible 1
    1902         -wireframe 0
     1899        -levels          10
     1900        -lighting        1
     1901        -linewidth       1.0
     1902        -opacity         1.0
     1903        -outline         0
     1904        -surfacevisible  1
     1905        -wireframe       0
    19031906    }
    19041907    array set style [$dataobj style $comp]
     
    19161919    # the code to handle aberrant cases.
    19171920
     1921    if { $_changed(-surfaceedges) } {
     1922        set style(-edges) $_settings(-surfaceedges)
     1923    }
     1924    if { $_changed(-surfacelighting) } {
     1925        set style(-lighting) $_settings(-surfacelighting)
     1926    }
    19181927    if { $_changed(-surfaceopacity) } {
    19191928        set style(-opacity) [expr $_settings(-surfaceopacity) * 0.01]
     1929    }
     1930    if { $_changed(-surfacewireframe) } {
     1931        set style(-wireframe) $_settings(-surfacewireframe)
    19201932    }
    19211933    if { $_changed(-numcontours) } {
     
    19361948        DrawLegend
    19371949    }
    1938     set _settings(-isolinesvisible) $style(-isolinesvisible)
    1939     set _settings(-surfacevisible) $style(-surfacevisible)
     1950    foreach setting {-outline -isolinesvisible -surfacevisible -isolinecolor} {
     1951        if {$_changed($setting)} {
     1952            # User-modified UI setting overrides style
     1953            set style($setting) $_settings($setting)
     1954        } else {
     1955            # Set UI control to style setting (tool provided or default)
     1956            set _settings($setting) $style($setting)
     1957        }
     1958    }
    19401959
    19411960    SendCmd "outline add $tag"
    19421961    SendCmd "outline color [Color2RGB $itk_option(-plotforeground)] $tag"
    19431962    SendCmd "outline visible $style(-outline) $tag"
    1944     set _settings(-outline) $style(-outline)
    19451963
    19461964    SendCmd "polydata add $tag"
     1965    if { $_curFldName != "" } {
     1966        SendCmd "polydata colormode $_colorMode $_curFldName $tag"
     1967    }
    19471968    SendCmd "polydata edges $style(-edges) $tag"
    19481969    set _settings(-surfaceedges) $style(-edges)
     
    23032324    blt::vector destroy $v
    23042325}
     2326
     2327itcl::body Rappture::VtkSurfaceViewer::SetCurrentFieldName { dataobj } {
     2328    set _first $dataobj
     2329    $itk_component(field) choices delete 0 end
     2330    $itk_component(fieldmenu) delete 0 end
     2331    array unset _fields
     2332    set _curFldName ""
     2333    foreach cname [$_first components] {
     2334        foreach fname [$_first fieldnames $cname] {
     2335            if { [info exists _fields($fname)] } {
     2336                continue
     2337            }
     2338            foreach { label units components } \
     2339                [$_first fieldinfo $fname] break
     2340            $itk_component(field) choices insert end "$fname" "$label"
     2341            $itk_component(fieldmenu) add radiobutton -label "$label" \
     2342                -value $label -variable [itcl::scope _curFldLabel] \
     2343                -selectcolor red \
     2344                -activebackground $itk_option(-plotbackground) \
     2345                -activeforeground $itk_option(-plotforeground) \
     2346                -font "Arial 8" \
     2347                -command [itcl::code $this LegendTitleAction save]
     2348            set _fields($fname) [list $label $units $components]
     2349            if { $_curFldName == "" } {
     2350                set _curFldName $fname
     2351                set _curFldLabel $label
     2352            }
     2353        }
     2354    }
     2355    $itk_component(field) value $_curFldLabel
     2356}
Note: See TracChangeset for help on using the changeset viewer.