Ignore:
Timestamp:
Nov 23, 2014 8:59:51 AM (10 years ago)
Author:
ldelgass
Message:

Merge some changes from trunk (mostly still unused)

File:
1 edited

Legend:

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

    r4768 r4774  
    6161    }
    6262    public method scale {args}
     63
     64    private method GetDatasetsWithComponent { cname }
     65
     66    private variable _volcomponents   ; # Array of components found
     67    private variable _componentsList   ; # List of component names
    6368
    6469    # The following methods are only used by this class.
     
    146151    private variable _curFldName ""
    147152    private variable _curFldLabel ""
    148     private variable _colorMode "vmag";#  Mode of colormap (vmag or scalar)
     153    private variable _colorMode "scalar"; #  Mode of colormap (vmag or scalar)
    149154    private variable _cutplaneCmd "cutplane"
     155    private variable _allowMultiComponent 0
    150156}
    151157
     
    222228        -axisminorticks                 1
    223229        -background                     black
     230        -color                          BCGYR
    224231        -cutplanelighting               1
    225232        -cutplaneopacity                100
     
    642649# ----------------------------------------------------------------------
    643650itcl::body Rappture::VtkVolumeViewer::scale {args} {
     651    array unset _limits
     652    array unset _volcomponents
     653    set _componentsList ""
     654
    644655    foreach dataobj $args {
    645656        if { ![$dataobj isvalid] } {
    646657            continue;                     # Object doesn't contain valid data.
    647658        }
     659        # Determine limits for each axis.
    648660        foreach axis { x y z } {
    649661            set lim [$dataobj limits $axis]
     
    662674            set _limits($axis) [list $amin $amax]
    663675        }
     676        # Determine limits for each field.
    664677        foreach { fname lim } [$dataobj fieldlimits] {
    665678            if { ![info exists _limits($fname)] } {
     
    676689            }
    677690            set _limits($fname) [list $fmin $fmax]
     691        }
     692        # Get limits for each component.
     693        foreach cname [$dataobj components] {
     694            if { ![info exists _volcomponents($cname)] } {
     695                lappend _componentsList $cname
     696            }
     697            lappend _volcomponents($cname) $dataobj-$cname
     698            array unset limits
     699            array set limits [$dataobj valueLimits $cname]
     700            if { ![info exists _limits($cname)] } {
     701                set _limits($cname) $limits(v)
     702                continue
     703            }
     704            foreach {min max} $limits(v) break
     705            foreach {vmin vmax} $_limits($cname) break
     706            if { $vmin > $min } {
     707                set vmin $min
     708            }
     709            if { $vmax < $max } {
     710                set vmax $max
     711            }
     712            set _limits($cname) [list $vmin $vmax]
    678713        }
    679714    }
     
    10311066                    [$_first fieldinfo $fname] break
    10321067                # Only scalar fields are valid
    1033                 if {$components == 1} {
     1068                if {$_allowMultiComponent || $components == 1} {
    10341069                    $itk_component(field) choices insert end "$fname" "$label"
    10351070                    $itk_component(fieldmenu) add radiobutton -label "$label" \
     
    10511086    }
    10521087
    1053     InitSettings -volumepalette \
     1088    InitSettings -color \
    10541089        -volumematerial \
    10551090        -volumelighting -volumeopacity -volumequality -volumeoutline -volumevisible \
     
    14421477            set _cutplanePending 0
    14431478        }
    1444         "-volumepalette" {
    1445             set palette [$itk_component(palette) value]
    1446             set _settings($what) $palette
     1479        "-color" {
     1480            set color [$itk_component(colormap) value]
     1481            set _settings($what) $color
    14471482            foreach dataset [CurrentDatasets -visible $_first] {
    14481483                foreach {dataobj comp} [split $dataset -] break
    1449                 ChangeColormap $dataobj $comp $palette
     1484                ChangeColormap $dataobj $comp $color
    14501485            }
    14511486            set _legendPending 1
     
    14571492            if { [info exists _fields($fname)] } {
    14581493                foreach { label units components } $_fields($fname) break
    1459                 if { $components > 1 } {
     1494                if { !$_allowMultiComponent && $components > 1 } {
    14601495                    puts stderr "Can't use a vector field in a volume"
    14611496                    return
    14621497                } else {
    1463                     set _colorMode scalar
     1498                    if { $components > 1 } {
     1499                        set _colorMode vmag
     1500                    } else {
     1501                        set _colorMode scalar
     1502                    }
    14641503                }
    14651504                set _curFldName $fname
     
    14701509            }
    14711510            foreach dataset [CurrentDatasets -visible $_first] {
    1472                 #SendCmd "volume colormode $_colorMode ${fname} $dataset"
    1473                 SendCmd "$_cutplaneCmd colormode $_colorMode ${fname} $dataset"
     1511                #SendCmd "$_cutplaneCmd colormode $_colorMode $_curFldName $dataset"
     1512                SendCmd "dataset scalar $_curFldName $dataset"
    14741513            }
    14751514            SendCmd "camera reset"
     
    15031542        if { [info exists _dataset2style($dataset)] } {
    15041543            SendCmdNoWait \
    1505                 "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0"
     1544                "legend2 $_dataset2style($dataset) $w $h"
     1545                #"legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0"
    15061546            break;
    15071547        }
     
    17091749        [itcl::code $this AdjustSetting -field]
    17101750
    1711     label $inner.palette_l -text "Palette" -font $font
    1712     itk_component add palette {
    1713         Rappture::Combobox $inner.palette -editable no
    1714     }
    1715     $inner.palette choices insert end [GetColormapList]
    1716     $itk_component(palette) value "BCGYR"
    1717     bind $inner.palette <<Value>> \
    1718         [itcl::code $this AdjustSetting -volumepalette]
     1751    label $inner.colormap_l -text "Colormap" -font $font
     1752    itk_component add colormap {
     1753        Rappture::Combobox $inner.colormap -editable no
     1754    }
     1755    $inner.colormap choices insert end [GetColormapList]
     1756    bind $inner.colormap <<Value>> \
     1757        [itcl::code $this AdjustSetting -color]
     1758    $itk_component(colormap) value $_settings(-color)
    17191759
    17201760    blt::table $inner \
     
    17301770        6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \
    17311771        7,0 $inner.quality   -fill x   -pady 2 -cspan 4 \
    1732         8,0 $inner.palette_l -anchor w -pady 2  \
    1733         8,1 $inner.palette   -fill x   -pady 2 -cspan 3 \
     1772        8,0 $inner.colormap_l -anchor w -pady 2  \
     1773        8,1 $inner.colormap   -fill x   -pady 2 -cspan 3 \
    17341774
    17351775    blt::table configure $inner r* c0 c1 c3 -resize none
     
    23762416    set _view(-zoom) 1.0
    23772417}
     2418
     2419#
     2420# GetDatasetsWithComponents --
     2421#
     2422#       Returns a list of all the datasets (known by the combination of
     2423#       their data object and component name) that match the given
     2424#       component name.  For example, this is used where we want to change
     2425#       the settings of volumes that have the current component.
     2426#
     2427itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } {
     2428    if { ![info exists _volcomponents($cname)] } {
     2429        return ""
     2430    }
     2431    return $_volcomponents($cname)
     2432}
Note: See TracChangeset for help on using the changeset viewer.