Ignore:
Timestamp:
Sep 20, 2012, 12:46:32 PM (12 years ago)
Author:
ldelgass
Message:

sync with trunk

Location:
branches/nanovis2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/nanovis2

  • branches/nanovis2/gui/scripts/periodictable.tcl

    r2977 r3175  
    1 
    21# ----------------------------------------------------------------------
    32#  COMPONENT: periodictable - drop-down list of items
     
    76#
    87# ======================================================================
    9 #  AUTHOR:  Michael McLennan, Purdue University
    10 #  Copyright (c) 2004-2005  Purdue Research Foundation
     8#  AUTHOR:  George Howlett, Purdue University
     9#  Copyright (c) 2004-2012  Purdue Research Foundation
    1110#
    1211#  See the file "license.terms" for information on usage and
     
    3231    public method value { {name ""} }
    3332
    34     private variable _table
     33    public proc FindElement { string }
     34    public proc ElementIsType { string args }
     35
    3536    private variable _dispatcher ""
    3637    private variable _current ""
     
    4344    protected method Activate { widget id x y }
    4445    protected method Deactivate { widget id }
    45     protected method FindElement { string }
    4646    private common _colors
    4747    array set _colors {
     
    242242        Lawrencium      103 Lr [262.110] 9 17   actinoid
    243243    }
     244
     245    private common _table
     246    foreach { name number symbol weight row column type } $_tableData {
     247        set _table($name) [list name $name number $number symbol $symbol \
     248                weight $weight row $row column $column type $type]
     249    }
     250
    244251    private common _types
    245252    array set _types {
     
    302309    $_dispatcher register !rebuild
    303310    $_dispatcher dispatch $this !rebuild "[itcl::code $this Redraw]; list"
    304     foreach { name number symbol weight row column type } $_tableData {
    305         set _table($name) [list name $name number $number symbol $symbol \
    306                 weight $weight row $row column $column type $type]
     311
     312    foreach name [array names _table] {
    307313        set _state($name) "normal"
    308314    }
     315
    309316    itk_component add scroller {
    310317        Rappture::Scroller $itk_interior.sc \
     
    494501    set _current $elem
    495502    $_dispatcher event -idle !rebuild
     503}
     504
     505# ----------------------------------------------------------------------
     506# USAGE: FindElement <what>
     507#
     508# Checks to see if the given string <what> is recognized as an element
     509# name, symbol, or number.  Returns the corresponding element name
     510# or "" if the element is not recognized.
     511# ----------------------------------------------------------------------
     512itcl::body Rappture::PeriodicTable::FindElement { what } {
     513    foreach name [array names _table] {
     514        array unset info
     515        array set info $_table($name)
     516        if { $what eq $info(name) || $what eq $info(number) ||
     517             $what eq $info(symbol) } {
     518            return $info(name)
     519        }
     520    }
     521    return ""
     522}
     523
     524# ----------------------------------------------------------------------
     525# USAGE: ElementIsType <name> <type> <type>...
     526#
     527# Checks to see if the given element <name> is one of the specified
     528# <type> values.  Returns true if the element is one of the types
     529# (logical or), or false if it is not.
     530# ----------------------------------------------------------------------
     531itcl::body Rappture::PeriodicTable::ElementIsType { name args } {
     532    foreach type $args {
     533        if {[info exists _types($type)]} {
     534            if {[lsearch -exact $_types($type) $name] >= 0} {
     535                return 1
     536            }
     537        }
     538    }
     539    return 0
    496540}
    497541
     
    608652    $c configure -height $height -width $width -background white
    609653}
    610 
    611 # ----------------------------------------------------------------------
    612 # USAGE: FindElement
    613 #
    614 # Used to manipulate the selection in the table.
    615 #
    616 # ----------------------------------------------------------------------
    617 itcl::body Rappture::PeriodicTable::FindElement { what } {
    618     foreach name [array names _table] {
    619         array unset info
    620         array set info $_table($name)
    621         if { $what == $info(name) || $what == $info(number) ||
    622              $what == $info(symbol) } {
    623             return $info(name)
    624         }
    625     }
    626     return ""
    627 }
    628                                                                
Note: See TracChangeset for help on using the changeset viewer.