Ignore:
Timestamp:
Oct 18, 2010, 11:59:55 AM (14 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/deviceEditor.tcl

    r1719 r1923  
    2323
    2424    constructor {owner args} {
    25         Rappture::ControlOwner::constructor $owner
     25        Rappture::ControlOwner::constructor $owner
    2626    } {
    27         # defined below
     27        # defined below
    2828    }
    2929    public method value {args}
     
    3232    public method delete {args}
    3333    public method parameters {title args} {
    34         # do nothing
     34        # do nothing
    3535    }
    3636    public method snap {w h}
     
    4444
    4545    public proc setMolvisServer {namelist} {
    46         if {[regexp {^[a-zA-Z0-9\.]+:[0-9]+(,[a-zA-Z0-9\.]+:[0-9]+)*$} $namelist match]} {
    47             set _molvisHosts $namelist
    48         } else {
    49             error "bad visualization server address \"$namelist\": should be host:port,host:port,..."
    50         }
    51     }
    52 }
    53                                                                                
     46        if {[regexp {^[a-zA-Z0-9\.]+:[0-9]+(,[a-zA-Z0-9\.]+:[0-9]+)*$} $namelist match]} {
     47            set _molvisHosts $namelist
     48        } else {
     49            error "bad visualization server address \"$namelist\": should be host:port,host:port,..."
     50        }
     51    }
     52}
     53                                                                               
    5454itk::usual DeviceEditor {
    5555}
     
    6060itcl::body Rappture::DeviceEditor::constructor {owner args} {
    6161    itk_component add top {
    62         frame $itk_interior.top
     62        frame $itk_interior.top
    6363    }
    6464    pack $itk_component(top) -fill x
     
    8181    set i [lsearch -exact $args -check]
    8282    if {$i >= 0} {
    83         set onlycheck 1
    84         set args [lreplace $args $i $i]
     83        set onlycheck 1
     84        set args [lreplace $args $i $i]
    8585    }
    8686
    8787    if {[llength $args] == 1} {
    88         if {$_xmlobj != ""} {
    89             if {$itk_option(-autocleanup)} {
    90                 # delete any existing object
    91                 itcl::delete object $_xmlobj
    92             }
    93             set _xmlobj ""
    94         }
    95 
    96         set newval [lindex $args 0]
    97         if {$newval != ""} {
    98             if {$onlycheck} {
    99                 return
    100             }
    101             if {![Rappture::library isvalid $newval]} {
    102                 error "bad value \"$newval\": should be Rappture::Library"
    103             }
    104             set _xmlobj $newval
    105         }
    106         _redraw
    107         $_current configure -device $_xmlobj
    108         event generate $itk_component(hull) <<Value>>
     88        if {$_xmlobj != ""} {
     89            if {$itk_option(-autocleanup)} {
     90                # delete any existing object
     91                itcl::delete object $_xmlobj
     92            }
     93            set _xmlobj ""
     94        }
     95
     96        set newval [lindex $args 0]
     97        if {$newval != ""} {
     98            if {$onlycheck} {
     99                return
     100            }
     101            if {![Rappture::library isvalid $newval]} {
     102                error "bad value \"$newval\": should be Rappture::Library"
     103            }
     104            set _xmlobj $newval
     105        }
     106        _redraw
     107        $_current configure -device $_xmlobj
     108        event generate $itk_component(hull) <<Value>>
    109109
    110110    } elseif {[llength $args] == 0} {
    111         sync  ;# querying -- must sync controls with the value
     111        sync  ;# querying -- must sync controls with the value
    112112    } else {
    113         error "wrong # args: should be \"value ?-check? ?newval?\""
     113        error "wrong # args: should be \"value ?-check? ?newval?\""
    114114    }
    115115    return $_xmlobj
     
    127127    set _xmlobj $dataobj
    128128    if {"" == $_current} {    # Make sure viewer instance exists
    129         _redraw
     129        _redraw
    130130    }
    131131    eval $_current add $dataobj [list $settings]
     
    140140itcl::body Rappture::DeviceEditor::delete {args} {
    141141    if {"" != $_current} {
    142         eval $_current delete $args
    143         set _xmlobj [lindex [$_current get] end]
     142        eval $_current delete $args
     143        set _xmlobj [lindex [$_current get] end]
    144144    }
    145145}
     
    157157itcl::body Rappture::DeviceEditor::download {option args} {
    158158    if {"" != $_current} {
    159         return [eval $_current download $option $args]
     159        return [eval $_current download $option $args]
    160160    }
    161161    return ""
     
    172172itcl::body Rappture::DeviceEditor::_redraw {} {
    173173    if {$_current != ""} {
    174         $_current configure -device ""
    175         set _current ""
     174        $_current configure -device ""
     175        set _current ""
    176176    }
    177177    switch -- [_type $_xmlobj] {
    178         molecule {
    179             if { ![winfo exists $itk_component(hull).mol] } {
    180                 catch {
    181                     destroy $itk_component(hull).dev
    182                 }
    183                 set servers [Rappture::VisViewer::GetServerList "pymol"]
    184                 if { "" != $servers } {
    185                     Rappture::MolvisViewer $itk_component(hull).mol $servers
    186                 } else {
    187                     Rappture::MoleculeViewer $itk_component(hull).mol $this
    188                 }
    189                 pack $itk_component(hull).mol -expand yes -fill both
    190             }
    191             set _current $itk_component(hull).mol
    192         }
    193         device1D {
    194             if { ![winfo exists $itk_component(hull).dev] } {
    195                 catch {
    196                     destroy $itk_component(hull).mol
    197                 }
    198                 Rappture::DeviceViewer1D $itk_component(hull).dev $this
    199                 pack $itk_component(hull).dev -expand yes -fill both
    200             }
    201             set _current $itk_component(hull).dev
    202         }
     178        molecule {
     179            if { ![winfo exists $itk_component(hull).mol] } {
     180                catch {
     181                    destroy $itk_component(hull).dev
     182                }
     183                set servers [Rappture::VisViewer::GetServerList "pymol"]
     184                if { "" != $servers } {
     185                    Rappture::MolvisViewer $itk_component(hull).mol $servers
     186                } else {
     187                    Rappture::MoleculeViewer $itk_component(hull).mol $this
     188                }
     189                pack $itk_component(hull).mol -expand yes -fill both
     190            }
     191            set _current $itk_component(hull).mol
     192        }
     193        device1D {
     194            if { ![winfo exists $itk_component(hull).dev] } {
     195                catch {
     196                    destroy $itk_component(hull).mol
     197                }
     198                Rappture::DeviceViewer1D $itk_component(hull).dev $this
     199                pack $itk_component(hull).dev -expand yes -fill both
     200            }
     201            set _current $itk_component(hull).dev
     202        }
    203203    }
    204204}
     
    214214itcl::body Rappture::DeviceEditor::_type {xmlobj} {
    215215    if {$xmlobj == ""} {
    216         return ""
     216        return ""
    217217    }
    218218    if {[llength [$xmlobj children -type molecule components]] > 0} {
    219         return "molecule"
     219        return "molecule"
    220220    }
    221221    return "device1D"
Note: See TracChangeset for help on using the changeset viewer.