Changeset 894 for trunk/gui/scripts
- Timestamp:
- Feb 16, 2008 10:57:41 PM (16 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field.tcl
r885 r894 203 203 } 204 204 if {[info exists _comp2unirect2d($what)]} { 205 set mobj $_comp2unirect2d($what) 205 set mobj $_comp2unirect2d($what) 206 206 return [$mobj values] 207 207 } … … 228 228 } 229 229 if {[info exists _comp2unirect2d($what)]} { 230 230 set mobj $_comp2unirect2d($what) 231 231 return [$mobj blob] 232 232 } … … 503 503 set class [$mobj info class] 504 504 ${class}::release $mobj 505 505 506 506 set fobj [lindex $_comp2vtk($name) 1] 507 507 rename $fobj "" … … 516 516 catch {unset _comp2style} 517 517 array unset _comp2unirect2d 518 518 519 519 # 520 520 # Scan through the components of the field and create … … 523 523 foreach cname [$_field children -type component] { 524 524 set type "" 525 if { ([$_field element $cname.constant] != "" && 526 [$_field element $cname.domain] != "") || 527 525 if { ([$_field element $cname.constant] != "" && 526 [$_field element $cname.domain] != "") || 527 [$_field element $cname.xy] != ""} { 528 528 set type "1D" 529 } elseif {[$_field element $cname.mesh] != "" && 530 529 } elseif {[$_field element $cname.mesh] != "" && 530 [$_field element $cname.values] != ""} { 531 531 set type "points-on-mesh" 532 532 } elseif {[$_field element $cname.vtk] != ""} { … … 538 538 } 539 539 set _comp2style($cname) "" 540 540 541 541 if {$type == "1D"} { 542 542 # … … 546 546 set xv "" 547 547 set yv "" 548 548 549 549 set val [$_field get $cname.constant] 550 550 if {$val != ""} { … … 558 558 set xv [blt::vector create x$_counter] 559 559 $xv append $z0 $z1 560 560 561 561 foreach {val pcomp} [_getValue $val] break 562 562 set yv [blt::vector create y$_counter] 563 563 $yv append $val $val 564 564 565 565 if {$pcomp != ""} { 566 566 set zm [expr {0.5*($z0+$z1)}] … … 573 573 set xv [blt::vector create x$_counter] 574 574 set yv [blt::vector create y$_counter] 575 575 576 576 foreach line [split $xydata \n] { 577 577 if {[scan $line {%g %g} xval yval] == 2} { … … 582 582 } 583 583 } 584 584 585 585 if {$xv != "" && $yv != ""} { 586 586 # sort x-coords in increasing order 587 587 $xv sort $yv 588 588 589 589 set _comp2dims($cname) "1D" 590 590 set _comp2xy($cname) [list $xv $yv] … … 599 599 set path [$_field get $cname.mesh] 600 600 if {[$_xmlobj element $path] != ""} { 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 601 set element [$_xmlobj element -as type $path] 602 if { $element == "unirect2d" } { 603 set _comp2dims($cname) "2D" 604 set _comp2unirect2d($cname) \ 605 [Rappture::UniRect2d \#auto $_xmlobj $_field $cname] 606 set _comp2style($cname) [$_field get $cname.style] 607 incr _counter 608 } elseif { $element == "cloud" || $element == "mesh" } { 609 switch -- $element { 610 cloud { 611 set mobj [Rappture::Cloud::fetch $_xmlobj $path] 612 } 613 mesh { 614 set mobj [Rappture::Mesh::fetch $_xmlobj $path] 615 } 616 } 617 if {[$mobj dimensions] > 1} { 618 # 619 # 2D/3D data 620 # Store cloud/field as components 621 # 622 set values [$_field get $cname.values] 623 set farray [vtkFloatArray ::vals$_counter] 624 625 foreach v $values { 626 if {"" != $_units} { 627 set v [Rappture::Units::convert $v \ 628 -context $_units -to $_units -units off] 629 } 630 $farray InsertNextValue $v 631 } 632 633 set _comp2dims($cname) "[$mobj dimensions]D" 634 set _comp2vtk($cname) [list $mobj $farray] 635 set _comp2style($cname) [$_field get $cname.style] 636 incr _counter 637 } else { 638 # 639 # OOPS! This is 1D data 640 # Forget the cloud/field -- store BLT vectors 641 # 642 set xv [blt::vector create x$_counter] 643 set yv [blt::vector create y$_counter] 644 645 set vtkpts [$mobj points] 646 set max [$vtkpts GetNumberOfPoints] 647 for {set i 0} {$i < $max} {incr i} { 648 set xval [lindex [$vtkpts GetPoint $i] 0] 649 $xv append $xval 650 } 651 set class [$mobj info class] 652 ${class}::release $mobj 653 654 set values [$_field get $cname.values] 655 foreach yval $values { 656 if {"" != $_units} { 657 set yval [Rappture::Units::convert $yval \ 658 -context $_units -to $_units -units off] 659 } 660 $yv append $yval 661 } 662 663 # sort x-coords in increasing order 664 $xv sort $yv 665 666 set _comp2dims($cname) "1D" 667 set _comp2xy($cname) [list $xv $yv] 668 incr _counter 669 } 670 } 671 } else { 672 puts "WARNING: can't find mesh $path for field component" 673 } 674 674 } elseif {$type == "vtk"} { 675 675 # -
trunk/gui/scripts/nanovisviewer.tcl
r890 r894 112 112 private variable _limits ;# autoscale min/max for all axes 113 113 private variable _view ;# view params for 3D view 114 114 115 115 private variable _isomarkers ;# array of isosurface level values 0..1 116 116 private common _isosurface ;# indicates to use isosurface shading … … 123 123 124 124 itcl::class Rappture::NanovisViewer::IsoMarker { 125 private variable _value "";# Absolute value of marker.126 private variable _label 127 private variable _tick 128 private variable _canvas 129 private variable _nvobj 125 private variable _value ""; # Absolute value of marker. 126 private variable _label "" 127 private variable _tick "" 128 private variable _canvas "" 129 private variable _nvobj "" 130 130 private common _normalIcon "" 131 131 private common _activeIcon "" … … 133 133 private variable _active_press 0 134 134 135 constructor {c obj args} { 136 137 138 139 140 135 constructor {c obj args} { 136 set _canvas $c 137 set _nvobj $obj 138 139 if { $_normalIcon == "" } { 140 set normal_icon_data { 141 141 R0lGODlhBwATAOcxAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N 142 142 DQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8f … … 156 156 LAAAAAAHABMAAAg2AP8JHEiwoMGDCBFmW0gw259sDR9GhDjQIUWBFidiXPhwYTZTpv6AXBjy 157 157 j0iSJk9+BDnSo8uAADs= 158 159 158 } 159 set active_icon_data { 160 160 R0lGODlhBwATAOcxAAAAAAEBAQICAgMDAwQEBAUFBQYGBgcHBwgICAkJCQoKCgsLCwwMDA0N 161 161 DQ4ODg8PDxAQEBERERISEhMTExQUFBUVFRYWFhcXFxgYGBkZGRoaGhsbGxwcHB0dHR4eHh8f … … 175 175 LAAAAAAHABMAAAg2AP8JHEiwoMGDCBFmW0gwG4BsDR9GhDjQIUWBFidiXPhwYbY/fwCAXBgS 176 176 gEiSJk9+BDnSo8uAADs= 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 } 198 destructor { 199 177 } 178 set _normalIcon [image create photo -data $normal_icon_data] 179 set _activeIcon [image create photo -data $active_icon_data] 180 } 181 set w [winfo width $_canvas] 182 set h [winfo height $_canvas] 183 set _tick [$c create image 0 $h \ 184 -image $_normalIcon -anchor s \ 185 -tags "$this $obj" -state hidden] 186 set _label [$c create text 0 $h \ 187 -anchor n -fill white -font "Helvetica 6" \ 188 -tags "$this $obj" -state hidden] 189 $c bind $_tick <Enter> [itcl::code $this handle_event "enter"] 190 $c bind $_tick <Leave> [itcl::code $this handle_event "leave"] 191 $c bind $_tick <ButtonPress-1> \ 192 [itcl::code $this handle_event "start" %x %y] 193 $c bind $_tick <B1-Motion> \ 194 [itcl::code $this handle_event "update" %x %y] 195 $c bind $_tick <ButtonRelease-1> \ 196 [itcl::code $this handle_event "end" %x %y] 197 } 198 destructor { 199 $_canvas delete $this 200 200 } 201 201 202 202 public method get_absolute_value {} { 203 203 return $_value 204 204 } 205 205 public method get_relative_value {} { 206 array set limits [$_nvobj get_limits] 207 208 209 210 211 206 array set limits [$_nvobj get_limits] 207 if { $limits(vmax) == $limits(vmin) } { 208 set limits(vmin) 0.0 209 set limits(vmax) 1.0 210 } 211 return [expr {($_value-$limits(vmin))/($limits(vmax) - $limits(vmin))}] 212 212 } 213 213 public method activate { bool } { 214 215 216 217 218 219 220 214 if { $bool || $_active_press || $_active_motion } { 215 $_canvas itemconfigure $_label -state normal 216 $_canvas itemconfigure $_tick -image $_activeIcon 217 } else { 218 $_canvas itemconfigure $_label -state hidden 219 $_canvas itemconfigure $_tick -image $_normalIcon 220 } 221 221 } 222 222 public method show {} { 223 224 225 223 set_absolute_value $_value 224 $_canvas itemconfigure $_tick -state normal 225 $_canvas raise $_tick 226 226 } 227 227 public method hide {} { 228 229 } 230 public method get_screen_position { } { 231 232 233 234 235 set x 1.0 236 237 set low 10 238 239 240 241 228 $_canvas itemconfigure $_tick -state hidden 229 } 230 public method get_screen_position { } { 231 set x [get_relative_value] 232 if { $x < 0.0 } { 233 set x 0.0 234 } elseif { $x > 1.0 } { 235 set x 1.0 236 } 237 set low 10 238 set w [winfo width $_canvas] 239 set high [expr {$w - 10}] 240 set x [expr {round($x*($high - $low) + $low)}] 241 return $x 242 242 } 243 243 public method set_absolute_value { x } { 244 245 246 247 248 249 244 set _value $x 245 set y 31 246 $_canvas itemconfigure $_label -text [format %.4g $_value] 247 set x [get_screen_position] 248 $_canvas coords $_tick $x [expr {$y+3}] 249 $_canvas coords $_label $x [expr {$y+5}] 250 250 } 251 251 public method set_relative_value { x } { 252 array set limits [$_nvobj get_limits] 253 254 255 256 257 258 252 array set limits [$_nvobj get_limits] 253 if { $limits(vmax) == $limits(vmin) } { 254 set limits(vmin) 0.0 255 set limits(vmax) 1.0 256 } 257 set r [expr $limits(vmax) - $limits(vmin)] 258 set_absolute_value [expr {($x * $r) + $limits(vmin)}] 259 259 } 260 260 public method handle_event { option args } { 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 261 switch -- $option { 262 enter { 263 set _active_motion 1 264 activate yes 265 $_canvas raise $_tick 266 } 267 leave { 268 set _active_motion 0 269 activate no 270 } 271 start { 272 $_canvas raise $_tick 273 set _active_press 1 274 activate yes 275 } 276 update { 277 set w [winfo width $_canvas] 278 set x [lindex $args 0] 279 set_relative_value [expr {double($x-10)/($w-20)}] 280 $_nvobj over_isomarker $this $x 281 $_nvobj update_transfer_function 282 } 283 end { 284 set x [lindex $args 0] 285 if { ![$_nvobj remove_duplicate_isomarker $this $x]} { 286 eval handle_event update $args 287 } 288 set _active_press 0 289 activate no 290 } 291 default { 292 error "bad option \"$option\": should be start, update, end" 293 } 294 } 295 295 } 296 296 } -
trunk/gui/scripts/sequence.tcl
r822 r894 63 63 set obj [Rappture::Curve ::#auto $xmlobj $path.$name.$cname] 64 64 } 65 65 histogram { 66 66 set obj [Rappture::Histogram ::#auto $xmlobj $path.$name.$cname] 67 67 } … … 73 73 } 74 74 structure { 75 75 # extract unique result set prefix 76 76 scan $xmlobj "::libraryObj%d" rset 77 77 … … 79 79 set obj [$xmlobj element -as object $path.$name.$cname] 80 80 81 81 # scene id (sequence id) 82 82 set sceneid [$xmlobj element -as id $path]-$rset 83 83 84 84 # sequence/element/frame number starting at 1 85 85 set frameid [expr [$xmlobj element -as id $path.$name] + 1] 86 86 87 88 89 87 # only supporting one molecule per structure at the moment 88 # otherwise should go through all children that are molecules 89 # and insert scene/frame data. 90 90 $obj put "components.molecule.state" $frameid 91 91 $obj put "components.molecule.model" $sceneid 92 92 } 93 93 default { 94 94 error "don't know how to handle sequences of $type"
Note: See TracChangeset
for help on using the changeset viewer.