Changeset 3056 for trunk/gui/scripts/periodictable.tcl
- Timestamp:
- Jun 25, 2012, 3:43:37 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/periodictable.tcl
r2977 r3056 1 2 1 # ---------------------------------------------------------------------- 3 2 # COMPONENT: periodictable - drop-down list of items … … 7 6 # 8 7 # ====================================================================== 9 # AUTHOR: Michael McLennan, Purdue University10 # Copyright (c) 2004-20 05Purdue Research Foundation8 # AUTHOR: George Howlett, Purdue University 9 # Copyright (c) 2004-2012 Purdue Research Foundation 11 10 # 12 11 # See the file "license.terms" for information on usage and … … 32 31 public method value { {name ""} } 33 32 34 private variable _table 33 public proc FindElement { string } 34 public proc ElementIsType { string args } 35 35 36 private variable _dispatcher "" 36 37 private variable _current "" … … 43 44 protected method Activate { widget id x y } 44 45 protected method Deactivate { widget id } 45 protected method FindElement { string }46 46 private common _colors 47 47 array set _colors { … … 242 242 Lawrencium 103 Lr [262.110] 9 17 actinoid 243 243 } 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 244 251 private common _types 245 252 array set _types { … … 302 309 $_dispatcher register !rebuild 303 310 $_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] { 307 313 set _state($name) "normal" 308 314 } 315 309 316 itk_component add scroller { 310 317 Rappture::Scroller $itk_interior.sc \ … … 494 501 set _current $elem 495 502 $_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 # ---------------------------------------------------------------------- 512 itcl::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 # ---------------------------------------------------------------------- 531 itcl::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 496 540 } 497 541 … … 608 652 $c configure -height $height -width $width -background white 609 653 } 610 611 # ----------------------------------------------------------------------612 # USAGE: FindElement613 #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 info620 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.