Changeset 16
- Timestamp:
- Jun 9, 2005, 9:47:20 PM (19 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 3 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/cloud.tcl
r14 r16 170 170 # ---------------------------------------------------------------------- 171 171 itcl::body Rappture::Cloud::dimensions {} { 172 puts "dimensions for cloud [$_cloud element -as id]" 173 puts [string range [$_cloud xml] 0 300] 172 174 # count the dimensions with real limits 173 175 set dims 0 174 176 foreach d {x y z} { 177 puts "checking dims: $d => $_limits(${d}min) $_limits(${d}max)" 175 178 if {$_limits(${d}min) != $_limits(${d}max)} { 176 179 incr dims -
trunk/gui/scripts/contourresult.tcl
r13 r16 40 40 } 41 41 42 blt::bitmap define ContourResult-xslice { 43 #define x_width 12 44 #define x_height 12 45 static unsigned char x_bits[] = { 46 0x00, 0x00, 0x00, 0x00, 0x9c, 0x03, 0x98, 0x01, 0xf0, 0x00, 0x60, 0x00, 47 0x60, 0x00, 0xf0, 0x00, 0x98, 0x01, 0x9c, 0x03, 0x00, 0x00, 0x00, 0x00}; 48 } 49 50 blt::bitmap define ContourResult-yslice { 51 #define y_width 12 52 #define y_height 12 53 static unsigned char y_bits[] = { 54 0x00, 0x00, 0x00, 0x00, 0x0e, 0x07, 0x0c, 0x03, 0x98, 0x01, 0xf0, 0x00, 55 0x60, 0x00, 0x60, 0x00, 0x60, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00}; 56 } 57 blt::bitmap define ContourResult-zslice { 58 #define z_width 12 59 #define z_height 12 60 static unsigned char z_bits[] = { 61 0x00, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x84, 0x03, 0xc0, 0x01, 0xe0, 0x00, 62 0x70, 0x00, 0x38, 0x00, 0x1c, 0x02, 0xfc, 0x03, 0x00, 0x00, 0x00, 0x00}; 63 } 64 42 65 option add *ContourResult.width 4i widgetDefault 43 66 option add *ContourResult.height 4i widgetDefault 44 67 option add *ContourResult.foreground black widgetDefault 45 68 option add *ContourResult.controlBackground gray widgetDefault 69 option add *ContourResult.controlDarkBackground #999999 widgetDefault 46 70 option add *ContourResult.font \ 47 71 -*-helvetica-medium-r-normal-*-*-120-* widgetDefault … … 64 88 protected method _zoom {option} 65 89 protected method _move {option x y} 90 protected method _slice {option args} 66 91 protected method _fixLimits {} 67 92 protected method _color2rgb {color} … … 74 99 private variable _actors ;# list of actors for each renderer 75 100 private variable _click ;# info used for _move operations 76 private variable _xmin "" ;# autoscale min for x-axis 77 private variable _xmax "" ;# autoscale max for x-axis 78 private variable _ymin "" ;# autoscale min for y-axis 79 private variable _ymax "" ;# autoscale max for y-axis 80 private variable _zmin "" ;# autoscale min for z-axis 81 private variable _zmax "" ;# autoscale max for z-axis 101 private variable _slicer ;# vtk transform used for 3D slice plane 102 private variable _limits ;# autoscale min/max for all axes 82 103 83 104 private common _counter 0 ;# used for auto-generated names … … 94 115 option add hull.width hull.height 95 116 pack propagate $itk_component(hull) no 117 118 set _slicer(axis) "" 119 set _slicer(xform) "" 120 set _slicer(readout) "" 96 121 97 122 itk_component add controls { … … 142 167 Rappture::Tooltip::for $itk_component(zoomout) "Zoom out" 143 168 169 itk_component add xslice { 170 label $itk_component(controls).xslice \ 171 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 172 -bitmap ContourResult-xslice 173 } { 174 usual 175 ignore -borderwidth 176 rename -highlightbackground -controlbackground controlBackground Background 177 } 178 bind $itk_component(xslice) <ButtonPress> \ 179 [itcl::code $this _slice axis x] 180 Rappture::Tooltip::for $itk_component(xslice) "Slice along x-axis" 181 182 itk_component add yslice { 183 label $itk_component(controls).yslice \ 184 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 185 -bitmap ContourResult-yslice 186 } { 187 usual 188 ignore -borderwidth 189 rename -highlightbackground -controlbackground controlBackground Background 190 } 191 bind $itk_component(yslice) <ButtonPress> \ 192 [itcl::code $this _slice axis y] 193 Rappture::Tooltip::for $itk_component(yslice) "Slice along y-axis" 194 195 itk_component add zslice { 196 label $itk_component(controls).zslice \ 197 -borderwidth 1 -relief raised -padx 1 -pady 1 \ 198 -bitmap ContourResult-zslice 199 } { 200 usual 201 ignore -borderwidth 202 rename -highlightbackground -controlbackground controlBackground Background 203 } 204 bind $itk_component(zslice) <ButtonPress> \ 205 [itcl::code $this _slice axis z] 206 Rappture::Tooltip::for $itk_component(zslice) "Slice along z-axis" 207 208 itk_component add slicer { 209 ::scale $itk_component(controls).slicer -from 100 -to 0 \ 210 -width 10 -orient vertical -showvalue off \ 211 -borderwidth 1 -highlightthickness 0 \ 212 -command [itcl::code $this _slice move] 213 } { 214 usual 215 ignore -borderwidth 216 ignore -highlightthickness 217 rename -highlightbackground -controlbackground controlBackground Background 218 rename -troughcolor -controldarkbackground controlDarkBackground Background 219 } 220 pack $itk_component(slicer) -side bottom -padx 4 -pady 4 221 Rappture::Tooltip::for $itk_component(slicer) "Move the cut plane" 222 223 # 224 # RENDERING AREA 225 # 144 226 itk_component add area { 145 227 frame $itk_interior.area … … 175 257 176 258 eval itk_initialize $args 177 178 blt::busy hold $itk_component(area) -cursor left_ptr179 bind $itk_component(area)_Busy <ButtonPress> \180 [itcl::code $this _move click %x %y]181 bind $itk_component(area)_Busy <B1-Motion> \182 [itcl::code $this _move drag %x %y]183 bind $itk_component(area)_Busy <ButtonRelease> \184 [itcl::code $this _move release %x %y]185 259 } 186 260 … … 296 370 # ---------------------------------------------------------------------- 297 371 itcl::body Rappture::ContourResult::scale {args} { 298 set _xmin "" 299 set _xmax "" 300 set _ymin "" 301 set _ymax "" 302 set _zmin "" 303 set _zmax "" 372 foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} { 373 set _limits($val) "" 374 } 304 375 foreach obj $args { 305 foreach axis {x y z } {376 foreach axis {x y z v} { 306 377 foreach {min max} [$obj limits $axis] break 307 378 if {"" != $min && "" != $max} { 308 if {"" == [set _${axis}min]} {309 set _ ${axis}min$min310 set _ ${axis}max$max379 if {"" == $_limits(${axis}min)} { 380 set _limits(${axis}min) $min 381 set _limits(${axis}max) $max 311 382 } else { 312 if {$min < [set _${axis}min]} {313 set _ ${axis}min$min383 if {$min < $_limits(${axis}min)} { 384 set _limits(${axis}min) $min 314 385 } 315 if {$max > [set _${axis}max]} {316 set _ ${axis}max$max386 if {$max > $_limits(${axis}max)} { 387 set _limits(${axis}max) $max 317 388 } 318 389 } … … 343 414 } 344 415 set _obj2vtk($dataobj) "" 416 } 417 set _slicer(axis) "" 418 set _slicer(xform) "" 419 set _slicer(readout) "" 420 421 # determine the dimensionality from the topmost (raised) object 422 set dlist [get] 423 set dataobj [lindex $dlist end] 424 if {$dataobj != ""} { 425 set dims [$dataobj components -dimensions] 426 } else { 427 set dims "0D" 345 428 } 346 429 … … 354 437 [$pd GetPointData] SetScalars [$dataobj values $comp] 355 438 356 # use _zmin/_zmax if possible, otherwise get from data357 if {$_ zmin == "" || $_zmax== ""} {358 foreach { z0 z1} [$pd GetScalarRange] break439 # use vmin/vmax if possible, otherwise get from data 440 if {$_limits(vmin) == "" || $_limits(vmax) == ""} { 441 foreach {v0 v1} [$pd GetScalarRange] break 359 442 } else { 360 set z0 $_zmin361 set z1 $_zmax443 set v0 $_limits(vmin) 444 set v1 $_limits(vmax) 362 445 } 363 446 364 447 set tr $this-triangles$_counter 365 vtkDelaunay 2D$tr448 vtkDelaunay$dims $tr 366 449 $tr SetInput $pd 367 450 $tr SetTolerance 0.0000000000001 … … 369 452 set lu $this-lookup$_counter 370 453 vtkLookupTable $lu 371 $lu SetTableRange $ z0 $z1454 $lu SetTableRange $v0 $v1 372 455 $lu SetHueRange 0.66667 0.0 373 456 $lu Build … … 379 462 # 380 463 if {$_counter == 0} { 381 set mp $this-mapper$_counter 382 vtkPolyDataMapper $mp 383 $mp SetInput [$tr GetOutput] 384 $mp SetScalarRange $z0 $z1 385 $mp SetLookupTable $lu 386 387 set ac $this-actor$_counter 388 vtkActor $ac 389 $ac SetMapper $mp 390 $ac SetPosition 0 0 0 391 [$ac GetProperty] SetColor 0 0 0 392 $this-ren AddActor $ac 393 lappend _actors($this-ren) $ac 394 395 lappend _obj2vtk($dataobj) $mp $ac 464 if {$dims == "3D"} { 465 pack $itk_component(slicer) -side bottom -padx 4 -pady 4 466 pack $itk_component(zslice) -side bottom -padx 4 -pady 4 467 pack $itk_component(yslice) -side bottom -padx 4 -pady 4 468 pack $itk_component(xslice) -side bottom -padx 4 -pady 4 469 470 # 471 # 3D CUT PLANE 472 # 473 set pl $this-cutplane$_counter 474 vtkPlaneSource $pl 475 $pl SetResolution 50 50 476 477 set xf $this-cpxform$_counter 478 vtkTransform $xf 479 set _slicer(xform) $xf 480 _slice axis "z" 481 482 set pdf $this-cpfilter$_counter 483 vtkTransformPolyDataFilter $pdf 484 $pdf SetInput [$pl GetOutput] 485 $pdf SetTransform $xf 486 487 set pb $this-cpprobe$_counter 488 vtkProbeFilter $pb 489 $pb SetInput [$pdf GetOutput] 490 $pb SetSource [$tr GetOutput] 491 492 lappend _obj2vtk($dataobj) $pl $xf $pdf $pb 493 494 set mp $this-mapper$_counter 495 vtkPolyDataMapper $mp 496 $mp SetInput [$pb GetOutput] 497 $mp SetScalarRange $v0 $v1 498 $mp SetLookupTable $lu 499 500 set ac $this-actor$_counter 501 vtkActor $ac 502 $ac SetMapper $mp 503 $ac SetPosition 0 0 0 504 [$ac GetProperty] SetColor 0 0 0 505 $this-ren AddActor $ac 506 lappend _actors($this-ren) $ac 507 508 lappend _obj2vtk($dataobj) $mp $ac 509 510 set olf $this-3dolfilter$_counter 511 vtkOutlineFilter $olf 512 $olf SetInput [$tr GetOutput] 513 514 set olm $this-3dolmapper$_counter 515 vtkPolyDataMapper $olm 516 $olm SetInput [$olf GetOutput] 517 518 set ola $this-3dolactor$_counter 519 vtkActor $ola 520 $ola SetMapper $olm 521 eval [$ola GetProperty] SetColor 0 0 0 522 $this-ren AddActor $ola 523 lappend _actors($this-ren) $ola 524 525 lappend _obj2vtk($dataobj) $olf $olm $ola 526 527 # 528 # CUT PLANE READOUT 529 # 530 set tx $this-text$_counter 531 vtkTextMapper $tx 532 set tp [$tx GetTextProperty] 533 eval $tp SetColor [_color2rgb $itk_option(-foreground)] 534 $tp SetVerticalJustificationToTop 535 set _slicer(readout) $tx 536 537 set txa $this-texta$_counter 538 vtkActor2D $txa 539 $txa SetMapper $tx 540 [$txa GetPositionCoordinate] \ 541 SetCoordinateSystemToNormalizedDisplay 542 [$txa GetPositionCoordinate] SetValue 0.02 0.98 543 544 $this-ren AddActor $txa 545 lappend _actors($this-ren) $txa 546 547 lappend _obj2vtk($dataobj) $tx $txa 548 } else { 549 pack forget $itk_component(xslice) 550 pack forget $itk_component(yslice) 551 pack forget $itk_component(zslice) 552 pack forget $itk_component(slicer) 553 554 set mp $this-mapper$_counter 555 vtkPolyDataMapper $mp 556 $mp SetInput [$tr GetOutput] 557 $mp SetScalarRange $v0 $v1 558 $mp SetLookupTable $lu 559 560 set ac $this-actor$_counter 561 vtkActor $ac 562 $ac SetMapper $mp 563 $ac SetPosition 0 0 0 564 [$ac GetProperty] SetColor 0 0 0 565 $this-ren AddActor $ac 566 lappend _actors($this-ren) $ac 567 568 lappend _obj2vtk($dataobj) $mp $ac 569 } 396 570 } 397 571 … … 403 577 vtkContourFilter $cf 404 578 $cf SetInput [$tr GetOutput] 405 $cf GenerateValues 20 $ z0 $z1579 $cf GenerateValues 20 $v0 $v1 406 580 407 581 set mp $this-clmapper$_counter 408 582 vtkPolyDataMapper $mp 409 583 $mp SetInput [$cf GetOutput] 410 $mp SetScalarRange $ z0 $z1584 $mp SetScalarRange $v0 $v1 411 585 $mp SetLookupTable $lu 412 586 … … 469 643 } 470 644 _fixLimits 645 _zoom reset 646 647 if {$dims == "3D"} { 648 # allow interactions in 3D 649 catch {blt::busy release $itk_component(area)} 650 } else { 651 # prevent interactions in 2D 652 blt::busy hold $itk_component(area) -cursor left_ptr 653 bind $itk_component(area)_Busy <ButtonPress> \ 654 [itcl::code $this _move click %x %y] 655 bind $itk_component(area)_Busy <B1-Motion> \ 656 [itcl::code $this _move drag %x %y] 657 bind $itk_component(area)_Busy <ButtonRelease> \ 658 [itcl::code $this _move release %x %y] 659 } 471 660 } 472 661 … … 545 734 546 735 # ---------------------------------------------------------------------- 736 # USAGE: _slice axis x|y|z 737 # USAGE: _slice move <newval> 738 # 739 # Called automatically when the user drags the slider to move the 740 # cut plane that slices 3D data. Gets the current value from the 741 # slider and moves the cut plane to the appropriate point in the 742 # data set. 743 # ---------------------------------------------------------------------- 744 itcl::body Rappture::ContourResult::_slice {option args} { 745 if {$_slicer(xform) == ""} { 746 # no slicer? then bail out! 747 return 748 } 749 switch -- $option { 750 axis { 751 if {[llength $args] != 1} { 752 error "wrong # args: should be \"_slice axis xyz\"" 753 } 754 set axis [lindex $args 0] 755 756 set _slicer(axis) $axis 757 $itk_component(slicer) set 50 758 _slice move 50 759 $this-renWin Render 760 761 foreach a {x y z} { 762 $itk_component(${a}slice) configure -relief raised 763 } 764 $itk_component(${axis}slice) configure -relief sunken 765 } 766 move { 767 if {[llength $args] != 1} { 768 error "wrong # args: should be \"_slice move newval\"" 769 } 770 set newval [lindex $args 0] 771 772 switch -- $_slicer(axis) { 773 x { 774 # Rotate 90 around x-axis -- switch y/z scales 775 # limit z-motion according to y-scale 776 set min ymin; set max ymax 777 # switch scales for y/z 778 set sx [expr {$_limits(xmax)-$_limits(xmin)}] 779 set sy [expr {$_limits(zmax)-$_limits(zmin)}] 780 set sz [expr {$_limits(ymax)-$_limits(ymin)}] 781 } 782 y { 783 # Rotate 90 around x-axis -- switch x/z scales 784 # limit z-motion according to x-scale 785 set min xmin; set max xmax 786 # switch scales for x/z 787 set sx [expr {$_limits(zmax)-$_limits(zmin)}] 788 set sy [expr {$_limits(ymax)-$_limits(ymin)}] 789 set sz [expr {$_limits(xmax)-$_limits(xmin)}] 790 } 791 z { 792 # No rotation -- treat z-axis normally 793 set min zmin; set max zmax 794 set sx [expr {$_limits(xmax)-$_limits(xmin)}] 795 set sy [expr {$_limits(ymax)-$_limits(ymin)}] 796 set sz [expr {$_limits(zmax)-$_limits(zmin)}] 797 } 798 } 799 800 set zval [expr {0.01*($newval-50) 801 *($_limits($max)-$_limits($min)) 802 + 0.5*($_limits($max)+$_limits($min))}] 803 804 $_slicer(xform) Identity 805 switch -- $_slicer(axis) { 806 x { $_slicer(xform) RotateX 90 } 807 y { $_slicer(xform) RotateY 90 } 808 z { # all set } 809 default { error "bad axis \"$axis\": should be x, y, z" } 810 } 811 $_slicer(xform) Translate 0 0 $zval 812 $_slicer(xform) Scale $sx $sy $sz 813 814 # show the current value in the readout 815 if {$_slicer(readout) != ""} { 816 set a $_slicer(axis) 817 set newval [expr {0.01*($newval-50) 818 *($_limits(${a}max)-$_limits(${a}min)) 819 + 0.5*($_limits(${a}max)+$_limits(${a}min))}] 820 $_slicer(readout) SetInput "$a = $newval" 821 } 822 823 $this-renWin Render 824 } 825 default { 826 error "bad option \"$option\": should be axis or move" 827 } 828 } 829 } 830 831 # ---------------------------------------------------------------------- 547 832 # USAGE: _fixLimits 548 833 # -
trunk/gui/scripts/field.tcl
r14 r16 180 180 # ---------------------------------------------------------------------- 181 181 itcl::body Rappture::Field::limits {axis} { 182 foreach val {xmin xmax ymin ymax zmin zmax } {182 foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} { 183 183 set results($val) "" 184 184 } … … 192 192 set lims(xmax) $x(max) 193 193 194 $yv variable y 195 set lims(ymin) $y(min) 196 set lims(ymax) $y(max) 197 194 set lims(ymin) 0 195 set lims(ymax) 0 198 196 set lims(zmin) 0 199 197 set lims(zmax) 0 198 199 $yv variable v 200 set lims(vmin) $v(min) 201 set lims(vmax) $v(max) 200 202 } 201 203 2D - 3D { … … 204 206 foreach {lims(xmin) lims(xmax)} [$xv limits x] break 205 207 foreach {lims(ymin) lims(ymax)} [$xv limits y] break 206 foreach {lims(zmin) lims(zmax)} [$yv GetRange] break 207 } 208 } 209 foreach val {xmin ymin zmin} { 208 foreach {lims(zmin) lims(zmax)} [$xv limits z] break 209 foreach {lims(vmin) lims(vmax)} [$yv GetRange] break 210 } 211 } 212 foreach val {xmin ymin zmin vmin} { 210 213 if {"" == $results($val) || $lims($val) < $results($val)} { 211 214 set results($val) $lims($val) 212 215 } 213 216 } 214 foreach val {xmax ymax zmax } {217 foreach val {xmax ymax zmax vmax} { 215 218 if {"" == $results($val) || $lims($val) > $results($val)} { 216 219 set results($val) $lims($val) -
trunk/gui/scripts/resultviewer.tcl
r14 r16 196 196 } 197 197 } 198 2D {198 2D - 3D { 199 199 set mode "contour" 200 200 if {![info exists _mode2widget($mode)]} { -
trunk/gui/scripts/xyresult.tcl
r14 r16 56 56 private variable _xmin "" ;# autoscale min for x-axis 57 57 private variable _xmax "" ;# autoscale max for x-axis 58 private variable _ ymin "" ;# autoscale min for y-axis59 private variable _ ymax "" ;# autoscale max for y-axis58 private variable _vmin "" ;# autoscale min for y-axis 59 private variable _vmax "" ;# autoscale max for y-axis 60 60 private variable _hilite "" ;# info from last _hilite operation 61 61 } … … 242 242 set _xmin "" 243 243 set _xmax "" 244 set _ ymin ""245 set _ ymax ""244 set _vmin "" 245 set _vmax "" 246 246 foreach obj $args { 247 foreach axis {x y} {247 foreach axis {x v} { 248 248 foreach {min max} [$obj limits $axis] break 249 249 if {"" != $min && "" != $max} { … … 373 373 } 374 374 375 if {"" != $_ ymin && "" != $_ymax} {376 set min $_ ymin377 set max $_ ymax375 if {"" != $_vmin && "" != $_vmax} { 376 set min $_vmin 377 set max $_vmax 378 378 set log [$g axis cget y -logscale] 379 379 if {$log} {
Note: See TracChangeset
for help on using the changeset viewer.