Changeset 1562
- Timestamp:
- Sep 14, 2009 2:14:22 PM (15 years ago)
- Location:
- trunk/gui/scripts
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/curve.tcl
r1550 r1562 47 47 private variable _xmarkers "";# list of {x,label,options} triplets. 48 48 private variable _ymarkers "";# list of {y,label,options} triplets. 49 50 49 private common _counter 0 ;# counter for unique vector names 51 50 } … … 239 238 set _hints(tooltip) $_hints(label) 240 239 } 241 } 242 240 set _hints(xmlobj) $_xmlobj 241 } 243 242 if {$keyword != ""} { 244 243 if {[info exists _hints($keyword)]} { -
trunk/gui/scripts/molvisviewer.tcl
r1556 r1562 55 55 private method DoResize {} 56 56 private method EventuallyResize { w h } 57 private method Get PngImage { widget width height }57 private method GetImage { widget } 58 58 private method ReceiveImage { size cacheid frame rock } 59 59 private method WaitIcon { option widget } … … 81 81 public method isconnected {} 82 82 public method labels {option {model "all"}} 83 public method cartoon {option {model "all"}}84 83 public method cartoontrace {option {model "all"}} 85 84 public method opacity {option {models "all"} } … … 90 89 public method representation {option {model "all"} } 91 90 public method rock {option} 91 private method DownloadPopup { popup command } 92 private method EnableDownload { popup what } 93 92 94 private variable _icon 0 93 95 … … 200 202 $this-spherescale 0.25 201 203 $this-stickradius 0.14 202 $this-cartoon no203 204 $this-cartoontrace no 204 205 $this-model ballnstick … … 402 403 $inner configure -borderwidth 4 403 404 404 label $inner.drawinglabel -text "Molecule Repr sentation" \405 label $inner.drawinglabel -text "Molecule Representation" \ 405 406 -font "Arial 9 bold" 406 407 … … 430 431 radiobutton $inner.lines -text "lines" \ 431 432 -command [itcl::code $this representation lines all] \ 432 -variable Rappture::MolvisViewer::_settings($this-model)\433 -variable [itcl::scope _settings($this-model)] \ 433 434 -value lines -font "Arial 9" -pady 0 434 435 Rappture::Tooltip::for $inner.lines \ 435 436 "Display bonds as lines. Do not display atoms." 437 438 radiobutton $inner.cartoon -text "cartoon" \ 439 -command [itcl::code $this representation cartoon all] \ 440 -variable [itcl::scope _settings($this-model)] \ 441 -value cartoon -font "Arial 9" -pady 0 442 Rappture::Tooltip::for $inner.cartoon \ 443 "Display cartoon representation of bonds (sticks)." 436 444 437 445 scale $inner.spherescale -width 10 -font "Arial 9 bold" \ … … 474 482 "Toggle between orthoscopic/perspective projection modes." 475 483 476 checkbutton $inner.cartoon -text "Cartoon" \477 -command [itcl::code $this cartoon update] \478 -variable [itcl::scope _settings($this-cartoon)] \479 -font "Arial 9 bold"480 Rappture::Tooltip::for $inner.cartoon \481 "Set cartoon representation of bonds (sticks)."482 483 484 checkbutton $inner.cartoontrace -text "Cartoon Trace" \ 484 485 -command [itcl::code $this cartoontrace update] \ … … 491 492 blt::table $inner \ 492 493 0,0 $inner.drawinglabel -anchor w -columnspan 4 \ 493 1,1 $inner.pict -anchor w -rowspan 4\494 1,1 $inner.pict -anchor w -rowspan 5 \ 494 495 1,2 $inner.bstick -anchor w -columnspan 2 \ 495 496 2,2 $inner.spheres -anchor w -columnspan 2 \ 496 497 3,2 $inner.sticks -anchor w -columnspan 2 \ 497 498 4,2 $inner.lines -anchor w -columnspan 2 \ 498 5, 0 $inner.labels -anchor w -columnspan 4 -pady {6 0}\499 6,0 $inner. rock -anchor w -columnspan 4 -pady {60} \500 7,0 $inner. ortho -anchor w -columnspan 4 -pady {60} \501 8, 1 $inner.spherescale -fill x -columnspan 4 -pady {60} \502 10,1 $inner.stickradius -fill x -columnspan 4 -pady {60} \503 1 2,0 $inner.cartoon -anchor w -columnspan 4 -pady {60} \504 1 3,0 $inner.cartoontrace -anchor w -columnspan 4 -pady {60} \499 5,2 $inner.cartoon -anchor w -columnspan 2 \ 500 6,0 $inner.labels -anchor w -columnspan 4 -pady {1 0} \ 501 7,0 $inner.rock -anchor w -columnspan 4 -pady {1 0} \ 502 8,0 $inner.ortho -anchor w -columnspan 4 -pady {1 0} \ 503 9,0 $inner.cartoontrace -anchor w -columnspan 4 -pady {1 0} \ 504 10,1 $inner.spherescale -fill x -columnspan 4 -pady {1 0} \ 505 11,1 $inner.stickradius -fill x -columnspan 4 -pady {1 0} \ 505 506 506 507 blt::table configure $inner c0 -resize expand -width 2 … … 508 509 blt::table configure $inner c3 -resize expand 509 510 blt::table configure $inner r* -resize none 510 blt::table configure $inner r1 4-resize expand511 blt::table configure $inner r13 -resize expand 511 512 } 512 513 … … 537 538 controls { 538 539 set popup .molvisviewerdownload 539 if {![winfo exists .molvisviewerdownload]} { 540 # if we haven't created the popup yet, do it now 541 Rappture::Balloon $popup \ 542 -title "[Rappture::filexfer::label downloadWord] as..." 543 set inner [$popup component inner] 544 label $inner.summary -text "" -anchor w 545 pack $inner.summary -side top 546 set img $_image(plot) 547 set res "[image width $img]x[image height $img]" 548 radiobutton $inner.draft -text "Image (draft $res)" \ 549 -variable Rappture::MolvisViewer::_downloadPopup(format) \ 550 -value draft 551 pack $inner.draft -anchor w 552 553 set res "1200x1200" 554 radiobutton $inner.medium -text "Image (standard $res)" \ 555 -variable Rappture::MolvisViewer::_downloadPopup(format) \ 556 -value $res 557 pack $inner.medium -anchor w 558 559 set res "2400x2400" 560 radiobutton $inner.high -text "Image (high quality $res)" \ 561 -variable Rappture::MolvisViewer::_downloadPopup(format) \ 562 -value $res 563 pack $inner.high -anchor w 564 565 radiobutton $inner.pdb -text "PDB File" \ 566 -variable Rappture::MolvisViewer::_downloadPopup(format) \ 567 -value pdb 568 pack $inner.pdb -anchor w 569 button $inner.go -text [Rappture::filexfer::label download] \ 570 -command [lindex $args 0] 571 pack $inner.go -pady 4 540 if { ![winfo exists .molvisviewerdownload] } { 541 set inner [DownloadPopup $popup [lindex $args 0]] 572 542 } else { 573 543 set inner [$popup component inner] 574 544 } 545 set _downloadPopup(image_controls) $inner.image_frame 575 546 set num [llength [get]] 576 547 set num [expr {($num == 1) ? "1 result" : "$num results"}] … … 587 558 } 588 559 switch -- $_downloadPopup(format) { 589 draft { 590 # Get the image data (as base64) and decode it back to 591 # binary. This is better than writing to temporary 592 # files. When we switch to the BLT picture image it 593 # won't be necessary to decode the image data. 594 set bytes [$_image(plot) data -format "jpeg -quality 100"] 595 set bytes [Rappture::encoding::decode -as b64 $bytes] 596 return [list .jpg $bytes] 560 "image" { 561 return [$this GetImage [lindex $args 0]] 597 562 } 598 "2400x2400" { 599 return [$this GetPngImage [lindex $args 0] 2400 2400] 600 } 601 "1200x1200" { 602 return [$this GetPngImage [lindex $args 0] 1200 1200] 603 } 604 pdb { 563 "pdb" { 605 564 return [list .pdb $_pdbdata] 606 565 } … … 900 859 labels update 901 860 opacity update 902 cartoon update903 861 cartoontrace update 904 862 … … 1536 1494 } 1537 1495 1538 itcl::body Rappture::MolvisViewer::Get PngImage { widget width height } {1496 itcl::body Rappture::MolvisViewer::GetImage { widget } { 1539 1497 set token "print[incr _nextToken]" 1540 1498 set var ::Rappture::MolvisViewer::_hardcopy($this-$token) 1541 1499 set $var "" 1542 1500 1501 set controls $_downloadPopup(image_controls) 1502 set combo $controls.size_combo 1503 set size [$combo translate [$combo value]] 1504 switch -- $size { 1505 "standard" { 1506 set width 1200 1507 set height 1200 1508 } 1509 "highquality" { 1510 set width 2400 1511 set height 2400 1512 } 1513 "draft" { 1514 set width 400 1515 set height 400 1516 } 1517 default { 1518 error "unknown image size [$inner.image_size_combo value]" 1519 } 1520 } 1543 1521 # Setup an automatic timeout procedure. 1544 1522 $_dispatcher dispatch $this !pngtimeout "set $var {} ; list" 1545 1523 1546 1524 set popup .molvisviewerprint 1547 1525 if { ![winfo exists $popup] } { … … 1564 1542 set inner [$popup component inner] 1565 1543 } 1566 1544 set combo $controls.bgcolor_combo 1545 set bgcolor [$combo translate [$combo value]] 1546 1567 1547 $_dispatcher event -after 60000 !pngtimeout 1568 1548 WaitIcon start $inner.icon 1569 1549 grab set -local $inner 1570 1550 focus $inner.cancel 1571 1572 SendCmd "print $token $width $height "1551 1552 SendCmd "print $token $width $height $bgcolor" 1573 1553 1574 1554 $popup activate $widget below … … 1587 1567 1588 1568 if { $_hardcopy($this-$token) != "" } { 1589 return [list .png $_hardcopy($this-$token)] 1569 set combo $controls.type_combo 1570 set type [$combo translate [$combo value]] 1571 switch -- $type { 1572 "jpg" { 1573 set img [image create photo -data $_hardcopy($this-$token)] 1574 set bytes [$img data -format "jpeg -quality 100"] 1575 set bytes [Rappture::encoding::decode -as b64 $bytes] 1576 return [list .jpg $bytes] 1577 } 1578 "gif" { 1579 set img [image create photo -data $_hardcopy($this-$token)] 1580 set bytes [$img data -format "gif"] 1581 set bytes [Rappture::encoding::decode -as b64 $bytes] 1582 return [list .gif $bytes] 1583 } 1584 "png" { 1585 return [list .png $_hardcopy($this-$token)] 1586 } 1587 } 1590 1588 } 1591 1589 return "" … … 1729 1727 1730 1728 # ---------------------------------------------------------------------- 1731 # USAGE: cartoon on|off|toggle1732 # USAGE: cartoon update1733 #1734 # Used internally to turn labels associated with atoms on/off, and to1735 # update the positions of the labels so they sit on top of each atom.1736 # ----------------------------------------------------------------------1737 itcl::body Rappture::MolvisViewer::cartoon {option {models "all"}} {1738 set cartoon $_settings($this-cartoon)1739 if { $option == "update" } {1740 set cartoon $_settings($this-cartoon)1741 } elseif { [string is boolean $option] } {1742 set cartoon $option1743 } else {1744 error "bad option \"$option\""1745 }1746 set _settings($this-cartoon) $cartoon1747 if { $models == "all" } {1748 set models [array names _mlist]1749 }1750 SendCmd "cartoon -model all off"1751 if { $cartoon } {1752 foreach model $models {1753 if { [info exists _active($model)] } {1754 SendCmd "cartoon -model $model $cartoon"1755 }1756 }1757 }1758 }1759 1760 # ----------------------------------------------------------------------1761 1729 # USAGE: cartoontrace on|off|toggle 1762 1730 # USAGE: cartoontrace update … … 1787 1755 } 1788 1756 } 1757 1758 itcl::body Rappture::MolvisViewer::DownloadPopup { popup command } { 1759 Rappture::Balloon $popup \ 1760 -title "[Rappture::filexfer::label downloadWord] as..." 1761 set inner [$popup component inner] 1762 label $inner.summary -text "" -anchor w -font "Arial 11 bold" 1763 radiobutton $inner.pdb_button -text "PDB File" \ 1764 -variable [itcl::scope _downloadPopup(format)] \ 1765 -command [itcl::code $this EnableDownload $popup pdb] \ 1766 -font "Arial 10 " \ 1767 -value pdb 1768 radiobutton $inner.image_button -text "Image File" \ 1769 -variable [itcl::scope _downloadPopup(format)] \ 1770 -command [itcl::code $this EnableDownload $popup image] \ 1771 -font "Arial 10 " \ 1772 -value image 1773 1774 set controls [frame $inner.image_frame -bd 2 -relief groove] 1775 label $controls.size_label -text "Size:" \ 1776 -font "Arial 9" 1777 set img $_image(plot) 1778 set res "[image width $img]x[image height $img]" 1779 Rappture::Combobox $controls.size_combo -width 20 -editable no 1780 $controls.size_combo choices insert end \ 1781 "draft" "Draft (400x400)" \ 1782 "standard" "Standard (1200x1200)" \ 1783 "highquality" "High Quality (2400x2400)" 1784 1785 label $controls.bgcolor_label -text "Background:" \ 1786 -font "Arial 9" 1787 Rappture::Combobox $controls.bgcolor_combo -width 20 -editable no 1788 $controls.bgcolor_combo choices insert end \ 1789 "black" "Black" \ 1790 "white" "White" 1791 1792 label $controls.type_label -text "Type:" \ 1793 -font "Arial 9" 1794 Rappture::Combobox $controls.type_combo -width 20 -editable no 1795 $controls.type_combo choices insert end \ 1796 "jpg" "JPEG Joint Photographic Experts Group Format (*.jpg)" \ 1797 "png" "PNG Portable Network Graphics Format (*.png)" 1798 1799 button $inner.go -text [Rappture::filexfer::label download] \ 1800 -command $command 1801 1802 blt::table $controls \ 1803 1,0 $controls.size_label -anchor e \ 1804 1,1 $controls.size_combo -anchor w \ 1805 2,0 $controls.bgcolor_label -anchor e \ 1806 2,1 $controls.bgcolor_combo -anchor w \ 1807 3,0 $controls.type_label -anchor e \ 1808 3,1 $controls.type_combo -anchor w 1809 blt::table configure $controls r0 -height 16 1810 blt::table configure $controls -padx 4 -pady {0 6} 1811 blt::table $inner \ 1812 0,0 $inner.summary -cspan 2 \ 1813 1,0 $inner.pdb_button -cspan 2 -anchor w \ 1814 2,0 $inner.image_button -cspan 2 -rspan 2 -anchor nw \ 1815 3,1 $controls \ 1816 6,0 $inner.go -cspan 2 -pady 5 1817 blt::table configure $inner c0 -width 11 1818 blt::table configure $inner r2 -height 11 1819 #blt::table configure $inner c1 -width 8 1820 raise $inner.image_button 1821 $inner.pdb_button invoke 1822 $controls.bgcolor_combo value "Black" 1823 $controls.size_combo value "Draft (400x400)" 1824 $controls.type_combo value "PNG Portable Network Graphics Format (*.png)" 1825 return $inner 1826 } 1827 1828 itcl::body Rappture::MolvisViewer::EnableDownload { popup what } { 1829 set inner [$popup component inner] 1830 switch -- $what { 1831 "pdb" { 1832 foreach w [winfo children $inner.image_frame] { 1833 $w configure -state disabled 1834 } 1835 } 1836 "image" { 1837 foreach w [winfo children $inner.image_frame] { 1838 $w configure -state normal 1839 } 1840 } 1841 default { 1842 error "unknown type of download" 1843 } 1844 } 1845 } -
trunk/gui/scripts/xyresult.tcl
r1527 r1562 91 91 protected method _hilite {state x y} 92 92 protected method _axis {option args} 93 protected method _getAxes { xydata}93 protected method _getAxes {curve} 94 94 protected method _getLineMarkerOptions { style } 95 95 protected method _getTextMarkerOptions { style } … … 435 435 436 436 catch {unset _limits} 437 foreach xydata$args {437 foreach curve $args { 438 438 # find the axes for this curve (e.g., {x y2}) 439 foreach {map(x) map(y)} [_getAxes $ xydata] break439 foreach {map(x) map(y)} [_getAxes $curve] break 440 440 441 441 foreach axis {x y} { … … 444 444 # store results -- ex: _limits(x2log-min) 445 445 set id $map($axis)$type 446 foreach {min max} [$ xydatalimits $axis$type] break446 foreach {min max} [$curve limits $axis$type] break 447 447 if {"" != $min && "" != $max} { 448 448 if {![info exists _limits($id-min)]} { … … 460 460 } 461 461 462 if {[$ xydatahints ${axis}scale] == "log"} {462 if {[$curve hints ${axis}scale] == "log"} { 463 463 _axis scale $map($axis) log 464 464 } … … 633 633 set anum(x) 0 634 634 set anum(y) 0 635 foreach xydata[get] {635 foreach curve [get] { 636 636 foreach ax {x y} { 637 set label [$ xydatahints ${ax}label]637 set label [$curve hints ${ax}label] 638 638 if {"" != $label} { 639 639 if {![info exists _label2axis($ax-$label)]} { … … 651 651 652 652 # if this axis has a description, add it as a tooltip 653 set desc [string trim [$ xydatahints ${ax}desc]]653 set desc [string trim [$curve hints ${ax}desc]] 654 654 Rappture::Tooltip::text $g-$axis $desc 655 655 } … … 698 698 # 699 699 set count 0 700 foreach xydata$_clist {701 set label [$ xydatahints label]702 foreach {mapx mapy} [_getAxes $ xydata] break703 704 foreach comp [$ xydatacomponents] {705 set xv [$ xydatamesh $comp]706 set yv [$ xydatavalues $comp]707 708 if {[info exists _curve2color($ xydata)]} {709 set color $_curve2color($ xydata)700 foreach curve $_clist { 701 set label [$curve hints label] 702 foreach {mapx mapy} [_getAxes $curve] break 703 704 foreach comp [$curve components] { 705 set xv [$curve mesh $comp] 706 set yv [$curve values $comp] 707 708 if {[info exists _curve2color($curve)]} { 709 set color $_curve2color($curve) 710 710 } else { 711 set color [$ xydatahints color]711 set color [$curve hints color] 712 712 if {"" == $color} { 713 713 set color black … … 715 715 } 716 716 717 if {[info exists _curve2width($ xydata)]} {718 set lwidth $_curve2width($ xydata)717 if {[info exists _curve2width($curve)]} { 718 set lwidth $_curve2width($curve) 719 719 } else { 720 720 set lwidth 2 721 721 } 722 722 723 if {[info exists _curve2dashes($ xydata)]} {724 set dashes $_curve2dashes($ xydata)723 if {[info exists _curve2dashes($curve)]} { 724 set dashes $_curve2dashes($curve) 725 725 } else { 726 726 set dashes "" … … 736 736 737 737 set elem "elem[incr count]" 738 set _elem2curve($elem) $ xydata739 738 set _elem2curve($elem) $curve 739 lappend label2elem($label) $elem 740 740 $g element create $elem -x $xv -y $yv \ 741 -symbol $sym -pixels $pixels -linewidth $lwidth -label $label \ 741 -symbol $sym -pixels $pixels -linewidth $lwidth \ 742 -label $label \ 742 743 -color $color -dashes $dashes \ 743 744 -mapx $mapx -mapy $mapy … … 745 746 } 746 747 747 foreach xydata $_clist { 748 # Fix duplicate labels by appending the simulation number 749 foreach label [array names label2elem] { 750 if { [llength $label2elem($label)] == 1 } { 751 continue 752 } 753 foreach elem $label2elem($label) { 754 set curve $_elem2curve($elem) 755 scan [$curve hints xmlobj] "::libraryObj%d" suffix 756 incr suffix 757 set elabel [format "%s \#%d" $label $suffix] 758 $g element configure $elem -label $elabel 759 } 760 } 761 762 foreach curve $_clist { 748 763 set xmin -Inf 749 764 set ymin -Inf … … 753 768 # Create text/line markers for each *axis.marker specified. 754 769 # 755 foreach m [$ xydataxmarkers] {770 foreach m [$curve xmarkers] { 756 771 foreach {at label style} $m break 757 772 set id [$g marker create line -coords [list $at $ymin $at $ymax]] … … 773 788 } 774 789 } 775 foreach m [$ xydataymarkers] {790 foreach m [$curve ymarkers] { 776 791 foreach {at label style} $m break 777 792 set id [$g marker create line -coords [list $xmin $at $xmax $at]] … … 1521 1536 # x-axis name (x, x2, x3, etc.), and y is the y-axis name. 1522 1537 # ---------------------------------------------------------------------- 1523 itcl::body Rappture::XyResult::_getAxes { xydata} {1538 itcl::body Rappture::XyResult::_getAxes {curve} { 1524 1539 # rebuild if needed, so we know about the axes 1525 1540 if {[$_dispatcher ispending !rebuild]} { … … 1529 1544 1530 1545 # what is the x axis? x? x2? x3? ... 1531 set xlabel [$ xydatahints xlabel]1546 set xlabel [$curve hints xlabel] 1532 1547 if {[info exists _label2axis(x-$xlabel)]} { 1533 1548 set mapx $_label2axis(x-$xlabel) … … 1537 1552 1538 1553 # what is the y axis? y? y2? y3? ... 1539 set ylabel [$ xydatahints ylabel]1554 set ylabel [$curve hints ylabel] 1540 1555 if {[info exists _label2axis(y-$ylabel)]} { 1541 1556 set mapy $_label2axis(y-$ylabel)
Note: See TracChangeset
for help on using the changeset viewer.