Changeset 4774
- Timestamp:
- Nov 23, 2014, 8:59:51 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/vtkvolumeviewer.tcl
r4768 r4774 61 61 } 62 62 public method scale {args} 63 64 private method GetDatasetsWithComponent { cname } 65 66 private variable _volcomponents ; # Array of components found 67 private variable _componentsList ; # List of component names 63 68 64 69 # The following methods are only used by this class. … … 146 151 private variable _curFldName "" 147 152 private variable _curFldLabel "" 148 private variable _colorMode " vmag";# Mode of colormap (vmag or scalar)153 private variable _colorMode "scalar"; # Mode of colormap (vmag or scalar) 149 154 private variable _cutplaneCmd "cutplane" 155 private variable _allowMultiComponent 0 150 156 } 151 157 … … 222 228 -axisminorticks 1 223 229 -background black 230 -color BCGYR 224 231 -cutplanelighting 1 225 232 -cutplaneopacity 100 … … 642 649 # ---------------------------------------------------------------------- 643 650 itcl::body Rappture::VtkVolumeViewer::scale {args} { 651 array unset _limits 652 array unset _volcomponents 653 set _componentsList "" 654 644 655 foreach dataobj $args { 645 656 if { ![$dataobj isvalid] } { 646 657 continue; # Object doesn't contain valid data. 647 658 } 659 # Determine limits for each axis. 648 660 foreach axis { x y z } { 649 661 set lim [$dataobj limits $axis] … … 662 674 set _limits($axis) [list $amin $amax] 663 675 } 676 # Determine limits for each field. 664 677 foreach { fname lim } [$dataobj fieldlimits] { 665 678 if { ![info exists _limits($fname)] } { … … 676 689 } 677 690 set _limits($fname) [list $fmin $fmax] 691 } 692 # Get limits for each component. 693 foreach cname [$dataobj components] { 694 if { ![info exists _volcomponents($cname)] } { 695 lappend _componentsList $cname 696 } 697 lappend _volcomponents($cname) $dataobj-$cname 698 array unset limits 699 array set limits [$dataobj valueLimits $cname] 700 if { ![info exists _limits($cname)] } { 701 set _limits($cname) $limits(v) 702 continue 703 } 704 foreach {min max} $limits(v) break 705 foreach {vmin vmax} $_limits($cname) break 706 if { $vmin > $min } { 707 set vmin $min 708 } 709 if { $vmax < $max } { 710 set vmax $max 711 } 712 set _limits($cname) [list $vmin $vmax] 678 713 } 679 714 } … … 1031 1066 [$_first fieldinfo $fname] break 1032 1067 # Only scalar fields are valid 1033 if {$ components == 1} {1068 if {$_allowMultiComponent || $components == 1} { 1034 1069 $itk_component(field) choices insert end "$fname" "$label" 1035 1070 $itk_component(fieldmenu) add radiobutton -label "$label" \ … … 1051 1086 } 1052 1087 1053 InitSettings - volumepalette\1088 InitSettings -color \ 1054 1089 -volumematerial \ 1055 1090 -volumelighting -volumeopacity -volumequality -volumeoutline -volumevisible \ … … 1442 1477 set _cutplanePending 0 1443 1478 } 1444 "- volumepalette" {1445 set palette [$itk_component(palette) value]1446 set _settings($what) $ palette1479 "-color" { 1480 set color [$itk_component(colormap) value] 1481 set _settings($what) $color 1447 1482 foreach dataset [CurrentDatasets -visible $_first] { 1448 1483 foreach {dataobj comp} [split $dataset -] break 1449 ChangeColormap $dataobj $comp $ palette1484 ChangeColormap $dataobj $comp $color 1450 1485 } 1451 1486 set _legendPending 1 … … 1457 1492 if { [info exists _fields($fname)] } { 1458 1493 foreach { label units components } $_fields($fname) break 1459 if { $components > 1 } {1494 if { !$_allowMultiComponent && $components > 1 } { 1460 1495 puts stderr "Can't use a vector field in a volume" 1461 1496 return 1462 1497 } else { 1463 set _colorMode scalar 1498 if { $components > 1 } { 1499 set _colorMode vmag 1500 } else { 1501 set _colorMode scalar 1502 } 1464 1503 } 1465 1504 set _curFldName $fname … … 1470 1509 } 1471 1510 foreach dataset [CurrentDatasets -visible $_first] { 1472 #SendCmd " volume colormode $_colorMode ${fname}$dataset"1473 SendCmd " $_cutplaneCmd colormode $_colorMode ${fname}$dataset"1511 #SendCmd "$_cutplaneCmd colormode $_colorMode $_curFldName $dataset" 1512 SendCmd "dataset scalar $_curFldName $dataset" 1474 1513 } 1475 1514 SendCmd "camera reset" … … 1503 1542 if { [info exists _dataset2style($dataset)] } { 1504 1543 SendCmdNoWait \ 1505 "legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0" 1544 "legend2 $_dataset2style($dataset) $w $h" 1545 #"legend $_dataset2style($dataset) $_colorMode $_curFldName {} $w $h 0" 1506 1546 break; 1507 1547 } … … 1709 1749 [itcl::code $this AdjustSetting -field] 1710 1750 1711 label $inner. palette_l -text "Palette" -font $font1712 itk_component add palette{1713 Rappture::Combobox $inner. palette-editable no1714 } 1715 $inner. palettechoices insert end [GetColormapList]1716 $itk_component(palette) value "BCGYR"1717 bind $inner.palette <<Value>> \1718 [itcl::code $this AdjustSetting -volumepalette]1751 label $inner.colormap_l -text "Colormap" -font $font 1752 itk_component add colormap { 1753 Rappture::Combobox $inner.colormap -editable no 1754 } 1755 $inner.colormap choices insert end [GetColormapList] 1756 bind $inner.colormap <<Value>> \ 1757 [itcl::code $this AdjustSetting -color] 1758 $itk_component(colormap) value $_settings(-color) 1719 1759 1720 1760 blt::table $inner \ … … 1730 1770 6,0 $inner.quality_l -anchor w -pady 2 -cspan 4 \ 1731 1771 7,0 $inner.quality -fill x -pady 2 -cspan 4 \ 1732 8,0 $inner. palette_l -anchor w -pady 2 \1733 8,1 $inner. palette-fill x -pady 2 -cspan 3 \1772 8,0 $inner.colormap_l -anchor w -pady 2 \ 1773 8,1 $inner.colormap -fill x -pady 2 -cspan 3 \ 1734 1774 1735 1775 blt::table configure $inner r* c0 c1 c3 -resize none … … 2376 2416 set _view(-zoom) 1.0 2377 2417 } 2418 2419 # 2420 # GetDatasetsWithComponents -- 2421 # 2422 # Returns a list of all the datasets (known by the combination of 2423 # their data object and component name) that match the given 2424 # component name. For example, this is used where we want to change 2425 # the settings of volumes that have the current component. 2426 # 2427 itcl::body Rappture::VtkVolumeViewer::GetDatasetsWithComponent { cname } { 2428 if { ![info exists _volcomponents($cname)] } { 2429 return "" 2430 } 2431 return $_volcomponents($cname) 2432 }
Note: See TracChangeset
for help on using the changeset viewer.