Changeset 2048 for branches/blt4/gui
- Timestamp:
- Jan 19, 2011 11:30:00 AM (13 years ago)
- Location:
- branches/blt4/gui/scripts
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/gui/scripts/drawing.tcl
r1923 r2048 1 1 2 # ---------------------------------------------------------------------- 2 3 # COMPONENT: drawing - 2D drawing of data -
branches/blt4/gui/scripts/heightmapviewer.tcl
r1985 r2048 71 71 private method BuildCameraTab {} 72 72 private method PanCamera {} 73 74 private method AddImageControls { frame widget } 75 private method SetWaitVariable { value } { 76 set _getimage $value 77 } 78 private method GetWaitVariable {} { 79 return $_getimage 80 } 81 private method WaitForImage {} { 82 tkwait variable [itcl::scope _getimage] 83 return $_getimage 84 } 85 73 86 protected method CurrentSurfaces {{what -all}} 74 87 protected method Rebuild {} … … 104 117 private variable _resizeLegendPending 0 105 118 private variable _frame 0; # Current frame number. 119 private variable _getimage 0; 120 private variable _downloadPopup 106 121 } 107 122 … … 138 153 $_parser alias legend [itcl::code $this ReceiveLegend] 139 154 155 array set _downloadPopup { 156 format image 157 image_controls "" 158 } 140 159 # Initialize the view to some default parameters. 141 160 array set _view { … … 479 498 } 480 499 controls { 481 # no controls for this download yet 482 return "" 500 set popup .heightmapviewerdownload 501 if {![winfo exists $popup]} { 502 # If we haven't created the popup yet, do it now 503 Rappture::Balloon $popup \ 504 -title "[Rappture::filexfer::label downloadWord] as..." 505 set inner [$popup component inner] 506 label $inner.summary -text "" -anchor w 507 pack $inner.summary -side top 508 radiobutton $inner.image -text "Image (PNG/JPEG/GIF)" \ 509 -variable \ 510 ::Rappture::HeightmapViewer::_downloadPopup(format) \ 511 -font "Arial 10 " \ 512 -value image 513 Rappture::Tooltip::for $inner.image "Save as image." 514 pack $inner.image -anchor w 515 button $inner.go -text [Rappture::filexfer::label download] \ 516 -command [lindex $args 0] 517 pack $inner.go -side bottom -pady 4 518 $inner.image select 519 } else { 520 set inner [$popup component inner] 521 } 522 set num [llength [get]] 523 set num [expr {($num == 1) ? "1 result" : "$num results"}] 524 set word [Rappture::filexfer::label downloadWord] 525 $inner.summary configure -text "$word $num in the following format:" 526 update idletasks ; # Fix initial sizes 527 return $popup 483 528 } 484 529 now { 485 $_image(download) export jpg -quality 100 -data bytes 486 return [list .jpg $bytes] 530 set popup .heightmapviewerdownload 531 if { [winfo exists $popup] } { 532 $popup deactivate 533 } 534 switch -- $_downloadPopup(format) { 535 "image" { 536 set popup .heightmapviewerimage 537 if { ![winfo exists $popup] } { 538 # Create the balloon popup and and the print image 539 # dialog widget to it. 540 Rappture::Balloon $popup -title "Save as image..." \ 541 -deactivatecommand \ 542 [itcl::code $this SetWaitVariable 0] 543 set inner [$popup component inner] 544 AddImageControls $inner [lindex $args 0] 545 } else { 546 set inner [$popup component inner] 547 } 548 set _downloadPopup(image_controls) $inner 549 update 550 # Activate the popup and call for the output. 551 foreach { widget toolName plotName } $args break 552 SetWaitVariable 0 553 $popup activate $widget left 554 set bool [WaitForImage] 555 $popup deactivate 556 if { $bool } { 557 set inner $_downloadPopup(image_controls) 558 set fmt [$inner.format translate [$inner.format value]] 559 switch $fmt { 560 "jpg" { 561 $_image(download) export jpg -quality 100 \ 562 -data bytes 563 } 564 "png" { 565 $_image(download) export png -data bytes 566 } 567 "gif" { 568 $_image(download) export gif -data bytes 569 } 570 default { 571 return "" 572 } 573 } 574 return [list .$fmt $bytes] 575 } 576 } 577 } 578 return "" 487 579 } 488 580 default { … … 1288 1380 return $img 1289 1381 } 1382 1383 1384 itcl::body Rappture::HeightmapViewer::AddImageControls { inner widget } { 1385 label $inner.size_l -text "Size:" -font "Arial 9" 1386 set _downloadPopup(image_controls) $inner 1387 set img $_image(plot) 1388 set res "[image width $img]x[image height $img]" 1389 Rappture::Combobox $inner.size -width 30 -editable no 1390 $inner.size choices insert end \ 1391 "draft" "Draft ($res)" 1392 1393 label $inner.bgcolor_l -text "Background:" -font "Arial 9" 1394 Rappture::Combobox $inner.bgcolor -width 30 -editable no 1395 $inner.bgcolor choices insert end \ 1396 "black" "Black" \ 1397 "white" "White" \ 1398 "none" "Transparent (PNG only)" 1399 1400 label $inner.format_l -text "Format:" -font "Arial 9" 1401 Rappture::Combobox $inner.format -width 30 -editable no 1402 $inner.format choices insert end \ 1403 "png" "PNG (Portable Network Graphics format)" \ 1404 "jpg" "JPEG (Joint Photographic Experts Group format)" \ 1405 "gif" "GIF (GIF Graphics Interchange Format)" 1406 1407 button $inner.go -text [Rappture::filexfer::label download] \ 1408 -command [itcl::code $this SetWaitVariable 1] 1409 1410 blt::table $inner \ 1411 0,0 $inner.format_l -anchor e \ 1412 0,1 $inner.format -anchor w -fill x \ 1413 1,0 $inner.size_l -anchor e \ 1414 1,1 $inner.size -anchor w -fill x \ 1415 2,0 $inner.bgcolor_l -anchor e \ 1416 2,1 $inner.bgcolor -anchor w -fill x \ 1417 6,0 $inner.go -cspan 2 -pady 5 1418 $inner.bgcolor value "Black" 1419 $inner.size value "Draft ($res)" 1420 $inner.format value "PNG (Portable Network Graphics format)" 1421 } -
branches/blt4/gui/scripts/imageresult.tcl
r1937 r2048 41 41 protected method _move {option args} 42 42 43 private method AddImageControls { frame widget } 44 private method SetWaitVariable { value } { 45 set _getimage $value 46 } 47 private method GetWaitVariable {} { 48 return $_getimage 49 } 50 private method WaitForImage {} { 51 tkwait variable [itcl::scope _getimage] 52 return $_getimage 53 } 54 43 55 private variable _dispatcher "" ;# dispatcher for !events 44 56 private variable _dlist "" ;# list of data objects … … 47 59 private variable _scale ;# info related to zoom 48 60 private variable _image ;# image buffers used for scaling 61 private variable _downloadPopup 49 62 } 50 63 … … 69 82 x 0 70 83 y 0 84 } 85 array set _downloadPopup { 86 format image 87 image_controls "" 71 88 } 72 89 … … 305 322 } 306 323 controls { 307 # no controls for this download yet 308 return "" 324 set popup .imageresultdownload 325 if {![winfo exists $popup]} { 326 # If we haven't created the popup yet, do it now 327 Rappture::Balloon $popup \ 328 -title "[Rappture::filexfer::label downloadWord] as..." 329 set inner [$popup component inner] 330 label $inner.summary -text "" -anchor w 331 pack $inner.summary -side top 332 radiobutton $inner.image -text "Image (PNG/JPEG/GIF)" \ 333 -variable \ 334 ::Rappture::ImageResult::_downloadPopup(format) \ 335 -font "Arial 10 " \ 336 -value image 337 Rappture::Tooltip::for $inner.image "Save as image." 338 pack $inner.image -anchor w 339 button $inner.go -text [Rappture::filexfer::label download] \ 340 -command [lindex $args 0] 341 pack $inner.go -side bottom -pady 4 342 $inner.image select 343 } else { 344 set inner [$popup component inner] 345 } 346 set num [llength [get]] 347 set num [expr {($num == 1) ? "1 result" : "$num results"}] 348 set word [Rappture::filexfer::label downloadWord] 349 $inner.summary configure -text "$word $num in the following format:" 350 update idletasks ; # Fix initial sizes 351 return $popup 309 352 } 310 353 now { 311 set top [_top image] 312 if {$top == ""} { 313 return "" 314 } 315 $top export jpg -quality 100 -data bytes 316 return [list .jpg $bytes] 354 set popup .imageresultdownload 355 if { [winfo exists $popup] } { 356 $popup deactivate 357 } 358 switch -- $_downloadPopup(format) { 359 "image" { 360 set top [_top image] 361 set top [_top image] 362 if {$top == ""} { 363 return "" 364 } 365 set popup .imageresultimage 366 if { ![winfo exists $popup] } { 367 # Create the balloon popup and and the print image 368 # dialog widget to it. 369 Rappture::Balloon $popup -title "Save as image..." \ 370 -deactivatecommand \ 371 [itcl::code $this SetWaitVariable 0] 372 set inner [$popup component inner] 373 AddImageControls $inner [lindex $args 0] 374 } else { 375 set inner [$popup component inner] 376 } 377 set _downloadPopup(image_controls) $inner 378 update 379 # Activate the popup and call for the output. 380 foreach { widget toolName plotName } $args break 381 SetWaitVariable 0 382 $popup activate $widget left 383 set bool [WaitForImage] 384 $popup deactivate 385 if { $bool } { 386 set inner $_downloadPopup(image_controls) 387 set fmt [$inner.format translate [$inner.format value]] 388 switch $fmt { 389 "jpg" { 390 $top export jpg -quality 100 -data bytes 391 } 392 "png" { 393 $top export png -data bytes 394 } 395 "gif" { 396 $top export gif -data bytes 397 } 398 default { 399 return "" 400 } 401 } 402 return [list .$fmt $bytes] 403 } 404 } 405 } 406 return "" 317 407 } 318 408 default { … … 604 694 return $img 605 695 } 696 697 itcl::body Rappture::ImageResult::AddImageControls { inner widget } { 698 label $inner.size_l -text "Size:" -font "Arial 9" 699 set _downloadPopup(image_controls) $inner 700 set img $_image(plot) 701 set res "[image width $img]x[image height $img]" 702 Rappture::Combobox $inner.size -width 30 -editable no 703 $inner.size choices insert end \ 704 "draft" "Draft ($res)" 705 706 label $inner.bgcolor_l -text "Background:" -font "Arial 9" 707 Rappture::Combobox $inner.bgcolor -width 30 -editable no 708 $inner.bgcolor choices insert end \ 709 "black" "Black" \ 710 "white" "White" \ 711 "none" "Transparent (PNG only)" 712 713 label $inner.format_l -text "Format:" -font "Arial 9" 714 Rappture::Combobox $inner.format -width 30 -editable no 715 $inner.format choices insert end \ 716 "png" "PNG (Portable Network Graphics format)" \ 717 "jpg" "JPEG (Joint Photographic Experts Group format)" \ 718 "gif" "GIF (GIF Graphics Interchange Format)" 719 720 button $inner.go -text [Rappture::filexfer::label download] \ 721 -command [itcl::code $this SetWaitVariable 1] 722 723 blt::table $inner \ 724 0,0 $inner.format_l -anchor e \ 725 0,1 $inner.format -anchor w -fill x \ 726 1,0 $inner.size_l -anchor e \ 727 1,1 $inner.size -anchor w -fill x \ 728 2,0 $inner.bgcolor_l -anchor e \ 729 2,1 $inner.bgcolor -anchor w -fill x \ 730 6,0 $inner.go -cspan 2 -pady 5 731 $inner.bgcolor value "Black" 732 $inner.size value "Draft ($res)" 733 $inner.format value "PNG (Portable Network Graphics format)" 734 } -
branches/blt4/gui/scripts/molvisviewer.tcl
r1997 r2048 84 84 private variable _restore 1; # Restore camera settings 85 85 private variable _cell 0; # Restore camera settings 86 private variable _getimage 0; 86 87 87 88 constructor { hostlist args } { … … 103 104 private method WaitIcon { option widget } 104 105 private method DownloadPopup { popup command } 105 private method EnableDownload { popup what } 106 106 private method AddImageControls { frame widget } 107 private method SetWaitVariable { value } { 108 set _getimage $value 109 } 110 private method GetWaitVariable {} { 111 return $_getimage 112 } 113 private method WaitForImage {} { 114 tkwait variable [itcl::scope _getimage] 115 return $_getimage 116 } 107 117 protected method Map {} 108 118 protected method Pan {option x y} … … 560 570 controls { 561 571 set popup .molvisviewerdownload 562 if { ![winfo exists .molvisviewerdownload] } { 563 set inner [DownloadPopup $popup [lindex $args 0]] 572 if {![winfo exists $popup]} { 573 # if we haven't created the popup yet, do it now 574 Rappture::Balloon $popup \ 575 -title "[Rappture::filexfer::label downloadWord] as..." 576 set inner [$popup component inner] 577 label $inner.summary -text "" -anchor w 578 pack $inner.summary -side top 579 radiobutton $inner.pdb \ 580 -text "PDB Protein Data Bank Format File" \ 581 -variable [itcl::scope _downloadPopup(format)] \ 582 -font "Arial 10 " \ 583 -value pdb 584 pack $inner.pdb -anchor w 585 Rappture::Tooltip::for $inner.pdb \ 586 "Save as PDB Protein Data Bank format file." 587 radiobutton $inner.image -text "Image (PNG/JPEG/GIF)" \ 588 -variable [itcl::scope _downloadPopup(format)] \ 589 -font "Arial 10 " \ 590 -value image 591 Rappture::Tooltip::for $inner.image \ 592 "Save as image." 593 pack $inner.image -anchor w 594 button $inner.go -text [Rappture::filexfer::label download] \ 595 -command [lindex $args 0] 596 pack $inner.go -side bottom -pady 4 597 $inner.pdb select 564 598 } else { 565 599 set inner [$popup component inner] 566 600 } 567 set _downloadPopup(image_controls) $inner.image_frame568 601 set num [llength [get]] 569 602 set num [expr {($num == 1) ? "1 result" : "$num results"}] … … 574 607 } 575 608 now { 576 577 609 set popup .molvisviewerdownload 578 if {[winfo exists .molvisviewerdownload]} {610 if {[winfo exists $popup]} { 579 611 $popup deactivate 580 612 } 581 613 switch -- $_downloadPopup(format) { 582 "image" {583 return [$this GetImage [lindex $args 0]]584 }585 614 "pdb" { 586 615 return [list .pdb $_pdbdata] 587 } 616 } 617 "image" { 618 set popup .molvisviewerimage 619 if { ![winfo exists $popup] } { 620 # Create the balloon popup and and the print image 621 # dialog widget to it. 622 Rappture::Balloon $popup -title "Save as image..." \ 623 -deactivatecommand \ 624 [itcl::code $this SetWaitVariable 0] 625 set inner [$popup component inner] 626 AddImageControls $inner [lindex $args 0] 627 } else { 628 set inner [$popup component inner] 629 } 630 update 631 # Activate the popup and call for the output. 632 foreach { widget toolName plotName } $args break 633 SetWaitVariable 0 634 $popup activate $widget left 635 set bool [WaitForImage] 636 $popup deactivate 637 if { $bool } { 638 return [GetImage $widget] 639 } 640 return "" 641 } 588 642 } 589 643 } … … 1662 1716 1663 1717 set controls $_downloadPopup(image_controls) 1664 set combo $controls.size_combo 1718 set combo $controls.size 1719 puts stderr combo=$combo 1665 1720 set size [$combo translate [$combo value]] 1666 1721 switch -- $size { … … 1678 1733 } 1679 1734 default { 1680 error "unknown image size [$ inner.image_size_combo value]"1735 error "unknown image size [$combo value]" 1681 1736 } 1682 1737 } … … 1684 1739 $_dispatcher dispatch $this !pngtimeout "set $var {} ; list" 1685 1740 1686 set popup .molvisviewer print1741 set popup .molvisviewerimagedownload 1687 1742 if { ![winfo exists $popup] } { 1688 1743 Rappture::Balloon $popup -title "Generating file..." … … 1704 1759 set inner [$popup component inner] 1705 1760 } 1706 set combo $controls.bgcolor _combo1761 set combo $controls.bgcolor 1707 1762 set bgcolor [$combo translate [$combo value]] 1708 1763 … … 1729 1784 1730 1785 if { $_hardcopy($this-$token) != "" } { 1731 set combo $controls. type_combo1786 set combo $controls.format 1732 1787 set type [$combo translate [$combo value]] 1733 1788 switch -- $type { … … 1920 1975 } 1921 1976 1922 itcl::body Rappture::MolvisViewer::DownloadPopup { popup command } { 1923 Rappture::Balloon $popup \ 1924 -title "[Rappture::filexfer::label downloadWord] as..." 1925 set inner [$popup component inner] 1926 label $inner.summary -text "" -anchor w -font "Arial 11 bold" 1927 radiobutton $inner.pdb_button -text "PDB Protein Data Bank Format File" \ 1928 -variable [itcl::scope _downloadPopup(format)] \ 1929 -command [itcl::code $this EnableDownload $popup pdb] \ 1930 -font "Arial 10 " \ 1931 -value pdb 1932 Rappture::Tooltip::for $inner.pdb_button \ 1933 "Save as PDB Protein Data Bank format file." 1934 radiobutton $inner.image_button -text "Image File" \ 1935 -variable [itcl::scope _downloadPopup(format)] \ 1936 -command [itcl::code $this EnableDownload $popup image] \ 1937 -font "Arial 10 " \ 1938 -value image 1939 Rappture::Tooltip::for $inner.image_button \ 1940 "Save as digital image." 1941 1942 set controls [frame $inner.image_frame -bd 2 -relief groove] 1943 label $controls.size_label -text "Size:" \ 1944 -font "Arial 9" 1977 itcl::body Rappture::MolvisViewer::AddImageControls { inner widget } { 1978 label $inner.size_l -text "Size:" -font "Arial 9" 1979 set _downloadPopup(image_controls) $inner 1945 1980 set img $_image(plot) 1946 1981 set res "[image width $img]x[image height $img]" 1947 Rappture::Combobox $controls.size_combo -width 20 -editable no 1948 $controls.size_combo choices insert end \ 1982 puts stderr combo=$inner.size 1983 Rappture::Combobox $inner.size -width 30 -editable no 1984 $inner.size choices insert end \ 1949 1985 "draft" "Draft (400x400)" \ 1950 1986 "standard" "Standard (1200x1200)" \ 1951 1987 "highquality" "High Quality (2400x2400)" 1952 1988 1953 label $controls.bgcolor_label -text "Background:" \ 1954 -font "Arial 9" 1955 Rappture::Combobox $controls.bgcolor_combo -width 20 -editable no 1956 $controls.bgcolor_combo choices insert end \ 1989 label $inner.bgcolor_l -text "Background:" -font "Arial 9" 1990 Rappture::Combobox $inner.bgcolor -width 30 -editable no 1991 $inner.bgcolor choices insert end \ 1957 1992 "black" "Black" \ 1958 1993 "white" "White" \ 1959 1994 "none" "Transparent (PNG only)" 1960 1995 1961 label $ controls.type_label -text "Type:" \1962 -font "Arial 9"1963 Rappture::Combobox $controls.type_combo -width 20 -editable no1964 $controls.type_combo choices insert end\1965 "jpg" "JPEG Joint Photographic Experts Group Format (*.jpg)" \1966 " png" "PNG Portable Network Graphics Format (*.png)"1996 label $inner.format_l -text "Format:" -font "Arial 9" 1997 Rappture::Combobox $inner.format -width 30 -editable no 1998 $inner.format choices insert end \ 1999 "png" "PNG (Portable Network Graphics format)" \ 2000 "jpg" "JPEG (Joint Photographic Experts Group format)" \ 2001 "gif" "GIF (GIF Graphics Interchange Format)" 1967 2002 1968 2003 button $inner.go -text [Rappture::filexfer::label download] \ 1969 -command $command 1970 1971 blt::table $controls \ 1972 1,0 $controls.size_label -anchor e \ 1973 1,1 $controls.size_combo -anchor w -fill x \ 1974 2,0 $controls.bgcolor_label -anchor e \ 1975 2,1 $controls.bgcolor_combo -anchor w -fill x \ 1976 3,0 $controls.type_label -anchor e \ 1977 3,1 $controls.type_combo -anchor w -fill x 1978 blt::table configure $controls r0 -height 16 1979 blt::table configure $controls -padx 4 -pady {0 6} 2004 -command [itcl::code $this SetWaitVariable 1] 2005 1980 2006 blt::table $inner \ 1981 0,0 $inner.summary -cspan 2 \ 1982 1,0 $inner.pdb_button -cspan 2 -anchor w \ 1983 2,0 $inner.image_button -cspan 2 -rspan 2 -anchor nw -ipadx 2 -ipady 2 \ 1984 3,1 $controls -fill both \ 2007 0,0 $inner.format_l -anchor e \ 2008 0,1 $inner.format -anchor w -fill x \ 2009 1,0 $inner.size_l -anchor e \ 2010 1,1 $inner.size -anchor w -fill x \ 2011 2,0 $inner.bgcolor_l -anchor e \ 2012 2,1 $inner.bgcolor -anchor w -fill x \ 1985 2013 6,0 $inner.go -cspan 2 -pady 5 1986 blt::table configure $inner c0 -width 11 1987 blt::table configure $inner r2 -height 11 1988 #blt::table configure $inner c1 -width 8 1989 raise $inner.image_button 1990 $inner.pdb_button invoke 1991 $controls.bgcolor_combo value "Black" 1992 $controls.size_combo value "Draft (400x400)" 1993 $controls.type_combo value "PNG Portable Network Graphics Format (*.png)" 1994 return $inner 1995 } 1996 1997 itcl::body Rappture::MolvisViewer::EnableDownload { popup what } { 1998 set inner [$popup component inner] 1999 switch -- $what { 2000 "pdb" { 2001 foreach w [winfo children $inner.image_frame] { 2002 $w configure -state disabled 2003 } 2004 } 2005 "image" { 2006 foreach w [winfo children $inner.image_frame] { 2007 $w configure -state normal 2008 } 2009 } 2010 default { 2011 error "unknown type of download" 2012 } 2013 } 2014 $inner.bgcolor value "Black" 2015 $inner.size value "Draft (400x400)" 2016 $inner.format value "PNG (Portable Network Graphics format)" 2014 2017 } 2015 2018 -
branches/blt4/gui/scripts/nanovisviewer.tcl
r1923 r2048 119 119 private method GetVolumeInfo { w } 120 120 121 private method AddImageControls { frame widget } 122 private method SetWaitVariable { value } { 123 set _getimage $value 124 } 125 private method GetWaitVariable {} { 126 return $_getimage 127 } 128 private method WaitForImage {} { 129 tkwait variable [itcl::scope _getimage] 130 return $_getimage 131 } 132 121 133 private variable _outbuf ;# buffer for outgoing commands 122 134 … … 144 156 private variable _first "" ;# This is the topmost volume. 145 157 private variable _buffering 0 146 158 147 159 # This 148 160 # indicates which isomarkers and transfer … … 155 167 private variable _resizePending 0 156 168 private variable _resizeLegendPending 0 169 private variable _getimage 0 157 170 } 158 171 … … 550 563 } 551 564 controls { 552 # no controls for this download yet 553 return "" 565 set popup .nanovisviewerdownload 566 if {![winfo exists $popup]} { 567 # If we haven't created the popup yet, do it now 568 Rappture::Balloon $popup \ 569 -title "[Rappture::filexfer::label downloadWord] as..." 570 set inner [$popup component inner] 571 label $inner.summary -text "" -anchor w 572 pack $inner.summary -side top 573 radiobutton $inner.image -text "Image (PNG/JPEG/GIF)" \ 574 -variable \ 575 ::Rappture::NanovisViewer::_downloadPopup(format) \ 576 -font "Arial 10 " \ 577 -value image 578 Rappture::Tooltip::for $inner.image "Save as image." 579 pack $inner.image -anchor w 580 button $inner.go -text [Rappture::filexfer::label download] \ 581 -command [lindex $args 0] 582 pack $inner.go -side bottom -pady 4 583 $inner.image select 584 } else { 585 set inner [$popup component inner] 586 } 587 set num [llength [get]] 588 set num [expr {($num == 1) ? "1 result" : "$num results"}] 589 set word [Rappture::filexfer::label downloadWord] 590 $inner.summary configure -text "$word $num in the following format:" 591 update idletasks ; # Fix initial sizes 592 return $popup 554 593 } 555 594 now { 556 $_image(plot) export jpg -quality 100 -data bytes 557 return [list .jpg $bytes] 595 set popup .nanovisviewerdownload 596 if { [winfo exists $popup] } { 597 $popup deactivate 598 } 599 switch -- $_downloadPopup(format) { 600 "image" { 601 set popup .nanovisviewerimage 602 if { ![winfo exists $popup] } { 603 # Create the balloon popup and and the print image 604 # dialog widget to it. 605 Rappture::Balloon $popup -title "Save as image..." \ 606 -deactivatecommand \ 607 [itcl::code $this SetWaitVariable 0] 608 set inner [$popup component inner] 609 AddImageControls $inner [lindex $args 0] 610 } else { 611 set inner [$popup component inner] 612 } 613 set _downloadPopup(image_controls) $inner 614 update 615 # Activate the popup and call for the output. 616 foreach { widget toolName plotName } $args break 617 SetWaitVariable 0 618 $popup activate $widget left 619 set bool [WaitForImage] 620 $popup deactivate 621 if { $bool } { 622 set inner $_downloadPopup(image_controls) 623 set fmt [$inner.format translate [$inner.format value]] 624 switch $fmt { 625 "jpg" { 626 $_image(download) export jpg -quality 100 \ 627 -data bytes 628 } 629 "png" { 630 $_image(download) export png -data bytes 631 } 632 "gif" { 633 $_image(download) export gif -data bytes 634 } 635 default { 636 return "" 637 } 638 } 639 return [list .$fmt $bytes] 640 } 641 } 642 } 643 return "" 558 644 } 559 645 default { … … 2054 2140 return $img 2055 2141 } 2142 2143 itcl::body Rappture::NanovisViewer::AddImageControls { inner widget } { 2144 label $inner.size_l -text "Size:" -font "Arial 9" 2145 set _downloadPopup(image_controls) $inner 2146 set img $_image(plot) 2147 set res "[image width $img]x[image height $img]" 2148 Rappture::Combobox $inner.size -width 30 -editable no 2149 $inner.size choices insert end \ 2150 "draft" "Draft ($res)" 2151 2152 label $inner.bgcolor_l -text "Background:" -font "Arial 9" 2153 Rappture::Combobox $inner.bgcolor -width 30 -editable no 2154 $inner.bgcolor choices insert end \ 2155 "black" "Black" \ 2156 "white" "White" \ 2157 "none" "Transparent (PNG only)" 2158 2159 label $inner.format_l -text "Format:" -font "Arial 9" 2160 Rappture::Combobox $inner.format -width 30 -editable no 2161 $inner.format choices insert end \ 2162 "png" "PNG (Portable Network Graphics format)" \ 2163 "jpg" "JPEG (Joint Photographic Experts Group format)" \ 2164 "gif" "GIF (GIF Graphics Interchange Format)" 2165 2166 button $inner.go -text [Rappture::filexfer::label download] \ 2167 -command [itcl::code $this SetWaitVariable 1] 2168 2169 blt::table $inner \ 2170 0,0 $inner.format_l -anchor e \ 2171 0,1 $inner.format -anchor w -fill x \ 2172 1,0 $inner.size_l -anchor e \ 2173 1,1 $inner.size -anchor w -fill x \ 2174 2,0 $inner.bgcolor_l -anchor e \ 2175 2,1 $inner.bgcolor -anchor w -fill x \ 2176 6,0 $inner.go -cspan 2 -pady 5 2177 $inner.bgcolor value "Black" 2178 $inner.size value "Draft ($res)" 2179 $inner.format value "PNG (Portable Network Graphics format)" 2180 } -
branches/blt4/gui/scripts/page.tcl
r1923 r2048 1 1 2 # ---------------------------------------------------------------------- 2 3 # COMPONENT: page - single page of widgets -
branches/blt4/gui/scripts/resultset.tcl
r1923 r2048 1093 1093 } else { 1094 1094 lappend params "???" 1095 } 1096 if { $_active == "" } { 1097 return 1095 1098 } 1096 1099 eval lappend params [_getValues $_active all] -
branches/blt4/gui/scripts/sequenceresult.tcl
r1937 r2048 1 1 2 # ---------------------------------------------------------------------- 2 3 # COMPONENT: sequenceresult - series of results forming an animation … … 27 28 inherit itk::Widget 28 29 29 constructor {args} { # defined below } 30 destructor { # defined below } 31 30 constructor {args} { 31 # defined below 32 } 33 destructor { 34 # defined below 35 } 32 36 public method add {dataobj {settings ""}} 33 37 public method get {} 34 38 public method delete {args} 35 39 public method scale {args} 36 public method parameters {title args} { # do nothing } 40 public method parameters {title args} { 41 # do nothing 42 } 37 43 public method download {option args} 38 44 … … 45 51 protected method _fixValue {} 46 52 private method Capture {w h} 47 48 private variable _dispatcher "" ;# dispatcher for !events 49 private variable _dlist "" ;# list of data objects 50 private variable _topmost "" ;# topmost data object in _dlist 51 private variable _indices "" ;# list of active indices 52 private variable _pos 0 ;# current position in the animation 53 private variable _afterId "" ;# current "after" event for play op 54 55 private common _play ;# options for "play" operation 53 private method Animate {w h} 54 private method VerifySequence {} 55 private method BuildViewer { viewer } 56 private method AnimationPopup { popup info } 57 private variable _dispatcher "" ; # dispatcher for !events 58 private variable _dlist "" ; # list of data objects 59 private variable _topmost "" ; # topmost data object in _dlist 60 private variable _indices "" ; # list of active indices 61 private variable _pos 0 ; # current position in the animation 62 private variable _afterId "" ; # current "after" event for play op 63 64 private variable _viewerclass ""; # Class of viewer. 65 private variable _animate 0 ; # Indicates if the sequence can be 66 # animated (i.e. produce an animated 67 # gif or mpeg video). 68 private variable _popup ""; # Popup window for dialog. 69 private common _play ; # options for "play" operation 70 71 private variable _class ""; # Class of element in sequence. 72 private variable _dim 0; # Dimension elements in sequence. 73 private variable _mode ""; # Mode of viewer. 74 56 75 set _play(speed) 60 57 76 set _play(loop) 0 … … 298 317 } 299 318 controls { 300 return [eval $itk_component(area).viewer download controls $args] 319 set _popup \ 320 [eval $itk_component(area).viewer download controls $args] 321 if { $_animate } { 322 # Add the animation button to the download dialog 323 set inner [$_popup component inner] 324 if { ![winfo exists $inner.animation] } { 325 radiobutton $inner.animation -text "Animation (GIF/MPEG)" \ 326 -variable ${_viewerclass}::_downloadPopup(format) \ 327 -value animation 328 pack $inner.animation -anchor w 329 update 330 } 331 } 332 return $_popup 301 333 } 302 334 now { 303 if 0 { 304 # produce a movie of results 305 if {"" != $_topmost} { 306 return [Capture 0 0] 307 } 308 return "" 309 } else { 310 # otherwise, return download of single frame 311 return [eval $itk_component(area).viewer download now $args] 335 if { $_animate } { 336 # Examine the radiobutton variable to see if an animated GIF 337 # of MPEG movie was selected for download. 338 set fmt [set ${_viewerclass}::_downloadPopup(format)] 339 if { $fmt == "animation" } { 340 if { [winfo exists $_popup] } { 341 $_popup deactivate 342 } 343 set popup .sequenceanimationdownload 344 return [AnimationPopup $popup $args] 345 } 312 346 } 347 # Otherwise, return download of single frame 348 return [eval $itk_component(area).viewer download now $args] 313 349 } 314 350 default { … … 328 364 return; # No frames (i.e. no data). 329 365 } 330 # cancel any existing animation366 # Stop any existing animation. 331 367 pause 332 368 333 # at the end? then restart fresh369 # At the end? then restart fresh 334 370 if {$_pos >= [llength $_indices]-1} { 335 371 goto 0 336 372 } 337 373 338 # toggle the button to "pause" mode374 # Toggle the button to "pause" mode 339 375 $itk_component(play) configure \ 340 376 -bitmap [Rappture::icon pause] \ … … 343 379 global readyForNextFrame 344 380 set readyForNextFrame 1; # By default, always ready 345 # schedule the first frame381 # Schedule the first frame 346 382 set delay [expr {int(ceil(pow($_play(speed)/10.0+2,2.0)*15))}] 347 383 set _afterId [after $delay [itcl::code $this _playFrame]] … … 396 432 } 397 433 398 # 399 # If we have any data, then show the viewer. 400 # Otherwise, hide it. 401 # 434 VerifySequence 435 436 # If we have any data, then show the viewer. Otherwise, hide it. 402 437 set viewer $itk_component(area).viewer 403 if { [winfo exists $viewer]} {404 if { "" == $_topmost} {438 if { [winfo exists $viewer] } { 439 if { "" == $_topmost } { 405 440 pack forget $viewer 406 441 pack forget $itk_component(player) 407 442 return 408 } else { 409 pack $viewer -expand yes -fill both 410 pack $itk_component(player) -side bottom -fill x 411 } 443 } 444 pack $viewer -expand yes -fill both 445 pack $itk_component(player) -side bottom -fill x 412 446 } else { 413 if { "" == $_topmost} {447 if { "" == $_topmost } { 414 448 return 415 449 } 416 417 set type "" 418 if {[$_topmost size] > 0} { 419 set dataobj [lindex [$_topmost value 0] 0] 420 set type [$dataobj info class] 421 } 422 switch -- $type { 423 ::Rappture::Curve { 424 Rappture::XyResult $viewer 425 pack $viewer -expand yes -fill both 426 } 427 ::Rappture::DataTable { 428 Rappture::DataTable $viewer 429 pack $viewer -expand yes -fill both 430 } 431 ::Rappture::Image { 432 Rappture::ImageResult $viewer 433 pack $viewer -expand yes -fill both 434 } 435 ::Rappture::Field { 436 set dimensions "" 437 set dim "" 438 foreach dim [$dataobj components -dimensions] { 439 # check to see if the dimensions are the same 440 # for all elements of the field. i dont think 441 # we can display fields of differing dimensions 442 # within the same field object. 443 if {"" != $dimensions} { 444 if {$dimensions != $dim} { 445 error "don't know how to view sequences of $type\ 446 with dimensions as follows:\ 447 [$dataobj components -dimensions]" 448 } 449 } else { 450 set dimensions $dim 451 } 452 } 453 switch -- $dimensions { 454 2D { 455 if { [$dataobj isunirect2d] } { 456 set mode "heightmap" 457 } else { 458 set mode "vtk" 459 } 460 Rappture::Field2DResult $viewer -mode $mode 461 } 462 3D { 463 Rappture::Field3DResult $viewer 464 } 465 default { 466 error "don't know how to view sequences of $type\ 467 with $dimensions dimensions" 468 } 469 } 470 pack $viewer -expand yes -fill both 471 } 472 ::Rappture::LibraryObj { 473 switch -- [$dataobj element -as type] { 474 structure { 475 Rappture::DeviceResult $viewer 476 pack $viewer -expand yes -fill both 477 } 478 default { 479 error "don't know how to view sequences of [$dataobj element -as type]" 480 } 481 } 482 } 483 default { 484 puts stderr "don't know how to view sequences of type \"$type\"" 485 puts stderr "Is the sequence empty?" 486 return 487 } 488 } 489 } 490 491 # 492 # Load the current sequence info the viewer. 493 # 450 BuildViewer $viewer 451 } 452 453 # Load the current sequence info the viewer. 494 454 $itk_component(indexLabel) configure -text [$_topmost hints indexlabel] 495 455 … … 619 579 return [list .gif $bytes] 620 580 } 581 582 # ---------------------------------------------------------------------- 583 # USAGE: Animate 584 # 585 # Invoked automatically whenever the value on the dial changes. 586 # Updates the viewer to display the value for the selected result. 587 # ---------------------------------------------------------------------- 588 itcl::body Rappture::SequenceResult::Animate {w h} { 589 set viewer $itk_component(area).viewer 590 if {![winfo exists $viewer]} { 591 return 592 } 593 set save $_pos 594 $viewer delete ;# Delete all objects from the viewer 595 for { set i 0 } { $i < [llength $_indices] } { incr i } { 596 set dataobj [$_topmost value $i] 597 set val [$itk_component(dial) get -format label @$i] 598 set _pos [lsearch -glob $_indices $val*] 599 set settings "-color autoreset -width 2" 600 if {[catch {$dataobj hints style} style] == 0} { 601 eval lappend settings $style 602 } 603 if { [catch {$dataobj hints type} type] == 0} { 604 if {"" != $type} { 605 lappend settings -type $type 606 } 607 } 608 $viewer add $dataobj $settings 609 set img [$viewer snap $x $y] 610 # add caption to frame. 611 if { $val != "" } { 612 $img draw text "$label $val" 10 10 \ 613 -font "Arial 10" -color white -shadow 1 614 } 615 $viewer delete 616 lappend imageList $img 617 } 618 set _pos $save 619 set dataobj [$_topmost value $_pos] 620 set settings "-color autoreset -width 2" 621 if {[catch {$dataobj hints style} style] == 0} { 622 eval lappend settings $style 623 } 624 if { [catch {$dataobj hints type} type] == 0} { 625 if {"" != $type} { 626 lappend settings -type $type 627 } 628 } 629 $viewer add $dataobj $settings 630 631 set dest [image create picture] 632 eval $dest list replace 0 end $imageList 633 set delay [expr {int(ceil(pow($_play(speed)/10.0+2,2.0)*15))}] 634 set delay [expr $_play(speed)] 635 $dest export gif -animate -delay $delay -data bytes 636 eval image delete $dest $imageList 637 return [list .gif $bytes] 638 } 639 640 # 641 # VerifySequence -- 642 # 643 # Verifies the correctness of the sequence. The sequence must 644 # contain a homogenous set of elements. If the element is a 645 # "field", then also the dimensions of every component must be 646 # the same. 647 # 648 itcl::body Rappture::SequenceResult::VerifySequence {} { 649 650 # Step 1: Use the topmost object as the standard. Check whether it 651 # can be sequenced. 652 set dataobj [lindex [$_topmost value 0] 0] 653 set _class [$dataobj info class] 654 set _dim 0 655 set mode "" 656 switch -- $_class { 657 ::Rappture::Curve - 658 ::Rappture::DataTable - 659 ::Rappture::Image { 660 # empty 661 } 662 ::Rappture::Field { 663 set _dim [lindex [$dataobj components -dimensions] 0] 664 switch $_dim { 665 "2D" { 666 if { [$dataobj isunirect2d] } { 667 set _mode "heightmap" 668 } else { 669 set _mode "vtk" 670 } 671 } 672 "3D" { 673 # empty 674 } 675 default { 676 error "Found field element $_class with $_dim dimensions" 677 } 678 } 679 } 680 ::Rappture::LibraryObj { 681 set type [$dataobj element -as type] 682 if { $type != "structure" } { 683 error "Don't know how to view sequences of $type" 684 } 685 } 686 default { 687 puts stderr "Don't know how to view sequences of type \"$_class\"" 688 puts stderr "Is the sequence empty?" 689 return 0 690 } 691 } 692 693 # Step 2: Review all the data objects. They must be all of the same 694 # class (e.g. can't mix curves with images). Also check that 695 # fields are all the same dimension. 696 foreach dataobj $_dlist { 697 set dataobj [lindex [$dataobj value 0] 0] 698 set class [$dataobj info class] 699 if { $_class != $class } { 700 puts stderr "Found element \"$class\" in sequence of \"$_class\"" 701 continue 702 } 703 if { $class == "::Rappture::Field" } { 704 # check to see if the dimensions are the same for all components 705 # in the elements of the field. I dont think we can display fields 706 # of differing dimensions within the same field object. 707 foreach dim [$dataobj components -dimensions] { 708 if { $_dim != $dim } { 709 error "Found field element of dimension \"$dim\" in sequence of $_dim dimension elements" 710 } 711 } 712 continue 713 } 714 } 715 if { $_class == "" } { 716 puts stderr "Don't know how to view sequences of class \"$_class\"" 717 puts stderr "Is the sequence empty?" 718 return 0 719 } 720 } 721 722 itcl::body Rappture::SequenceResult::AnimationPopup { popup info } { 723 if { ![winfo exists $popup] } { 724 # Create a popup for the print dialog 725 Rappture::Balloon $popup -title "Save as animation..." 726 set inner [$popup component inner] 727 728 # Create the print dialog widget and add it to the the balloon popup. 729 Rappture::SequenceAnimation $inner.print $this 730 $popup configure -deactivatecommand [list $inner.print reset] 731 blt::table $inner 0,0 $inner.print -fill both 732 } 733 update 734 # Activate the popup and call for the output. 735 foreach { widget toolName plotName } $info break 736 $popup activate $widget left 737 set inner [$popup component inner] 738 set output [$inner.print print "image" $toolName $plotName] 739 $popup deactivate 740 return $output 741 } 742 743 744 itcl::body Rappture::SequenceResult::BuildViewer { viewer } { 745 switch -- $_class { 746 ::Rappture::Curve { 747 Rappture::XyResult $viewer 748 set _viewerclass ::Rappture::XyResult 749 set _animate 1 750 } 751 ::Rappture::DataTable { 752 Rappture::DataTable $viewer 753 set _viewerclass ::Rappture::DataTable 754 } 755 ::Rappture::Image { 756 Rappture::ImageResult $viewer 757 set _viewerclass ::Rappture::ImageResult 758 set _animate 1 759 } 760 ::Rappture::Field { 761 switch -- $_dim { 762 2D { 763 Rappture::Field2DResult $viewer -mode $mode 764 if { $_mode == "heightmap" } { 765 set _viewerclass ::Rappture::HeightmapViewer 766 set _animate 1 767 } 768 } 769 3D { 770 Rappture::Field3DResult $viewer 771 set _viewerclass ::Rappture::NanovisViewer 772 set _animate 1 773 } 774 } 775 } 776 ::Rappture::LibraryObj { 777 Rappture::DeviceResult $viewer 778 set _viewerclass ::Rappture::MolvisViewer 779 set _animate 1 780 } 781 } 782 pack $viewer -expand yes -fill both 783 } -
branches/blt4/gui/scripts/tool.tcl
r1923 r2048 28 28 public method run {args} 29 29 public method abort {} 30 public method getRunFile {} 30 31 31 32 protected method _mkdir {dir} … … 34 35 private variable _installdir "" ;# installation directory for this tool 35 36 private variable _outputcb "" ;# callback for tool output 37 private variable _runFile "" ;# location of last created run.xml 36 38 private common job ;# array var used for blt::bgexec jobs 37 39 private common jobnum 0 ;# counter for unique job number … … 260 262 # see if the job was aborted 261 263 if {[regexp {^KILLED} $job(control)]} { 264 set _runFile "" 262 265 return [list 0 "ABORT"] 263 266 } … … 285 288 } 286 289 file rename -force -- $file $_resources(-resultdir) 287 } 290 set _runFile [file join $_resources(-resultdir) $file] 291 } 292 } else { 293 set _runFile $file 288 294 } 289 295 } else { … … 291 297 set result "Can't find result file in output.\nDid you call Rappture 292 298 ::result in your simulator?" 299 set _runFile "" 293 300 } 294 301 return [list $status $result] … … 337 344 } 338 345 } 346 347 # ---------------------------------------------------------------------- 348 # USAGE: getRunFile 349 # 350 # Returns the file name of the last generated run.xml, as opposed to a 351 # library object as returned by the run method. 352 # ---------------------------------------------------------------------- 353 itcl::body Rappture::Tool::getRunFile {} { 354 return $_runFile 355 } 356 -
branches/blt4/gui/scripts/xyprint.tcl
r2007 r2048 669 669 $m item configure all \ 670 670 -variable [itcl::scope _settings($this-general-format)] 671 Rappture::Tooltip::for $page.format "Set the format of the image."671 Rappture::Tooltip::for $page.format_l "Set the format of the image." 672 672 673 673 label $page.style_l -text "style" … … 689 689 $m item configure all \ 690 690 -variable [itcl::scope _settings($this-general-style)] 691 Rappture::Tooltip::for $page. format"Set the style template."691 Rappture::Tooltip::for $page.style_l "Set the style template." 692 692 693 693 blt::tk::checkbutton $page.remember -text "remember settings" \ -
branches/blt4/gui/scripts/xyresult.tcl
r1932 r2048 1 1 2 # ---------------------------------------------------------------------- 2 3 # COMPONENT: xyresult - X/Y plot in a ResultSet … … 350 351 itcl::body Rappture::XyResult::get {} { 351 352 # put the dataobj list in order according to -raise options 352 set clist $_dlist 353 foreach obj $clist { 353 set bottom {} 354 set top {} 355 foreach obj $_dlist { 354 356 if {[info exists _dataobj2raise($obj)] && $_dataobj2raise($obj)} { 355 set i [lsearch -exact $clist $obj] 356 if {$i >= 0} { 357 set clist [lreplace $clist $i $i] 358 lappend clist $obj 359 } 360 } 361 } 362 return $clist 357 lappend top $obj 358 } else { 359 lappend bottom $obj 360 } 361 } 362 set _dlist [concat $bottom $top] 363 return $_dlist 363 364 } 364 365 … … 380 381 if {$pos >= 0} { 381 382 set _dlist [lreplace $_dlist $pos $pos] 382 catch {unset _dataobj2color($dataobj)}383 catch {unset _dataobj2width($dataobj)}384 catch {unset _dataobj2dashes($dataobj)}385 catch {unset _dataobj2raise($dataobj)}383 array unset _dataobj2color $dataobj 384 array unset _dataobj2width $dataobj 385 array unset _dataobj2dashes $dataobj 386 array unset _dataobj2raise $dataobj 386 387 foreach elem [array names _elem2dataobj] { 387 388 if {$_elem2dataobj($elem) == $dataobj} { 388 unset _elem2dataobj($elem)389 array unset _elem2dataobj $elem 389 390 } 390 391 } … … 494 495 button $inner.go -text [Rappture::filexfer::label download] \ 495 496 -command [lindex $args 0] 496 pack $inner.go - pady 4497 pack $inner.go -side bottom -pady 4 497 498 } else { 498 499 set inner [$popup component inner] … … 1525 1526 itcl::body Rappture::XyResult::_getAxes {dataobj} { 1526 1527 # rebuild if needed, so we know about the axes 1528 if 0 { 1527 1529 if {[$_dispatcher ispending !rebuild]} { 1528 1530 $_dispatcher cancel !rebuild 1529 1531 $_dispatcher event -now !rebuild 1530 1532 } 1531 1533 } 1532 1534 # what is the x axis? x? x2? x3? ... 1533 1535 set xlabel [$dataobj hints xlabel]
Note: See TracChangeset
for help on using the changeset viewer.