Changeset 4504 for branches/1.3/gui/scripts
- Timestamp:
- Jul 16, 2014, 12:21:36 PM (10 years ago)
- Location:
- branches/1.3/gui/scripts
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/Makefile.in
r4482 r4504 111 111 $(srcdir)/tool.tcl \ 112 112 $(srcdir)/tooltip.tcl \ 113 $(srcdir)/transferfunctioneditor.tcl \ 113 114 $(srcdir)/tuples.tcl \ 114 115 $(srcdir)/unirect2d.tcl \ -
branches/1.3/gui/scripts/cloud.tcl
r4474 r4504 149 149 foreach {x y z} $line break 150 150 foreach axis {x y z} units $_units { 151 set value [Rappture::Units::convert [set $axis] \ 151 if { $units == "" } { 152 set value [set $axis] 153 } else { 154 set value [Rappture::Units::convert [set $axis] \ 152 155 -context $units -to $units -units off] 156 } 153 157 set $axis $value; # Set the (x/y/z) coordinate to 154 158 # converted value. -
branches/1.3/gui/scripts/field.tcl
r4494 r4504 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 2 # ---------------------------------------------------------------------- 4 3 # COMPONENT: field - extracts data from an XML description of a field … … 82 81 # valid data. 83 82 private variable _isValidComponent; # Array of valid components found 83 private variable _alwaysConvertDX 0; 84 84 85 constructor {xmlobj path} { 85 86 # defined below … … 88 89 # defined below 89 90 } 90 public method blob { cname } 91 public method blob { cname } 91 92 public method components {args} 92 93 public method controls {option args} … … 94 95 public method numComponents {cname} 95 96 public method fieldlimits {} 97 public method valueLimits { cname } 96 98 public method flowhints { cname } 97 99 public method hints {{key ""}} … … 150 152 151 153 private method AvsToVtk { cname contents } 154 private method DicomToVtk { cname contents } 152 155 private method BuildPointsOnMesh { cname } 153 156 protected method GetAssociation { cname } … … 318 321 } 319 322 if {[info exists _comp2dx($cname)]} { 320 return "" ;# no mesh -- it's embedded in the blobdata323 return "" ;# no mesh -- it's embedded in the value data 321 324 } 322 325 if {[info exists _comp2mesh($cname)]} { … … 362 365 } 363 366 if {[info exists _comp2dx($cname)]} { 364 error "method \"values\" is not implemented for dx filedata"367 error "method \"values\" is not implemented for dx data" 365 368 } 366 369 if {[info exists _comp2unirect2d($cname)]} { … … 389 392 } 390 393 if {[info exists _comp2dx($cname)]} { 391 return $_comp2dx($cname) ;# return gzipped, base64-encoded DX data394 return $_comp2dx($cname) 392 395 } 393 396 if {[info exists _comp2unirect2d($cname)]} { … … 400 403 } 401 404 error "can't get field blob: Unknown component \"$cname\": should be one of [join [lsort [array names _comp2dims]] {, }]" 405 } 406 407 itcl::body Rappture::Field::valueLimits { cname } { 408 if { [info exists _comp2limits($cname)] } { 409 return $_comp2limits($cname) 410 } 411 return "" 402 412 } 403 413 … … 520 530 return [list $min $max] 521 531 } 532 522 533 523 534 # ---------------------------------------------------------------------- … … 789 800 } elseif {[$_field element $cname.ucd] != ""} { 790 801 set type "ucd" 802 } elseif {[$_field element $cname.dicom] != ""} { 803 set type "dicom" 791 804 } 792 805 set _comp2style($cname) "" … … 894 907 set _dim 3 895 908 set _comp2dims($cname) "3D" 896 if { $_viewer != "nanovis" && $_viewer != "flowvis" } { 897 set vtkdata [$_field get -decode yes $cname.$type] 898 if { $vtkdata == "" } { 899 puts stderr "WARNING: No data for \"$_path.$cname.$type\"" 900 continue; # Ignore this component 901 } 902 if 0 { 903 set f [open /tmp/$_path.$cname.dx "w"] 904 puts -nonewline $f $vtkdata 905 close $f 906 } 907 set vtkdata [Rappture::DxToVtk $vtkdata] 908 if 0 { 909 set f [open /tmp/$_path.$cname.vtk "w"] 910 puts -nonewline $f $vtkdata 911 close $f 912 } 909 set data [$_field get -decode no $cname.$type] 910 set contents [Rappture::encoding::decode -as zb64 $data] 911 if { $contents == "" } { 912 puts stderr "WARNING: No data for \"$_path.$cname.$type\"" 913 continue; # Ignore this component 914 } 915 set vector "" 916 if 0 { 917 set f [open /tmp/$_path.$cname.dx "w"] 918 puts -nonewline $f $contents 919 close $f 920 } 921 # This is temporary. I put a check for this in the DxToVtk 922 # parser. 923 if { [string range $contents 0 3] == "<DX>" } { 924 set contents [string range $contents 4 end] 925 } 926 if { [catch { Rappture::DxToVtk $contents } vtkdata] == 0 } { 913 927 ReadVtkDataSet $cname $vtkdata 928 } else { 929 puts stderr "Can't parse dx data: $vtkdata" 930 } 931 if 0 { 932 set f [open /tmp/$_path.$cname.vtk "w"] 933 puts -nonewline $f $vtkdata 934 close $f 935 } 936 if { $_alwaysConvertDX || 937 ($_viewer != "nanovis" && $_viewer != "flowvis") } { 914 938 set _type "vtk" 915 939 set _comp2vtk($cname) $vtkdata 916 940 } else { 917 set contents [$_field get -decode no $cname.$type]918 if { $contents == "" } {919 puts stderr "WARNING: No data for \"$_path.$cname.$type\""920 continue; # Ignore this component921 }922 941 set _type "dx" 923 set _comp2dx($cname) $ contents942 set _comp2dx($cname) $data 924 943 } 925 944 set _comp2style($cname) [$_field get $cname.style] … … 928 947 [Rappture::FlowHints ::\#auto $_field $cname $_units] 929 948 } 949 set _dim 3 950 incr _counter 951 } elseif { $type == "dicom"} { 952 set contents [$_field get $cname.dicom] 953 if { $contents == "" } { 954 continue; # Ignore this component 955 } 956 set viewer [$_field get "about.view"] 957 if { $viewer != "" } { 958 set _viewer $viewer 959 } 960 set vtkdata [DicomToVtk $cname $contents] 961 if { $_viewer == "" } { 962 set _viewer [expr {($_dim == 3) ? "vtkvolume" : "vtkimage"}] 963 } 964 set _comp2vtk($cname) $vtkdata 965 set _comp2style($cname) [$_field get $cname.style] 930 966 incr _counter 931 967 } elseif { $type == "ucd"} { … … 941 977 } 942 978 set _isValidComponent($cname) 1 979 #puts stderr "Field $cname type is: $_type" 943 980 } 944 981 if { [array size _isValidComponent] == 0 } { … … 1508 1545 # sort x-coords in increasing order 1509 1546 $xv sort $yv 1510 1511 1547 set _comp2dims($cname) "1D" 1512 1548 set _comp2xy($cname) [list $xv $yv] … … 1641 1677 file delete $tmpfile 1642 1678 return $vtkdata 1679 } 1680 1681 itcl::body Rappture::Field::DicomToVtk { cname path } { 1682 package require vtk 1683 1684 if { ![file exists $path] } { 1685 puts stderr "path \"$path\" doesn't exist." 1686 return 0 1687 } 1688 1689 if { [file isdir $path] } { 1690 set files [glob -nocomplain $path/*.dcm] 1691 if { [llength $files] == 0 } { 1692 set files [glob -nocomplain $path/*] 1693 if { [llength $files] == 0 } { 1694 puts stderr "no dicom files found in \"$path\"" 1695 return 0 1696 } 1697 } 1698 1699 #array set data [Rappture::DicomToVtk files $files] 1700 array set data [Rappture::DicomToVtk dir $path] 1701 } else { 1702 array set data [Rappture::DicomToVtk files [list $path]] 1703 } 1704 1705 foreach key [array names data] { 1706 if {$key == "vtkdata"} { 1707 if {1} { 1708 set f [open /tmp/$cname.vtk "w"] 1709 fconfigure $f -translation binary -encoding binary 1710 puts -nonewline $f $data(vtkdata) 1711 close $f 1712 } 1713 } else { 1714 puts stderr "$key = \"$data($key)\"" 1715 } 1716 } 1717 1718 # Save viewer choice 1719 set viewer $_viewer 1720 ReadVtkDataSet $cname $data(vtkdata) 1721 # Restore viewer choice (ReadVtkDataSet wants to set it to contour/isosurface) 1722 set _viewer $viewer 1723 return $data(vtkdata) 1643 1724 } 1644 1725 -
branches/1.3/gui/scripts/fieldresult.tcl
r4481 r4504 156 156 # ---------------------------------------------------------------------- 157 157 itcl::body Rappture::FieldResult::add {dataobj {settings ""}} { 158 if { ![info exists itk_component(renderer)] } { 159 puts stderr "add: no renderer created." 160 return 161 } 158 162 eval $itk_component(renderer) add $dataobj [list $settings] 159 163 } … … 166 170 # ---------------------------------------------------------------------- 167 171 itcl::body Rappture::FieldResult::get {} { 172 if { ![info exists itk_component(renderer)] } { 173 puts stderr "get: no renderer created." 174 return 175 } 168 176 return [$itk_component(renderer) get] 169 177 } … … 191 199 # ---------------------------------------------------------------------- 192 200 itcl::body Rappture::FieldResult::scale {args} { 201 if { ![info exists itk_component(renderer)] } { 202 puts stderr "scale: no renderer created." 203 return 204 } 193 205 eval $itk_component(renderer) scale $args 194 206 } … … 205 217 # ---------------------------------------------------------------------- 206 218 itcl::body Rappture::FieldResult::download {option args} { 219 if { ![info exists itk_component(renderer)] } { 220 puts stderr "download: no renderer created." 221 return 222 } 207 223 eval $itk_component(renderer) download $option $args 208 224 } 209 225 210 226 itcl::body Rappture::FieldResult::snap { w h } { 227 if { ![info exists itk_component(renderer)] } { 228 puts stderr "snap: no renderer created." 229 return 230 } 211 231 return [$itk_component(renderer) snap $w $h] 212 232 } -
branches/1.3/gui/scripts/nanovisviewer.tcl
r4500 r4504 1 1 # -*- mode: tcl; indent-tabs-mode: nil -*- 2 3 2 # ---------------------------------------------------------------------- 4 3 # COMPONENT: nanovisviewer - 3D volume rendering … … 76 75 public method isconnected {} 77 76 public method limits { tf } 78 public method overmarker { m x }79 77 public method parameters {title args} { 80 78 # do nothing 81 79 } 82 public method rmdupmarker { m x }83 80 public method scale {args} 84 public method updatetransferfuncs {} 85 86 protected method Connect {} 87 protected method CurrentDatasets {{what -all}} 88 protected method Disconnect {} 89 protected method DoResize {} 90 protected method FixLegend {} 91 protected method AdjustSetting {what {value ""}} 92 protected method InitSettings { args } 93 protected method Pan {option x y} 94 protected method Rebuild {} 95 protected method ReceiveData { args } 96 protected method ReceiveImage { args } 97 protected method ReceiveLegend { tf vmin vmax size } 98 protected method Rotate {option x y} 99 protected method SendTransferFuncs {} 100 protected method Slice {option args} 101 protected method SlicerTip {axis} 102 protected method Zoom {option} 81 public method updateTransferFunctions {} 103 82 104 83 # The following methods are only used by this class. 105 private method AddIsoMarker { x y } 84 85 private method AddNewMarker { x y } 86 private method AdjustSetting {what {value ""}} 106 87 private method BuildCameraTab {} 107 88 private method BuildCutplanesTab {} 108 89 private method BuildViewTab {} 90 private method BuildVolumeComponents {} 109 91 private method BuildVolumeTab {} 110 private method ResetColormap { color } 111 private method ComputeTransferFunc { tf } 92 private method ComputeAlphamap { cname } 93 private method ComputeTransferFunction { cname } 94 private method Connect {} 95 private method CurrentDatasets {{what -all}} 96 private method Disconnect {} 97 private method DoResize {} 98 private method DrawLegend { cname } 99 private method EventuallyRedrawLegend { } 112 100 private method EventuallyResize { w h } 113 private method EventuallyResizeLegend { } 114 private method NameTransferFunc { dataobj comp } 101 private method FixLegend {} 102 private method GetAlphamap { cname color } 103 private method GetColormap { cname color } 104 private method GetDatasetsWithComponent { cname } 105 private method GetVolumeInfo { w } 106 private method HideAllMarkers {} 107 private method InitComponentSettings { cname } 108 private method InitSettings { args } 109 private method NameToAlphamap { name } 110 private method NameTransferFunction { dataobj comp } 111 private method Pan {option x y} 115 112 private method PanCamera {} 116 private method ParseLevelsOption { tf levels } 117 private method ParseMarkersOption { tf markers } 118 private method volume { tag name } 119 private method GetVolumeInfo { w } 113 private method ParseLevelsOption { cname levels } 114 private method ParseMarkersOption { cname markers } 115 private method Rebuild {} 116 private method ReceiveData { args } 117 private method ReceiveImage { args } 118 private method ReceiveLegend { tf vmin vmax size } 119 private method RemoveMarker { x y } 120 private method ResetColormap { cname color } 121 private method Rotate {option x y} 122 private method SendTransferFunctions {} 120 123 private method SetOrientation { side } 124 private method Slice {option args} 125 private method SlicerTip {axis} 126 private method SwitchComponent { cname } 127 private method ToggleVolume { tag name } 128 private method Zoom {option} 129 private method ViewToQuaternion {} { 130 return [list $_view(-qw) $_view(-qx) $_view(-qy) $_view(-qz)] 131 } 121 132 122 133 private variable _arcball "" 123 134 124 135 private variable _dlist "" ;# list of data objects 125 private variable _allDataObjs126 136 private variable _obj2ovride ;# maps dataobj => style override 127 137 private variable _serverDatasets ;# contains all the dataobj-component 128 138 ;# to volumes in the server 129 private variable _serverTfs ;# contains all the transfer functions 130 ;# in the server. 131 private variable _recvdDatasets ;# list of data objs to send to server 132 private variable _dataset2style ;# maps dataobj-component to transfunc 133 private variable _style2datasets ;# maps tf back to list of 134 # dataobj-components using the tf. 135 136 private variable _reset 1; # Connection to server has been reset 137 private variable _click ;# info used for rotate operations 138 private variable _limits ;# autoscale min/max for all axes 139 private variable _view ;# view params for 3D view 140 private variable _isomarkers ;# array of isosurface level values 0..1 139 private variable _recvdDatasets; # list of data objs to send to server 140 private variable _dataset2style; # maps dataobj-component to transfunc 141 private variable _style2datasets; # maps tf back to list of 142 # dataobj-components using the tf. 143 144 private variable _reset 1; # Connection to server has been reset. 145 private variable _click; # Info used for rotate operations. 146 private variable _limits; # Autoscale min/max for all axes 147 private variable _view; # View params for 3D view 148 private variable _parsedFunction 149 private variable _transferFunctionEditors 141 150 private variable _settings 142 # Array of transfer functions in server. If 0 the transfer has been143 # defined but not loaded. If 1 the transfer function has been named144 # and loaded.145 private variable _activeTfs146 private variable _first "" ;# This is the topmost volume.147 151 private variable _alphamap 148 149 # This 150 # indicates which isomarkers and transfer 151 # function to use when changing markers, 152 # opacity, or thickness. 152 private variable _widget 153 154 private variable _first "" ; # This is the topmost volume. 155 private variable _current ""; # Currently selected component 156 private variable _volcomponents ; # Array of components found 157 private variable _componentsList ; # Array of components found 158 private variable _cname2style 159 private variable _cname2transferFunction 160 private variable _cname2defaultcolormap 161 private variable _cname2defaultalphamap 162 153 163 common _downloadPopup ;# download options from popup 154 164 private common _hardcopy … … 177 187 $_dispatcher register !send_transfunc 178 188 $_dispatcher dispatch $this !send_transfunc \ 179 "[itcl::code $this SendTransferFunc s]; list"189 "[itcl::code $this SendTransferFunctions]; list" 180 190 181 191 # Rebuild event … … 196 206 # Initialize the view to some default parameters. 197 207 array set _view { 198 qw 0.853553199 qx -0.353553200 qy 0.353553201 qz 0.146447202 zoom 1.0203 xpan 0204 ypan0208 -qw 0.853553 209 -qx -0.353553 210 -qy 0.353553 211 -qz 0.146447 212 -xpan 0 213 -ypan 0 214 -zoom 1.0 205 215 } 206 216 set _arcball [blt::arcball create 100 100] 207 set q [list $_view(qw) $_view(qx) $_view(qy) $_view(qz)] 208 $_arcball quaternion $q 209 210 set _limits(vmin) 0.0 211 set _limits(vmax) 1.0 217 $_arcball quaternion [ViewToQuaternion] 218 219 set _limits(v) [list 0.0 1.0] 212 220 set _reset 1 213 221 214 array set _settings [subst { 215 $this-qw $_view(qw) 216 $this-qx $_view(qx) 217 $this-qy $_view(qy) 218 $this-qz $_view(qz) 219 $this-zoom $_view(zoom) 220 $this-xpan $_view(xpan) 221 $this-ypan $_view(ypan) 222 $this-volume 1 223 $this-xcutplane 0 224 $this-xcutposition 0 225 $this-ycutplane 0 226 $this-ycutposition 0 227 $this-zcutplane 0 228 $this-zcutposition 0 229 }] 230 222 array set _settings { 223 -axesvisible 1 224 -colormap default 225 -cutplanesvisible 0 226 -gridvisible 0 227 -isosurfaceshading 0 228 -legendvisible 1 229 -light2side 1 230 -outlinevisible 0 231 -qw 0.853553 232 -qx -0.353553 233 -qy 0.353553 234 -qz 0.146447 235 -thickness 350 236 -volume 1 237 -volumeopacity 0.5 238 -volumevisible 1 239 -xcutplaneposition 50 240 -xcutplanevisible 1 241 -xpan 0 242 -ycutplaneposition 50 243 -ycutplanevisible 1 244 -ypan 0 245 -zcutplaneposition 50 246 -zcutplanevisible 1 247 -zoom 1.0 248 } 249 array set _widget { 250 -volumeopacity 50 251 } 231 252 itk_component add 3dview { 232 253 label $itk_component(plotarea).view -image $_image(plot) \ … … 249 270 } 250 271 pack $itk_component(reset) -side top -padx 2 -pady 2 251 Rappture::Tooltip::for $itk_component(reset) "Reset the view to the default zoom level" 272 Rappture::Tooltip::for $itk_component(reset) \ 273 "Reset the view to the default zoom level" 252 274 253 275 itk_component add zoomin { … … 279 301 -onimage [Rappture::icon volume-on] \ 280 302 -offimage [Rappture::icon volume-off] \ 281 -command [itcl::code $this AdjustSetting volume] \282 -variable [itcl::scope _settings( $this-volume)]303 -command [itcl::code $this AdjustSetting -volume] \ 304 -variable [itcl::scope _settings(-volume)] 283 305 } 284 306 $itk_component(volume) select … … 286 308 "Toggle the volume cloud on/off" 287 309 pack $itk_component(volume) -padx 2 -pady 2 310 311 itk_component add cutplane { 312 Rappture::PushButton $f.cutplane \ 313 -onimage [Rappture::icon cutbutton] \ 314 -offimage [Rappture::icon cutbutton] \ 315 -variable [itcl::scope _settings(-cutplanesvisible)] \ 316 -command [itcl::code $this AdjustSetting -cutplanesvisible] 317 } 318 Rappture::Tooltip::for $itk_component(cutplane) \ 319 "Show/Hide cutplanes" 320 pack $itk_component(cutplane) -padx 2 -pady 2 288 321 289 322 if { [catch { … … 298 331 299 332 # Legend 300 301 333 set _image(legend) [image create photo] 302 334 itk_component add legend { … … 308 340 } 309 341 bind $itk_component(legend) <Configure> \ 310 [itcl::code $this EventuallyResizeLegend] 342 [itcl::code $this EventuallyRedrawLegend] 343 bind $itk_component(legend) <KeyPress-Delete> \ 344 [itcl::code $this RemoveMarker %x %y] 345 bind $itk_component(legend) <Enter> \ 346 [list focus $itk_component(legend)] 311 347 312 348 # Hack around the Tk panewindow. The problem is that the requested … … 387 423 image delete $_image(legend) 388 424 image delete $_image(download) 425 foreach name [array names _transferFunctionEditors] { 426 itcl::delete object $_transferFunctionEditors($cname) 427 } 389 428 catch { blt::arcball destroy $_arcball } 390 array unset _settings $this-*429 array unset _settings 391 430 } 392 431 … … 420 459 if {$pos < 0} { 421 460 lappend _dlist $dataobj 422 set _allDataObjs($dataobj) 1423 461 set _obj2ovride($dataobj-color) $params(-color) 424 462 set _obj2ovride($dataobj-width) $params(-width) … … 497 535 if { $pos >= 0 } { 498 536 set _dlist [lreplace $_dlist $pos $pos] 499 array unset _limits $dataobj*500 537 array unset _obj2ovride $dataobj-* 538 array unset _dataset2style $dataobj-* 501 539 set changed 1 502 540 } … … 518 556 # ---------------------------------------------------------------------- 519 557 itcl::body Rappture::NanovisViewer::scale {args} { 520 foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} { 521 set _limits($val) "" 522 } 558 array set styles { 559 -color BCGYR 560 -levels 6 561 -markers "" 562 } 563 array unset _limits 564 array unset _volcomponents 523 565 foreach dataobj $args { 524 566 if { ![$dataobj isvalid] } { 525 567 continue; # Object doesn't contain valid data. 526 568 } 569 foreach cname [$dataobj components] { 570 if { ![info exists _volcomponents($cname)] } { 571 lappend _componentsList $cname 572 array set styles [lindex [$dataobj components -style $cname] 0] 573 set cmap [ColorsToColormap $styles(-color)] 574 set _cname2defaultcolormap($cname) $cmap 575 set _settings($cname-colormap) $styles(-color) 576 } 577 lappend _volcomponents($cname) $dataobj-$cname 578 array unset limits 579 array set limits [$dataobj valueLimits $cname] 580 set _limits($cname) $limits(v) 581 } 527 582 foreach axis {x y z v} { 528 583 foreach { min max } [$dataobj limits $axis] break 529 584 if {"" != $min && "" != $max} { 530 if {"" == $_limits(${axis}min)} { 531 set _limits(${axis}min) $min 532 set _limits(${axis}max) $max 585 if { ![info exists _limits($axis)] } { 586 set _limits($axis) [list $min $max] 533 587 } else { 534 if {$min < $_limits(${axis}min)} { 535 set _limits(${axis}min) $min 588 foreach {amin amax} $_limits($axis) break 589 if {$min < $amin} { 590 set amin $min 536 591 } 537 if {$max > $ _limits(${axis}max)} {538 set _limits(${axis}max)$max592 if {$max > $amax} { 593 set amax $max 539 594 } 595 set _limits($axis) [list $amin $amax] 540 596 } 541 597 } 542 598 } 543 599 } 600 BuildVolumeComponents 544 601 } 545 602 … … 660 717 661 718 # ---------------------------------------------------------------------- 662 # USAGE: SendTransferFuncs 663 # ---------------------------------------------------------------------- 664 itcl::body Rappture::NanovisViewer::SendTransferFuncs {} { 665 if { $_first == "" } { 666 puts stderr "first not set" 667 return 668 } 669 # Ensure that the global opacity and thickness settings (in the slider 670 # settings widgets) are used for the active transfer-function. Update 671 # the values in the _settings varible. 672 set opacity [expr { double($_settings($this-opacity)) * 0.01 }] 673 # Scale values between 0.00001 and 0.01000 674 set thickness [expr {double($_settings($this-thickness)) * 0.0001}] 675 676 foreach tag [CurrentDatasets] { 677 if { ![info exists _serverDatasets($tag)] || !$_serverDatasets($tag) } { 678 # The volume hasn't reached the server yet. How did we get 679 # here? 680 puts stderr "Don't have $tag in _serverDatasets" 681 continue 682 } 683 if { ![info exists _dataset2style($tag)] } { 684 puts stderr "don't have style for volume $tag" 685 continue; # How does this happen? 686 } 687 set tf $_dataset2style($tag) 688 set _settings($this-$tf-opacity) $opacity 689 set _settings($this-$tf-thickness) $thickness 690 ComputeTransferFunc $tf 691 # FIXME: Need to the send information as to what transfer functions 692 # to update so that we only update the transfer function 693 # as necessary. Right now, all transfer functions are 694 # updated. This makes moving the isomarker slider chunky. 695 if { ![info exists _activeTfs($tf)] || !$_activeTfs($tf) } { 696 set _activeTfs($tf) 1 697 } 698 SendCmd "volume shading transfunc $tf $tag" 719 # USAGE: SendTransferFunctions 720 # ---------------------------------------------------------------------- 721 itcl::body Rappture::NanovisViewer::SendTransferFunctions {} { 722 foreach cname [array names _volcomponents] { 723 ComputeTransferFunction $cname 699 724 } 700 725 FixLegend … … 727 752 728 753 # 729 # ReceiveLegend -- 730 # 731 # The procedure is the response from the render server to each "legend" 732 # command. The server sends back a "legend" command invoked our 733 # the slave interpreter. The purpose is to collect data of the image 734 # representing the legend in the canvas. In addition, the isomarkers 735 # of the active transfer function are displayed. 736 # 737 # I don't know is this is the right place to display the isomarkers. 738 # I don't know all the different paths used to draw the plot. There's 739 # "Rebuild", "add", etc. 740 # 741 itcl::body Rappture::NanovisViewer::ReceiveLegend { tf vmin vmax size } { 742 if { ![isconnected] } { 743 return 744 } 745 set bytes [ReceiveBytes $size] 746 $_image(legend) configure -data $bytes 747 ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 754 # DrawLegend -- 755 # 756 itcl::body Rappture::NanovisViewer::DrawLegend { cname } { 748 757 set c $itk_component(legend) 749 758 set w [winfo width $c] … … 751 760 set lx 10 752 761 set ly [expr {$h - 1}] 753 if {"" == [$c find withtag transfunc]} {762 if {"" == [$c find withtag colorbar]} { 754 763 $c create image 10 10 -anchor nw \ 755 -image $_image(legend) -tags transfunc764 -image $_image(legend) -tags colorbar 756 765 $c create text $lx $ly -anchor sw \ 757 -fill $itk_option(-plotforeground) -tags "limits vmin"766 -fill $itk_option(-plotforeground) -tags "limits text vmin" 758 767 $c create text [expr {$w-$lx}] $ly -anchor se \ 759 -fill $itk_option(-plotforeground) -tags "limits vmax" 760 $c lower transfunc 761 $c bind transfunc <ButtonRelease-1> \ 762 [itcl::code $this AddIsoMarker %x %y] 763 } 764 # Display the markers used by the active transfer function. 765 766 array set limits [limits $tf] 767 $c itemconfigure vmin -text [format %g $limits(min)] 768 -fill $itk_option(-plotforeground) -tags "limits text vmax" 769 $c create text [expr {$w/2}] $ly -anchor s \ 770 -fill $itk_option(-plotforeground) -tags "limits text title" 771 $c lower colorbar 772 $c bind colorbar <ButtonRelease-1> [itcl::code $this AddNewMarker %x %y] 773 } 774 775 # Display the markers used by the current transfer function. 776 HideAllMarkers 777 $_transferFunctionEditors($cname) showMarkers $_limits($cname) 778 779 foreach {min max} $_limits($cname) break 780 $c itemconfigure vmin -text [format %g $min] 768 781 $c coords vmin $lx $ly 769 782 770 $c itemconfigure vmax -text [format %g $ limits(max)]783 $c itemconfigure vmax -text [format %g $max] 771 784 $c coords vmax [expr {$w-$lx}] $ly 772 785 773 if { [info exists _isomarkers($tf)] } { 774 foreach m $_isomarkers($tf) { 775 $m visible yes 776 } 777 } 786 set title [$_first hints label] 787 set units [$_first hints units] 788 if { $units != "" } { 789 set title "$title ($units)" 790 } 791 $c itemconfigure title -text $title 792 $c coords title [expr {$w/2}] $ly 778 793 779 794 # The colormap may have changed. Resync the slicers with the colormap. 780 795 set datasets [CurrentDatasets -cutplanes] 781 SendCmd "volume data state $_settings($this-volume) $datasets"782 796 783 797 # Adjust the cutplane for only the first component in the topmost volume … … 787 801 # Turn off cutplanes for all volumes 788 802 SendCmd "cutplane state 0 $axis" 789 if { $_settings( $this-${axis}cutplane) } {803 if { $_settings(-${axis}cutplanevisible) } { 790 804 # Turn on cutplane for this particular volume and set the position 791 805 SendCmd "cutplane state 1 $axis $tag" 792 set pos [expr {0.01*$_settings( $this-${axis}cutposition)}]806 set pos [expr {0.01*$_settings(-${axis}cutplaneposition)}] 793 807 SendCmd "cutplane position $pos $axis $tag" 794 808 } 795 809 } 810 } 811 812 # 813 # 814 # ReceiveLegend -- 815 # 816 # The procedure is the response from the render server to each "legend" 817 # command. The server sends back a "legend" command invoked our 818 # the slave interpreter. The purpose is to collect data of the image 819 # representing the legend in the canvas. In addition, the 820 # active transfer function is displayed. 821 # 822 # 823 itcl::body Rappture::NanovisViewer::ReceiveLegend { cname vmin vmax size } { 824 if { ![isconnected] } { 825 return 826 } 827 set bytes [ReceiveBytes $size] 828 $_image(legend) configure -data $bytes 829 ReceiveEcho <<line "<read $size bytes for [image width $_image(legend)]x[image height $_image(legend)] legend>" 830 831 DrawLegend $_current 796 832 } 797 833 … … 833 869 set dataobj [lindex $parts 0] 834 870 set _serverDatasets($tag) 1 835 if { $_settings( $this-volume) && $dataobj == $_first } {871 if { $_settings(-volumevisible) && $dataobj == $_first } { 836 872 SendCmd "volume state 1 $tag" 837 873 } 838 set _limits($tag-min) $info(min); # Minimum value of the volume. 839 set _limits($tag-max) $info(max); # Maximum value of the volume. 840 set _limits(vmin) $info(vmin); # Overall minimum value. 841 set _limits(vmax) $info(vmax); # Overall maximum value. 874 set _limits($tag) [list $info(min) $info(max)] 875 set _limits(v) [list $info(vmin) $info(vmax)] 842 876 843 877 unset _recvdDatasets($tag) 844 878 if { [array size _recvdDatasets] == 0 } { 845 # The active transfer function is by default the first component of 846 # the first data object. This assumes that the data is always 847 # successfully transferred. 848 updatetransferfuncs 879 updateTransferFunctions 849 880 } 850 881 } … … 869 900 # generates a new call to Rebuild). 870 901 StartBufferingCommands 871 872 # Hide all the isomarkers. Can't remove them. Have to remember the873 # settings since the user may have created/deleted/moved markers.874 875 foreach tf [array names _isomarkers] {876 foreach m $_isomarkers($tf) {877 $m visible no878 }879 }880 902 881 903 if { $_width != $w || $_height != $h || $_reset } { … … 895 917 } 896 918 set data [$dataobj blob $cname] 919 if 0 { 920 set f [open "/tmp/values-$cname.txt" "w"] 921 puts $f [$dataobj values $cname] 922 close $f 923 } 897 924 } else { 898 925 set data [$dataobj vtkdata $cname] … … 920 947 set _serverDatasets($tag) 0 921 948 } 922 NameTransferFunc $dataobj $cname949 NameTransferFunction $dataobj $cname 923 950 } 924 951 } … … 928 955 # Reset the camera and other view parameters 929 956 # 930 set _settings( $this-qw) $_view(qw)931 set _settings( $this-qx) $_view(qx)932 set _settings( $this-qy) $_view(qy)933 set _settings( $this-qz) $_view(qz)934 set _settings( $this-xpan) $_view(xpan)935 set _settings( $this-ypan) $_view(ypan)936 set _settings( $this-zoom) $_view(zoom)937 938 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]957 set _settings(-qw) $_view(-qw) 958 set _settings(-qx) $_view(-qx) 959 set _settings(-qy) $_view(-qy) 960 set _settings(-qz) $_view(-qz) 961 set _settings(-xpan) $_view(-xpan) 962 set _settings(-ypan) $_view(-ypan) 963 set _settings(-zoom) $_view(-zoom) 964 965 set q [ViewToQuaternion] 939 966 $_arcball quaternion $q 940 967 SendCmd "camera orient $q" 941 968 SendCmd "camera reset" 942 969 PanCamera 943 SendCmd "camera zoom $_view(zoom)" 944 InitSettings light2side light transp isosurface grid axes 970 SendCmd "camera zoom $_view(-zoom)" 945 971 972 #cutplane state 0 all 946 973 foreach axis {x y z} { 947 974 # Turn off cutplanes for all volumes 948 975 SendCmd "cutplane state 0 $axis" 949 976 } 977 978 InitSettings -light2side -light -volumeopacity \ 979 -isosurfaceshading -gridvisible -axesvisible \ 980 -current 981 950 982 if {"" != $_first} { 951 983 set axis [$_first hints updir] … … 960 992 } 961 993 # Outline seems to need to be reset every update. 962 InitSettings outline994 InitSettings -outlinevisible -cutplanesvisible 963 995 # nothing to send -- activate the proper ivol 964 996 SendCmd "volume state 0" … … 972 1004 set cname [lindex [$_first components] 0] 973 1005 if { [info exists _serverDatasets($_first-$cname)] } { 974 update transferfuncs1006 updateTransferFunctions 975 1007 } 976 1008 } … … 1021 1053 switch -- $option { 1022 1054 "in" { 1023 set _view( zoom) [expr {$_view(zoom)*1.25}]1024 set _settings( $this-zoom) $_view(zoom)1025 SendCmd "camera zoom $_view( zoom)"1055 set _view(-zoom) [expr {$_view(-zoom)*1.25}] 1056 set _settings(-zoom) $_view(-zoom) 1057 SendCmd "camera zoom $_view(-zoom)" 1026 1058 } 1027 1059 "out" { 1028 set _view( zoom) [expr {$_view(zoom)*0.8}]1029 set _settings( $this-zoom) $_view(zoom)1030 SendCmd "camera zoom $_view( zoom)"1060 set _view(-zoom) [expr {$_view(-zoom)*0.8}] 1061 set _settings(-zoom) $_view(-zoom) 1062 SendCmd "camera zoom $_view(-zoom)" 1031 1063 } 1032 1064 "reset" { 1033 1065 array set _view { 1034 qw 0.8535531035 qx -0.3535531036 qy 0.3535531037 qz 0.1464471038 zoom 1.01039 xpan01040 ypan01066 -qw 0.853553 1067 -qx -0.353553 1068 -qy 0.353553 1069 -qz 0.146447 1070 -xpan 0 1071 -ypan 0 1072 -zoom 1.0 1041 1073 } 1042 1074 if { $_first != "" } { … … 1046 1078 } 1047 1079 } 1048 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1080 set q [ViewToQuaternion] 1049 1081 $_arcball quaternion $q 1050 1082 SendCmd "camera orient $q" 1051 1083 SendCmd "camera reset" 1052 set _settings( $this-qw) $_view(qw)1053 set _settings( $this-qx) $_view(qx)1054 set _settings( $this-qy) $_view(qy)1055 set _settings( $this-qz) $_view(qz)1056 set _settings( $this-xpan) $_view(xpan)1057 set _settings( $this-ypan) $_view(ypan)1058 set _settings( $this-zoom) $_view(zoom)1084 set _settings(-qw) $_view(-qw) 1085 set _settings(-qx) $_view(-qx) 1086 set _settings(-qy) $_view(-qy) 1087 set _settings(-qz) $_view(-qz) 1088 set _settings(-xpan) $_view(-xpan) 1089 set _settings(-ypan) $_view(-ypan) 1090 set _settings(-zoom) $_view(-zoom) 1059 1091 } 1060 1092 } … … 1062 1094 1063 1095 itcl::body Rappture::NanovisViewer::PanCamera {} { 1064 #set x [expr ($_view(xpan)) / $_limits(xrange)] 1065 #set y [expr ($_view(ypan)) / $_limits(yrange)] 1066 set x $_view(xpan) 1067 set y $_view(ypan) 1096 set x $_view(-xpan) 1097 set y $_view(-ypan) 1068 1098 SendCmd "camera pan $x $y" 1069 1099 } … … 1104 1134 1105 1135 set q [$_arcball rotate $x $y $_click(x) $_click(y)] 1106 foreach { _view( qw) _view(qx) _view(qy) _view(qz) } $q break1107 set _settings( $this-qw) $_view(qw)1108 set _settings( $this-qx) $_view(qx)1109 set _settings( $this-qy) $_view(qy)1110 set _settings( $this-qz) $_view(qz)1136 foreach { _view(-qw) _view(-qx) _view(-qy) _view(-qz) } $q break 1137 set _settings(-qw) $_view(-qw) 1138 set _settings(-qx) $_view(-qx) 1139 set _settings(-qy) $_view(-qy) 1140 set _settings(-qz) $_view(-qz) 1111 1141 SendCmd "camera orient $q" 1112 1142 … … 1141 1171 set x [expr $x / double($w)] 1142 1172 set y [expr $y / double($h)] 1143 set _view( xpan) [expr $_view(xpan) + $x]1144 set _view( ypan) [expr $_view(ypan) + $y]1173 set _view(-xpan) [expr $_view(-xpan) + $x] 1174 set _view(-ypan) [expr $_view(-ypan) + $y] 1145 1175 PanCamera 1146 set _settings( $this-xpan) $_view(xpan)1147 set _settings( $this-ypan) $_view(ypan)1176 set _settings(-xpan) $_view(-xpan) 1177 set _settings(-ypan) $_view(-ypan) 1148 1178 return 1149 1179 } … … 1158 1188 set _click(x) $x 1159 1189 set _click(y) $y 1160 set _view( xpan) [expr $_view(xpan) - $dx]1161 set _view( ypan) [expr $_view(ypan) - $dy]1190 set _view(-xpan) [expr $_view(-xpan) - $dx] 1191 set _view(-ypan) [expr $_view(-ypan) - $dy] 1162 1192 PanCamera 1163 set _settings( $this-xpan) $_view(xpan)1164 set _settings( $this-ypan) $_view(ypan)1193 set _settings(-xpan) $_view(-xpan) 1194 set _settings(-ypan) $_view(-ypan) 1165 1195 } 1166 1196 if { $option == "release" } { … … 1194 1224 } 1195 1225 switch -- $what { 1196 light { 1197 set val $_settings($this-light) 1226 "-axesvisible" { 1227 SendCmd "axis visible $_settings($what)" 1228 } 1229 "-colormap" { 1230 set color [$itk_component(colormap) value] 1231 set _settings($what) $color 1232 set _settings($_current${what}) $color 1233 ResetColormap $_current $color 1234 } 1235 "-current" { 1236 set cname [$itk_component(volcomponents) value] 1237 SwitchComponent $cname 1238 } 1239 "-cutplanesvisible" { 1240 set bool $_settings($what) 1241 set datasets [CurrentDatasets -cutplanes] 1242 set tag [lindex $datasets 0] 1243 SendCmd "cutplane visible $bool $tag" 1244 } 1245 "-gridvisible" { 1246 SendCmd "grid visible $_settings($what)" 1247 } 1248 "-isosurfaceshading" { 1249 SendCmd "volume shading isosurface $_settings($what)" 1250 } 1251 "-legendvisible" { 1252 if { $_settings($what) } { 1253 blt::table $itk_component(plotarea) \ 1254 0,0 $itk_component(3dview) -fill both \ 1255 1,0 $itk_component(legend) -fill x 1256 blt::table configure $itk_component(plotarea) r1 -resize none 1257 } else { 1258 blt::table forget $itk_component(legend) 1259 } 1260 } 1261 "-light" { 1262 set val $_settings($what) 1198 1263 set diffuse [expr {0.01*$val}] 1199 1264 set ambient [expr {1.0-$diffuse}] … … 1205 1270 SendCmd "volume shading specularExp $specularExp" 1206 1271 } 1207 light2side{1208 set val $_settings($ this-light2side)1272 "-light2side" { 1273 set val $_settings($what) 1209 1274 SendCmd "volume shading light2side $val" 1210 1275 } 1211 transp { 1212 set val $_settings($this-transp) 1213 set sval [expr { 0.01 * double($val) }] 1214 SendCmd "volume shading opacity $sval" 1215 } 1216 opacity { 1217 set val $_settings($this-opacity) 1218 set sval [expr { 0.01 * double($val) }] 1219 foreach tf [array names _activeTfs] { 1220 set _settings($this-$tf-opacity) $sval 1221 set _activeTfs($tf) 0 1222 } 1223 updatetransferfuncs 1224 } 1225 thickness { 1226 if { [array names _activeTfs] > 0 } { 1227 set val $_settings($this-thickness) 1228 # Scale values between 0.00001 and 0.01000 1229 set sval [expr {0.0001*double($val)}] 1230 foreach tf [array names _activeTfs] { 1231 set _settings($this-$tf-thickness) $sval 1232 set _activeTfs($tf) 0 1233 } 1234 updatetransferfuncs 1235 } 1236 } 1237 "outline" { 1238 SendCmd "volume outline state $_settings($this-outline)" 1239 } 1240 "isosurface" { 1241 SendCmd "volume shading isosurface $_settings($this-isosurface)" 1242 } 1243 "colormap" { 1244 set color [$itk_component(colormap) value] 1245 set _settings(colormap) $color 1246 # Only set the colormap on the first volume. Ignore the others. 1247 #ResetColormap $color 1248 } 1249 "grid" { 1250 SendCmd "grid visible $_settings($this-grid)" 1251 } 1252 "axes" { 1253 SendCmd "axis visible $_settings($this-axes)" 1254 } 1255 "legend" { 1256 if { $_settings($this-legend) } { 1257 blt::table $itk_component(plotarea) \ 1258 0,0 $itk_component(3dview) -fill both \ 1259 1,0 $itk_component(legend) -fill x 1260 blt::table configure $itk_component(plotarea) r1 -resize none 1261 } else { 1262 blt::table forget $itk_component(legend) 1263 } 1264 } 1265 "volume" { 1266 set datasets [CurrentDatasets -cutplanes] 1267 SendCmd "volume data state $_settings($this-volume) $datasets" 1268 } 1269 "xcutplane" - "ycutplane" - "zcutplane" { 1270 set axis [string range $what 0 0] 1271 set bool $_settings($this-$what) 1276 "-volumeopacity" { 1277 set _settings($what) [expr $_widget($what) * 0.01] 1278 set _settings($_current${what}) $_settings($what) 1279 foreach tag [GetDatasetsWithComponent $_current] { 1280 SendCmd "volume shading opacity $_settings($what) $tag" 1281 } 1282 #updateTransferFunctions 1283 } 1284 "-outlinevisible" { 1285 SendCmd "volume outline state $_settings($what)" 1286 } 1287 "-thickness" { 1288 set val $_settings($what) 1289 set _settings($_current${what}) $val 1290 updateTransferFunctions 1291 } 1292 "-volume" { 1293 # This is the global volume visibility control. It controls the 1294 # visibility of all the all volumes. Whenever it's changed, you 1295 # have to synchronize each of the local controls (see below) with 1296 # this. 1297 set datasets [CurrentDatasets] 1298 set bool $_settings($what) 1299 SendCmd "volume data state $bool $datasets" 1300 foreach cname $_componentsList { 1301 set _settings($cname-volumevisible) $bool 1302 } 1303 set _settings(-volumevisible) $bool 1304 } 1305 "-volumevisible" { 1306 # This is the component specific control. It changes the 1307 # visibility of only the current component. 1308 set _settings($_current${what}) $_settings($what) 1309 foreach tag [GetDatasetsWithComponent $_current] { 1310 SendCmd "volume data state $_settings($what) $tag" 1311 } 1312 } 1313 "-xcutplanevisible" - "-ycutplanevisible" - "-zcutplanevisible" { 1314 set axis [string range $what 1 1] 1315 set bool $_settings($what) 1272 1316 set datasets [CurrentDatasets -cutplanes] 1273 1317 set tag [lindex $datasets 0] … … 1299 1343 set w [expr {$_width-20}] 1300 1344 set h [expr {[winfo height $itk_component(legend)]-20-$lineht}] 1301 if {$w > 0 && $h > 0 && [array names _activeTfs] > 0 && $_first != "" } { 1302 set tag [lindex [CurrentDatasets] 0] 1303 if { [info exists _dataset2style($tag)] } { 1304 SendCmd "legend $_dataset2style($tag) $w $h" 1305 } 1306 } else { 1307 # Can't do this as this will remove the items associated with the 1308 # isomarkers. 1309 1310 #$itk_component(legend) delete all 1311 } 1312 } 1313 1314 # 1315 # NameTransferFunc -- 1345 if {$w > 0 && $h > 0 && $_first != "" } { 1346 if { [info exists _cname2transferFunction($_current)] } { 1347 SendCmd "legend $_current $w $h" 1348 } 1349 } 1350 } 1351 1352 # 1353 # NameTransferFunction -- 1316 1354 # 1317 1355 # Creates a transfer function name based on the <style> settings in the … … 1321 1359 # server parses the 3D data and sends back the limits via ReceiveData.] 1322 1360 # 1323 # FIXME: The current way we generate transfer-function names completely 1324 # ignores the -markers option. The problem is that we are forced 1325 # to compute the name from an increasing complex set of values: 1326 # color, levels, marker, opacity. I think we're stuck doing it 1327 # now. 1328 # 1329 itcl::body Rappture::NanovisViewer::NameTransferFunc { dataobj cname } { 1361 itcl::body Rappture::NanovisViewer::NameTransferFunction { dataobj cname } { 1330 1362 array set styles { 1331 1363 -color BCGYR 1332 1364 -levels 6 1333 -opacity 1.01334 1365 -markers "" 1335 1366 } 1336 1367 set tag $dataobj-$cname 1337 1368 array set styles [lindex [$dataobj components -style $cname] 0] 1338 set tf "$styles(-color):$styles(-levels):$styles(-opacity)" 1339 set _dataset2style($tag) $tf 1340 lappend _style2datasets($tf) $tag 1341 return $tf 1342 } 1343 1344 # 1345 # ComputeTransferFunc -- 1346 # 1347 # Computes and sends the transfer function to the render server. It's 1348 # assumed that the volume data limits are known and that the global 1349 # transfer-functions slider values have been set up. Both parts are 1350 # needed to compute the relative value (location) of the marker, and 1351 # the alpha map of the transfer function. 1352 # 1353 itcl::body Rappture::NanovisViewer::ComputeTransferFunc { tf } { 1354 array set styles { 1355 -color BCGYR 1356 -levels 6 1357 -opacity 1.0 1358 -markers "" 1359 -alphamap "" 1360 } 1361 1362 foreach {dataobj cname} [split [lindex $_style2datasets($tf) 0] -] break 1363 array set styles [lindex [$dataobj components -style $cname] 0] 1369 if { ![info exists _cname2transferFunction($cname)] } { 1370 # Get the colormap right now, since it doesn't change with marker 1371 # changes. 1372 set cmap [ColorsToColormap $styles(-color)] 1373 set wmap [list 0.0 0.0 1.0 1.0] 1374 set _cname2transferFunction($cname) [list $cmap $wmap] 1375 SendCmd [list transfunc define $cname $cmap $wmap] 1376 } 1377 SendCmd "volume shading transfunc $cname $tag" 1378 if { ![info exists _transferFunctionEditors($cname)] } { 1379 set _transferFunctionEditors($cname) \ 1380 [Rappture::TransferFunctionEditor ::\#auto $itk_component(legend) \ 1381 $cname \ 1382 -command [itcl::code $this updateTransferFunctions]] 1383 } 1384 set _dataset2style($tag) $cname 1385 lappend _style2datasets($cname) $tag 1386 return $cname 1387 } 1388 1389 # 1390 # ComputeTransferFunction -- 1391 # 1392 # Computes and sends the transfer function to the render server. It's 1393 # assumed that the volume data limits are known and that the global 1394 # transfer-functions slider values have been set up. Both parts are 1395 # needed to compute the relative value (location) of the marker, and 1396 # the alpha map of the transfer function. 1397 # 1398 itcl::body Rappture::NanovisViewer::ComputeTransferFunction { cname } { 1399 foreach {cmap wmap} $_cname2transferFunction($cname) break 1364 1400 1365 1401 # We have to parse the style attributes for a volume using this … … 1369 1405 # of the volumes (the first in the list) using the transfer-function as a 1370 1406 # reference. 1371 # 1372 # FIXME: The current way we generate transfer-function names completely 1373 # ignores the -markers option. The problem is that we are forced 1374 # to compute the name from an increasing complex set of values: 1375 # color, levels, marker, opacity. I think the cow's out of the 1376 # barn on this one. 1377 1378 if { ![info exists _isomarkers($tf)] } { 1407 if { ![info exists _parsedFunction($cname)] } { 1408 array set styles { 1409 -color BCGYR 1410 -levels 6 1411 -markers "" 1412 } 1413 # Accumulate the style from all the datasets using it. 1414 foreach tag [GetDatasetsWithComponent $cname] { 1415 foreach {dataobj cname} [split [lindex $tag 0] -] break 1416 array set styles [lindex [$dataobj components -style $cname] 0] 1417 } 1418 eval $_transferFunctionEditors($cname) limits $_limits($cname) 1379 1419 # Have to defer creation of isomarkers until we have data limits 1380 1420 if { [info exists styles(-markers)] && 1381 1421 [llength $styles(-markers)] > 0 } { 1382 ParseMarkersOption $ tf$styles(-markers)1422 ParseMarkersOption $cname $styles(-markers) 1383 1423 } else { 1384 ParseLevelsOption $tf $styles(-levels) 1385 } 1386 if { $styles(-alphamap) != "" } { 1387 set _alphamap($cname) $styles(-alphamap) 1388 } 1389 } 1390 set cmap [ColorsToColormap $styles(-color)] 1391 set tag $this-$tf 1392 if { ![info exists _settings($tag-opacity)] } { 1393 set _settings($tag-opacity) $styles(-opacity) 1394 } 1395 set max 1.0 ;#$_settings($tag-opacity) 1396 1397 set isovalues {} 1398 foreach m $_isomarkers($tf) { 1399 lappend isovalues [$m relval] 1400 } 1401 # Sort the isovalues 1402 set isovalues [lsort -real $isovalues] 1403 1404 if { ![info exists _settings($tag-thickness)]} { 1405 set _settings($tag-thickness) 0.005 1406 } 1407 set delta $_settings($tag-thickness) 1408 1409 set first [lindex $isovalues 0] 1410 set last [lindex $isovalues end] 1411 set wmap "" 1412 if { $first == "" || $first != 0.0 } { 1413 lappend wmap 0.0 0.0 1414 } 1415 foreach x $isovalues { 1416 set x1 [expr {$x-$delta-0.00001}] 1417 set x2 [expr {$x-$delta}] 1418 set x3 [expr {$x+$delta}] 1419 set x4 [expr {$x+$delta+0.00001}] 1420 if { $x1 < 0.0 } { 1421 set x1 0.0 1422 } elseif { $x1 > 1.0 } { 1423 set x1 1.0 1424 } 1425 if { $x2 < 0.0 } { 1426 set x2 0.0 1427 } elseif { $x2 > 1.0 } { 1428 set x2 1.0 1429 } 1430 if { $x3 < 0.0 } { 1431 set x3 0.0 1432 } elseif { $x3 > 1.0 } { 1433 set x3 1.0 1434 } 1435 if { $x4 < 0.0 } { 1436 set x4 0.0 1437 } elseif { $x4 > 1.0 } { 1438 set x4 1.0 1439 } 1440 # add spikes in the middle 1441 lappend wmap $x1 0.0 1442 lappend wmap $x2 $max 1443 lappend wmap $x3 $max 1444 lappend wmap $x4 0.0 1445 } 1446 if { $last == "" || $last != 1.0 } { 1447 lappend wmap 1.0 0.0 1448 } 1449 if { [info exists _alphamap($cname)] } { 1450 set wmap $_alphamap($cname) 1451 } 1452 SendCmd [list transfunc define $tf $cmap $wmap] 1424 ParseLevelsOption $cname $styles(-levels) 1425 } 1426 1427 } 1428 set wmap [ComputeAlphamap $cname] 1429 set _cname2transferFunction($cname) [list $cmap $wmap] 1430 SendCmd [list transfunc define $cname $cmap $wmap] 1431 } 1432 1433 itcl::body Rappture::NanovisViewer::AddNewMarker { x y } { 1434 if { ![info exists _transferFunctionEditors($_current)] } { 1435 continue 1436 } 1437 # Add a new marker to the current transfer function 1438 $_transferFunctionEditors($_current) newMarker $x $y normal 1439 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) 1440 } 1441 1442 itcl::body Rappture::NanovisViewer::RemoveMarker { x y } { 1443 if { ![info exists _transferFunctionEditors($_current)] } { 1444 continue 1445 } 1446 # Add a new marker to the current transfer function 1447 $_transferFunctionEditors($_current) deleteMarker $x $y 1453 1448 } 1454 1449 … … 1498 1493 # marker is a relative value from 0.0 to 1.0. 1499 1494 # 1500 itcl::body Rappture::NanovisViewer::ParseLevelsOption { tflevels } {1495 itcl::body Rappture::NanovisViewer::ParseLevelsOption { cname levels } { 1501 1496 set c $itk_component(legend) 1497 set list {} 1502 1498 regsub -all "," $levels " " levels 1503 1499 if {[string is int $levels]} { 1504 1500 for {set i 1} { $i <= $levels } {incr i} { 1505 set x [expr {double($i)/($levels+1)}] 1506 set m [Rappture::IsoMarker \#auto $c $this $tf] 1507 $m relval $x 1508 lappend _isomarkers($tf) $m 1501 lappend list [expr {double($i)/($levels+1)}] 1509 1502 } 1510 1503 } else { 1511 1504 foreach x $levels { 1512 set m [Rappture::IsoMarker \#auto $c $this $tf] 1513 $m relval $x 1514 lappend _isomarkers($tf) $m 1515 } 1516 } 1505 lappend list $x 1506 } 1507 } 1508 set _parsedFunction($cname) 1 1509 $_transferFunctionEditors($cname) addMarkers $list 1510 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) 1517 1511 } 1518 1512 … … 1529 1523 # not be seen. 1530 1524 # 1531 itcl::body Rappture::NanovisViewer::ParseMarkersOption { tfmarkers } {1525 itcl::body Rappture::NanovisViewer::ParseMarkersOption { cname markers } { 1532 1526 set c $itk_component(legend) 1527 set list {} 1528 foreach { min max } $_limits($cname) break 1533 1529 regsub -all "," $markers " " markers 1534 1530 foreach marker $markers { 1535 1531 set n [scan $marker "%g%s" value suffix] 1536 1532 if { $n == 2 && $suffix == "%" } { 1537 # ${n}% : Set relative value. 1538 set value [expr {$value * 0.01}] 1539 set m [Rappture::IsoMarker \#auto $c $this $tf] 1540 $m relval $value 1541 lappend _isomarkers($tf) $m 1533 # $n% : Set relative value (0..1). 1534 lappend list [expr {$value * 0.01}] 1542 1535 } else { 1543 # ${n} : Set absolute value. 1544 set m [Rappture::IsoMarker \#auto $c $this $tf] 1545 $m absval $value 1546 lappend _isomarkers($tf) $m 1547 } 1548 } 1536 # $n : absolute value, compute relative 1537 lappend list [expr {(double($value)-$min)/($max-$min)]} 1538 } 1539 } 1540 set _parsedFunction($cname) 1 1541 $_transferFunctionEditors($cname) addMarkers $list 1542 $itk_component(legend) itemconfigure labels -fill $itk_option(-plotforeground) 1549 1543 } 1550 1544 … … 1552 1546 # USAGE: UndateTransferFuncs 1553 1547 # ---------------------------------------------------------------------- 1554 itcl::body Rappture::NanovisViewer::update transferfuncs {} {1548 itcl::body Rappture::NanovisViewer::updateTransferFunctions {} { 1555 1549 $_dispatcher event -idle !send_transfunc 1556 1550 } 1557 1551 1558 itcl::body Rappture::NanovisViewer::AddIsoMarker { x y } { 1559 if { $_first == "" } { 1560 error "active transfer function isn't set" 1561 } 1562 set tag [lindex [CurrentDatasets] 0] 1563 set tf $_dataset2style($tag) 1564 set c $itk_component(legend) 1565 set m [Rappture::IsoMarker \#auto $c $this $tf] 1566 set w [winfo width $c] 1567 $m relval [expr {double($x-10)/($w-20)}] 1568 lappend _isomarkers($tf) $m 1569 updatetransferfuncs 1570 return 1 1571 } 1572 1573 itcl::body Rappture::NanovisViewer::rmdupmarker { marker x } { 1574 set tf [$marker transferfunc] 1575 set bool 0 1576 if { [info exists _isomarkers($tf)] } { 1577 set list {} 1578 set marker [namespace tail $marker] 1579 foreach m $_isomarkers($tf) { 1580 set sx [$m screenpos] 1581 if { $m != $marker } { 1582 if { $x >= ($sx-3) && $x <= ($sx+3) } { 1583 $marker relval [$m relval] 1584 itcl::delete object $m 1585 bell 1586 set bool 1 1587 continue 1588 } 1589 } 1590 lappend list $m 1591 } 1592 set _isomarkers($tf) $list 1593 updatetransferfuncs 1594 } 1595 return $bool 1596 } 1597 1598 itcl::body Rappture::NanovisViewer::overmarker { marker x } { 1599 set tf [$marker transferfunc] 1600 if { [info exists _isomarkers($tf)] } { 1601 set marker [namespace tail $marker] 1602 foreach m $_isomarkers($tf) { 1603 set sx [$m screenpos] 1604 if { $m != $marker } { 1605 set bool [expr { $x >= ($sx-3) && $x <= ($sx+3) }] 1606 $m activate $bool 1607 } 1608 } 1609 } 1610 return "" 1611 } 1612 1613 itcl::body Rappture::NanovisViewer::limits { tf } { 1552 itcl::body Rappture::NanovisViewer::limits { cname } { 1614 1553 set _limits(min) 0.0 1615 1554 set _limits(max) 1.0 1616 if { ![info exists _style2datasets($ tf)] } {1555 if { ![info exists _style2datasets($cname)] } { 1617 1556 return [array get _limits] 1618 1557 } 1619 1558 set min ""; set max "" 1620 foreach tag $_style2datasets($tf){1621 if { ![info exists _ serverDatasets($tag)] } {1559 foreach tag [GetDatasetsWithComponent $cname] { 1560 if { ![info exists _limits($tag)] } { 1622 1561 continue 1623 1562 } 1624 if { ![info exists _limits($tag-min)] } { 1625 continue 1626 } 1627 if { $min == "" || $min > $_limits($tag-min) } { 1628 set min $_limits($tag-min) 1629 } 1630 if { $max == "" || $max < $_limits($tag-max) } { 1631 set max $_limits($tag-max) 1563 foreach {amin amax} $_limits($tag) break 1564 if { $min == "" || $min > $amin } { 1565 set min $amin 1566 } 1567 if { $max == "" || $max < $amax } { 1568 set max $amax 1632 1569 } 1633 1570 } … … 1638 1575 set _limits(max) $max 1639 1576 } 1640 return [ array get _limits]1577 return [list $_limits(min) $_limits(max)] 1641 1578 } 1642 1579 1643 1580 1644 1581 itcl::body Rappture::NanovisViewer::BuildViewTab {} { 1645 foreach { key value } {1646 grid 01647 axes 11648 outline 01649 volume 11650 legend 11651 particles 11652 lic 11653 } {1654 set _settings($this-$key) $value1655 }1656 1657 1582 set fg [option get $itk_component(hull) font Font] 1658 1583 #set bfg [option get $itk_component(hull) boldFont Font] … … 1663 1588 $inner configure -borderwidth 4 1664 1589 1665 set ::Rappture::NanovisViewer::_settings( $this-isosurface) 01590 set ::Rappture::NanovisViewer::_settings(-isosurfaceshading) 0 1666 1591 checkbutton $inner.isosurface \ 1667 1592 -text "Isosurface shading" \ 1668 -variable [itcl::scope _settings( $this-isosurface)] \1669 -command [itcl::code $this AdjustSetting isosurface] \1593 -variable [itcl::scope _settings(-isosurfaceshading)] \ 1594 -command [itcl::code $this AdjustSetting -isosurfaceshading] \ 1670 1595 -font "Arial 9" 1671 1596 1672 1597 checkbutton $inner.axes \ 1673 1598 -text "Axes" \ 1674 -variable [itcl::scope _settings( $this-axes)] \1675 -command [itcl::code $this AdjustSetting axes] \1599 -variable [itcl::scope _settings(-axesvisible)] \ 1600 -command [itcl::code $this AdjustSetting -axesvisible] \ 1676 1601 -font "Arial 9" 1677 1602 1678 1603 checkbutton $inner.grid \ 1679 1604 -text "Grid" \ 1680 -variable [itcl::scope _settings( $this-grid)] \1681 -command [itcl::code $this AdjustSetting grid] \1605 -variable [itcl::scope _settings(-gridvisible)] \ 1606 -command [itcl::code $this AdjustSetting -gridvisible] \ 1682 1607 -font "Arial 9" 1683 1608 1684 1609 checkbutton $inner.outline \ 1685 1610 -text "Outline" \ 1686 -variable [itcl::scope _settings( $this-outline)] \1687 -command [itcl::code $this AdjustSetting outline] \1611 -variable [itcl::scope _settings(-outlinevisible)] \ 1612 -command [itcl::code $this AdjustSetting -outlinevisible] \ 1688 1613 -font "Arial 9" 1689 1614 1690 1615 checkbutton $inner.legend \ 1691 1616 -text "Legend" \ 1692 -variable [itcl::scope _settings( $this-legend)] \1693 -command [itcl::code $this AdjustSetting legend] \1617 -variable [itcl::scope _settings(-legendvisible)] \ 1618 -command [itcl::code $this AdjustSetting -legendvisible] \ 1694 1619 -font "Arial 9" 1695 1620 1696 1621 checkbutton $inner.volume \ 1697 1622 -text "Volume" \ 1698 -variable [itcl::scope _settings( $this-volume)] \1699 -command [itcl::code $this AdjustSetting volume] \1623 -variable [itcl::scope _settings(-volume)] \ 1624 -command [itcl::code $this AdjustSetting -volume] \ 1700 1625 -font "Arial 9" 1701 1626 … … 1715 1640 1716 1641 itcl::body Rappture::NanovisViewer::BuildVolumeTab {} { 1717 foreach { key value } {1718 light2side 11719 light 401720 transp 501721 opacity 1001722 thickness 3501723 } {1724 set _settings($this-$key) $value1725 }1726 1727 1642 set inner [$itk_component(main) insert end \ 1728 1643 -title "Volume Settings" \ … … 1730 1645 $inner configure -borderwidth 4 1731 1646 1647 set font [option get $itk_component(hull) font Font] 1732 1648 set fg [option get $itk_component(hull) font Font] 1733 1649 #set bfg [option get $itk_component(hull) boldFont Font] 1734 1650 1735 1651 checkbutton $inner.vol -text "Show volume" -font $fg \ 1736 -variable [itcl::scope _settings( $this-volume)] \1737 -command [itcl::code $this AdjustSetting volume]1652 -variable [itcl::scope _settings(-volumevisible)] \ 1653 -command [itcl::code $this AdjustSetting -volumevisible] 1738 1654 label $inner.shading -text "Shading:" -font $fg 1739 1655 1740 1656 checkbutton $inner.light2side -text "Two-sided lighting" -font $fg \ 1741 -variable [itcl::scope _settings( $this-light2side)] \1742 -command [itcl::code $this AdjustSetting light2side]1657 -variable [itcl::scope _settings(-light2side)] \ 1658 -command [itcl::code $this AdjustSetting -light2side] 1743 1659 1744 1660 label $inner.dim -text "Glow" -font $fg 1745 1661 ::scale $inner.light -from 0 -to 100 -orient horizontal \ 1746 -variable [itcl::scope _settings( $this-light)] \1662 -variable [itcl::scope _settings(-light)] \ 1747 1663 -width 10 \ 1748 -showvalue off -command [itcl::code $this AdjustSetting light]1664 -showvalue off -command [itcl::code $this AdjustSetting -light] 1749 1665 label $inner.bright -text "Surface" -font $fg 1750 1666 1667 # Opacity 1751 1668 label $inner.fog -text "Clear" -font $fg 1752 1669 ::scale $inner.transp -from 0 -to 100 -orient horizontal \ 1753 -variable [itcl::scope _ settings($this-transp)] \1670 -variable [itcl::scope _widget(-volumeopacity)] \ 1754 1671 -width 10 \ 1755 -showvalue off -command [itcl::code $this AdjustSetting transp]1672 -showvalue off -command [itcl::code $this AdjustSetting -volumeopacity] 1756 1673 label $inner.plastic -text "Opaque" -font $fg 1757 1674 1758 label $inner.clear -text "Clear" -font $fg 1759 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1760 -variable [itcl::scope _settings($this-opacity)] \ 1761 -width 10 \ 1762 -showvalue off -command [itcl::code $this AdjustSetting opacity] 1763 label $inner.opaque -text "Opaque" -font $fg 1764 1675 # Tooth thickness 1765 1676 label $inner.thin -text "Thin" -font $fg 1766 1677 ::scale $inner.thickness -from 0 -to 1000 -orient horizontal \ 1767 -variable [itcl::scope _settings( $this-thickness)] \1678 -variable [itcl::scope _settings(-thickness)] \ 1768 1679 -width 10 \ 1769 -showvalue off -command [itcl::code $this AdjustSetting thickness]1680 -showvalue off -command [itcl::code $this AdjustSetting -thickness] 1770 1681 label $inner.thick -text "Thick" -font $fg 1771 1682 1683 # Colormap 1772 1684 label $inner.colormap_l -text "Colormap" -font "Arial 9" 1773 1685 itk_component add colormap { … … 1778 1690 $itk_component(colormap) value "BCGYR" 1779 1691 bind $inner.colormap <<Value>> \ 1780 [itcl::code $this AdjustSetting colormap] 1692 [itcl::code $this AdjustSetting -colormap] 1693 $itk_component(colormap) value "default" 1694 set _settings(-colormap) "default" 1695 1696 # Component 1697 label $inner.volcomponents_l -text "Component" -font $font 1698 itk_component add volcomponents { 1699 Rappture::Combobox $inner.volcomponents -editable no 1700 } 1701 bind $inner.volcomponents <<Value>> \ 1702 [itcl::code $this AdjustSetting -current] 1781 1703 1782 1704 blt::table $inner \ 1783 0,0 $inner.vol -cspan 4 -anchor w -pady 2 \ 1705 0,0 $inner.volcomponents_l -anchor e -cspan 2 \ 1706 0,2 $inner.volcomponents -cspan 3 -fill x \ 1784 1707 1,0 $inner.shading -cspan 4 -anchor w -pady {10 2} \ 1785 1708 2,0 $inner.light2side -cspan 4 -anchor w -pady 2 \ … … 1804 1727 $inner configure -borderwidth 4 1805 1728 1729 checkbutton $inner.visible \ 1730 -text "Show Cutplanes" \ 1731 -variable [itcl::scope _settings(-cutplanesvisible)] \ 1732 -command [itcl::code $this AdjustSetting -cutplanesvisible] \ 1733 -font "Arial 9" 1734 1806 1735 # X-value slicer... 1807 1736 itk_component add xCutButton { … … 1809 1738 -onimage [Rappture::icon x-cutplane] \ 1810 1739 -offimage [Rappture::icon x-cutplane] \ 1811 -command [itcl::code $this AdjustSetting xcutplane] \1812 -variable [itcl::scope _settings( $this-xcutplane)]1740 -command [itcl::code $this AdjustSetting -xcutplanevisible] \ 1741 -variable [itcl::scope _settings(-xcutplanevisible)] 1813 1742 } 1814 1743 Rappture::Tooltip::for $itk_component(xCutButton) \ 1815 1744 "Toggle the X cut plane on/off" 1745 $itk_component(xCutButton) select 1816 1746 1817 1747 itk_component add xCutScale { … … 1820 1750 -borderwidth 1 -highlightthickness 0 \ 1821 1751 -command [itcl::code $this Slice move x] \ 1822 -variable [itcl::scope _settings( $this-xcutposition)]1752 -variable [itcl::scope _settings(-xcutplaneposition)] 1823 1753 } { 1824 1754 usual … … 1836 1766 -onimage [Rappture::icon y-cutplane] \ 1837 1767 -offimage [Rappture::icon y-cutplane] \ 1838 -command [itcl::code $this AdjustSetting ycutplane] \1839 -variable [itcl::scope _settings( $this-ycutplane)]1768 -command [itcl::code $this AdjustSetting -ycutplanevisible] \ 1769 -variable [itcl::scope _settings(-ycutplanevisible)] 1840 1770 } 1841 1771 Rappture::Tooltip::for $itk_component(yCutButton) \ 1842 1772 "Toggle the Y cut plane on/off" 1773 $itk_component(yCutButton) select 1843 1774 1844 1775 itk_component add yCutScale { … … 1847 1778 -borderwidth 1 -highlightthickness 0 \ 1848 1779 -command [itcl::code $this Slice move y] \ 1849 -variable [itcl::scope _settings( $this-ycutposition)]1780 -variable [itcl::scope _settings(-ycutplaneposition)] 1850 1781 } { 1851 1782 usual … … 1863 1794 -onimage [Rappture::icon z-cutplane] \ 1864 1795 -offimage [Rappture::icon z-cutplane] \ 1865 -command [itcl::code $this AdjustSetting zcutplane] \1866 -variable [itcl::scope _settings( $this-zcutplane)]1796 -command [itcl::code $this AdjustSetting -zcutplanevisible] \ 1797 -variable [itcl::scope _settings(-zcutplanevisible)] 1867 1798 } 1868 1799 Rappture::Tooltip::for $itk_component(zCutButton) \ 1869 1800 "Toggle the Z cut plane on/off" 1801 $itk_component(zCutButton) select 1870 1802 1871 1803 itk_component add zCutScale { … … 1874 1806 -borderwidth 1 -highlightthickness 0 \ 1875 1807 -command [itcl::code $this Slice move z] \ 1876 -variable [itcl::scope _settings( $this-zcutposition)]1808 -variable [itcl::scope _settings(-zcutplaneposition)] 1877 1809 } { 1878 1810 usual … … 1881 1813 $itk_component(zCutScale) set 50 1882 1814 $itk_component(zCutScale) configure -state disabled 1883 #$itk_component(zCutScale) configure -state disabled1884 1815 Rappture::Tooltip::for $itk_component(zCutScale) \ 1885 1816 "@[itcl::code $this SlicerTip z]" … … 1923 1854 label $inner.${tag}label -text $tag -font "Arial 9" 1924 1855 entry $inner.${tag} -font "Arial 9" -bg white \ 1925 -textvariable [itcl::scope _settings( $this-$tag)]1856 -textvariable [itcl::scope _settings(-$tag)] 1926 1857 bind $inner.${tag} <Return> \ 1927 [itcl::code $this camera set ${tag}]1858 [itcl::code $this camera set -${tag}] 1928 1859 bind $inner.${tag} <KP_Enter> \ 1929 [itcl::code $this camera set ${tag}]1860 [itcl::code $this camera set -${tag}] 1930 1861 blt::table $inner \ 1931 1862 $row,0 $inner.${tag}label -anchor e -pady 2 \ … … 1976 1907 itcl::body Rappture::NanovisViewer::SlicerTip {axis} { 1977 1908 set val [$itk_component(${axis}CutScale) get] 1978 # set val [expr {0.01*($val-50)1979 # *($_limits(${axis}max)-$_limits(${axis}min))1980 # + 0.5*($_limits(${axis}max)+$_limits(${axis}min))}]1981 1909 return "Move the [string toupper $axis] cut plane.\nCurrently: $axis = $val%" 1982 1910 } … … 1999 1927 } 2000 1928 2001 itcl::body Rappture::NanovisViewer::EventuallyRe sizeLegend {} {1929 itcl::body Rappture::NanovisViewer::EventuallyRedrawLegend {} { 2002 1930 if { !$_resizeLegendPending } { 2003 1931 $_dispatcher event -idle !legend … … 2014 1942 } 2015 1943 "set" { 2016 set wh o[lindex $args 0]2017 set x $_settings($ this-$who)1944 set what [lindex $args 0] 1945 set x $_settings($what) 2018 1946 set code [catch { string is double $x } result] 2019 1947 if { $code != 0 || !$result } { 2020 set _settings($ this-$who) $_view($who)1948 set _settings($what) $_view($what) 2021 1949 return 2022 1950 } 2023 switch -- $wh o{2024 " xpan" - "ypan" {2025 set _view($wh o) $_settings($this-$who)1951 switch -- $what { 1952 "-xpan" - "-ypan" { 1953 set _view($what) $_settings($what) 2026 1954 PanCamera 2027 1955 } 2028 " qx" - "qy" - "qz" - "qw" {2029 set _view($wh o) $_settings($this-$who)2030 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]1956 "-qx" - "-qy" - "-qz" - "-qw" { 1957 set _view($what) $_settings($what) 1958 set q [ViewToQuaternion] 2031 1959 $_arcball quaternion $q 2032 1960 SendCmd "camera orient $q" 2033 1961 } 2034 " zoom" {2035 set _view($wh o) $_settings($this-$who)2036 SendCmd "camera zoom $_view( zoom)"1962 "-zoom" { 1963 set _view($what) $_settings($what) 1964 SendCmd "camera zoom $_view($what)" 2037 1965 } 2038 1966 } … … 2074 2002 array set info $vol 2075 2003 set name $info(name) 2076 if { ![info exists _settings( $this-volume-$name)] } {2077 set _settings( $this-volume-$name) $info(hide)2004 if { ![info exists _settings(-volumevisible-$name)] } { 2005 set _settings(-volumevisible-$name) $info(hide) 2078 2006 } 2079 2007 checkbutton $inner.vol$row -text $info(label) \ 2080 -variable [itcl::scope _settings( $this-volume-$name)] \2008 -variable [itcl::scope _settings(-volumevisible-$name)] \ 2081 2009 -onvalue 0 -offvalue 1 \ 2082 -command [itcl::code $this volume $key $name] \2010 -command [itcl::code $this ToggleVolume $key $name] \ 2083 2011 -font "Arial 9" 2084 2012 Rappture::Tooltip::for $inner.vol$row $info(description) 2085 2013 blt::table $inner $row,0 $inner.vol$row -anchor w 2086 if { !$_settings( $this-volume-$name) } {2014 if { !$_settings(-volume-$name) } { 2087 2015 $inner.vol$row select 2088 2016 } … … 2095 2023 } 2096 2024 2097 itcl::body Rappture::NanovisViewer:: volume { tag name } {2098 set bool $_settings( $this-volume-$name)2099 SendCmd "volume stat ue $bool $name"2025 itcl::body Rappture::NanovisViewer::ToggleVolume { tag name } { 2026 set bool $_settings(-volumevisible-$name) 2027 SendCmd "volume state $bool $name" 2100 2028 } 2101 2029 … … 2109 2037 bottom "0.707107 0.707107 0 0" 2110 2038 } 2111 foreach name { qw qx qyqz } value $positions($side) {2039 foreach name { -qw -qx -qy -qz } value $positions($side) { 2112 2040 set _view($name) $value 2113 2041 } 2114 set q [ list $_view(qw) $_view(qx) $_view(qy) $_view(qz)]2042 set q [ViewToQuaternion] 2115 2043 $_arcball quaternion $q 2116 2044 SendCmd "camera orient $q" 2117 2045 SendCmd "camera reset" 2118 set _view(xpan) 0 2119 set _view(ypan) 0 2120 set _view(zoom) 1.0 2121 set _settings($this-xpan) $_view(xpan) 2122 set _settings($this-ypan) $_view(ypan) 2123 set _settings($this-zoom) $_view(zoom) 2124 } 2125 2046 set _view(-xpan) 0 2047 set _view(-ypan) 0 2048 set _view(-zoom) 1.0 2049 set _settings(-xpan) $_view(-xpan) 2050 set _settings(-ypan) $_view(-ypan) 2051 set _settings(-zoom) $_view(-zoom) 2052 } 2053 2054 2055 # 2056 # InitComponentSettings -- 2057 # 2058 # Initializes the volume settings for a specific component. This 2059 # should match what's used as global settings above. This 2060 # is called the first time we try to switch to a given component 2061 # in SwitchComponent below. 2062 # 2063 itcl::body Rappture::NanovisViewer::InitComponentSettings { cname } { 2064 # Expanding component name for key. 2065 array set _settings [subst { 2066 $cname-ambient 60 2067 $cname-colormap default 2068 $cname-diffuse 40 2069 $cname-light2side 1 2070 $cname-volumeopacity 0.5 2071 $cname-specularexponent 90 2072 $cname-specularlevel 30 2073 $cname-thickness 350 2074 $cname-volumevisible 1 2075 }] 2076 } 2077 2078 # 2079 # SwitchComponent -- 2080 # 2081 # This is called when the current component is changed by the 2082 # dropdown menu in the volume tab. It synchronizes the global 2083 # volume settings with the settings of the new current component. 2084 # 2085 itcl::body Rappture::NanovisViewer::SwitchComponent { cname } { 2086 if { ![info exists _settings($cname-ambient)] } { 2087 InitComponentSettings $cname 2088 } 2089 # _settings variables change widgets, except for colormap 2090 set _settings(-ambient) $_settings($cname-ambient) 2091 set _settings(-colormap) $_settings($cname-colormap) 2092 set _settings(-diffuse) $_settings($cname-diffuse) 2093 set _settings(-light2side) $_settings($cname-light2side) 2094 set _settings(-specularexponent) $_settings($cname-specularexponent) 2095 set _settings(-specularlevel) $_settings($cname-specularlevel) 2096 set _settings(-thickness) $_settings($cname-thickness) 2097 set _settings(-volumeopacity) $_settings($cname-volumeopacity) 2098 set _settings(-volumevisible) $_settings($cname-volumevisible) 2099 $itk_component(colormap) value $_settings($cname-colormap) 2100 set _current $cname; # Reset the current component 2101 } 2102 2103 # 2104 # BuildVolumeComponents -- 2105 # 2106 # This is called from the "scale" method which is called when a 2107 # new dataset is added or deleted. It repopulates the dropdown 2108 # menu of volume component names. It sets the current component 2109 # to the first component in the list (of components found). 2110 # Finally, if there is only one component, don't display the 2111 # label or the combobox in the volume settings tab. 2112 # 2113 itcl::body Rappture::NanovisViewer::BuildVolumeComponents {} { 2114 $itk_component(volcomponents) choices delete 0 end 2115 foreach name $_componentsList { 2116 $itk_component(volcomponents) choices insert end $name $name 2117 } 2118 set _current [lindex $_componentsList 0] 2119 $itk_component(volcomponents) value $_current 2120 set parent [winfo parent $itk_component(volcomponents)] 2121 if { [llength $_componentsList] <= 1 } { 2122 # Unpack the components label and dropdown if there's only one 2123 # component. 2124 blt::table forget $parent.volcomponents_l $parent.volcomponents 2125 } else { 2126 # Pack the components label and dropdown into the table there's 2127 # more than one component to select. 2128 blt::table $parent \ 2129 0,0 $parent.volcomponents_l -anchor e -cspan 2 \ 2130 0,2 $parent.volcomponents -cspan 3 -fill x 2131 } 2132 } 2133 2134 # 2135 # GetDatasetsWithComponents -- 2136 # 2137 # Returns a list of all the datasets (known by the combination of 2138 # their data object and component name) that match the given 2139 # component name. For example, this is used where we want to change 2140 # the settings of volumes that have the current component. 2141 # 2142 itcl::body Rappture::NanovisViewer::GetDatasetsWithComponent { cname } { 2143 if { ![info exists _volcomponents($cname)] } { 2144 return "" 2145 } 2146 set list "" 2147 foreach tag $_volcomponents($cname) { 2148 if { ![info exists _serverDatasets($tag)] } { 2149 continue 2150 } 2151 lappend list $tag 2152 } 2153 return $list 2154 } 2155 2156 # 2157 # HideAllMarkers -- 2158 # 2159 # Hide all the markers in all the transfer functions. Can't simply 2160 # delete and recreate markers from the <style> since the user may 2161 # have create, deleted, or moved markers. 2162 # 2163 itcl::body Rappture::NanovisViewer::HideAllMarkers {} { 2164 foreach cname [array names _transferFunctionEditors] { 2165 $_transferFunctionEditors($cname) hideMarkers 2166 } 2167 } 2168 2169 itcl::body Rappture::NanovisViewer::GetColormap { cname color } { 2170 if { $color == "default" } { 2171 return $_cname2defaultcolormap($cname) 2172 } 2173 return [ColorsToColormap $color] 2174 } 2175 2176 itcl::body Rappture::NanovisViewer::GetAlphamap { cname name } { 2177 if { $name == "default" } { 2178 return $_cname2defaultalphamap($cname) 2179 } 2180 return [NameToAlphamap $name] 2181 } 2182 2183 itcl::body Rappture::NanovisViewer::ResetColormap { cname color } { 2184 # Get the current transfer function 2185 if { ![info exists _cname2transferFunction($cname)] } { 2186 return 2187 } 2188 foreach { cmap wmap } $_cname2transferFunction($cname) break 2189 set cmap [GetColormap $cname $color] 2190 set _cname2transferFunction($cname) [list $cmap $wmap] 2191 SendCmd [list transfunc define $cname $cmap $wmap] 2192 EventuallyRedrawLegend 2193 } 2194 2195 itcl::body Rappture::NanovisViewer::ComputeAlphamap { cname } { 2196 if { ![info exists _transferFunctionEditors($cname)] } { 2197 return [list 0.0 0.0 1.0 1.0] 2198 } 2199 if { ![info exists _settings($cname-ambient)] } { 2200 InitComponentSettings $cname 2201 } 2202 2203 set isovalues [$_transferFunctionEditors($cname) values] 2204 2205 # Currently using volume shading opacity to scale opacity in 2206 # the volume shader. The transfer function always sets full 2207 # opacity 2208 set max 1.0 2209 2210 # Use the component-wise thickness setting from the slider 2211 # settings widget 2212 # Scale values between 0.00001 and 0.01000 2213 set delta [expr {double($_settings($cname-thickness)) * 0.0001}] 2214 2215 set first [lindex $isovalues 0] 2216 set last [lindex $isovalues end] 2217 set wmap "" 2218 if { $first == "" || $first != 0.0 } { 2219 lappend wmap 0.0 0.0 2220 } 2221 foreach x $isovalues { 2222 set x1 [expr {$x-$delta-0.00001}] 2223 set x2 [expr {$x-$delta}] 2224 set x3 [expr {$x+$delta}] 2225 set x4 [expr {$x+$delta+0.00001}] 2226 if { $x1 < 0.0 } { 2227 set x1 0.0 2228 } elseif { $x1 > 1.0 } { 2229 set x1 1.0 2230 } 2231 if { $x2 < 0.0 } { 2232 set x2 0.0 2233 } elseif { $x2 > 1.0 } { 2234 set x2 1.0 2235 } 2236 if { $x3 < 0.0 } { 2237 set x3 0.0 2238 } elseif { $x3 > 1.0 } { 2239 set x3 1.0 2240 } 2241 if { $x4 < 0.0 } { 2242 set x4 0.0 2243 } elseif { $x4 > 1.0 } { 2244 set x4 1.0 2245 } 2246 # add spikes in the middle 2247 lappend wmap $x1 0.0 2248 lappend wmap $x2 $max 2249 lappend wmap $x3 $max 2250 lappend wmap $x4 0.0 2251 } 2252 if { $last == "" || $last != 1.0 } { 2253 lappend wmap 1.0 0.0 2254 } 2255 return $wmap 2256 } 2257 2258 2259 itcl::body Rappture::NanovisViewer::NameToAlphamap { name } { 2260 switch -- $name { 2261 "ramp-up" { 2262 set wmap { 2263 0.0 0.0 2264 1.0 1.0 2265 } 2266 } 2267 "ramp-down" { 2268 set wmap { 2269 0.0 1.0 2270 1.0 0.0 2271 } 2272 } 2273 "vee" { 2274 set wmap { 2275 0.0 1.0 2276 0.5 0.0 2277 1.0 1.0 2278 } 2279 } 2280 "tent-1" { 2281 set wmap { 2282 0.0 0.0 2283 0.5 1.0 2284 1.0 0.0 2285 } 2286 } 2287 "tent-2" { 2288 set wmap { 2289 0.0 0.0 2290 0.25 1.0 2291 0.5 0.0 2292 0.75 1.0 2293 1.0 0.0 2294 } 2295 } 2296 "tent-3" { 2297 set wmap { 2298 0.0 0.0 2299 0.16666 1.0 2300 0.33333 0.0 2301 0.5 1.0 2302 0.66666 0.0 2303 0.83333 1.0 2304 1.0 0.0 2305 } 2306 } 2307 "tent-4" { 2308 set wmap { 2309 0.0 0.0 2310 0.125 1.0 2311 0.25 0.0 2312 0.375 1.0 2313 0.5 0.0 2314 0.625 1.0 2315 0.75 0.0 2316 0.875 1.0 2317 1.0 0.0 2318 } 2319 } 2320 "sinusoid-1" { 2321 set wmap { 2322 0.0 0.000 0.600 0.800 2323 0.14285714285714285 0.400 0.900 1.000 2324 0.2857142857142857 0.600 1.000 1.000 2325 0.42857142857142855 0.800 1.000 1.000 2326 0.5714285714285714 0.900 0.900 0.900 2327 0.7142857142857143 0.600 0.600 0.600 2328 0.8571428571428571 0.400 0.400 0.400 2329 1.0 0.200 0.200 0.200 2330 } 2331 } 2332 "sinusoid-2" { 2333 set wmap { 2334 0.0 0.900 1.000 1.000 2335 0.1111111111111111 0.800 0.983 1.000 2336 0.2222222222222222 0.700 0.950 1.000 2337 0.3333333333333333 0.600 0.900 1.000 2338 0.4444444444444444 0.500 0.833 1.000 2339 0.5555555555555556 0.400 0.750 1.000 2340 0.6666666666666666 0.300 0.650 1.000 2341 0.7777777777777778 0.200 0.533 1.000 2342 0.8888888888888888 0.100 0.400 1.000 2343 1.0 0.000 0.250 1.000 2344 } 2345 } 2346 "sinusoid-6" { 2347 set wmap { 2348 0.0 0.200 0.100 0.000 2349 0.09090909090909091 0.400 0.187 0.000 2350 0.18181818181818182 0.600 0.379 0.210 2351 0.2727272727272727 0.800 0.608 0.480 2352 0.36363636363636365 0.850 0.688 0.595 2353 0.45454545454545453 0.950 0.855 0.808 2354 0.5454545454545454 0.800 0.993 1.000 2355 0.6363636363636364 0.600 0.973 1.000 2356 0.7272727272727273 0.400 0.940 1.000 2357 0.8181818181818182 0.200 0.893 1.000 2358 0.9090909090909091 0.000 0.667 0.800 2359 1.0 0.000 0.480 0.600 2360 } 2361 } 2362 "sinusoid-10" { 2363 set wmap { 2364 0.0 0.000 0.480 0.600 2365 0.09090909090909091 0.000 0.667 0.800 2366 0.18181818181818182 0.200 0.893 1.000 2367 0.2727272727272727 0.400 0.940 1.000 2368 0.36363636363636365 0.600 0.973 1.000 2369 0.45454545454545453 0.800 0.993 1.000 2370 0.5454545454545454 0.950 0.855 0.808 2371 0.6363636363636364 0.850 0.688 0.595 2372 0.7272727272727273 0.800 0.608 0.480 2373 0.8181818181818182 0.600 0.379 0.210 2374 0.9090909090909091 0.400 0.187 0.000 2375 1.0 0.200 0.100 0.000 2376 } 2377 } 2378 "step-2" { 2379 set wmap { 2380 0.0 0.000 0.167 1.000 2381 0.09090909090909091 0.100 0.400 1.000 2382 0.18181818181818182 0.200 0.600 1.000 2383 0.2727272727272727 0.400 0.800 1.000 2384 0.36363636363636365 0.600 0.933 1.000 2385 0.45454545454545453 0.800 1.000 1.000 2386 0.5454545454545454 1.000 1.000 0.800 2387 0.6363636363636364 1.000 0.933 0.600 2388 0.7272727272727273 1.000 0.800 0.400 2389 0.8181818181818182 1.000 0.600 0.200 2390 0.9090909090909091 1.000 0.400 0.100 2391 1.0 1.000 0.167 0.000 2392 } 2393 } 2394 "step-5" { 2395 set wmap { 2396 0.0 1.000 0.167 0.000 2397 0.09090909090909091 1.000 0.400 0.100 2398 0.18181818181818182 1.000 0.600 0.200 2399 0.2727272727272727 1.000 0.800 0.400 2400 0.36363636363636365 1.000 0.933 0.600 2401 0.45454545454545453 1.000 1.000 0.800 2402 0.5454545454545454 0.800 1.000 1.000 2403 0.6363636363636364 0.600 0.933 1.000 2404 0.7272727272727273 0.400 0.800 1.000 2405 0.8181818181818182 0.200 0.600 1.000 2406 0.9090909090909091 0.100 0.400 1.000 2407 1.0 0.000 0.167 1.000 2408 } 2409 } 2410 "step-12" { 2411 set wmap { 2412 "#EE82EE" 2413 "#4B0082" 2414 "blue" 2415 "#008000" 2416 "yellow" 2417 "#FFA500" 2418 "red" 2419 } 2420 } 2421 default { 2422 } 2423 } 2424 return "" 2425 } 2426 2427 -
branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl
r4475 r4504 141 141 private variable _contourList 142 142 private variable _currentLimits "" 143 private variable _widget 144 143 145 common _downloadPopup; # download options from popup 144 146 private common _hardcopy … … 242 244 -cutplaneedges 0 243 245 -cutplanelighting 1 244 -cutplaneopacity 1 00246 -cutplaneopacity 1.0 245 247 -cutplanepreinterp 1 246 248 -cutplanesvisible 0 … … 250 252 -isosurfaceedges 0 251 253 -isosurfacelighting 1 252 -isosurfaceopacity 60254 -isosurfaceopacity 0.6 253 255 -isosurfacevisible 1 254 256 -isosurfacewireframe 0 … … 269 271 -colormap 0 270 272 -isosurfaceopacity 0 273 -cutplaneopacity 0 271 274 -numcontours 0 275 } 276 array set _widget { 277 -isosurfaceopacity 0 278 -cutplaneopacity 0 272 279 } 273 280 … … 483 490 GenerateContourList 484 491 SendCmd [list contour3d contourlist $_contourList(values)] 485 #SendCmd [list camera reset]492 SendCmd [list camera reset] 486 493 DrawLegend 487 494 set _contourList(updatePending) 0 … … 970 977 # generates a new call to Rebuild). 971 978 StartBufferingCommands 972 973 979 if { $_reset } { 974 980 set _width $w … … 991 997 InitSettings -xgrid -ygrid -zgrid -axismode \ 992 998 -axesvisible -axislabelsvisible 993 foreach axis { x y z } {994 SendCmd "axis lformat $axis %g" 995 } 999 SendCmd "axis lformat all %g" 1000 # Too many major ticks, so turn off minor ticks 1001 SendCmd "axis minticks all 0" 996 1002 StopBufferingCommands 997 1003 SendCmd "imgflush" … … 1101 1107 set label [string toupper $axis] 1102 1108 } 1103 # May be a space in the axis label.1104 1109 SendCmd [list axis name $axis $label] 1105 1110 } … … 1413 1418 } 1414 1419 "-cutplaneopacity" { 1415 set val $_settings($what) 1416 set sval [expr { 0.01 * double($val) }] 1417 SendCmd "cutplane opacity $sval" 1420 set _settings($what) [$_widget(-cutplaneopacity) * 0.01] 1421 SendCmd "cutplane opacity $_settings($what)" 1418 1422 } 1419 1423 "-cutplanepreinterp" { … … 1509 1513 } 1510 1514 "-isosurfaceopacity" { 1511 set val $_settings($what) 1512 set sval [expr { 0.01 * double($val) }] 1513 SendCmd "contour3d opacity $sval" 1515 set _settings($what) [$_widget(-isosurfaceopacity) * 0.01] 1516 SendCmd "contour3d opacity $_settings($what)" 1514 1517 } 1515 1518 "-field" { … … 1539 1542 SendCmd "contour3d colormode $_colorMode $_curFldName" 1540 1543 SendCmd "camera reset" 1544 UpdateContourList 1541 1545 DrawLegend 1542 1546 } … … 1714 1718 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1715 1719 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1716 -variable [itcl::scope _ settings(-isosurfaceopacity)] \1720 -variable [itcl::scope _widget(-isosurfaceopacity)] \ 1717 1721 -width 10 \ 1718 1722 -showvalue off \ 1719 1723 -command [itcl::code $this AdjustSetting -isosurfaceopacity] 1724 $inner.opacity set [expr $_settings(-isosurfaceeopacity) * 100.0] 1720 1725 1721 1726 itk_component add field_l { … … 1734 1739 Rappture::Combobox $inner.colormap -width 10 -editable 0 1735 1740 } 1736 1737 1741 $inner.colormap choices insert end [GetColormapList] 1742 1738 1743 $itk_component(colormap) value "BCGYR" 1739 1744 bind $inner.colormap <<Value>> \ … … 1927 1932 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1928 1933 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ 1929 -variable [itcl::scope _ settings(-cutplaneopacity)] \1934 -variable [itcl::scope _widget(-cutplaneopacity)] \ 1930 1935 -width 10 \ 1931 1936 -showvalue off \ 1932 1937 -command [itcl::code $this AdjustSetting -cutplaneopacity] 1933 $inner.opacity set $_settings(-cutplaneopacity)1938 $inner.opacity set [expr $_settings(-cutplaneopacity) * 100.0] 1934 1939 1935 1940 # X-value slicer... … … 2150 2155 set tag $dataobj-$comp 2151 2156 array set style { 2152 -color BCGYR2153 -cutplanesvisible 02154 -edgecolor black2155 -edges 02156 -isosurface visible 12157 - levels 102158 -l ighting 12159 -li newidth 1.02160 - opacity 0.62161 -outline 02162 -wireframe 02163 -xcutplaneposition 502164 -xcutplanevisible 12165 -ycutplaneposition 502166 -ycutplanevisible 12167 -zcutplaneposition 502168 -zcutplanevisible 12157 -color BCGYR 2158 -cutplanesvisible 0 2159 -edgecolor black 2160 -edges 0 2161 -isosurfaceopacity 0.6 2162 -isosurfacevisible 1 2163 -levels 10 2164 -lighting 1 2165 -linewidth 1.0 2166 -outline 0 2167 -wireframe 0 2168 -xcutplaneposition 50 2169 -xcutplanevisible 1 2170 -ycutplaneposition 50 2171 -ycutplanevisible 1 2172 -zcutplaneposition 50 2173 -zcutplanevisible 1 2169 2174 } 2170 2175 array set style [$dataobj style $comp] 2171 2176 if { $dataobj != $_first || $style(-levels) == 1 } { 2172 set style(- opacity) 12177 set style(-isosurfaceopacity) 1.0 2173 2178 } 2174 2179 … … 2183 2188 2184 2189 if { $_changed(-isosurfaceopacity) } { 2185 set style(- opacity) [expr $_settings(-isosurfaceopacity) * 0.01]2190 set style(-isosurfaceopacity) $_settings(-isosurfaceopacity) 2186 2191 } 2187 2192 if { $_changed(-numcontours) } { … … 2196 2201 } 2197 2202 if { $_contourList(numLevels) != $style(-levels) } { 2198 set _settings(-numcontours) $style(-levels) 2199 $itk_component(numcontours) value $style(-levels) 2200 set _contourList(numLevels) $style(-levels) 2203 if { [llength $style(-levels)] > 1 } { 2204 set _contourList(reqValues) [lsort -real $style(-levels)] 2205 } else { 2206 set _settings(-numcontours) $style(-levels) 2207 $itk_component(numcontours) value $style(-levels) 2208 set _contourList(numLevels) $style(-levels) 2209 } 2201 2210 EventuallyChangeContourLevels 2202 2211 } … … 2228 2237 SendCmd "contour3d linecolor [Color2RGB $style(-edgecolor)] $tag" 2229 2238 SendCmd "contour3d linewidth $style(-linewidth) $tag" 2230 SendCmd "contour3d opacity $style(- opacity) $tag"2231 set _settings(-isosurfaceopacity) [expr $style(-opacity) * 100.0]2239 SendCmd "contour3d opacity $style(-isosurfaceopacity) $tag" 2240 set _settings(-isosurfaceopacity) $style(-isosurfaceopacity) 2232 2241 SetCurrentColormap $style(-color) 2233 2242 SendCmd "contour3d wireframe $style(-wireframe) $tag" … … 2593 2602 itcl::body Rappture::VtkIsosurfaceViewer::GenerateContourList {} { 2594 2603 if { ![info exists _limits($_curFldName)] } { 2604 puts stderr "no _curFldName" 2595 2605 return "" 2596 2606 } 2597 2607 if { $_contourList(numLevels) < 1 } { 2608 puts stderr "numLevels < 1" 2598 2609 return "" 2599 2610 } 2600 foreach { vmin vmax } $_limits($_curFldName) break 2601 set v [blt::vector create \#auto] 2602 $v seq $vmin $vmax [expr $_contourList(numLevels)+2] 2603 $v delete end 0 2604 set values [$v range 0 end] 2605 blt::vector destroy $v 2611 if { [llength $_contourList(reqValues)] > 1 } { 2612 set values $_contourList(reqValues) 2613 } else { 2614 foreach { vmin vmax } $_limits($_curFldName) break 2615 set v [blt::vector create \#auto] 2616 $v seq $vmin $vmax [expr $_contourList(numLevels)+2] 2617 $v delete end 0 2618 set values [$v range 0 end] 2619 blt::vector destroy $v 2620 } 2606 2621 set _contourList(values) $values 2607 2622 }
Note: See TracChangeset
for help on using the changeset viewer.