Changeset 17
- Timestamp:
- Jun 11, 2005, 9:56:37 PM (19 years ago)
- Location:
- trunk/gui
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/apps/driver
r13 r17 44 44 option add *TemperatureGauge.textBackground white 45 45 option add *Switch.textBackground white 46 47 switch $tcl_platform(platform) { 48 unix - windows { 49 event add <<PopupMenu>> <ButtonPress-3> 50 } 51 macintosh { 52 event add <<PopupMenu>> <Control-ButtonPress-1> 53 } 54 } 46 55 47 56 # -
trunk/gui/scripts/analyzer.tcl
r13 r17 379 379 } 380 380 381 if {"" != $label} { 381 set hidden [$xmlobj get output.$item.hide] 382 set hidden [expr {"" != $hidden && $hidden}] 383 384 if {"" != $label && !$hidden} { 382 385 set haveresults 1 383 386 } … … 396 399 } 397 400 398 if {"" != $label} { 401 set hidden [$xmlobj get output.$item.hide] 402 set hidden [expr {"" != $hidden && $hidden}] 403 404 if {"" != $label && !$hidden} { 399 405 if {![info exists _label2page($label)]} { 400 406 set name "page[incr _pages]" -
trunk/gui/scripts/cloud.tcl
r16 r17 20 20 21 21 public method points {} 22 public method mesh {} 22 23 public method size {} 23 24 public method dimensions {} … … 156 157 157 158 # ---------------------------------------------------------------------- 159 # USAGE: mesh 160 # 161 # Returns the vtk object representing the mesh. 162 # ---------------------------------------------------------------------- 163 itcl::body Rappture::Cloud::mesh {} { 164 return $this-points 165 } 166 167 # ---------------------------------------------------------------------- 158 168 # USAGE: size 159 169 # … … 170 180 # ---------------------------------------------------------------------- 171 181 itcl::body Rappture::Cloud::dimensions {} { 172 puts "dimensions for cloud [$_cloud element -as id]"173 puts [string range [$_cloud xml] 0 300]174 182 # count the dimensions with real limits 175 183 set dims 0 176 184 foreach d {x y z} { 177 puts "checking dims: $d => $_limits(${d}min) $_limits(${d}max)"178 185 if {$_limits(${d}min) != $_limits(${d}max)} { 179 186 incr dims -
trunk/gui/scripts/contourresult.tcl
r16 r17 86 86 87 87 protected method _rebuild {} 88 protected method _clear {} 88 89 protected method _zoom {option} 89 90 protected method _move {option x y} 90 91 protected method _slice {option args} 92 protected method _3dView {theta phi} 91 93 protected method _fixLimits {} 92 94 protected method _color2rgb {color} 93 95 94 96 private variable _dlist "" ;# list of data objects 97 private variable _dims "" ;# dimensionality of data objects 95 98 private variable _obj2color ;# maps dataobj => plotting color 96 99 private variable _obj2width ;# maps dataobj => line width … … 98 101 private variable _obj2vtk ;# maps dataobj => vtk objects 99 102 private variable _actors ;# list of actors for each renderer 103 private variable _lights ;# list of lights for each renderer 100 104 private variable _click ;# info used for _move operations 101 105 private variable _slicer ;# vtk transform used for 3D slice plane 102 106 private variable _limits ;# autoscale min/max for all axes 107 private variable _view ;# view params for 3D view 103 108 104 109 private common _counter 0 ;# used for auto-generated names … … 117 122 118 123 set _slicer(axis) "" 119 set _slicer( xform) ""124 set _slicer(plane) "" 120 125 set _slicer(readout) "" 126 set _view(theta) 0 127 set _view(phi) 0 121 128 122 129 itk_component add controls { … … 263 270 # ---------------------------------------------------------------------- 264 271 itcl::body Rappture::ContourResult::destructor {} { 272 _clear 273 after cancel [itcl::code $this _rebuild] 274 265 275 rename $this-renWin "" 266 276 rename $this-ren "" … … 270 280 rename $this-ren2 "" 271 281 rename $this-iren2 "" 272 273 after cancel [itcl::code $this _rebuild]274 282 } 275 283 … … 402 410 # ---------------------------------------------------------------------- 403 411 itcl::body Rappture::ContourResult::_rebuild {} { 404 # clear out any old constructs 405 foreach ren [array names _actors] { 406 foreach actor $_actors($ren) { 407 $ren RemoveActor $actor 408 } 409 set _actors($ren) "" 410 } 411 foreach dataobj [array names _obj2vtk] { 412 foreach cmd $_obj2vtk($dataobj) { 413 rename $cmd "" 414 } 415 set _obj2vtk($dataobj) "" 416 } 417 set _slicer(axis) "" 418 set _slicer(xform) "" 419 set _slicer(readout) "" 412 _clear 420 413 421 414 # determine the dimensionality from the topmost (raised) object … … 423 416 set dataobj [lindex $dlist end] 424 417 if {$dataobj != ""} { 425 set dims [$dataobj components -dimensions]418 set _dims [$dataobj components -dimensions] 426 419 } else { 427 set dims "0D"420 set _dims "0D" 428 421 } 429 422 … … 432 425 foreach dataobj [get] { 433 426 foreach comp [$dataobj components] { 434 set pd $this-polydata$_counter 435 vtkPolyData $pd 436 $pd SetPoints [$dataobj mesh $comp] 437 [$pd GetPointData] SetScalars [$dataobj values $comp] 438 427 # 428 # LOOKUP TABLE FOR COLOR CONTOURS 429 # 439 430 # use vmin/vmax if possible, otherwise get from data 440 431 if {$_limits(vmin) == "" || $_limits(vmax) == ""} { … … 445 436 } 446 437 447 set tr $this-triangles$_counter448 vtkDelaunay$dims $tr449 $tr SetInput $pd450 $tr SetTolerance 0.0000000000001451 452 438 set lu $this-lookup$_counter 453 439 vtkLookupTable $lu … … 456 442 $lu Build 457 443 458 lappend _obj2vtk($dataobj) $ pd $tr $lu444 lappend _obj2vtk($dataobj) $lu 459 445 460 446 # … … 462 448 # 463 449 if {$_counter == 0} { 464 if {$ dims == "3D"} {450 if {$_dims == "3D"} { 465 451 pack $itk_component(slicer) -side bottom -padx 4 -pady 4 466 452 pack $itk_component(zslice) -side bottom -padx 4 -pady 4 … … 469 455 470 456 # 457 # 3D LIGHTS (on both sides of all three axes) 458 # 459 set xm [expr {0.5*($_limits(xmax)+$_limits(xmin))}] 460 set ym [expr {0.5*($_limits(ymax)+$_limits(ymin))}] 461 set zm [expr {0.5*($_limits(zmax)+$_limits(zmin))}] 462 set xr [expr {$_limits(xmax)-$_limits(xmin)}] 463 set yr [expr {$_limits(ymax)-$_limits(ymin)}] 464 set zr [expr {$_limits(zmax)-$_limits(zmin)}] 465 466 set lt $this-lightxm$_counter 467 vtkLight $lt 468 $lt SetColor 1 1 1 469 $lt SetAttenuationValues 0 0 0 470 $lt SetFocalPoint $xm $ym $zm 471 $lt SetPosition [expr {$xm-$xr}] 0 0 472 $this-ren AddLight $lt 473 lappend _lights($this-ren) $lt 474 475 set lt $this-lightxp$_counter 476 vtkLight $lt 477 $lt SetColor 1 1 1 478 $lt SetAttenuationValues 0 0 0 479 $lt SetFocalPoint $xm $ym $zm 480 $lt SetPosition [expr {$xm+$xr}] 0 0 481 $this-ren AddLight $lt 482 lappend _lights($this-ren) $lt 483 484 set lt $this-lightym$_counter 485 vtkLight $lt 486 $lt SetColor 1 1 1 487 $lt SetAttenuationValues 0 0 0 488 $lt SetFocalPoint $xm $ym $zm 489 $lt SetPosition 0 [expr {$ym-$yr}] 0 490 $this-ren AddLight $lt 491 lappend _lights($this-ren) $lt 492 493 set lt $this-lightyp$_counter 494 vtkLight $lt 495 $lt SetColor 1 1 1 496 $lt SetAttenuationValues 0 0 0 497 $lt SetFocalPoint $xm $ym $zm 498 $lt SetPosition 0 [expr {$ym+$yr}] 0 499 $this-ren AddLight $lt 500 lappend _lights($this-ren) $lt 501 502 set lt $this-lightzm$_counter 503 vtkLight $lt 504 $lt SetColor 1 1 1 505 $lt SetAttenuationValues 0 0 0 506 $lt SetFocalPoint $xm $ym $zm 507 $lt SetPosition 0 0 [expr {$zm-$zr}] 508 $this-ren AddLight $lt 509 lappend _lights($this-ren) $lt 510 511 set lt $this-lightzp$_counter 512 vtkLight $lt 513 $lt SetColor 1 1 1 514 $lt SetAttenuationValues 0 0 0 515 $lt SetFocalPoint $xm $ym $zm 516 $lt SetPosition 0 0 [expr {$zm+$zr}] 517 $this-ren AddLight $lt 518 lappend _lights($this-ren) $lt 519 520 # 521 # 3D DATA SET 522 # 523 set mesh [$dataobj mesh $comp] 524 switch -- [$mesh GetClassName] { 525 vtkPoints { 526 # handle cloud of 3D points 527 set pd $this-polydata$_counter 528 vtkPolyData $pd 529 $pd SetPoints $mesh 530 [$pd GetPointData] SetScalars [$dataobj values $comp] 531 532 set tr $this-triangles$_counter 533 vtkDelaunay3D $tr 534 $tr SetInput $pd 535 $tr SetTolerance 0.0000000000001 536 set source [$tr GetOutput] 537 538 set mp $this-mapper$_counter 539 vtkPolyDataMapper $mp 540 541 lappend _obj2vtk($dataobj) $pd $tr $mp 542 } 543 vtkUnstructuredGrid { 544 # handle 3D grid with connectivity 545 set gr $this-grdata$_counter 546 vtkUnstructuredGrid $gr 547 $gr ShallowCopy $mesh 548 [$gr GetPointData] SetScalars [$dataobj values $comp] 549 set source $gr 550 551 lappend _obj2vtk($dataobj) $gr 552 } 553 default { 554 error "don't know how to handle [$mesh GetClassName] data" 555 } 556 } 557 558 # 471 559 # 3D CUT PLANE 472 560 # 473 561 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 562 vtkPlane $pl 563 set _slicer(plane) $pl 480 564 _slice axis "z" 481 565 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 566 set ct $this-cutter$_counter 567 vtkCutter $ct 568 $ct SetInput $source 569 $ct SetCutFunction $pl 570 571 set mp $this-cutmapper$_counter 495 572 vtkPolyDataMapper $mp 496 $mp SetInput [$ pbGetOutput]573 $mp SetInput [$ct GetOutput] 497 574 $mp SetScalarRange $v0 $v1 498 575 $mp SetLookupTable $lu 576 577 lappend _obj2vtk($dataobj) $pl $ct $mp 499 578 500 579 set ac $this-actor$_counter … … 505 584 $this-ren AddActor $ac 506 585 lappend _actors($this-ren) $ac 507 508 lappend _obj2vtk($dataobj) $mp $ac 586 lappend _obj2vtk($dataobj) $ac 509 587 510 588 set olf $this-3dolfilter$_counter 511 589 vtkOutlineFilter $olf 512 $olf SetInput [$tr GetOutput]590 $olf SetInput $source 513 591 514 592 set olm $this-3dolmapper$_counter … … 552 630 pack forget $itk_component(slicer) 553 631 632 set pd $this-polydata$_counter 633 vtkPolyData $pd 634 $pd SetPoints [$dataobj mesh $comp] 635 [$pd GetPointData] SetScalars [$dataobj values $comp] 636 637 set tr $this-triangles$_counter 638 vtkDelaunay2D $tr 639 $tr SetInput $pd 640 $tr SetTolerance 0.0000000000001 641 set source [$tr GetOutput] 642 554 643 set mp $this-mapper$_counter 555 644 vtkPolyDataMapper $mp 556 $mp SetInput [$tr GetOutput]645 $mp SetInput $source 557 646 $mp SetScalarRange $v0 $v1 558 647 $mp SetLookupTable $lu … … 566 655 lappend _actors($this-ren) $ac 567 656 568 lappend _obj2vtk($dataobj) $ mp $ac657 lappend _obj2vtk($dataobj) $pd $tr $mp $ac 569 658 } 570 659 } … … 576 665 set cf $this-clfilter$_counter 577 666 vtkContourFilter $cf 578 $cf SetInput [$tr GetOutput]667 $cf SetInput $source 579 668 $cf GenerateValues 20 $v0 $v1 580 669 … … 601 690 set olf $this-olfilter$_counter 602 691 vtkOutlineFilter $olf 603 $olf SetInput [$tr GetOutput]692 $olf SetInput $source 604 693 605 694 set olm $this-olmapper$_counter … … 645 734 _zoom reset 646 735 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 } 736 # prevent interactions -- use our own 737 blt::busy hold $itk_component(area) -cursor left_ptr 738 bind $itk_component(area)_Busy <ButtonPress> \ 739 [itcl::code $this _move click %x %y] 740 bind $itk_component(area)_Busy <B1-Motion> \ 741 [itcl::code $this _move drag %x %y] 742 bind $itk_component(area)_Busy <ButtonRelease> \ 743 [itcl::code $this _move release %x %y] 744 } 745 746 # ---------------------------------------------------------------------- 747 # USAGE: _clear 748 # 749 # Used internally to clear the drawing area and tear down all vtk 750 # objects in the current scene. 751 # ---------------------------------------------------------------------- 752 itcl::body Rappture::ContourResult::_clear {} { 753 # clear out any old constructs 754 foreach ren [array names _actors] { 755 foreach actor $_actors($ren) { 756 $ren RemoveActor $actor 757 } 758 set _actors($ren) "" 759 } 760 foreach ren [array names _lights] { 761 foreach light $_lights($ren) { 762 $ren RemoveLight $light 763 rename $light "" 764 } 765 set _lights($ren) "" 766 } 767 foreach dataobj [array names _obj2vtk] { 768 foreach cmd $_obj2vtk($dataobj) { 769 rename $cmd "" 770 } 771 set _obj2vtk($dataobj) "" 772 } 773 set _slicer(axis) "" 774 set _slicer(plane) "" 775 set _slicer(readout) "" 660 776 } 661 777 … … 671 787 switch -- $option { 672 788 in { 673 set camera [$this-ren GetActiveCamera] 674 set zoom [$camera Zoom 1.25] 789 [$this-ren GetActiveCamera] Zoom 1.25 675 790 $this-renWin Render 676 791 } 677 792 out { 678 set camera [$this-ren GetActiveCamera] 679 set zoom [$camera Zoom 0.8] 793 [$this-ren GetActiveCamera] Zoom 0.8 680 794 $this-renWin Render 681 795 } 682 796 reset { 683 $this-ren ResetCamera 684 [$this-ren GetActiveCamera] Zoom 1.5 797 if {$_dims == "3D"} { 798 [$this-ren GetActiveCamera] SetViewAngle 30 799 $this-ren ResetCamera 800 _3dView 45 45 801 } else { 802 $this-ren ResetCamera 803 [$this-ren GetActiveCamera] Zoom 1.5 804 } 685 805 $this-renWin Render 686 806 $this-renWin2 Render … … 703 823 set _click(x) $x 704 824 set _click(y) $y 825 set _click(theta) $_view(theta) 826 set _click(phi) $_view(phi) 705 827 } 706 828 drag { … … 712 834 set dx [expr {double($x-$_click(x))/$w}] 713 835 set dy [expr {double($y-$_click(y))/$h}] 714 foreach actor $_actors($this-ren) { 715 foreach {ax ay az} [$actor GetPosition] break 716 $actor SetPosition [expr {$ax+$dx}] [expr {$ay-$dy}] 0 836 837 if {$_dims == "2D"} { 838 # 839 # Shift the contour plot in 2D 840 # 841 foreach actor $_actors($this-ren) { 842 foreach {ax ay az} [$actor GetPosition] break 843 $actor SetPosition [expr {$ax+$dx}] [expr {$ay-$dy}] 0 844 } 845 $this-renWin Render 846 } elseif {$_dims == "3D"} { 847 # 848 # Rotate the camera in 3D 849 # 850 set theta [expr {$_view(theta) - $dy*180}] 851 if {$theta < 2} { set theta 2 } 852 if {$theta > 178} { set theta 178 } 853 set phi [expr {$_view(phi) - $dx*360}] 854 855 _3dView $theta $phi 856 $this-renWin Render 717 857 } 718 $this-renWin Render719 720 858 set _click(x) $x 721 859 set _click(y) $y … … 743 881 # ---------------------------------------------------------------------- 744 882 itcl::body Rappture::ContourResult::_slice {option args} { 745 if {$_slicer( xform) == ""} {883 if {$_slicer(plane) == ""} { 746 884 # no slicer? then bail out! 747 885 return … … 754 892 set axis [lindex $args 0] 755 893 894 switch -- $axis { 895 x { $_slicer(plane) SetNormal 1 0 0 } 896 y { $_slicer(plane) SetNormal 0 1 0 } 897 z { $_slicer(plane) SetNormal 0 0 1 } 898 default { 899 error "bad axis \"$axis\": should be x, y, z" 900 } 901 } 902 756 903 set _slicer(axis) $axis 757 904 $itk_component(slicer) set 50 … … 770 917 set newval [lindex $args 0] 771 918 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 919 set xm [expr {0.5*($_limits(xmax)+$_limits(xmin))}] 920 set ym [expr {0.5*($_limits(ymax)+$_limits(ymin))}] 921 set zm [expr {0.5*($_limits(zmax)+$_limits(zmin))}] 922 923 set a $_slicer(axis) 924 set newval [expr {0.01*($newval-50) 925 *($_limits(${a}max)-$_limits(${a}min)) 926 + 0.5*($_limits(${a}max)+$_limits(${a}min))}] 813 927 814 928 # show the current value in the readout 815 929 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 930 $_slicer(readout) SetInput "$a = $newval" 821 931 } 932 933 # keep a little inside the volume, or the slice will disappear! 934 if {$newval == $_limits(${a}min)} { 935 set range [expr {$_limits(${a}max)-$_limits(${a}min)}] 936 set newval [expr {$newval + 1e-6*$range}] 937 } 938 939 # xfer new value to the proper dimension and move the cut plane 940 set ${a}m $newval 941 $_slicer(plane) SetOrigin $xm $ym $zm 822 942 823 943 $this-renWin Render … … 827 947 } 828 948 } 949 } 950 951 # ---------------------------------------------------------------------- 952 # USAGE: _3dView <theta> <phi> 953 # 954 # Used internally to change the position of the camera for 3D data 955 # sets. Sets the camera according to the angles <theta> (angle from 956 # the z-axis) and <phi> (angle from the x-axis in the x-y plane). 957 # Both angles are in degrees. 958 # ---------------------------------------------------------------------- 959 itcl::body Rappture::ContourResult::_3dView {theta phi} { 960 set deg2rad 0.0174532927778 961 set xn [expr {sin($theta*$deg2rad)*cos($phi*$deg2rad)}] 962 set yn [expr {sin($theta*$deg2rad)*sin($phi*$deg2rad)}] 963 set zn [expr {cos($theta*$deg2rad)}] 964 965 set xm [expr {0.5*($_limits(xmax)+$_limits(xmin))}] 966 set ym [expr {0.5*($_limits(ymax)+$_limits(ymin))}] 967 set zm [expr {0.5*($_limits(zmax)+$_limits(zmin))}] 968 969 set cam [$this-ren GetActiveCamera] 970 set zoom [$cam GetViewAngle] 971 $cam SetViewAngle 30 972 973 $cam SetFocalPoint $xm $ym $zm 974 $cam SetPosition [expr {$xm-$xn}] [expr {$ym-$yn}] [expr {$zm+$zn}] 975 $cam ComputeViewPlaneNormal 976 $cam SetViewUp 0 0 1 ;# z-dir is up 977 $cam OrthogonalizeViewUp 978 $this-ren ResetCamera 979 $cam SetViewAngle $zoom 980 981 set _view(theta) $theta 982 set _view(phi) $phi 829 983 } 830 984 -
trunk/gui/scripts/curve.tcl
r13 r17 117 117 switch -- $which { 118 118 x { set pos 0 } 119 y { set pos 1 }119 y - v { set pos 1 } 120 120 default { 121 121 error "bad option \"$which\": should be x or y" -
trunk/gui/scripts/editor.tcl
r11 r17 91 91 [itcl::code $this _click %X %Y] 92 92 93 itk_component add emenu { 94 menu $itk_component(editor).menu -tearoff 0 95 } { 96 usual 97 ignore -tearoff 98 ignore -background -foreground 99 } 100 $itk_component(emenu) add command -label "Cut" -accelerator "^X" \ 101 -command [list event generate $itk_component(editor) <<Cut>>] 102 $itk_component(emenu) add command -label "Copy" -accelerator "^C" \ 103 -command [list event generate $itk_component(editor) <<Copy>>] 104 $itk_component(emenu) add command -label "Paste" -accelerator "^V" \ 105 -command [list event generate $itk_component(editor) <<Paste>>] 106 bind $itk_component(editor) <<PopupMenu>> { 107 tk_popup %W.menu %X %Y 108 } 109 93 110 eval itk_initialize $args 94 111 } … … 104 121 itcl::body Rappture::Editor::activate {} { 105 122 set e $itk_component(editor) 123 if {[winfo ismapped $e]} { 124 return ;# already mapped -- nothing to do 125 } 106 126 107 127 set info "" … … 234 254 if {[winfo containing $x $y] != $itk_component(editor)} { 235 255 deactivate 256 } else { 257 # make sure the editor has keyboard focus! 258 # it loses focus sometimes during cut/copy/paste operations 259 focus -force $itk_component(editor) 236 260 } 237 261 } -
trunk/gui/scripts/field.tcl
r16 r17 92 92 } 93 93 foreach name [array names _comp2vtk] { 94 set cobj [lindex $_comp2vtk($name) 0] 95 Rappture::Cloud::release $cobj 94 set mobj [lindex $_comp2vtk($name) 0] 95 set class [$mobj info class] 96 ${class}::release $mobj 96 97 97 98 set fobj [lindex $_comp2vtk($name) 1] … … 147 148 } 148 149 if {[info exists _comp2vtk($what)]} { 149 set cobj [lindex $_comp2vtk($what) 0]150 return [$ cobj points]150 set mobj [lindex $_comp2vtk($what) 0] 151 return [$mobj mesh] 151 152 } 152 153 error "bad option \"$what\": should be [join [lsort [array names _comp2dims]] {, }]" … … 305 306 } 306 307 foreach name [array names _comp2vtk] { 307 set cobj [lindex $_comp2vtk($name) 0] 308 Rappture::Cloud::release $cobj 308 set mobj [lindex $_comp2vtk($name) 0] 309 set class [$mobj info class] 310 ${class}::release $mobj 309 311 310 312 set fobj [lindex $_comp2vtk($name) 1] … … 390 392 set path [$_field get $cname.mesh] 391 393 if {[$_xmlobj element $path] != ""} { 392 set cobj [Rappture::Cloud::fetch $_xmlobj $path] 393 if {[$cobj dimensions] > 1} { 394 switch -- [$_xmlobj element -as type $path] { 395 cloud { 396 set mobj [Rappture::Cloud::fetch $_xmlobj $path] 397 } 398 mesh { 399 set mobj [Rappture::Mesh::fetch $_xmlobj $path] 400 } 401 } 402 403 if {[$mobj dimensions] > 1} { 394 404 # 395 405 # 2D/3D data … … 407 417 } 408 418 409 set _comp2dims($cname) "[$ cobj dimensions]D"410 set _comp2vtk($cname) [list $ cobj $farray]419 set _comp2dims($cname) "[$mobj dimensions]D" 420 set _comp2vtk($cname) [list $mobj $farray] 411 421 incr _counter 412 422 } else { … … 418 428 set yv [blt::vector create y$_counter] 419 429 420 set vtkpts [$ cobj points]430 set vtkpts [$mobj points] 421 431 set max [$vtkpts GetNumberOfPoints] 422 432 for {set i 0} {$i < $max} {incr i} { … … 424 434 $xv append $xval 425 435 } 426 Rappture::Cloud::release $cobj 436 set class [$mobj info class] 437 ${class}::release $mobj 427 438 428 439 set values [$_field get $cname.values] -
trunk/gui/scripts/gauge.tcl
r11 r17 38 38 39 39 public method value {args} 40 public method edit {option} 40 41 41 42 protected method _redraw {} … … 87 88 bind $itk_component(value) <Enter> [itcl::code $this _hilite value on] 88 89 bind $itk_component(value) <Leave> [itcl::code $this _hilite value off] 90 91 bind $itk_component(value) <<Cut>> [itcl::code $this edit cut] 92 bind $itk_component(value) <<Copy>> [itcl::code $this edit copy] 93 bind $itk_component(value) <<Paste>> [itcl::code $this edit paste] 94 95 itk_component add emenu { 96 menu $itk_component(value).menu -tearoff 0 97 } { 98 usual 99 ignore -tearoff 100 } 101 $itk_component(emenu) add command -label "Cut" -accelerator "^X" \ 102 -command [list event generate $itk_component(value) <<Cut>>] 103 $itk_component(emenu) add command -label "Copy" -accelerator "^C" \ 104 -command [list event generate $itk_component(value) <<Copy>>] 105 $itk_component(emenu) add command -label "Paste" -accelerator "^V" \ 106 -command [list event generate $itk_component(value) <<Paste>>] 107 bind $itk_component(value) <<PopupMenu>> { 108 tk_popup %W.menu %X %Y 109 } 89 110 90 111 itk_component add editor { … … 196 217 197 218 # ---------------------------------------------------------------------- 219 # USAGE: edit cut 220 # USAGE: edit copy 221 # USAGE: edit paste 222 # 223 # Used internally to handle cut/copy/paste operations for the current 224 # value. Usually invoked by <<Cut>>, <<Copy>>, <<Paste>> events, but 225 # can also be called directly through this method. 226 # ---------------------------------------------------------------------- 227 itcl::body Rappture::Gauge::edit {option} { 228 switch -- $option { 229 cut { 230 edit copy 231 _editor popup 232 $itk_component(editor) value "" 233 $itk_component(editor) deactivate 234 } 235 copy { 236 clipboard clear 237 clipboard append $_value 238 } 239 paste { 240 _editor popup 241 $itk_component(editor) value [clipboard get] 242 $itk_component(editor) deactivate 243 } 244 default { 245 error "bad option \"$option\": should be cut, copy, paste" 246 } 247 } 248 } 249 250 # ---------------------------------------------------------------------- 198 251 # USAGE: _redraw 199 252 # -
trunk/gui/scripts/loader.tcl
r14 r17 96 96 set label "Example #$_counter" 97 97 } 98 $itk_component(combo) choices insert end $obj $label 99 100 if {[string equal $defval [file tail $fname]]} { 101 $xmlobj put $path.default $label 98 99 # if this is new, add it 100 set i [$itk_component(combo) choices index -label $label] 101 if {$i < 0} { 102 $itk_component(combo) choices insert end $obj $label 103 104 if {[string equal $defval [file tail $fname]]} { 105 $xmlobj put $path.default $label 106 } 102 107 } 103 108 } -
trunk/gui/scripts/mainwin.tcl
r13 r17 13 13 # ====================================================================== 14 14 package require Itk 15 package require BLT 15 16 16 17 option add *MainWin.mode desktop widgetDefault … … 31 32 32 33 public method draw {option args} 34 public method syncCutBuffer {option args} 33 35 34 36 protected method _redraw {} 35 37 36 38 private variable _contents "" ;# frame containing app 39 private variable _sync ;# to sync current selection and cut buffer 37 40 private variable _bgscript "" ;# script of background drawing cmds 38 41 private variable _bgparser "" ;# parser for bgscript … … 96 99 set btags [bindtags $itk_component(hull)] 97 100 bindtags $itk_component(hull) [lappend btags RapptureMainWin] 101 102 set _sync(cutbuffer) "" 103 set _sync(selection) "" 104 syncCutBuffer ifneeded 105 } 106 107 # ---------------------------------------------------------------------- 108 # USAGE: syncCutBuffer ifneeded 109 # USAGE: syncCutBuffer transfer <offset> <maxchars> 110 # USAGE: syncCutBuffer lostselection 111 # 112 # Invoked automatically whenever the mouse pointer enters or leaves 113 # a main window to sync the cut buffer with the primary selection. 114 # This helps applications work properly with the "Copy/Paste with 115 # Desktop" option on the VNC applet for the nanoHUB. 116 # 117 # The "ifneeded" option syncs the cutbuffer and the primary selection 118 # if either one has new data. 119 # 120 # The "fromselection" option syncs from the primary selection to the 121 # cut buffer. If there's a primary selection, it gets copied to the 122 # cut buffer. 123 # ---------------------------------------------------------------------- 124 itcl::body Rappture::MainWin::syncCutBuffer {option args} { 125 set mainwin $itk_component(hull) 126 switch -- $option { 127 ifneeded { 128 # 129 # See if the incoming cut buffer has changed. 130 # If so, then sync the new input to the primary selection. 131 # 132 set s [blt::cutbuffer get] 133 if {"" != $s && ![string equal $s $_sync(cutbuffer)]} { 134 set _sync(cutbuffer) $s 135 136 if {![string equal $s $_sync(selection)] 137 && [selection own -selection PRIMARY] != $mainwin} { 138 set _sync(selection) $s 139 140 clipboard clear 141 clipboard append -- $s 142 selection handle -selection PRIMARY $mainwin \ 143 [itcl::code $this syncCutBuffer transfer] 144 selection own -selection PRIMARY -command \ 145 [itcl::code $this syncCutBuffer lostselection] \ 146 $mainwin 147 } 148 } 149 150 # 151 # See if the selection has changed. If so, then sync 152 # the new input to the cut buffer, so it's available 153 # outside the VNC client. 154 # 155 set s "" 156 if {[catch {selection get -selection PRIMARY} s] || "" == $s} { 157 if {[catch {clipboard get} s]} { 158 set s "" 159 } 160 } 161 if {"" != $s && ![string equal $s $_sync(selection)]} { 162 set _sync(selection) $s 163 blt::cutbuffer set $s 164 } 165 166 # do this again soon 167 after 1000 [itcl::code $this syncCutBuffer ifneeded] 168 } 169 transfer { 170 if {[llength $args] != 2} { 171 error "wrong # args: should be \"syncCutBuffer transfer offset max\"" 172 } 173 set offset [lindex $args 0] 174 set maxchars [lindex $args 1] 175 return [string range $_currseln $offset [expr {$offset+$maxchars-1}]] 176 } 177 lostselection { 178 # nothing to do 179 } 180 default { 181 error "bad option \"$option\": should be ifneeded, transfer, or lostselection" 182 } 183 } 98 184 } 99 185 … … 127 213 } 128 214 215 set bd 0 ;# optional border 129 216 set sw [winfo width $itk_component(area)] 130 217 set sh [winfo height $itk_component(area)] … … 133 220 set w [winfo reqwidth $itk_component(app)] 134 221 set h [winfo reqheight $itk_component(app)] 135 if {$w > $sw } {136 set $w $sw222 if {$w > $sw-2*$bd} { 223 set $w [expr {$sw-2*$bd}] 137 224 set clip 1 138 225 } … … 141 228 n { 142 229 set x [expr {$sw/2}] 143 set y 0230 set y $bd 144 231 } 145 232 s { 146 233 set x [expr {$sw/2}] 147 set y $sh234 set y [expr {$sh-$bd}] 148 235 } 149 236 center { … … 152 239 } 153 240 w { 154 set x 0241 set x $bd 155 242 set y [expr {$sh/2}] 156 243 } 157 244 e { 158 set x $sw245 set x [expr {$sw-$bd}] 159 246 set y [expr {$sh/2}] 160 247 } 161 248 nw { 162 set x 0163 set y 0249 set x $bd 250 set y $bd 164 251 } 165 252 ne { 166 set x $sw167 set y 0253 set x [expr {$sw-$bd}] 254 set y $bd 168 255 } 169 256 sw { 170 set x 0171 set y $sh257 set x $bd 258 set y [expr {$sh-$bd}] 172 259 } 173 260 se { 174 set x $sw175 set y $sh261 set x [expr {$sw-$bd}] 262 set y [expr {$sh-$bd}] 176 263 } 177 264 } -
trunk/gui/scripts/mesh.tcl
r14 r17 23 23 public method points {} 24 24 public method elements {} 25 public method size {} 25 public method mesh {} 26 public method size {{what -points}} 26 27 public method dimensions {} 27 28 public method limits {which} … … 36 37 private variable _units "m" ;# system of units for this mesh 37 38 private variable _limits ;# limits xmin, xmax, ymin, ymax, ... 38 private variable _npts 0 ;# number of points39 private variable _nelems 0 ;# number of elements40 39 41 40 private common _xp2obj ;# used for fetch/release ref counting … … 105 104 } 106 105 106 # create the vtk objects containing points and connectivity 107 vtkPoints $this-points 108 vtkVoxel $this-vox 109 vtkUnstructuredGrid $this-grid 110 107 111 foreach lim {xmin xmax ymin ymax zmin zmax} { 108 112 set _limits($lim) "" 109 113 } 110 114 115 # 116 # Extract each node and add it to the points list. 117 # 111 118 foreach comp [$xmlobj children -type node $path] { 112 119 set xyz [$xmlobj get $path.$comp] … … 133 140 } 134 141 } 135 incr _npts 136 } 137 set _nelems [llength [$xmlobj children -type element $path]] 142 $this-points InsertNextPoint $x $y $z 143 } 144 $this-grid SetPoints $this-points 145 146 # 147 # Extract each element and add it to the mesh. 148 # 149 foreach comp [$xmlobj children -type element $path] { 150 set nlist [$_mesh get $comp.nodes] 151 set i 0 152 foreach n $nlist { 153 [$this-vox GetPointIds] SetId $i $n 154 incr i 155 } 156 $this-grid InsertNextCell [$this-vox GetCellType] \ 157 [$this-vox GetPointIds] 158 } 138 159 } 139 160 … … 144 165 # don't destroy the _xmlobj! we don't own it! 145 166 itcl::delete object $_mesh 167 168 rename $this-points "" 169 rename $this-vox "" 170 rename $this-grid "" 146 171 } 147 172 … … 153 178 itcl::body Rappture::Mesh::points {} { 154 179 # not implemented 155 return ""180 return $this-points 156 181 } 157 182 … … 198 223 199 224 # ---------------------------------------------------------------------- 200 # USAGE: size 225 # USAGE: mesh 226 # 227 # Returns the vtk object representing the mesh. 228 # ---------------------------------------------------------------------- 229 itcl::body Rappture::Mesh::mesh {} { 230 return $this-grid 231 } 232 233 # ---------------------------------------------------------------------- 234 # USAGE: size ?-points|-elements? 201 235 # 202 236 # Returns the number of points in this mesh. 203 237 # ---------------------------------------------------------------------- 204 itcl::body Rappture::Mesh::size {} { 205 return $_npts 238 itcl::body Rappture::Mesh::size {{what -points}} { 239 switch -- $what { 240 -points { 241 return [$this-points GetNumberOfPoints] 242 } 243 -elements { 244 return [$this-points GetNumberOfCells] 245 } 246 default { 247 error "bad option \"$what\": should be -points or -elements" 248 } 249 } 206 250 } 207 251 -
trunk/gui/scripts/textentry.tcl
r11 r17 109 109 if {$_mode == "entry"} { 110 110 $itk_component(entry) configure -state normal 111 $itk_component(emenu) entryconfigure "Cut" -state normal 112 $itk_component(emenu) entryconfigure "Copy" -state normal 113 $itk_component(emenu) entryconfigure "Paste" -state normal 111 114 $itk_component(entry) delete 0 end 112 115 $itk_component(entry) insert 0 $newval 113 116 if {!$itk_option(-editable)} { 114 117 $itk_component(entry) configure -state disabled 118 $itk_component(emenu) entryconfigure "Cut" -state disabled 119 $itk_component(emenu) entryconfigure "Copy" -state disabled 120 $itk_component(emenu) entryconfigure "Paste" -state disabled 115 121 } 116 122 } elseif {$_mode == "text"} { 117 123 $itk_component(text) configure -state normal 124 $itk_component(tmenu) entryconfigure "Cut" -state normal 125 $itk_component(tmenu) entryconfigure "Copy" -state normal 126 $itk_component(tmenu) entryconfigure "Paste" -state normal 118 127 $itk_component(text) delete 1.0 end 119 128 $itk_component(text) insert end $newval 120 129 if {!$itk_option(-editable)} { 121 130 $itk_component(text) configure -state disabled 131 $itk_component(tmenu) entryconfigure "Cut" -state disabled 132 $itk_component(tmenu) entryconfigure "Copy" -state disabled 133 $itk_component(tmenu) entryconfigure "Paste" -state disabled 122 134 } 123 135 } … … 231 243 -foreground $itk_option(-textforeground) 232 244 245 itk_component add emenu { 246 menu $itk_component(entry).menu -tearoff 0 247 } 248 $itk_component(emenu) add command -label "Cut" -accelerator "^X" \ 249 -command [list event generate $itk_component(entry) <<Cut>>] 250 $itk_component(emenu) add command -label "Copy" -accelerator "^C" \ 251 -command [list event generate $itk_component(entry) <<Copy>>] 252 $itk_component(emenu) add command -label "Paste" -accelerator "^V" \ 253 -command [list event generate $itk_component(entry) <<Paste>>] 254 bind $itk_component(entry) <<PopupMenu>> { 255 tk_popup %W.menu %X %Y 256 } 257 233 258 $itk_component(entry) insert end $val 234 259 if {!$itk_option(-editable)} { … … 270 295 $itk_component(scrollbars) contents $itk_component(text) 271 296 297 itk_component add tmenu { 298 menu $itk_component(text).menu -tearoff 0 299 } 300 $itk_component(tmenu) add command -label "Cut" -accelerator "^X" \ 301 -command [list event generate $itk_component(text) <<Cut>>] 302 $itk_component(tmenu) add command -label "Copy" -accelerator "^C" \ 303 -command [list event generate $itk_component(text) <<Copy>>] 304 $itk_component(tmenu) add command -label "Paste" -accelerator "^V" \ 305 -command [list event generate $itk_component(text) <<Paste>>] 306 bind $itk_component(text) <<PopupMenu>> { 307 tk_popup %W.menu %X %Y 308 } 309 272 310 $itk_component(text) insert end $val 273 311 if {!$itk_option(-editable)} { 274 312 $itk_component(text) configure -state disabled 313 $itk_component(menu) entryconfigure "Cut" -state disabled 314 $itk_component(menu) entryconfigure "Copy" -state disabled 315 $itk_component(menu) entryconfigure "Paste" -state disabled 275 316 } 276 317 set _mode "text" … … 306 347 if {$_mode == "entry"} { 307 348 $itk_component(editor) configure -state $state 349 $itk_component(emenu) entryconfigure "Cut" -state $state 350 $itk_component(emenu) entryconfigure "Copy" -state $state 351 $itk_component(emenu) entryconfigure "Paste" -state $state 308 352 } elseif {$_mode == "text"} { 309 353 $itk_component(text) configure -state $state 354 $itk_component(tmenu) entryconfigure "Cut" -state $state 355 $itk_component(tmenu) entryconfigure "Copy" -state $state 356 $itk_component(tmenu) entryconfigure "Paste" -state $state 310 357 } 311 358 } -
trunk/gui/scripts/tool.tcl
r13 r17 191 191 if {"" != [$newobj element -as type $path.current]} { 192 192 set val [$newobj get $path.current] 193 if {[string length $val] > 0} { 193 if {[string length $val] > 0 194 || [llength [$newobj children $path.current]] == 0} { 194 195 $_path2widget($path) value $val 195 196 } else {
Note: See TracChangeset
for help on using the changeset viewer.