Changeset 1342 for trunk/gui/scripts/sequence.tcl
- Timestamp:
- Mar 18, 2009, 2:59:21 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/sequence.tcl
r997 r1342 40 40 itcl::body Rappture::Sequence::constructor {xmlobj path} { 41 41 if {![Rappture::library isvalid $xmlobj]} { 42 42 error "bad value \"$xmlobj\": should be LibraryObj" 43 43 } 44 44 set _xmlobj [$xmlobj element -as object $path] … … 48 48 # 49 49 foreach name [$_xmlobj children -type element] { 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 50 set index [$xmlobj get $path.$name.index] 51 if {"" == $index} { 52 continue 53 } 54 55 # check for an element about.label stanza 56 set elelabel [$xmlobj get $path.$name.about.label] 57 58 set ctype "" 59 set _dataobjs($index) "" 60 set _labels($index) "" 61 foreach cname [$_xmlobj children $name] { 62 set type [$xmlobj element -as type $path.$name.$cname] 63 switch -- $type { 64 index { 65 # ignore this 66 continue 67 } 68 about { 69 # ignore this 70 continue 71 } 72 curve { 73 set obj [Rappture::Curve ::#auto $xmlobj $path.$name.$cname] 74 } 75 histogram { 76 set obj [Rappture::Histogram ::#auto $xmlobj $path.$name.$cname] 77 } 78 field { 79 set obj [Rappture::Field ::#auto $xmlobj $path.$name.$cname] 80 } 81 image { 82 set obj [Rappture::Image ::#auto $xmlobj $path.$name.$cname] 83 } 84 structure { 85 # extract unique result set prefix 86 scan $xmlobj "::libraryObj%d" rset 87 88 # object rooted at x.sequence(y).element(z).structure 89 set obj [$xmlobj element -as object $path.$name.$cname] 90 91 # scene id (sequence id) 92 set sceneid [$xmlobj element -as id $path]-$rset 93 94 # sequence/element/frame number starting at 1 95 set frameid [expr [$xmlobj element -as id $path.$name] + 1] 96 97 # only supporting one molecule per structure at the moment 98 # otherwise should go through all children that are molecules 99 # and insert scene/frame data. 100 $obj put "components.molecule.state" $frameid 101 $obj put "components.molecule.model" $sceneid 102 } 103 default { 104 error "don't know how to handle sequences of $type" 105 } 106 } 107 if {"" == $ctype} { 108 set ctype $type 109 } 110 if {$type == $ctype} { 111 lappend _dataobjs($index) $obj 112 set _labels($index) $elelabel 113 } else { 114 itcl::delete object $obj 115 } 116 } 117 117 } 118 118 … … 122 122 set units [$xmlobj get $path.index.units] 123 123 if {"" != $units} { 124 125 126 127 128 129 130 131 132 124 # build up a list: {10m 10} {10cm 0.1} ... 125 set vals "" 126 foreach key [array names _dataobjs] { 127 lappend vals [list $key [Rappture::Units::convert $key \ 128 -context $units -to $units -units off]] 129 } 130 131 # sort according to raw values; store both values 132 set _indices [lsort -real -index 1 $vals] 133 133 134 134 } else { 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 135 # are the indices integers, reals, or strings? 136 set how -integer 137 foreach key [array names _dataobjs] { 138 if {[regexp {^[0-9]+[eE][-+]?[0-9]+|([0-9]+)?\.[0-9]+([eE][-+]?[0-9]+)?$} $key]} { 139 set how -real 140 break 141 } elseif {![regexp {^[0-9]+$} $key]} { 142 set how -dictionary 143 break 144 } 145 } 146 147 # keep a list of indices sorted in order 148 set _indices "" 149 if {[string equal $how -dictionary]} { 150 set n 0 151 foreach val [lsort $how [array names _dataobjs]] { 152 lappend _indices [list $val $n] 153 incr n 154 } 155 } else { 156 foreach val [lsort $how [array names _dataobjs]] { 157 lappend _indices [list $val $val] 158 } 159 } 160 160 } 161 161 } … … 166 166 itcl::body Rappture::Sequence::destructor {} { 167 167 foreach key [array names _dataobjs] { 168 168 eval itcl::delete object $_dataobjs($key) 169 169 } 170 170 itcl::delete object $_xmlobj … … 223 223 itcl::body Rappture::Sequence::hints {{keyword ""}} { 224 224 if {![info exists _hints]} { 225 226 227 228 229 230 231 232 233 234 225 foreach {key path} { 226 label about.label 227 indexlabel index.label 228 indexdesc index.description 229 } { 230 set str [$_xmlobj get $path] 231 if {"" != $str} { 232 set _hints($key) $str 233 } 234 } 235 235 } 236 236 237 237 if {$keyword != ""} { 238 239 240 241 238 if {[info exists _hints($keyword)]} { 239 return $_hints($keyword) 240 } 241 return "" 242 242 } 243 243 return [array get _hints]
Note: See TracChangeset
for help on using the changeset viewer.