Changeset 3431 for trunk


Ignore:
Timestamp:
Mar 3, 2013 6:48:40 PM (11 years ago)
Author:
gah
Message:

fix for sequence of contours

File:
1 edited

Legend:

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

    r3430 r3431  
    5757    public method get {args}
    5858    public method isconnected {}
    59     public method limits { colormap }
    6059    public method parameters {title args} {
    6160        # do nothing
     
    232231    set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]
    233232    $_arcball quaternion $q
    234 
    235     set _limits(zmin) 0.0
    236     set _limits(zmax) 1.0
    237233
    238234    array set _settings [subst {
     
    702698itcl::body Rappture::VtkStreamlinesViewer::scale {args} {
    703699    foreach dataobj $args {
    704         set string [limits $dataobj]
    705         if { $string == "" } {
    706             continue
    707         }
    708         array set bounds $string
    709         if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} {
    710             set _limits(xmin) $bounds(xmin)
    711         }
    712         if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} {
    713             set _limits(xmax) $bounds(xmax)
    714         }
    715 
    716         if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} {
    717             set _limits(ymin) $bounds(ymin)
    718         }
    719         if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} {
    720             set _limits(ymax) $bounds(ymax)
    721         }
    722 
    723         if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} {
    724             set _limits(zmin) $bounds(zmin)
    725         }
    726         if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} {
    727             set _limits(zmax) $bounds(zmax)
     700        foreach axis { x y z } {
     701            set lim [$dataobj limits $axis]
     702            if { ![info exists _limits($axis)] } {
     703                set _limits($axis) $lim
     704                continue
     705            }
     706            foreach {min max} $lim break
     707            foreach {amin amax} $_limits($axis) break
     708            if { $amin > $min } {
     709                set amin $min
     710            }
     711            if { $amax < $max } {
     712                set amax $max
     713            }
     714            set _limits($axis) [list $amin $amax]
     715        }
     716        foreach { fname lim } [$dataobj fieldlimits] {
     717            if { ![info exists _limits($fname)] } {
     718                set _limits($fname) $lim
     719                continue
     720            }
     721            foreach {min max} $lim break
     722            foreach {fmin fmax} $_limits($fname) break
     723            if { $fmin > $min } {
     724                set fmin $min
     725            }
     726            if { $fmax < $max } {
     727                set fmax $max
     728            }
     729            set _limits($fname) [list $fmin $fmax]
    728730        }
    729731    }
     
    988990    }
    989991
    990     set _limits(zmin) ""
    991     set _limits(zmax) ""
    992992    set _first ""
    993993    SendCmd "dataset visible 0"
     
    16351635}
    16361636
    1637 itcl::body Rappture::VtkStreamlinesViewer::limits { dataobj } {
    1638     return
    1639     array unset _limits $dataobj-*
    1640     foreach comp [$dataobj components] {
    1641         set tag $dataobj-$comp
    1642         if { ![info exists _limits($tag)] } {
    1643             set data [$dataobj blob $comp]
    1644             set tmpfile file[pid].vtk
    1645             set f [open "$tmpfile" "w"]
    1646             fconfigure $f -translation binary -encoding binary
    1647             puts $f $data
    1648             close $f
    1649             set reader [vtkDataSetReader $tag-xvtkDataSetReader]
    1650             $reader SetFileName $tmpfile
    1651             $reader ReadAllScalarsOn
    1652             $reader ReadAllVectorsOn
    1653             $reader ReadAllFieldsOn
    1654             $reader Update
    1655             set output [$reader GetOutput]
    1656             set _limits($tag) [$output GetBounds]
    1657             set pointData [$output GetPointData]
    1658             puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]"
    1659             puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]"
    1660             puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]"
    1661             set fieldData [$output GetFieldData]
    1662             set pointData [$output GetPointData]
    1663             puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]"
    1664             for { set i 0 } { $i < [$fieldData GetNumberOfArrays] } { incr i } {
    1665                 puts stderr [$fieldData GetArrayName $i]
    1666             }
    1667             for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } {
    1668                 set name [$pointData GetArrayName $i]
    1669                 if { ![info exists _fields($name)] } {
    1670                     $itk_component(field) choices insert end "$name" "$name"
    1671                     set _fields($name) 1
    1672                 }
    1673             }
    1674             puts stderr "field \#components=[$fieldData GetNumberOfComponents]"
    1675             puts stderr "point \#components=[$pointData GetNumberOfComponents]"
    1676             puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]"
    1677             puts stderr "point \#tuples=[$pointData GetNumberOfTuples]"
    1678             puts stderr "point \#scalars=[$pointData GetScalars]"
    1679             puts stderr vectors=[$pointData GetVectors]
    1680             rename $output ""
    1681             rename $reader ""
    1682             file delete $tmpfile
    1683         }
    1684         foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break
    1685         if {![info exists limits(xmin)] || $limits(xmin) > $xMin} {
    1686             set limits(xmin) $xMin
    1687         }
    1688         if {![info exists limits(xmax)] || $limits(xmax) < $xMax} {
    1689             set limits(xmax) $xMax
    1690         }
    1691         if {![info exists limits(ymin)] || $limits(ymin) > $yMin} {
    1692             set limits(ymin) $xMin
    1693         }
    1694         if {![info exists limits(ymax)] || $limits(ymax) < $yMax} {
    1695             set limits(ymax) $yMax
    1696         }
    1697         if {![info exists limits(zmin)] || $limits(zmin) > $zMin} {
    1698             set limits(zmin) $zMin
    1699         }
    1700         if {![info exists limits(zmax)] || $limits(zmax) < $zMax} {
    1701             set limits(zmax) $zMax
    1702         }
    1703     }
    1704     return [array get limits]
    1705 }
    1706 
    17071637itcl::body Rappture::VtkStreamlinesViewer::BuildVolumeTab {} {
    17081638
     
    22942224itcl::body Rappture::VtkStreamlinesViewer::ReceiveLegend { colormap title vmin vmax size } {
    22952225    set _legendPending 0
    2296     set _limits(vmin) $vmin
    2297     set _limits(vmax) $vmax
    22982226    set _title $title
    22992227    regsub {\(mag\)} $title "" _title
     
    23622290        # Reset the item coordinates according the current size of the plot.
    23632291        $c itemconfigure title -text $title
    2364         if { $_limits(vmin) != "" } {
    2365             $c itemconfigure vmin -text [format %g $_limits(vmin)]
    2366         }
    2367         if { $_limits(vmax) != "" } {
    2368             $c itemconfigure vmax -text [format %g $_limits(vmax)]
     2292        if { [info exists _limits($_curFldName)] } {
     2293            foreach {vmin vmax} $_limits($_curFldName) break
     2294            $c itemconfigure vmin -text [format %g $vmin]
     2295            $c itemconfigure vmax -text [format %g $vmax]
    23692296        }
    23702297        set y 2
     
    24392366
    24402367    # Compute the value of the point
    2441     if { [info exists _limits(vmax)] && [info exists _limits(vmin)] } {
     2368    if { [info exists _limits($_curFldName)] } {
     2369        foreach {vmin vmax} $_limits($_curFldName) break
    24422370        set t [expr 1.0 - (double($imgY) / double($imgHeight-1))]
    2443         set value [expr $t * ($_limits(vmax) - $_limits(vmin)) + $_limits(vmin)]
     2371        set value [expr $t * ($vmax - $vmin) + $vmin]
    24442372    } else {
    24452373        set value 0.0
     
    25212449}
    25222450
    2523 
    25242451#
    25252452# ResetAxes --
     
    25282455#
    25292456itcl::body Rappture::VtkStreamlinesViewer::ResetAxes {} {
    2530     if { ![info exists _limits(v)] || ![info exists _fields($_curFldName)]} {
     2457    if { ![info exists _limits($_curFldName)] } {
    25312458        SendCmd "dataset maprange all"
    25322459        SendCmd "axis autorange z on"
     
    25372464    foreach { ymin ymax } $_limits(y) break
    25382465    foreach { zmin zmax } $_limits(z) break
    2539     foreach { vmin vmax } $_limits(v) break
     2466    foreach { vmin vmax } $_limits($_curFldName) break
    25402467    set dataRange   [expr $vmax - $vmin]
    25412468    set boundsRange [expr $xmax - $xmin]
     
    25522479    set bMin [expr $heightScale * $dataScale * $vmin]
    25532480    set bMax [expr $heightScale * $dataScale * $vmax]
    2554     SendCmd "dataset maprange explicit $_limits(v) $_curFldName"
     2481    SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName"
    25552482    SendCmd "axis bounds z $bMin $bMax"
    2556     SendCmd "axis range z $_limits(v)"
    2557 }
     2483    SendCmd "axis range z $_limits($_curFldName)"
     2484}
Note: See TracChangeset for help on using the changeset viewer.