Changeset 1339 for trunk


Ignore:
Timestamp:
Mar 18, 2009, 1:07:15 PM (16 years ago)
Author:
gah
Message:

first pass at HQ hardcopy.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/molvisviewer.tcl

    r1336 r1339  
    6868    public method representation {option {model "all"} }
    6969    public method atomscale {option {model "all"} }
     70    public method bondthickness {option {model "all"} }
    7071    public method ResetView {}
    7172    public method settings {option args}
     
    115116    common _downloadPopup           ;# download options from popup
    116117    private variable _pdbdata       ;# pdb data from run file sent to pymol
     118    private common hardcopy_
     119    private variable nextToken_ 0
    117120}
    118121
     
    435438        -value lines -font "Arial 9" -pady 0
    436439
    437     label $inner.sizelabel -text "Atom Scale" -font "Arial 9 bold"
    438     scale $inner.atomscale \
    439         -from 0.1 -to 2.0 -resolution 0.05 \
     440    scale $inner.atomscale -width 10 -font "Arial 9 bold" \
     441        -from 0.1 -to 2.0 -resolution 0.05 -label "Atom Scale" \
    440442        -showvalue true -orient horizontal \
    441443        -command [itcl::code $this atomscale] \
     
    443445    $inner.atomscale set $_settings($this-atomscale)
    444446
    445     label $inner.bondthicknesslabel -text "Bond Thickness" -font "Arial 9 bold"
    446     scale $inner.bondthickness \
    447         -from 0.1 -to 1.0 -resolution 0.25 \
     447    scale $inner.bondthickness -width 10 -font "Arial 9 bold" \
     448        -from 0.1 -to 1.0 -resolution 0.025 -label "Bond Thickness" \
    448449        -showvalue true -orient horizontal \
    449450        -command [itcl::code $this bondthickness] \
     
    469470        2,2 $inner.lines -anchor w -columnspan 2 \
    470471        3,2 $inner.bstick -anchor w -columnspan 2 \
    471         4,0 $inner.sizelabel -columnspan 4 -anchor w \
    472         5,1 $inner.atomscale -anchor w -columnspan 3 \
    473         6,0 $inner.bondthicknesslabel -columnspan 4 -anchor w \
    474         7,1 $inner.bondthickness -anchor w -columnspan 3 \
    475         8,0 $inner.labels -anchor w -columnspan 4 \
    476         9,0 $inner.rock -anchor w -columnspan 4 \
    477         10,0 $inner.ortho -anchor w -columnspan 4
     472        4,0 $inner.labels -anchor w -columnspan 4 \
     473        5,0 $inner.rock -anchor w -columnspan 4 \
     474        6,0 $inner.ortho -anchor w -columnspan 4 \
     475        8,1 $inner.atomscale -anchor w -columnspan 2 \
     476        10,1 $inner.bondthickness -anchor w -columnspan 2
    478477
    479478    blt::table configure $inner c0 -resize expand -width 2
     
    517516                    -variable Rappture::MolvisViewer::_downloadPopup(format) \
    518517                    -value jpg
     518                pack $inner.jpg -anchor w
     519                radiobutton $inner.jpg -text "PNG Image" \
     520                    -variable Rappture::MolvisViewer::_downloadPopup(format) \
     521                    -value png
    519522                pack $inner.jpg -anchor w
    520523                radiobutton $inner.pdb -text "PDB File" \
     
    541544            }
    542545            switch -- $_downloadPopup(format) {
    543               jpg {
    544                 return [ \
    545                   list .jpg [ \
    546                     Rappture::encoding::decode -as b64 [ \
    547                       $_image(plot) data -format jpeg]]]
    548               }
    549               pdb {
    550                 return [list .pdb $_pdbdata]
    551               }
     546                jpg {
     547                    set data [$_image(plot) data -format jpeg]
     548                    set encoded [Rappture::encoding::decode -as b64 $data]
     549                    return [list .jpg $encoded]
     550                }
     551                png {
     552                    set token "print[incr nextToken_]"
     553                    _send "print $token 2400 2400"
     554                    # Setup popup with cancel button and timeout.
     555                    blt::busy hold $popup
     556                    tkwait Rappture::MolvisViewer::hardcopy_($this-$token)
     557                    # Pass the image as-is. Don't convert it.
     558                    set data $hardcopy_($this-$token)
     559                    set encoded [Rappture::encoding::decode -as b64 $data]
     560                    blt::busy release $popup
     561                    return [list .png $encoded]
     562                }
     563                pdb {
     564                    return [list .pdb $_pdbdata]
     565                }
    552566            }
    553567        }
     
    646660        set _cacheid $cacheid
    647661    }
    648 #    debug "reading $size bytes from proxy\n"
    649     set _imagecache($tag) [ReceiveBytes $size]
    650 #    debug "success: reading $size bytes from proxy\n"
    651 
    652     #debug "CACHED: $tag,$cacheid"
    653     $_image(plot) configure -data $_imagecache($tag)
    654     set _image(id) $tag
     662    #debug "reading $size bytes from proxy\n"
     663    set data [ReceiveBytes $size]
     664    #debug "success: reading $size bytes from proxy\n"
     665    if { $cacheid == "print" } {
     666        # $frame is the token that we sent to the proxy.
     667        set hardcopy_($this-$frame) $data
     668    } else {
     669        set _imagecache($tag) $data
     670        #debug "CACHED: $tag,$cacheid"
     671        $_image(plot) configure -data $data
     672        set _image(id) $tag
     673    }
    655674}
    656675
     
    13481367        set scale $option
    13491368        if { ($scale < 0.1) || ($scale > 2.0) } {
    1350             error "bad atom size \"$scale\""
     1369            error "bad bind thickness \"$scale\""
    13511370        }
    13521371    } else {
Note: See TracChangeset for help on using the changeset viewer.