Changeset 5038


Ignore:
Timestamp:
Feb 22, 2015 1:43:00 PM (9 years ago)
Author:
ldelgass
Message:

whitespace

Location:
branches/1.3/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/scripts/moleculeViewer.tcl

    r3844 r5038  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22# ----------------------------------------------------------------------
    33#  COMPONENT: MoleculeViewer - view a molecule in 3D
     
    2727    itk_option define -device device Device ""
    2828
    29     constructor {tool args} { 
    30         # defined below 
    31     }
    32     destructor { 
    33         # defined below 
     29    constructor {tool args} {
     30        # defined below
     31    }
     32    destructor {
     33        # defined below
    3434    }
    3535
     
    3838    public method delete {args}
    3939    public method snap {w h}
    40     public method parameters {title args} { 
    41         # do nothing 
     40    public method parameters {title args} {
     41        # do nothing
    4242    }
    4343    public method emblems {option}
     
    6363    private variable _download "";# snapshot for download
    6464}
    65                                                                                
     65
    6666itk::usual MoleculeViewer {
    6767}
     
    236236    }
    237237    array set params $settings
    238  
     238
    239239    set pos [lsearch -exact $_dlist $dataobj]
    240240
     
    243243            error "bad value \"$dataobj\": should be Rappture::library object"
    244244        }
    245    
     245
    246246        set emblem [$dataobj get components.molecule.about.emblems]
    247247        if {$emblem == "" || ![string is boolean $emblem] || !$emblem} {
  • branches/1.3/gui/scripts/molvisviewer.tcl

    r4670 r5038  
    1 # -*- mode: tcl; indent-tabs-mode: nil -*- 
     1# -*- mode: tcl; indent-tabs-mode: nil -*-
    22
    33# ----------------------------------------------------------------------
     
    5252
    5353    private variable _active;           # array of active models.
    54     private variable _obj2models;       # array containing list of models 
     54    private variable _obj2models;       # array containing list of models
    5555                                        # for each data object.
    5656    private variable _view
     
    6363    private variable _imagecache
    6464    private variable _state
    65     private variable _labels  "default"
     65    private variable _labels "default"
    6666    private variable _cacheid ""
    6767    private variable _cacheimage ""
    68     private variable _first     ""
    69 
    70     private common _settings  ;         # Array of settings for all known 
     68    private variable _first ""
     69
     70    private common _settings  ;         # Array of settings for all known
    7171                                        # widgets
    7272    private variable _initialized
     
    8181    private variable _width
    8282    private variable _height
    83     private variable _reset 1;          # Restore camera settings
     83    private variable _reset 1;          # Restore camera settings
    8484    private variable _cell 0;           # Restore camera settings
    8585
     
    9696    }
    9797    private method BuildSettingsTab {}
    98     private method DoResize {} 
    99     private method DoRotate {} 
    100     private method DoUpdate {} 
    101     private method EventuallyResize { w h } 
    102     private method EventuallyRotate { a b c } 
    103     private method EventuallyChangeSettings { args } 
     98    private method DoResize {}
     99    private method DoRotate {}
     100    private method DoUpdate {}
     101    private method EventuallyResize { w h }
     102    private method EventuallyRotate { a b c }
     103    private method EventuallyChangeSettings { args }
    104104    private method GetImage { widget }
    105105    private method ReceiveImage { size cacheid frame rock }
     
    107107    private method AddImageControls { frame widget }
    108108    private method SetWaitVariable { value } {
    109         set _getimage $value 
     109        set _getimage $value
    110110    }
    111111    private method WaitForResponse {} {
     
    125125    public method Connect {}
    126126    public method Disconnect {}
    127     public method ResetView {} 
     127    public method ResetView {}
    128128    public method add {dataobj {options ""}}
    129129    public method delete {args}
     
    132132    public method isconnected {}
    133133    public method labels {option {model "all"}}
    134     public method parameters {title args} { 
    135         # do nothing 
     134    public method parameters {title args} {
     135        # do nothing
    136136    }
    137137
     
    236236        $this-showlabels-initialized no
    237237    }]
    238    
     238
    239239    itk_component add 3dview {
    240240        label $itk_component(plotarea).view -image $_image(plot) \
     
    294294    Rappture::Tooltip::for $itk_component(labels) \
    295295        "Show/hide the labels on atoms"
    296     pack $itk_component(labels) -padx 2 -pady {6 2} 
     296    pack $itk_component(labels) -padx 2 -pady {6 2}
    297297
    298298    itk_component add rock {
     
    303303            -variable [itcl::scope _settings($this-rock)]
    304304    }
    305     pack $itk_component(rock) -padx 2 -pady 2 
     305    pack $itk_component(rock) -padx 2 -pady 2
    306306    Rappture::Tooltip::for $itk_component(rock) "Rock model back and forth"
    307307
     
    319319    BuildSettingsTab
    320320
    321     # HACK ALERT. Initially force a requested width of the 3dview label. 
     321    # HACK ALERT. Initially force a requested width of the 3dview label.
    322322
    323323    # It's a chicken-and-the-egg problem.  The size of the 3dview label is set
     
    463463            if { $showlabels != "" && [string is boolean $showlabels] } {
    464464                set _settings($this-showlabels) $showlabels
    465             } 
     465            }
    466466        }
    467467
     
    567567                    -variable [itcl::scope _downloadPopup(format)] \
    568568                    -font "Arial 10 " \
    569                     -value pdb 
     569                    -value pdb
    570570                Rappture::Tooltip::for $inner.pdb \
    571571                    "Save as PDB Protein Data Bank format file."
     
    573573                    -variable [itcl::scope _downloadPopup(format)] \
    574574                    -font "Arial 10 " \
    575                     -value image 
     575                    -value image
    576576                Rappture::Tooltip::for $inner.image \
    577577                    "Save as image."
     
    589589                blt::table $f \
    590590                    0,0 $f.ok \
    591                     0,1 $f.cancel 
     591                    0,1 $f.cancel
    592592                blt::table $inner \
    593593                    0,0 $inner.summary -anchor w \
     
    628628                    } else {
    629629                        set inner [$popup component inner]
    630                     }                   
     630                    }
    631631                    update
    632632                    # Activate the popup and call for the output.
     
    635635                    $popup activate $widget left
    636636                    set bool [WaitForResponse]
    637                     $popup deactivate 
     637                    $popup deactivate
    638638                    if { $bool } {
    639639                        return [GetImage $widget]
     
    674674        return 0
    675675    }
    676     set _reset 1 
     676    set _reset 1
    677677    set result [VisViewer::Connect $hosts]
    678678    if { $result } {
     
    684684            set info {}
    685685            set user "???"
    686             if { [info exists env(USER)] } {
     686            if { [info exists env(USER)] } {
    687687                set user $env(USER)
    688             }
     688            }
    689689            set session "???"
    690             if { [info exists env(SESSION)] } {
     690            if { [info exists env(SESSION)] } {
    691691                set session $env(SESSION)
    692             }
     692            }
    693693            lappend info "version" "$Rappture::version"
    694694            lappend info "build" "$Rappture::build"
     
    760760    incr count
    761761    if { $cacheid != $_cacheid } {
    762         array unset _imagecache 
     762        array unset _imagecache
    763763        set _cacheid $cacheid
    764764    }
     
    798798        "sticks"      "sticks"          \
    799799        "lines"       "lines"           \
    800         "cartoon"     "cartoon"         
     800        "cartoon"     "cartoon"
    801801
    802802    bind $inner.rep <<Value>> [itcl::code $this Representation]
     
    883883    # Turn on buffering of commands to the server.  We don't want to
    884884    # be preempted by a server disconnect/reconnect (that automatically
    885     # generates a new call to Rebuild).   
     885    # generates a new call to Rebuild).
    886886    StartBufferingCommands
    887887    set _cell 0
     
    897897    set dlist [get]
    898898    foreach dataobj $dlist {
    899         if { $_first == "" } {
    900             set _first $dataobj
    901         }
     899        if { $_first == "" } {
     900            set _first $dataobj
     901        }
    902902        set model [$dataobj get components.molecule.model]
    903903        if {"" == $model } {
     
    906906            set model $model$suffix
    907907        }
    908         lappend _obj2models($dataobj) $model 
     908        lappend _obj2models($dataobj) $model
    909909        set state [$dataobj get components.molecule.state]
    910         if {"" == $state} { 
    911             set state $_state(server) 
     910        if {"" == $state} {
     911            set state $_state(server)
    912912        }
    913913        if { ![info exists _mlist($model)] } {  # new, turn on
    914914            set _mlist($model) 2
    915915        } elseif { $_mlist($model) == 1 } {     # on, leave on
    916             set _mlist($model) 3 
     916            set _mlist($model) 3
    917917        } elseif { $_mlist($model) == 0 } {     # off, turn on
    918918            set _mlist($model) 2
     
    10021002                        set charge     ""
    10031003                        if { "" == $lammpstypemap} {
    1004                             set atom $type 
     1004                            set atom $type
    10051005                        } else {
    10061006                            set atom [lindex $lammpstypemap [expr {$type - 1}]]
     
    10121012                        append data3 $pdbline
    10131013                    }
    1014                     # only read first model 
     1014                    # only read first model
    10151015                    if {[regexp "^ITEM: ATOMS" $lammpsline]} {
    10161016                      incr modelcount
     
    10251025                    set numBytes [string length $data3]
    10261026
    1027                     # We know we're buffered here, so append the "loadpdb" 
     1027                    # We know we're buffered here, so append the "loadpdb"
    10281028                    # command with the data payload immediately afterwards.
    10291029                    ServerCmd "loadpdb -defer follows $model $state $numBytes"
     
    10571057        }
    10581058    }
    1059        
     1059
    10601060    # enable/disable models as required (0=off->off, 1=on->off, 2=off->on,
    10611061    # 3=on->on)
     
    10741074        }
    10751075        if { $_mlist($model) == 1 } {
    1076             if {  [info exists _model($model-newtransparency)] || 
     1076            if {  [info exists _model($model-newtransparency)] ||
    10771077                  [info exists _model($model-newrep)] } {
    10781078                if { ![info exists _model($model-newrep)] } {
     
    11181118        # Set or restore viewing parameters.  We do this for the first
    11191119        # model and assume this works for everything else.
    1120         set w  [winfo width $itk_component(3dview)] 
    1121         set h  [winfo height $itk_component(3dview)] 
    1122         ServerCmd [subst { 
     1120        set w  [winfo width $itk_component(3dview)]
     1121        set h  [winfo height $itk_component(3dview)]
     1122        ServerCmd [subst {
    11231123            reset
    11241124            screen $w $h
     
    11341134    if { $changed } {
    11351135        # Default settings for all models.
    1136         SphereScale update 
     1136        SphereScale update
    11371137        StickRadius update
    1138         labels update 
    1139         Opacity update 
    1140         CartoonTrace update 
     1138        labels update
     1139        Opacity update
     1140        CartoonTrace update
    11411141        Cell update
    1142         OrthoProjection update 
     1142        OrthoProjection update
    11431143        Representation update
    11441144    }
     
    11881188    $_image(plot) configure -width $_width -height $_height
    11891189    # Immediately invalidate cache, defer update until mapped
    1190     array unset _imagecache 
     1190    array unset _imagecache
    11911191    set _resizePending 0
    11921192}
    1193    
     1193
    11941194itcl::body Rappture::MolvisViewer::EventuallyResize { w h } {
    11951195    set _width $w
     
    12031203itcl::body Rappture::MolvisViewer::DoRotate {} {
    12041204    ServerCmd "rotate $_view(a) $_view(b) $_view(c)"
    1205     array unset _imagecache 
     1205    array unset _imagecache
    12061206    set _rotatePending 0
    12071207}
    1208    
     1208
    12091209itcl::body Rappture::MolvisViewer::EventuallyRotate { a b c } {
    1210     set _view(a) $a 
     1210    set _view(a) $a
    12111211    set _view(b) $b
    1212     set _view(c) $c 
     1212    set _view(c) $c
    12131213    if { !$_rotatePending } {
    12141214        $_dispatcher event -after 100 !rotate
     
    12461246        set _view(x) [expr $_view(x) + $dx]
    12471247        set _view(y) [expr $_view(y) + $dy]
    1248         array unset _imagecache 
     1248        array unset _imagecache
    12491249        ServerCmd "pan $dx $dy"
    12501250        return
     
    12531253        set option "click"
    12541254    }
    1255     if { $option == "click" } { 
     1255    if { $option == "click" } {
    12561256        $itk_component(3dview) configure -cursor hand1
    12571257    }
     
    12611261        set _view(x) [expr $_view(x) + $dx]
    12621262        set _view(y) [expr $_view(y) + $dy]
    1263         array unset _imagecache 
     1263        array unset _imagecache
    12641264        ServerCmd "pan $dx $dy"
    12651265    }
     
    12941294        }
    12951295    }
    1296     array unset _imagecache 
     1296    array unset _imagecache
    12971297}
    12981298
     
    13241324        return
    13251325    }
    1326     set _rocker(on) $_settings($this-rock) 
     1326    set _rocker(on) $_settings($this-rock)
    13271327    if { $option == "step"} {
    13281328        if { $_rocker(client) >= 10 } {
     
    15541554    }
    15551555    if { $option == $_mrep } {
    1556         return 
     1556        return
    15571557    }
    15581558    if { $option == "update" } {
    15591559        set option $_settings($this-model)
    15601560    }
    1561     array unset _imagecache 
     1561    array unset _imagecache
    15621562    if { $option == "sticks" } {
    15631563        set _settings($this-modelimg) [Rappture::icon lines]
     
    16591659        return
    16601660    }
    1661     array unset _imagecache 
     1661    array unset _imagecache
    16621662    if { $cell } {
    16631663        Rappture::Tooltip::for $itk_component(ortho) \
     
    17231723    }
    17241724}
    1725            
     1725
    17261726itcl::body Rappture::MolvisViewer::GetImage { widget } {
    17271727    set token "print[incr _nextToken]"
     
    17291729    set $var ""
    17301730
    1731     set controls $_downloadPopup(image_controls) 
     1731    set controls $_downloadPopup(image_controls)
    17321732    set combo $controls.size
    17331733    set size [$combo translate [$combo value]]
     
    17511751    # Setup an automatic timeout procedure.
    17521752    $_dispatcher dispatch $this !pngtimeout "set $var {} ; list"
    1753    
     1753
    17541754    set popup .molvisviewerimagedownload
    17551755    if { ![winfo exists $popup] } {
     
    17651765            1,0 $inner.please -anchor w \
    17661766            1,1 $inner.icon -anchor e  \
    1767             2,0 $inner.cancel -cspan 2 
    1768         blt::table configure $inner r0 -pady 4 
    1769         blt::table configure $inner r2 -pady 4 
     1767            2,0 $inner.cancel -cspan 2
     1768        blt::table configure $inner r0 -pady 4
     1769        blt::table configure $inner r2 -pady 4
    17701770        bind $inner.cancel <Return> [list $inner.cancel invoke]
    17711771        bind $inner.cancel <KP_Enter> [list $inner.cancel invoke]
     
    17751775    set combo $controls.bgcolor
    17761776    set bgcolor [$combo translate [$combo value]]
    1777    
     1777
    17781778    $_dispatcher event -after 60000 !pngtimeout
    17791779    WaitIcon start $inner.icon
    17801780    grab set $inner
    17811781    focus $inner.cancel
    1782    
     1782
    17831783    ServerCmd "print $token $width $height $bgcolor"
    17841784
    17851785    $popup activate $widget below
    1786     # We wait here for either 
    1787     #  1) the png to be delivered or 
    1788     #  2) timeout or 
     1786    # We wait here for either
     1787    #  1) the png to be delivered or
     1788    #  2) timeout or
    17891789    #  3) user cancels the operation.
    17901790    tkwait variable $var
     
    18261826#
    18271827# Used internally to change the molecular atom scale used to render
    1828 # our scene. 
    1829 #
    1830 # Note: Only sets the specified radius for active models.  If the model 
     1828# our scene.
     1829#
     1830# Note: Only sets the specified radius for active models.  If the model
    18311831#       is inactive, then it overridden with the value "0.1".
    18321832# ----------------------------------------------------------------------
     
    18641864# our scene.
    18651865#
    1866 # Note: Only sets the specified radius for active models.  If the model 
     1866# Note: Only sets the specified radius for active models.  If the model
    18671867#       is inactive, then it overridden with the value "0.25".
    18681868# ----------------------------------------------------------------------
     
    19001900# our scene.
    19011901#
    1902 # Note: Only sets the specified transparency for active models.  If the model 
     1902# Note: Only sets the specified transparency for active models.  If the model
    19031903#       is inactive, then it overridden with the value "0.75".
    19041904# ----------------------------------------------------------------------
     
    19711971# ----------------------------------------------------------------------
    19721972itcl::body Rappture::MolvisViewer::CartoonTrace {option {models "all"}} {
    1973     array unset _imagecache 
     1973    array unset _imagecache
    19741974    set trace $_settings($this-cartoontrace)
    19751975    if { $option == "update" } {
     
    19961996
    19971997itcl::body Rappture::MolvisViewer::AddImageControls { inner widget } {
    1998     label $inner.size_l -text "Size:" -font "Arial 9" 
     1998    label $inner.size_l -text "Size:" -font "Arial 9"
    19991999    set _downloadPopup(image_controls) $inner
    20002000    set img $_image(plot)
     
    20062006        "highquality"  "High Quality (2400x2400)"
    20072007
    2008     label $inner.bgcolor_l -text "Background:" -font "Arial 9" 
     2008    label $inner.bgcolor_l -text "Background:" -font "Arial 9"
    20092009    Rappture::Combobox $inner.bgcolor -width 30 -editable no
    20102010    $inner.bgcolor choices insert end \
    20112011        "black"  "Black" \
    20122012        "white"  "White" \
    2013         "none"  "Transparent (PNG only)"         
    2014 
    2015     label $inner.format_l -text "Format:" -font "Arial 9" 
     2013        "none"  "Transparent (PNG only)"
     2014
     2015    label $inner.format_l -text "Format:" -font "Arial 9"
    20162016    Rappture::Combobox $inner.format -width 30 -editable no
    20172017    $inner.format choices insert end \
     
    20342034    blt::table $f \
    20352035        0,0 $f.ok  \
    2036         0,1 $f.cancel 
     2036        0,1 $f.cancel
    20372037
    20382038    blt::table $inner \
     
    20482048    $inner.bgcolor value "Black"
    20492049    $inner.size value "Draft (400x400)"
    2050     $inner.format value  "PNG (Portable Network Graphics format)" 
     2050    $inner.format value  "PNG (Portable Network Graphics format)"
    20512051}
    20522052
     
    20552055        set w [image width $_image(plot)]
    20562056        set h [image height $_image(plot)]
    2057     } 
     2057    }
    20582058    set tag "$_state(client),$_rocker(client)"
    20592059    if { $_image(id) != "$tag" } {
     
    21222122    }
    21232123
    2124     # Scale and translate points 
     2124    # Scale and translate points
    21252125    for { set i 0 } { $i < 8 } { incr i } {
    21262126        point${i} expr "(point${i} * scale) + origin"
Note: See TracChangeset for help on using the changeset viewer.