Ignore:
Timestamp:
Mar 18, 2009, 2:59:21 PM (16 years ago)
Author:
gah
Message:

preliminary HQ output from molvisviewer; unexpand tabs; all jpeg generation at 100%

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/sequence.tcl

    r997 r1342  
    4040itcl::body Rappture::Sequence::constructor {xmlobj path} {
    4141    if {![Rappture::library isvalid $xmlobj]} {
    42         error "bad value \"$xmlobj\": should be LibraryObj"
     42        error "bad value \"$xmlobj\": should be LibraryObj"
    4343    }
    4444    set _xmlobj [$xmlobj element -as object $path]
     
    4848    #
    4949    foreach name [$_xmlobj children -type element] {
    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         }
     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        }
    117117    }
    118118
     
    122122    set units [$xmlobj get $path.index.units]
    123123    if {"" != $units} {
    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]
     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]
    133133
    134134    } else {
    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         }
     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        }
    160160    }
    161161}
     
    166166itcl::body Rappture::Sequence::destructor {} {
    167167    foreach key [array names _dataobjs] {
    168         eval itcl::delete object $_dataobjs($key)
     168        eval itcl::delete object $_dataobjs($key)
    169169    }
    170170    itcl::delete object $_xmlobj
     
    223223itcl::body Rappture::Sequence::hints {{keyword ""}} {
    224224    if {![info exists _hints]} {
    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         }
     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        }
    235235    }
    236236
    237237    if {$keyword != ""} {
    238         if {[info exists _hints($keyword)]} {
    239             return $_hints($keyword)
    240         }
    241         return ""
     238        if {[info exists _hints($keyword)]} {
     239            return $_hints($keyword)
     240        }
     241        return ""
    242242    }
    243243    return [array get _hints]
Note: See TracChangeset for help on using the changeset viewer.