Changeset 3441 for trunk/gui/scripts/vtkvolumeviewer.tcl
- Timestamp:
- Mar 4, 2013, 7:18:28 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/vtkvolumeviewer.tcl
r3438 r3441 58 58 public method get {args} 59 59 public method isconnected {} 60 public method limits { colormap }61 60 public method parameters {title args} { 62 61 # do nothing … … 89 88 private method BuildVolumeTab {} 90 89 private method ConvertToVtkData { dataobj comp } 91 private method DrawLegend { title}90 private method DrawLegend {} 92 91 private method Combo { option } 93 92 private method EnterLegend { x y } … … 143 142 private variable _legendPending 0 144 143 private variable _outline 145 private variable _vectorFields146 private variable _scalarFields147 144 private variable _fields 148 private variable _currentField "" 149 private variable _field "" 150 private variable _numSeeds 200 145 private variable _curFldName "" 146 private variable _curFldLabel "" 151 147 private variable _colorMode "vmag";# Mode of colormap (vmag or scalar) 152 148 } … … 230 226 $_arcball quaternion $q 231 227 232 set _limits(zmin) 0.0 233 set _limits(zmax) 1.0 234 235 array set _settings [subst { 228 array set _settings { 236 229 axis-xgrid 0 237 230 axis-ygrid 0 … … 243 236 axis-yposition 0 244 237 axis-zposition 0 245 ax is-visible1246 axis -labels1247 cutplane -edges0238 axesVisible 1 239 axisLabels 1 240 cutplaneEdges 0 248 241 cutplane-xvisible 0 249 242 cutplane-yvisible 0 … … 252 245 cutplane-yposition 50 253 246 cutplane-zposition 50 254 cutplane -visible1255 cutplane -lighting1256 cutplane -wireframe0247 cutplaneVisible 1 248 cutplaneLighting 1 249 cutplaneWireframe 0 257 250 cutplane-opacity 100 258 volume -lighting1251 volumeLighting 1 259 252 volume-material 80 260 253 volume-opacity 40 261 254 volume-quality 50 262 volume -visible1263 legend -visible1264 } ]255 volumeVisible 1 256 legendVisible 1 257 } 265 258 266 259 itk_component add view { … … 340 333 -onimage [Rappture::icon volume-on] \ 341 334 -offimage [Rappture::icon volume-off] \ 342 -variable [itcl::scope _settings(volume -visible)] \343 -command [itcl::code $this AdjustSetting volume -visible]335 -variable [itcl::scope _settings(volumeVisible)] \ 336 -command [itcl::code $this AdjustSetting volumeVisible] 344 337 } 345 338 $itk_component(volume) select … … 352 345 -onimage [Rappture::icon cutbutton] \ 353 346 -offimage [Rappture::icon cutbutton] \ 354 -variable [itcl::scope _settings(cutplane -visible)] \355 -command [itcl::code $this AdjustSetting cutplane -visible]347 -variable [itcl::scope _settings(cutplaneVisible)] \ 348 -command [itcl::code $this AdjustSetting cutplaneVisible] 356 349 } 357 350 $itk_component(cutplane) select … … 677 670 itcl::body Rappture::VtkVolumeViewer::scale {args} { 678 671 foreach dataobj $args { 679 set string [limits $dataobj] 680 if { $string == "" } { 681 continue 682 } 683 array set bounds $string 684 if {![info exists _limits(xmin)] || $_limits(xmin) > $bounds(xmin)} { 685 set _limits(xmin) $bounds(xmin) 686 } 687 if {![info exists _limits(xmax)] || $_limits(xmax) < $bounds(xmax)} { 688 set _limits(xmax) $bounds(xmax) 689 } 690 691 if {![info exists _limits(ymin)] || $_limits(ymin) > $bounds(ymin)} { 692 set _limits(ymin) $bounds(ymin) 693 } 694 if {![info exists _limits(ymax)] || $_limits(ymax) < $bounds(ymax)} { 695 set _limits(ymax) $bounds(ymax) 696 } 697 698 if {![info exists _limits(zmin)] || $_limits(zmin) > $bounds(zmin)} { 699 set _limits(zmin) $bounds(zmin) 700 } 701 if {![info exists _limits(zmax)] || $_limits(zmax) < $bounds(zmax)} { 702 set _limits(zmax) $bounds(zmax) 672 foreach axis { x y z } { 673 set lim [$dataobj limits $axis] 674 if { ![info exists _limits($axis)] } { 675 set _limits($axis) $lim 676 continue 677 } 678 foreach {min max} $lim break 679 foreach {amin amax} $_limits($axis) break 680 if { $amin > $min } { 681 set amin $min 682 } 683 if { $amax < $max } { 684 set amax $max 685 } 686 set _limits($axis) [list $amin $amax] 687 } 688 foreach { fname lim } [$dataobj fieldlimits] { 689 if { ![info exists _limits($fname)] } { 690 set _limits($fname) $lim 691 continue 692 } 693 foreach {min max} $lim break 694 foreach {fmin fmax} $_limits($fname) break 695 if { $fmin > $min } { 696 set fmin $min 697 } 698 if { $fmax < $max } { 699 set fmax $max 700 } 701 set _limits($fname) [list $fmin $fmax] 703 702 } 704 703 } … … 969 968 } 970 969 DoRotate 971 InitSettings axis-xgrid axis-ygrid axis-zgrid axis -mode \972 ax is-visible axis-labels970 InitSettings axis-xgrid axis-ygrid axis-zgrid axisFlyMode \ 971 axesVisible axisLabels 973 972 PanCamera 974 973 } … … 976 975 977 976 SendCmd "imgflush" 978 set _limits(zmin) ""979 set _limits(zmax) ""980 977 set _first "" 981 978 … … 1031 1028 } 1032 1029 } 1033 array unset _scalarFields 1034 array unset _vectorFields 1035 set _currentField [$_first hints default] 1036 $itk_component(field) choices delete 0 end 1037 $itk_component(fieldmenu) delete 0 end 1038 array unset _fields 1039 foreach { name title units } [$_first hints vectors] { 1040 set _vectorFields($title) $name 1041 $itk_component(field) choices insert end "$name" "$title" 1042 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1043 -value $title -variable [itcl::scope _currentField] \ 1044 -selectcolor red \ 1045 -activebackground black \ 1046 -activeforeground white \ 1047 -font "Arial 8" \ 1048 -command [itcl::code $this Combo invoke] 1049 set _fields($name) [list $title $units] 1050 } 1051 foreach { name title units } [$_first hints scalars] { 1052 set _scalarFields($title) $name 1053 $itk_component(field) choices insert end "$name" "$title" 1054 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1055 -value $title -variable [itcl::scope _currentField] \ 1056 -selectcolor red \ 1057 -activebackground black \ 1058 -activeforeground white \ 1059 -font "Arial 8" \ 1060 -command [itcl::code $this Combo invoke] 1061 set _fields($name) [list $title $units] 1062 } 1063 foreach { name title units } { default Default ??? } { 1064 set _scalarFields($title) $name 1065 $itk_component(field) choices insert end "$name" "$title" 1066 $itk_component(fieldmenu) add radiobutton -label "$title" \ 1067 -value $title -variable [itcl::scope _currentField] \ 1068 -selectcolor red \ 1069 -activebackground black \ 1070 -activeforeground white \ 1071 -font "Arial 8" \ 1072 -command [itcl::code $this Combo invoke] 1073 set _fields($name) [list $title $units] 1074 } 1075 $itk_component(field) value $_currentField 1076 } 1077 1078 InitSettings volume-palette volume-material volume-quality volume-visible \ 1079 cutplane-visible \ 1030 $itk_component(field) choices delete 0 end 1031 $itk_component(fieldmenu) delete 0 end 1032 array unset _fields 1033 set _curFldName "" 1034 foreach cname [$_first components] { 1035 foreach fname [$_first fieldnames $cname] { 1036 if { [info exists _fields($fname)] } { 1037 continue 1038 } 1039 foreach { label units components } \ 1040 [$_first fieldinfo $fname] break 1041 $itk_component(field) choices insert end "$fname" "$label" 1042 $itk_component(fieldmenu) add radiobutton -label "$label" \ 1043 -value $label -variable [itcl::scope _curFldLabel] \ 1044 -selectcolor red \ 1045 -activebackground $itk_option(-plotbackground) \ 1046 -activeforeground $itk_option(-plotforeground) \ 1047 -font "Arial 8" \ 1048 -command [itcl::code $this Combo invoke] 1049 set _fields($fname) [list $label $units $components] 1050 if { $_curFldName == "" } { 1051 set _curFldName $fname 1052 set _curFldLabel $label 1053 } 1054 } 1055 } 1056 $itk_component(field) value $_curFldLabel 1057 } 1058 1059 InitSettings volume-palette volume-material volume-quality volumeVisible \ 1060 cutplaneVisible \ 1080 1061 cutplane-xposition cutplane-yposition cutplane-zposition \ 1081 1062 cutplane-xvisible cutplane-yvisible cutplane-zvisible 1082 1063 1083 1064 if { $_reset } { 1084 InitSettings volume -lighting1065 InitSettings volumeLighting 1085 1066 Zoom reset 1086 1067 set _reset 0 … … 1326 1307 } 1327 1308 switch -- $what { 1328 "volume -visible" {1329 set bool $_settings(volume -visible)1309 "volumeVisible" { 1310 set bool $_settings(volumeVisible) 1330 1311 foreach dataset [CurrentDatasets -visible] { 1331 1312 SendCmd "volume visible $bool $dataset" … … 1350 1331 } 1351 1332 } 1352 "volume -lighting" {1353 set bool $_settings(volume -lighting)1333 "volumeLighting" { 1334 set bool $_settings(volumeLighting) 1354 1335 foreach dataset [CurrentDatasets -visible] { 1355 1336 SendCmd "volume lighting $bool $dataset" … … 1363 1344 } 1364 1345 } 1365 "ax is-visible" {1366 set bool $_settings(ax is-visible)1346 "axesVisible" { 1347 set bool $_settings(axesVisible) 1367 1348 SendCmd "axis visible all $bool" 1368 1349 } 1369 "axis -labels" {1370 set bool $_settings(axis -labels)1350 "axisLabels" { 1351 set bool $_settings(axisLabels) 1371 1352 SendCmd "axis labels all $bool" 1372 1353 } … … 1376 1357 SendCmd "axis grid $axis $bool" 1377 1358 } 1378 "axis -mode" {1359 "axisFlyMode" { 1379 1360 set mode [$itk_component(axismode) value] 1380 1361 set mode [$itk_component(axismode) translate $mode] … … 1382 1363 SendCmd "axis flymode $mode" 1383 1364 } 1384 "cutplane -edges" {1365 "cutplaneEdges" { 1385 1366 set bool $_settings($what) 1386 1367 foreach dataset [CurrentDatasets -visible] { … … 1388 1369 } 1389 1370 } 1390 "cutplane -visible" {1371 "cutplaneVisible" { 1391 1372 set bool $_settings($what) 1392 1373 foreach dataset [CurrentDatasets -visible] { … … 1394 1375 } 1395 1376 } 1396 "cutplane -wireframe" {1377 "cutplaneWireframe" { 1397 1378 set bool $_settings($what) 1398 1379 foreach dataset [CurrentDatasets -visible] { … … 1400 1381 } 1401 1382 } 1402 "cutplane -lighting" {1383 "cutplaneLighting" { 1403 1384 set bool $_settings($what) 1404 1385 foreach dataset [CurrentDatasets -visible] { … … 1453 1434 set _legendPending 1 1454 1435 } 1455 "volume-field" { 1456 set new [$itk_component(field) value] 1457 set value [$itk_component(field) translate $new] 1458 set _settings(volume-field) $value 1459 if { [info exists _scalarFields($new)] } { 1460 set name $_scalarFields($new) 1461 set _colorMode scalar 1462 set _currentField $new 1463 } elseif { [info exists _vectorFields($new)] } { 1464 set name $_vectorFields($new) 1465 set _colorMode vmag 1466 set _currentField $new 1436 "field" { 1437 set label [$itk_component(field) value] 1438 set fname [$itk_component(field) translate $label] 1439 set _settings(field) $fname 1440 if { [info exists _fields($fname)] } { 1441 foreach { label units components } $_fields($fname) break 1442 if { $components > 1 } { 1443 set _colorMode vmag 1444 } else { 1445 set _colorMode scalar 1446 } 1447 set _curFldName $fname 1448 set _curFldLabel $label 1467 1449 } else { 1468 puts stderr "unknown field \"$ new\""1450 puts stderr "unknown field \"$fname\"" 1469 1451 return 1470 1452 } 1471 foreach dataset [CurrentDatasets -visible] { 1472 #puts stderr "volume colormode $_colorMode ${name} $dataset" 1473 puts stderr "cutplane colormode $_colorMode ${name} $dataset" 1474 #SendCmd "volume colormode $_colorMode ${name} $dataset" 1475 SendCmd "cutplane colormode $_colorMode ${name} $dataset" 1476 } 1477 set _legendPending 1 1453 # Get the new limits because the field changed. 1454 SendCmd "volume colormode $_colorMode ${name} $dataset" 1455 SendCmd "cutplane colormode $_colorMode ${name} $dataset" 1456 #SendCmd "dataset scalar $_curFldName" 1457 SendCmd "camera reset" 1458 DrawLegend 1478 1459 } 1479 1460 default { … … 1499 1480 return 1500 1481 } 1501 if { [info exists _scalarFields($_currentField)] } {1502 set name $_scalarFields($_currentField)1503 } elseif { [info exists _vectorFields($_currentField)] } {1504 set name $_vectorFields($_currentField)1505 } else {1506 return1507 }1508 1482 # Set the legend on the first volume dataset. 1509 1483 foreach dataset [CurrentDatasets -visible $_first] { … … 1511 1485 if { [info exists _dataset2style($dataset)] } { 1512 1486 SendCmdNoWait \ 1513 "legend $_dataset2style($dataset) $_colorMode $ name {} $w $h 0"1487 "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0" 1514 1488 break; 1515 1489 } … … 1611 1585 } 1612 1586 1613 itcl::body Rappture::VtkVolumeViewer::limits { dataobj } {1614 return1615 array unset _limits $dataobj-*1616 foreach comp [$dataobj components] {1617 set tag $dataobj-$comp1618 if { ![info exists _limits($tag)] } {1619 set data [$dataobj blob $comp]1620 set tmpfile file[pid].vtk1621 set f [open "$tmpfile" "w"]1622 fconfigure $f -translation binary -encoding binary1623 puts $f $data1624 close $f1625 set reader [vtkDataSetReader $tag-xvtkDataSetReader]1626 $reader SetFileName $tmpfile1627 $reader ReadAllScalarsOn1628 $reader ReadAllVectorsOn1629 $reader ReadAllFieldsOn1630 $reader Update1631 set output [$reader GetOutput]1632 set _limits($tag) [$output GetBounds]1633 set pointData [$output GetPointData]1634 puts stderr "\#scalars=[$reader GetNumberOfScalarsInFile]"1635 puts stderr "\#fielddata=[$reader GetNumberOfFieldDataInFile]"1636 puts stderr "fielddataname=[$reader GetFieldDataNameInFile 0]"1637 set fieldData [$output GetFieldData]1638 set pointData [$output GetPointData]1639 puts stderr "field \#arrays=[$fieldData GetNumberOfArrays]"1640 for { set i 0 } { $i < [$fieldData GetNumberOfArrays] } { incr i } {1641 puts stderr [$fieldData GetArrayName $i]1642 }1643 puts stderr "point \#arrays=[$pointData GetNumberOfArrays]"1644 for { set i 0 } { $i < [$pointData GetNumberOfArrays] } { incr i } {1645 set name [$pointData GetArrayName $i]1646 if { ![info exists _fields($name)] } {1647 $itk_component(field) choices insert end "$name" "$name"1648 set _fields($name) 11649 }1650 }1651 puts stderr "field \#components=[$fieldData GetNumberOfComponents]"1652 puts stderr "point \#components=[$pointData GetNumberOfComponents]"1653 puts stderr "field \#tuples=[$fieldData GetNumberOfTuples]"1654 puts stderr "point \#tuples=[$pointData GetNumberOfTuples]"1655 puts stderr "point \#scalars=[$pointData GetScalars]"1656 puts stderr vectors=[$pointData GetVectors]1657 rename $output ""1658 rename $reader ""1659 file delete $tmpfile1660 }1661 foreach { xMin xMax yMin yMax zMin zMax} $_limits($tag) break1662 if {![info exists limits(xmin)] || $limits(xmin) > $xMin} {1663 set limits(xmin) $xMin1664 }1665 if {![info exists limits(xmax)] || $limits(xmax) < $xMax} {1666 set limits(xmax) $xMax1667 }1668 if {![info exists limits(ymin)] || $limits(ymin) > $yMin} {1669 set limits(ymin) $xMin1670 }1671 if {![info exists limits(ymax)] || $limits(ymax) < $yMax} {1672 set limits(ymax) $yMax1673 }1674 if {![info exists limits(zmin)] || $limits(zmin) > $zMin} {1675 set limits(zmin) $zMin1676 }1677 if {![info exists limits(zmax)] || $limits(zmax) < $zMax} {1678 set limits(zmax) $zMax1679 }1680 }1681 return [array get limits]1682 }1683 1684 1587 itcl::body Rappture::VtkVolumeViewer::BuildVolumeTab {} { 1685 1588 … … 1694 1597 checkbutton $inner.volume \ 1695 1598 -text "Show Volume" \ 1696 -variable [itcl::scope _settings(volume -visible)] \1697 -command [itcl::code $this AdjustSetting volume -visible] \1599 -variable [itcl::scope _settings(volumeVisible)] \ 1600 -command [itcl::code $this AdjustSetting volumeVisible] \ 1698 1601 -font "Arial 9" 1699 1602 1700 1603 checkbutton $inner.lighting \ 1701 1604 -text "Enable Lighting" \ 1702 -variable [itcl::scope _settings(volume -lighting)] \1703 -command [itcl::code $this AdjustSetting volume -lighting] \1605 -variable [itcl::scope _settings(volumeLighting)] \ 1606 -command [itcl::code $this AdjustSetting volumeLighting] \ 1704 1607 -font "Arial 9" 1705 1608 … … 1724 1627 -showvalue off -command [itcl::code $this AdjustSetting volume-quality] 1725 1628 1726 label $inner.field_l -text "Field" -font "Arial 9" 1629 itk_component add field_l { 1630 label $inner.field_l -text "Field" -font "Arial 9" 1631 } { 1632 ignore -font 1633 } 1727 1634 itk_component add field { 1728 1635 Rappture::Combobox $inner.field -width 10 -editable no 1729 1636 } 1730 1637 bind $inner.field <<Value>> \ 1731 [itcl::code $this AdjustSetting volume-field]1638 [itcl::code $this AdjustSetting field] 1732 1639 1733 1640 label $inner.palette_l -text "Palette" -font "Arial 9" … … 1758 1665 1759 1666 blt::table $inner \ 1760 0,0 $inner.volume -anchor w -pady 2 -cspan 4 \ 1667 0,0 $inner.field_l -anchor w -pady 2 \ 1668 0,1 $inner.field -anchor w -pady 2 -cspan 2 \ 1669 1,0 $inner.volume -anchor w -pady 2 -cspan 4 \ 1761 1670 2,0 $inner.lighting -anchor w -pady 2 -cspan 4 \ 1762 1671 3,0 $inner.dim_l -anchor e -pady 2 \ … … 1765 1674 4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \ 1766 1675 5,0 $inner.quality -fill x -pady 2 -cspan 2 \ 1767 6,0 $inner.field_l -anchor w -pady 2 \1768 6,1 $inner.field -anchor w -pady 2 -cspan 2 \1769 1676 7,0 $inner.palette_l -anchor w -pady 2 \ 1770 1677 7,1 $inner.palette -anchor w -pady 2 -cspan 2 \ 1771 1678 1772 1679 blt::table configure $inner r* c* -resize none 1773 blt::table configure $inner r8 c3-resize expand1680 blt::table configure $inner r8 -resize expand 1774 1681 } 1775 1682 … … 1786 1693 checkbutton $inner.visible \ 1787 1694 -text "Show Axes" \ 1788 -variable [itcl::scope _settings(ax is-visible)] \1789 -command [itcl::code $this AdjustSetting ax is-visible] \1695 -variable [itcl::scope _settings(axesVisible)] \ 1696 -command [itcl::code $this AdjustSetting axesVisible] \ 1790 1697 -font "Arial 9" 1791 1698 1792 1699 checkbutton $inner.labels \ 1793 1700 -text "Show Axis Labels" \ 1794 -variable [itcl::scope _settings(axis -labels)] \1795 -command [itcl::code $this AdjustSetting axis -labels] \1701 -variable [itcl::scope _settings(axisLabels)] \ 1702 -command [itcl::code $this AdjustSetting axisLabels] \ 1796 1703 -font "Arial 9" 1797 1704 … … 1823 1730 "outer_edges" "outer" 1824 1731 $itk_component(axismode) value "static" 1825 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axis -mode]1732 bind $inner.mode <<Value>> [itcl::code $this AdjustSetting axisFlyMode] 1826 1733 1827 1734 blt::table $inner \ … … 1865 1772 -font "Arial 9" 1866 1773 blt::table $inner \ 1867 $row,0 $inner.ortho -c olumnspan 2 -anchor w -pady 21774 $row,0 $inner.ortho -cspan 2 -anchor w -pady 2 1868 1775 blt::table configure $inner r$row -resize none 1869 1776 incr row … … 1886 1793 checkbutton $inner.visible \ 1887 1794 -text "Show Cutplanes" \ 1888 -variable [itcl::scope _settings(cutplane -visible)] \1889 -command [itcl::code $this AdjustSetting cutplane -visible] \1795 -variable [itcl::scope _settings(cutplaneVisible)] \ 1796 -command [itcl::code $this AdjustSetting cutplaneVisible] \ 1890 1797 -font "Arial 9" 1891 1798 1892 1799 checkbutton $inner.wireframe \ 1893 1800 -text "Show Wireframe" \ 1894 -variable [itcl::scope _settings(cutplane -wireframe)] \1895 -command [itcl::code $this AdjustSetting cutplane -wireframe] \1801 -variable [itcl::scope _settings(cutplaneWireframe)] \ 1802 -command [itcl::code $this AdjustSetting cutplaneWireframe] \ 1896 1803 -font "Arial 9" 1897 1804 1898 1805 checkbutton $inner.lighting \ 1899 1806 -text "Enable Lighting" \ 1900 -variable [itcl::scope _settings(cutplane -lighting)] \1901 -command [itcl::code $this AdjustSetting cutplane -lighting] \1807 -variable [itcl::scope _settings(cutplaneLighting)] \ 1808 -command [itcl::code $this AdjustSetting cutplaneLighting] \ 1902 1809 -font "Arial 9" 1903 1810 1904 1811 checkbutton $inner.edges \ 1905 1812 -text "Show Edges" \ 1906 -variable [itcl::scope _settings(cutplane -edges)] \1907 -command [itcl::code $this AdjustSetting cutplane -edges] \1813 -variable [itcl::scope _settings(cutplaneEdges)] \ 1814 -command [itcl::code $this AdjustSetting cutplaneEdges] \ 1908 1815 -font "Arial 9" 1909 1816 … … 2171 2078 2172 2079 SendCmd "volume lighting $settings(-lighting) $tag" 2173 set _settings(volume -lighting) $settings(-lighting)2080 set _settings(volumeLighting) $settings(-lighting) 2174 2081 SetColormap $dataobj $comp 2175 2082 } … … 2192 2099 set _legendPending 0 2193 2100 puts stderr "ReceiveLegend colormap=$colormap title=$title range=$vmin,$vmax size=$size" 2194 set _limits(vmin) $vmin2195 set _limits(vmax) $vmax2196 set _title $title2197 regsub {\(mag\)} $title "" _title2198 2101 if { [IsConnected] } { 2199 2102 set bytes [ReceiveBytes $size] … … 2203 2106 $_image(legend) configure -data $bytes 2204 2107 #puts stderr "read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 2205 if { [catch {DrawLegend $_title} errs] != 0 } {2108 if { [catch {DrawLegend} errs] != 0 } { 2206 2109 puts stderr errs=$errs 2207 2110 } … … 2215 2118 # of the contour plot area. 2216 2119 # 2217 itcl::body Rappture::VtkVolumeViewer::DrawLegend { name } { 2120 itcl::body Rappture::VtkVolumeViewer::DrawLegend { } { 2121 set fname $_curFldName 2218 2122 set c $itk_component(view) 2219 2123 set w [winfo width $c] … … 2222 2126 set lineht [font metrics $font -linespace] 2223 2127 2224 if { [info exists _fields($ name)] } {2225 foreach { title units } $_fields($ name) break2128 if { [info exists _fields($fname)] } { 2129 foreach { title units } $_fields($fname) break 2226 2130 if { $units != "" } { 2227 2131 set title [format "%s (%s)" $title $units] 2228 2132 } 2229 2133 } else { 2230 set title $ name2231 } 2232 if { $_settings(legend -visible) } {2134 set title $fname 2135 } 2136 if { $_settings(legendVisible) } { 2233 2137 set x [expr $w - 2] 2234 2138 if { [$c find withtag "legend"] == "" } { … … 2260 2164 # Reset the item coordinates according the current size of the plot. 2261 2165 $c itemconfigure title -text $title 2262 if { $_limits(vmin) != "" } { 2263 $c itemconfigure vmin -text [format %g $_limits(vmin)] 2264 } 2265 if { $_limits(vmax) != "" } { 2266 $c itemconfigure vmax -text [format %g $_limits(vmax)] 2166 if { [info exists _limits($_curFldName)] } { 2167 foreach { vmin vmax } $_limits($_curFldName) break 2168 $c itemconfigure vmin -text [format %g $vmin] 2169 $c itemconfigure vmax -text [format %g $vmax] 2267 2170 } 2268 2171 set y 2 … … 2337 2240 2338 2241 # Compute the value of the point 2339 if { [info exists _limits(vmax)] && [info exists _limits(vmin)] } { 2242 if { [info exists _limits($_curFldName)] } { 2243 foreach { vmin vmax } $_limits($_curFldName) break 2340 2244 set t [expr 1.0 - (double($imgY) / double($imgHeight-1))] 2341 set value [expr $t * ($ _limits(vmax) - $_limits(vmin)) + $_limits(vmin)]2245 set value [expr $t * ($vmax - $vmin) + $vmin] 2342 2246 } else { 2343 2247 set value 0.0 … … 2411 2315 } 2412 2316 invoke { 2413 $itk_component(field) value $_currentField2414 AdjustSetting volume-field2317 $itk_component(field) value _curFldLabel 2318 AdjustSetting field 2415 2319 } 2416 2320 default {
Note: See TracChangeset
for help on using the changeset viewer.