- Timestamp:
- Mar 3, 2013 6:48:40 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkstreamlinesviewer.tcl
r3430 r3431 57 57 public method get {args} 58 58 public method isconnected {} 59 public method limits { colormap }60 59 public method parameters {title args} { 61 60 # do nothing … … 232 231 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 233 232 $_arcball quaternion $q 234 235 set _limits(zmin) 0.0236 set _limits(zmax) 1.0237 233 238 234 array set _settings [subst { … … 702 698 itcl::body Rappture::VtkStreamlinesViewer::scale {args} { 703 699 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] 728 730 } 729 731 } … … 988 990 } 989 991 990 set _limits(zmin) ""991 set _limits(zmax) ""992 992 set _first "" 993 993 SendCmd "dataset visible 0" … … 1635 1635 } 1636 1636 1637 itcl::body Rappture::VtkStreamlinesViewer::limits { dataobj } {1638 return1639 array unset _limits $dataobj-*1640 foreach comp [$dataobj components] {1641 set tag $dataobj-$comp1642 if { ![info exists _limits($tag)] } {1643 set data [$dataobj blob $comp]1644 set tmpfile file[pid].vtk1645 set f [open "$tmpfile" "w"]1646 fconfigure $f -translation binary -encoding binary1647 puts $f $data1648 close $f1649 set reader [vtkDataSetReader $tag-xvtkDataSetReader]1650 $reader SetFileName $tmpfile1651 $reader ReadAllScalarsOn1652 $reader ReadAllVectorsOn1653 $reader ReadAllFieldsOn1654 $reader Update1655 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) 11672 }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 $tmpfile1683 }1684 foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break1685 if {![info exists limits(xmin)] || $limits(xmin) > $xMin} {1686 set limits(xmin) $xMin1687 }1688 if {![info exists limits(xmax)] || $limits(xmax) < $xMax} {1689 set limits(xmax) $xMax1690 }1691 if {![info exists limits(ymin)] || $limits(ymin) > $yMin} {1692 set limits(ymin) $xMin1693 }1694 if {![info exists limits(ymax)] || $limits(ymax) < $yMax} {1695 set limits(ymax) $yMax1696 }1697 if {![info exists limits(zmin)] || $limits(zmin) > $zMin} {1698 set limits(zmin) $zMin1699 }1700 if {![info exists limits(zmax)] || $limits(zmax) < $zMax} {1701 set limits(zmax) $zMax1702 }1703 }1704 return [array get limits]1705 }1706 1707 1637 itcl::body Rappture::VtkStreamlinesViewer::BuildVolumeTab {} { 1708 1638 … … 2294 2224 itcl::body Rappture::VtkStreamlinesViewer::ReceiveLegend { colormap title vmin vmax size } { 2295 2225 set _legendPending 0 2296 set _limits(vmin) $vmin2297 set _limits(vmax) $vmax2298 2226 set _title $title 2299 2227 regsub {\(mag\)} $title "" _title … … 2362 2290 # Reset the item coordinates according the current size of the plot. 2363 2291 $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] 2369 2296 } 2370 2297 set y 2 … … 2439 2366 2440 2367 # 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 2442 2370 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] 2444 2372 } else { 2445 2373 set value 0.0 … … 2521 2449 } 2522 2450 2523 2524 2451 # 2525 2452 # ResetAxes -- … … 2528 2455 # 2529 2456 itcl::body Rappture::VtkStreamlinesViewer::ResetAxes {} { 2530 if { ![info exists _limits( v)] || ![info exists _fields($_curFldName)]} {2457 if { ![info exists _limits($_curFldName)] } { 2531 2458 SendCmd "dataset maprange all" 2532 2459 SendCmd "axis autorange z on" … … 2537 2464 foreach { ymin ymax } $_limits(y) break 2538 2465 foreach { zmin zmax } $_limits(z) break 2539 foreach { vmin vmax } $_limits( v) break2466 foreach { vmin vmax } $_limits($_curFldName) break 2540 2467 set dataRange [expr $vmax - $vmin] 2541 2468 set boundsRange [expr $xmax - $xmin] … … 2552 2479 set bMin [expr $heightScale * $dataScale * $vmin] 2553 2480 set bMax [expr $heightScale * $dataScale * $vmax] 2554 SendCmd "dataset maprange explicit $_limits( v) $_curFldName"2481 SendCmd "dataset maprange explicit $_limits($_curFldName) $_curFldName" 2555 2482 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.