Changeset 4494 for branches/1.3/gui/scripts/field.tcl
- Timestamp:
- Jul 13, 2014, 10:12:30 PM (10 years ago)
- Location:
- branches/1.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3
- Property svn:mergeinfo changed
/trunk merged: 3955,4101,4493
- Property svn:mergeinfo changed
-
branches/1.3/gui/scripts/field.tcl
r4491 r4494 157 157 158 158 private method VerifyVtkDataSet { contents } 159 private method VectorLimits { vector vectorsize {comp -1} } 159 160 private variable _values "" 160 161 } … … 317 318 } 318 319 if {[info exists _comp2dx($cname)]} { 319 return "" ;# no mesh -- it's embedded in the valuedata320 return "" ;# no mesh -- it's embedded in the blob data 320 321 } 321 322 if {[info exists _comp2mesh($cname)]} { … … 461 462 } 462 463 2D - 3D { 463 if {[info exists _comp2unirect3d($cname)]} { 464 set limits [$_comp2unirect3d($cname) limits $which] 465 foreach {axisMin axisMax} $limits break 466 set axis v 467 } elseif {[info exists _comp2limits($cname)]} { 464 if {[info exists _comp2limits($cname)]} { 468 465 array set limits $_comp2limits($cname) 469 466 switch -- $which { … … 1248 1245 set numArrays [$dataAttrs GetNumberOfArrays] 1249 1246 if { $numArrays > 0 } { 1250 set array [$dataAttrs GetArray 0]1251 # Calling GetRange with component set to -1 will return1252 # either the scalar range or vector magnitude range1253 foreach {vmin vmax} [$array GetRange -1] break1254 1255 1247 for {set i 0} {$i < [$dataAttrs GetNumberOfArrays] } {incr i} { 1256 1248 set array [$dataAttrs GetArray $i] 1257 1249 set fname [$dataAttrs GetArrayName $i] 1258 1250 foreach {min max} [$array GetRange -1] break 1251 if {$i == 0} { 1252 set vmin $min 1253 set vmax $max 1254 } 1259 1255 lappend limits $fname [list $min $max] 1260 1256 set _fld2Units($fname) "" … … 1397 1393 set vectorsize 1 1398 1394 } 1395 set _type unirect3d 1399 1396 set _dim 3 1400 1397 if { $_viewer == "" } { … … 1405 1402 [Rappture::Unirect3d \#auto $_xmlobj $_field $cname $vectorsize] 1406 1403 set _comp2style($cname) [$_field get $cname.style] 1404 set limits {} 1405 foreach axis { x y z } { 1406 lappend limits $axis [$_comp2unirect3d($cname) limits $axis] 1407 } 1408 # Get the data limits 1409 set vector [$_comp2unirect3d($cname) valuesObj] 1410 set minmax [VectorLimits $vector $vectorsize] 1411 lappend limits $cname $minmax 1412 lappend limits v $minmax 1413 set _comp2limits($cname) $limits 1407 1414 if {[$_field element $cname.flow] != ""} { 1408 1415 set _comp2flowhints($cname) \ … … 1419 1426 set vectorsize 1 1420 1427 } 1428 set _type unirect2d 1421 1429 set _dim 2 1422 1430 if { $_viewer == "" } { … … 1436 1444 set xv [blt::vector create \#auto] 1437 1445 $xv set $_values 1438 lappend limits $cname [$xv limits] 1439 lappend limits v [$xv limits] 1446 set minmax [VectorLimits $xv $vectorsize] 1447 lappend limits $cname $minmax 1448 lappend limits v $minmax 1440 1449 blt::vector destroy $xv 1441 1450 set _comp2limits($cname) $limits … … 1446 1455 "cloud" { 1447 1456 set mesh [Rappture::Cloud::fetch $_xmlobj $path] 1457 set _type cloud 1448 1458 } 1449 1459 "mesh" { 1450 1460 set mesh [Rappture::Mesh::fetch $_xmlobj $path] 1461 set _type mesh 1451 1462 } 1452 1463 "unirect2d" { … … 1455 1466 } 1456 1467 set mesh [Rappture::Unirect2d::fetch $_xmlobj $path] 1468 set _type unirect2d 1457 1469 } 1458 1470 } … … 1504 1516 if {$_dim == 2} { 1505 1517 # 2D data: By default surface or contour plot using heightmap widget. 1506 set _type "heightmap"1507 1518 set v [blt::vector create \#auto] 1508 1519 $v set [$_field get $cname.values] … … 1536 1547 set _comp2mesh($cname) [list $mesh $v] 1537 1548 set _comp2style($cname) [$_field get $cname.style] 1549 if {[$_field element $cname.flow] != ""} { 1550 set _comp2flowhints($cname) \ 1551 [Rappture::FlowHints ::\#auto $_field $cname $_units] 1552 } 1538 1553 incr _counter 1539 1554 array unset _comp2limits $cname … … 1541 1556 lappend _comp2limits($cname) $axis [$mesh limits $axis] 1542 1557 } 1543 lappend _comp2limits($cname) $cname [$v limits] 1544 lappend _comp2limits($cname) v [$v limits] 1558 set minmax [VectorLimits $v $_comp2size($cname)] 1559 lappend _comp2limits($cname) $cname $minmax 1560 lappend _comp2limits($cname) v $minmax 1545 1561 return 1 1546 1562 } … … 1550 1566 set _viewer "isosurface" 1551 1567 } 1552 set _type "isosurface"1553 1568 set v [blt::vector create \#auto] 1554 1569 $v set [$_field get $cname.values] … … 1579 1594 set _comp2mesh($cname) [list $mesh $v] 1580 1595 set _comp2style($cname) [$_field get $cname.style] 1596 if {[$_field element $cname.flow] != ""} { 1597 set _comp2flowhints($cname) \ 1598 [Rappture::FlowHints ::\#auto $_field $cname $_units] 1599 } 1581 1600 incr _counter 1582 1601 foreach axis { x y z } { 1583 1602 lappend _comp2limits($cname) $axis [$mesh limits $axis] 1584 1603 } 1585 lappend _comp2limits($cname) $cname [$v limits] 1586 lappend _comp2limits($cname) v [$v limits] 1604 set minmax [VectorLimits $v $_comp2size($cname)] 1605 lappend _comp2limits($cname) $cname $minmax 1606 lappend _comp2limits($cname) v $minmax 1587 1607 return 1 1588 1608 } … … 1663 1683 } 1664 1684 } 1685 1686 # 1687 # Compute the per-component limits or limits of vector magnitudes 1688 # 1689 itcl::body Rappture::Field::VectorLimits {vector vectorsize {comp -1}} { 1690 if {$vectorsize == 1} { 1691 set minmax [$vector limits] 1692 } else { 1693 set len [$vector length] 1694 if {[expr $len % $vectorsize] != 0} { 1695 error "Invalid vectorsize: $vectorsize" 1696 } 1697 if {$comp > $vectorsize-1} { 1698 error "Invalid vector component: $comp" 1699 } 1700 set numTuples [expr ($len/$vectorsize)] 1701 for {set i 0} {$i < $numTuples} {incr i} { 1702 if {$comp >= 0} { 1703 set idx [expr ($i * $vectorsize + $comp)] 1704 set val [$vector index $idx] 1705 } else { 1706 set idx [expr ($i * $vectorsize)] 1707 set mag 0 1708 for {set j 0} {$j < $vectorsize} {incr j} { 1709 set val [$vector index $idx] 1710 set mag [expr ($mag + $val * $val)] 1711 incr idx 1712 } 1713 set val [expr (sqrt($mag))] 1714 } 1715 if (![info exists minmax]) { 1716 set minmax [list $val $val] 1717 } else { 1718 if {$val < [lindex $minmax 0]} { 1719 lset minmax 0 $val 1720 } 1721 if {$val > [lindex $minmax 1]} { 1722 lset minmax 1 $val 1723 } 1724 } 1725 } 1726 } 1727 return $minmax 1728 }
Note: See TracChangeset
for help on using the changeset viewer.