Changeset 6 for trunk/gui/scripts


Ignore:
Timestamp:
Mar 23, 2005 8:19:29 PM (19 years ago)
Author:
mmc
Message:

Fixed the Tcl library to mirror the API developed for XML
libraries on the Python side. The Tcl Rappture::library
now has methods like "children", "element", "put", etc.
One difference: On the Tcl side, the default -flavor for
element/children is "component", since that works better
in Tcl code. In Python, the default is flavor=object.

Also fixed the Tcl install script to install not just
the tcl/scripts library, but also the ../gui and ../lib
directories.

Location:
trunk/gui/scripts
Files:
6 edited

Legend:

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

    r1 r6  
    258258# ----------------------------------------------------------------------
    259259itcl::configbody Rappture::Analyzer::tool {
    260     if {![Rappture::Library::valid $itk_option(-tool)]} {
     260    if {![Rappture::library isvalid $itk_option(-tool)]} {
    261261        error "bad value \"$itk_option(-tool)\": should be Rappture::Library"
    262262    }
     
    276276itcl::configbody Rappture::Analyzer::device {
    277277    if {$itk_option(-device) != ""
    278           && ![Rappture::Library::valid $itk_option(-device)]} {
     278          && ![Rappture::library isvalid $itk_option(-device)]} {
    279279        error "bad value \"$itk_option(-device)\": should be Rappture::Library"
    280280    }
     
    289289# ----------------------------------------------------------------------
    290290itcl::configbody Rappture::Analyzer::analysis {
    291     if {![Rappture::Library::valid $itk_option(-analysis)]} {
     291    if {![Rappture::library isvalid $itk_option(-analysis)]} {
    292292        error "bad value \"$itk_option(-analysis)\": should be Rappture::Library"
    293293    }
     
    299299
    300300    set counter 0
    301     foreach item [$itk_option(-analysis) get -children] {
     301    foreach item [$itk_option(-analysis) children] {
    302302        switch -glob -- $item {
    303303            xyplot* {
     
    311311
    312312                set _widgets($item) [Rappture::Xyplot $page.#auto \
    313                     -layout [$itk_option(-analysis) get -object $item]]
     313                    -layout [$itk_option(-analysis) element -flavor object $item]]
    314314                pack $_widgets($item) -expand yes -fill both
    315315            }
  • trunk/gui/scripts/curve.tcl

    r1 r6  
    3838# ----------------------------------------------------------------------
    3939itcl::body Rappture::Curve::constructor {libobj path} {
    40     if {![Rappture::Library::valid $libobj]} {
     40    if {![Rappture::library isvalid $libobj]} {
    4141        error "bad value \"$libobj\": should be LibraryObj"
    4242    }
    4343    set _libobj $libobj
    44     set _curve [$libobj get -object $path]
     44    set _curve [$libobj element -flavor object $path]
    4545
    4646    # build up vectors for various components of the curve
     
    144144    # vectors for each part.
    145145    #
    146     set max [$_curve get -count component]
    147     for {set i 0} {$i < $max} {incr i} {
     146    foreach cname [$_curve children -type component] {
    148147        set xv ""
    149148        set yv ""
    150149
    151         set xydata [$_curve get component$i.xy]
     150        set xydata [$_curve get $cname.xy]
    152151        if {"" != $xydata} {
    153152            set xv [blt::vector create x$_counter]
     
    163162
    164163        if {$xv != "" && $yv != ""} {
    165             set _comp2vecs(component$i) [list $xv $yv]
     164            set _comp2vecs($cname) [list $xv $yv]
    166165            incr _counter
    167166        }
  • trunk/gui/scripts/deviceLayout1D.tcl

    r1 r6  
    182182    # see if any of the slabs has a label
    183183    if {$_device != ""} {
    184         foreach nn [$_device get -children recipe] {
     184        foreach nn [$_device children recipe] {
    185185            if {"" != [$_device get recipe.$nn.label]} {
    186186                set extra [expr {1.2*[font metrics $fnt -linespace]}]
     
    192192
    193193    # a little extra height for the molecule image
    194     if {[$_device get -exists recipe.molecule]} {
     194    if {"" != [$_device element recipe.molecule]} {
    195195        set h [expr {$h+15}]
    196196    }
     
    210210    set z 0
    211211    if {$_device != ""} {
    212         foreach nn [$_device get -children recipe] {
     212        foreach nn [$_device children recipe] {
    213213            switch -glob -- $nn {
    214214                slab* - molecule* {
     
    310310    set h [expr {[winfo height $c]-1}]
    311311    # a little extra height for the molecule image
    312     if {[$_device get -exists recipe.molecule]} {
     312    if {"" != [$_device element recipe.molecule]} {
    313313        set h [expr {$h-15}]
    314314    }
     
    361361    set h [expr {[winfo height $c]-1}]
    362362    # a little extra height for the molecule image
    363     if {[$_device get -exists recipe.molecule]} {
     363    if {"" != [$_device element recipe.molecule]} {
    364364        set h [expr {$h-15}]
    365365    }
     
    395395    set h [expr {[winfo height $c]-1}]
    396396    # a little extra height for the molecule image
    397     if {[$_device get -exists recipe.molecule]} {
     397    if {"" != [$_device element recipe.molecule]} {
    398398        set h [expr {$h-15}]
    399399    }
     
    448448    #
    449449    if {"" != $_device} {
    450         set label [$_device get "$elem.label"]
     450        set label [$_device get $elem.label]
    451451        if {"" != $label} {
    452452            set y [expr {$y-0.5*$lh}]
     
    491491itcl::configbody Rappture::DeviceLayout1D::library {
    492492    if {$itk_option(-library) != ""} {
    493         if {![Rappture::Library::valid $itk_option(-library)]} {
     493        if {![Rappture::library isvalid $itk_option(-library)]} {
    494494            error "bad value \"$itk_option(-library)\": should be Rappture::Library"
    495495        }
     
    508508itcl::configbody Rappture::DeviceLayout1D::device {
    509509    if {$itk_option(-device) != ""} {
    510         if {![Rappture::Library::valid $itk_option(-device)]} {
     510        if {![Rappture::library isvalid $itk_option(-device)]} {
    511511            error "bad value \"$itk_option(-device)\": should be Rappture::Library"
    512512        }
  • trunk/gui/scripts/deviceViewer1D.tcl

    r1 r6  
    186186    #
    187187    if {$_device != ""} {
    188         foreach nn [$_device get -children] {
     188        foreach nn [$_device children] {
    189189            if {[string match field* $nn]} {
    190190                set name [$_device get $nn.label]
     
    516516itcl::body Rappture::DeviceViewer1D::_controlCreate {container libObj path} {
    517517    set presets ""
    518     set npre [$libObj get -count $path.preset]
    519     for {set i 0} {$i < $npre} {incr i} {
     518    foreach pre [$libObj children -type preset $path] {
    520519        lappend presets \
    521             [$libObj get $path.preset$i.value] \
    522             [$libObj get $path.preset$i.label]
     520            [$libObj get $path.$pre.value] \
     521            [$libObj get $path.$pre.label]
    523522    }
    524523
     
    606605itcl::configbody Rappture::DeviceViewer1D::device {
    607606    if {$itk_option(-device) != ""} {
    608         if {![Rappture::Library::valid $itk_option(-device)]} {
     607        if {![Rappture::library isvalid $itk_option(-device)]} {
    609608            error "bad value \"$itk_option(-device)\": should be Rappture::Library"
    610609        }
     
    623622itcl::configbody Rappture::DeviceViewer1D::tool {
    624623    if {$itk_option(-tool) != ""} {
    625         if {![Rappture::Library::valid $itk_option(-tool)]} {
     624        if {![Rappture::library isvalid $itk_option(-tool)]} {
    626625            error "bad value \"$itk_option(-tool)\": should be Rappture::Library"
    627626        }
  • trunk/gui/scripts/field.tcl

    r1 r6  
    4343# ----------------------------------------------------------------------
    4444itcl::body Rappture::Field::constructor {devobj libobj path} {
    45     if {![Rappture::Library::valid $devobj]} {
     45    if {![Rappture::library isvalid $devobj]} {
    4646        error "bad value \"$devobj\": should be LibraryObj"
    4747    }
    48     if {![Rappture::Library::valid $libobj]} {
     48    if {![Rappture::library isvalid $libobj]} {
    4949        error "bad value \"$libobj\": should be LibraryObj"
    5050    }
    5151    set _device $devobj
    5252    set _libobj $libobj
    53     set _field [$libobj get -object $path]
     53    set _field [$libobj element -flavor object $path]
    5454    set _units [$_field get units]
    5555
    5656    # determine the overall size of the device
    5757    set z0 [set z1 0]
    58     foreach elem [$_device get -children recipe] {
     58    foreach elem [$_device children recipe] {
    5959        switch -glob -- $elem {
    6060            slab* - molecule* {
     
    192192    # vectors for each part.
    193193    #
    194     set max [$_field get -count component]
    195     for {set i 0} {$i < $max} {incr i} {
     194    foreach cname [$_field children -type component] {
    196195        set xv ""
    197196        set yv ""
    198197
    199         set val [$_field get component$i.constant]
     198        set val [$_field get $cname.constant]
    200199        if {$val != ""} {
    201             set domain [$_field get component$i.domain]
     200            set domain [$_field get $cname.domain]
    202201            if {$domain == "" || ![info exists _limits($domain)]} {
    203202                set z0 0
     
    217216
    218217            set zm [expr {0.5*($z0+$z1)}]
    219             set _comp2cntls(component$i) \
    220                 [list component$i.constant $zm $val "$val$_units"]
     218            set _comp2cntls($cname) \
     219                [list $cname.constant $zm $val "$val$_units"]
    221220        } else {
    222             set xydata [$_field get component$i.xy]
     221            set xydata [$_field get $cname.xy]
    223222            if {"" != $xydata} {
    224223                set xv [blt::vector create x$_counter]
     
    235234
    236235        if {$xv != "" && $yv != ""} {
    237             set _comp2vecs(component$i) [list $xv $yv]
     236            set _comp2vecs($cname) [list $xv $yv]
    238237            incr _counter
    239238        }
  • trunk/gui/scripts/xyplot.tcl

    r1 r6  
    9696    if {$layout != "" && $run != ""} {
    9797        set count 0
    98         foreach item [$layout get -children] {
     98        foreach item [$layout children] {
    9999          switch -glob -- $item {
    100100            title {
     
    118118            field* {
    119119              set name [$layout get $item]
    120               if {[$run get -exists output.$name]} {
     120              if {"" != [$run element output.$name]} {
    121121                  set fobj [Rappture::Field ::#auto $_device $run output.$name]
    122122                  set _path2obj($name) $fobj
     
    144144            curve* {
    145145              set name [$layout get $item]
    146               if {[$run get -exists output.$name]} {
     146              if {"" != [$run get element output.$name]} {
    147147                  set cobj [Rappture::Curve ::#auto $run output.$name]
    148148                  set _path2obj($name) $cobj
     
    211211itcl::configbody Rappture::Xyplot::layout {
    212212    if {$itk_option(-layout) != ""} {
    213         if {![Rappture::Library::valid $itk_option(-layout)]} {
     213        if {![Rappture::library isvalid $itk_option(-layout)]} {
    214214            error "bad value \"$itk_option(-layout)\": should be Rappture::Library"
    215215        }
     
    231231    }
    232232    if {$itk_option(-run) != ""} {
    233         if {![Rappture::Library::valid $itk_option(-run)]} {
     233        if {![Rappture::library isvalid $itk_option(-run)]} {
    234234            error "bad value \"$itk_option(-run)\": should be Rappture::Library"
    235235        }
    236         set _device [$itk_option(-run) get -object device]
     236        set _device [$itk_option(-run) element -flavor object device]
    237237    }
    238238    after cancel [itcl::code $this _rebuild]
Note: See TracChangeset for help on using the changeset viewer.