Ignore:
Timestamp:
Sep 20, 2013, 1:30:29 PM (11 years ago)
Author:
gah
Message:

fix flowvisviewer for limits method in field, refactored isomarkers into transferfunctioneditor for nanovisviewer

File:
1 edited

Legend:

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

    r3915 r3940  
    4444    itk_option define -plotoutline plotOutline PlotOutline ""
    4545
     46    private variable _volcomponents   ; # Array of components found
     47    private variable _componentsList   ; # Array of components found
     48    private method BuildVolumeComponents {}
     49    private method GetDatasetsWithComponent { cname }
     50
    4651    constructor { hostlist args } {
    4752        Rappture::VisViewer::constructor $hostlist
     
    6368    public method get {args}
    6469    public method isconnected {}
    65     public method limits { tf }
     70    public method limits { cname }
    6671    public method overmarker { m x }
    6772    public method parameters {title args} {
     
    232237    $_arcball quaternion $q
    233238
    234     set _limits(vmin) 0.0
    235     set _limits(vmax) 1.0
     239    set _limits(v) [list 0.0 1.0]
    236240    set _reset 1
    237241
     
    692696# ----------------------------------------------------------------------
    693697itcl::body Rappture::FlowvisViewer::delete {args} {
    694      flow stop
     698    flow stop
    695699    if {[llength $args] == 0} {
    696700        set args $_dlist
     
    742746# ----------------------------------------------------------------------
    743747itcl::body Rappture::FlowvisViewer::scale {args} {
    744     foreach val {xmin xmax ymin ymax vmin vmax} {
    745         set _limits($val) ""
    746     }
    747     foreach obj $args {
    748         foreach axis {x y v} {
    749 
    750             foreach { min max } [$obj limits $axis] break
    751 
     748    array set style {
     749        -color BCGYR
     750        -levels 6
     751        -opacity 1.0
     752        -markers ""
     753    }
     754    array unset _limits
     755    array unset _volcomponents
     756    foreach dataobj $args {
     757        if { ![$dataobj isvalid] } {
     758            continue;                     # Object doesn't contain valid data.
     759        }
     760        foreach cname [$dataobj components] {
     761            if { ![info exists _volcomponents($cname)] } {
     762                lappend _componentsList $cname
     763                array set style [lindex [$dataobj components -style $cname] 0]
     764                set cmap [ColorsToColormap $style(-color)]
     765                set _cname2defaultcolormap($cname) $cmap
     766                set _settings($cname-colormap) $style(-color)
     767            }
     768            lappend _volcomponents($cname) $dataobj-$cname
     769            array unset limits
     770            array set limits [$dataobj valueLimits $cname]
     771            set _limits($cname) $limits(v)
     772        }
     773        foreach axis {x y z v} {
     774            foreach { min max } [$dataobj limits $axis] break
    752775            if {"" != $min && "" != $max} {
    753                 if {"" == $_limits(${axis}min)} {
    754                     set _limits(${axis}min) $min
    755                     set _limits(${axis}max) $max
     776                if { ![info exists _limits($axis)] } {
     777                    set _limits($axis) [list $min $max]
    756778                } else {
    757                     if {$min < $_limits(${axis}min)} {
    758                         set _limits(${axis}min) $min
     779                    foreach {amin amax} $_limits($axis) break
     780                    if {$min < $amin} {
     781                        set amin $min
    759782                    }
    760                     if {$max > $_limits(${axis}max)} {
    761                         set _limits(${axis}max) $max
     783                    if {$max > $amax} {
     784                        set amax $max
    762785                    }
     786                    set _limits($axis) [list $amin $amax]
    763787                }
    764788            }
    765789        }
    766790    }
     791    #BuildVolumeComponents
    767792}
    768793
     
    11321157    # Display the markers used by the active transfer function.
    11331158    set tf $_obj2style($tag)
    1134     array set limits [limits $tf]
    1135     $c itemconfigure vmin -text [format %.2g $limits(vmin)]
     1159    foreach {vmin vmax} [limits $tf] break
     1160    $c itemconfigure vmin -text [format %.2g $vmin]
    11361161    $c coords vmin $lx $ly
    11371162
    1138     $c itemconfigure vmax -text [format %.2g $limits(vmax)]
     1163    $c itemconfigure vmax -text [format %.2g $vmax]
    11391164    $c coords vmax [expr {$w-$lx}] $ly
    11401165
     
    11761201    set dataobj [lindex $parts 0]
    11771202    set _serverObjs($tag) 0
    1178     set _limits($tag-min)  $values(min);  # Minimum value of the volume.
    1179     set _limits($tag-max)  $values(max);  # Maximum value of the volume.
     1203    set _limits($tag) [list $values(min) $values(max)]
    11801204    unset _recvObjs($tag)
    11811205    if { [array size _recvObjs] == 0 } {
     
    14131437
    14141438itcl::body Rappture::FlowvisViewer::PanCamera {} {
    1415     #set x [expr ($_view(xpan)) / $_limits(xrange)]
    1416     #set y [expr ($_view(ypan)) / $_limits(yrange)]
    14171439    set x $_view(xpan)
    14181440    set y $_view(ypan)
     
    18271849#              now.
    18281850#
    1829 itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj comp } {
     1851itcl::body Rappture::FlowvisViewer::NameTransferFunc { dataobj cname } {
    18301852    array set style {
    18311853        -color BCGYR
     
    18351857        -transp 50
    18361858    }
    1837     array set style [lindex [$dataobj components -style $comp] 0]
     1859    array set style [lindex [$dataobj components -style $cname] 0]
    18381860    set _settings($this-light) $style(-light)
    18391861    set _settings($this-transp) $style(-transp)
    18401862    set _settings($this-opacity) [expr $style(-opacity) * 100]
    1841     set tf "$style(-color):$style(-levels):$style(-opacity)"
    1842     set _obj2style($dataobj-$comp) $tf
    1843     lappend _style2objs($tf) $dataobj $comp
    1844     return $tf
     1863    set _obj2style($dataobj-$cname) $cname
     1864    lappend _style2objs($cname) $dataobj $cname
     1865    return $cname
    18451866}
    18461867
     
    21182139}
    21192140
    2120 itcl::body Rappture::FlowvisViewer::limits { tf } {
    2121     set _limits(vmin) 0.0
    2122     set _limits(vmax) 1.0
    2123     if { ![info exists _style2objs($tf)] } {
    2124         puts stderr "no style2objs for $tf tf=($tf)"
     2141itcl::body Rappture::FlowvisViewer::limits { cname } {
     2142    set _limits(v) [list 0.0 1.0]
     2143    if { ![info exists _style2objs($cname)] } {
     2144        puts stderr "no style2objs for $cname cname=($cname)"
    21252145        return [array get _limits]
    21262146    }
    21272147    set min ""; set max ""
    2128     foreach {dataobj comp} $_style2objs($tf) {
    2129         set tag $dataobj-$comp
     2148    foreach tag [GetDatasetsWithComponent $cname] {
    21302149        if { ![info exists _serverObjs($tag)] } {
    21312150            puts stderr "$tag not in serverObjs?"
    21322151            continue
    21332152        }
    2134         if { ![info exists _limits($tag-min)] } {
     2153        if { ![info exists _limits($tag)] } {
    21352154            puts stderr "$tag no min?"
    21362155            continue
    21372156        }
    2138         if { $min == "" || $min > $_limits($tag-min) } {
    2139             set min $_limits($tag-min)
    2140         }
    2141         if { $max == "" || $max < $_limits($tag-max) } {
    2142             set max $_limits($tag-max)
    2143         }
    2144     }
    2145     if { $min != "" } {
    2146         set _limits(vmin) $min
    2147     }
    2148     if { $max != "" } {
    2149         set _limits(vmax) $max
    2150     }
    2151     return [array get _limits]
     2157        foreach {vmin vmax} $_limits($tag) break
     2158        if { $min == "" || $min > $vmin } {
     2159            set min $vmin
     2160        }
     2161        if { $max == "" || $max < $vmax } {
     2162            set max $vmax
     2163        }
     2164    }
     2165    if { $min != "" && $max != "" } {
     2166        set _limits(v) [list $min $max]
     2167        set _limits($cname) [list $min $max]
     2168    }
     2169    return $_limits($cname)
    21522170}
    21532171
     
    26382656itcl::body Rappture::FlowvisViewer::SlicerTip {axis} {
    26392657    set val [$itk_component(${axis}CutScale) get]
    2640 #    set val [expr {0.01*($val-50)
    2641 #        *($_limits(${axis}max)-$_limits(${axis}min))
    2642 #          + 0.5*($_limits(${axis}max)+$_limits(${axis}min))}]
    26432658    return "Move the [string toupper $axis] cut plane.\nCurrently:  $axis = $val%"
    26442659}
     
    30943109    set _settings($this-zoom) $_view(zoom)
    30953110}
     3111
     3112# Reset global settings from dataset's settings.
     3113itcl::body Rappture::FlowvisViewer::BuildVolumeComponents {} {
     3114    $itk_component(volcomponents) choices delete 0 end
     3115    foreach name $_componentsList {
     3116        $itk_component(volcomponents) choices insert end $name $name
     3117    }
     3118    set _current [lindex $_componentsList 0]
     3119    $itk_component(volcomponents) value $_current
     3120}
     3121
     3122# Reset global settings from dataset's settings.
     3123itcl::body Rappture::FlowvisViewer::GetDatasetsWithComponent { cname } {
     3124    if { ![info exists _volcomponents($cname)] } {
     3125        return ""
     3126    }
     3127    set list ""
     3128    foreach tag $_volcomponents($cname) {
     3129        if { ![info exists _serverObjs($tag)] } {
     3130            continue
     3131        }
     3132        lappend list $tag
     3133    }
     3134    return $list
     3135}
Note: See TracChangeset for help on using the changeset viewer.