Changeset 3139 for trunk/gui


Ignore:
Timestamp:
Aug 15, 2012 8:30:38 AM (12 years ago)
Author:
gah
Message:

fix to use drawing in loader

Location:
trunk/gui/scripts
Files:
4 edited

Legend:

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

    r1929 r3139  
    240240    # Assign the default value to this widget, if there is one.
    241241    #
    242     set defval [$_owner xml get $_path.default]
     242    set defval [string trim [$_owner xml get $_path.default]]
    243243    if {"" != $defval} {
    244244        if {[info exists _str2val($defval)]} {
  • trunk/gui/scripts/controlOwner.tcl

    r2977 r3139  
    5959    # in coordination with loaders inside the load function
    6060    array set _type2curpath {
    61         drawing components
     61        drawing all
    6262        choice current
    6363        boolean current
     
    270270        set type [[tool] xml element -as type $path]
    271271        if {[info exists _type2curpath($type)]} {
    272             set currentpath $path.$_type2curpath($type)
     272            if { $_type2curpath($type) == "all" } {
     273                set currentpath $path
     274            } else {
     275                set currentpath $path.$_type2curpath($type)
     276            }
    273277        } else {
    274278            # default incase i forgot an input type in _type2curpath
  • trunk/gui/scripts/drawingentry.tcl

    r3101 r3139  
    2828    private variable _drawingWidth 0
    2929    private variable _owner
     30    private variable _xmlobj ""
    3031    private variable _parser "";        # Slave interpreter where all
    3132                                        # substituted variables are stored.
     
    99100    set _path $path
    100101    set _owner $owner
     102    set _xmlobj [$_owner xml object]
    101103    #
    102104    # Display the current drawing.
     
    128130itcl::body Rappture::DrawingEntry::label {} {
    129131return ""
    130     set label [$_owner xml get $_path.about.label]
     132    set label [$_xmlobj get $_path.about.label]
    131133    if {"" == $label} {
    132134        set label "Drawing"
     
    145147itcl::body Rappture::DrawingEntry::tooltip {} {
    146148return ""
    147     set str [$_owner xml get $_path.about.description]
     149    set str [$_xmlobj get $_path.about.description]
    148150    return [string trim $str]
    149151}
     
    194196    ParseBackground
    195197    ParseSubstitutions
    196     foreach cname [$_owner xml children $_path.components] {
     198    foreach cname [$_xmlobj children $_path.components] {
    197199        switch -glob -- $cname {
    198200            "line*" {
     
    289291    #puts stderr "ParseGrid owner=$_owner cpath=$cpath xcoords=$xcoords ycoords=$ycoords"
    290292    set list {}
    291     foreach attr [$_owner xml children $cpath] {
     293    foreach attr [$_xmlobj children $cpath] {
    292294        if { [info exists attr2option($attr)] } {
    293295            set option $attr2option($attr)
     
    325327    }
    326328    array unset _cname2controls $cname
    327     foreach attr [$_owner xml children $cpath] {
     329    foreach attr [$_xmlobj children $cpath] {
    328330        if { [info exists attr2option($attr)] } {
    329331            set option $attr2option($attr)
     
    333335            set value [XmlGetSubst $cpath.$attr]
    334336            lappend _cname2controls($cname) $value
    335             $_owner xml put $value.hide 1
     337            $_xmlobj put $value.hide 1
    336338        }
    337339    }
     
    387389    #puts stderr "ParseLine owner=$_owner cpath=$cpath coords=$coords"
    388390    set list {}
    389     foreach attr [$_owner xml children $cpath] {
     391    foreach attr [$_xmlobj children $cpath] {
    390392        if { [info exists attr2option($attr)] } {
    391393            set option $attr2option($attr)
     
    417419        -outline black
    418420    }
    419     foreach attr [$_owner xml children $cpath] {
     421    foreach attr [$_xmlobj children $cpath] {
    420422        if { [info exists attr2option($attr)] } {
    421423            set option $attr2option($attr)
     
    449451        -anchor nw
    450452    }
    451     foreach attr [$_owner xml children $cpath] {
     453    foreach attr [$_xmlobj children $cpath] {
    452454        if { [info exists attr2option($attr)] } {
    453455            set option $attr2option($attr)
     
    558560    #puts stderr "ParsePolygon owner=$_owner cpath=$cpath coords=$coords"
    559561    set list {}
    560     foreach attr [$_owner xml children $cpath] {
     562    foreach attr [$_xmlobj children $cpath] {
    561563        if { [info exists attr2option($attr)] } {
    562564            set option $attr2option($attr)
     
    588590        -outline black
    589591    }
    590     foreach attr [$_owner xml children $cpath] {
     592    foreach attr [$_xmlobj children $cpath] {
    591593        if { [info exists attr2option($attr)] } {
    592594            set option $attr2option($attr)
     
    630632        -anchor c
    631633    }
    632     foreach attr [$_owner xml children $cpath] {
     634    foreach attr [$_xmlobj children $cpath] {
    633635        if { [info exists attr2option($attr)] } {
    634636            set option $attr2option($attr)
     
    668670            if { [info exists _name2path($varName)] } {
    669671                set path $_name2path($varName)
    670                 $_owner xml put $path.hide 1
     672                $_xmlobj put $path.hide 1
    671673                lappend _cname2controls($cname) $path
    672674            } else {
     
    830832
    831833itcl::body Rappture::DrawingEntry::ParseBackground {} {
    832     foreach elem [$_owner xml children $_path.background] {
     834    foreach elem [$_xmlobj children $_path.background] {
    833835        switch -glob -- $elem {
    834836            "color*" {
     
    859861
    860862itcl::body Rappture::DrawingEntry::ParseSubstitutions {} {
    861     foreach var [$_owner xml children $_path.substitutions] {
     863    foreach var [$_xmlobj children $_path.substitutions] {
    862864        if { ![string match "variable*" $var] } {
    863865            continue
     
    867869        set name ""
    868870        set path ""
    869         foreach elem [$_owner xml children $varPath] {
     871        foreach elem [$_xmlobj children $varPath] {
    870872            switch -glob -- $elem {
    871873                "name*" {
     
    981983# ----------------------------------------------------------------------
    982984itcl::body Rappture::DrawingEntry::value {args} {
    983     # drawing entries have no value
     985    # Redraw if there's a new library object.
     986    if { [llength $args] > 0 } {
     987        set libobj [lindex $args 0]
     988        if { $libobj != "" } {
     989            Redraw
     990        }
     991    }
    984992    return ""
    985993}
     
    10041012
    10051013itcl::body Rappture::DrawingEntry::XmlGet { path } {
    1006     set value [$_owner xml get $path]
     1014    set value [$_xmlobj get $path]
    10071015    return [string trim $value]
    10081016}
    10091017
    10101018itcl::body Rappture::DrawingEntry::XmlGetSubst { path } {
    1011     set value [$_owner xml get $path]
     1019    set value [$_xmlobj get $path]
    10121020    if { $_parser == "" } {
    10131021        return $value
     
    10171025
    10181026itcl::body Rappture::DrawingEntry::IsEnabled { path } {
    1019     set enable [string trim [$_owner xml get $path.about.enable]]
     1027    set enable [string trim [$_xmlobj get $path.about.enable]]
    10201028    if {"" == $enable} {
    10211029        return 1
  • trunk/gui/scripts/vtkviewer.tcl

    r3137 r3139  
    6969    protected method DoResize {}
    7070    protected method DoRotate {}
    71     private method DoUpdate {}
    7271    protected method AdjustSetting {what {value ""}}
    7372    protected method FixSettings { args  }
     
    9594    private method EventuallyResize { w h }
    9695    private method EventuallyRotate { q }
    97     private method EventuallyChangeSettings { args }
    9896    private method GetImage { args }
    9997    private method GetVtkData { args }
     
    232230    array set _settings [subst {
    233231        legend          1
    234         molecule-atomscale      0.5
    235         molecule-bondscale      0.2
    236         molecule-atomradius     "Van der Waals"
    237         molecule-representation  "ball and stick"
     232        molecule-representation  "Ball and Stick"
    238233        molecule-edges           0
    239234        molecule-labels          0
     
    469464}
    470465
    471 itcl::body Rappture::VtkViewer::DoUpdate { } {
    472     foreach dataset [CurrentDatasets -visible $_first] {
    473         foreach { dataobj comp } [split $dataset -] break
    474         set type [$dataobj type $comp]
    475         if { $type == "molecule" } {
    476             set val [expr $_settings(molecule-atomscale) * 0.1]
    477             SendCmd "molecule ascale $val $dataset"
    478             set val [expr $_settings(molecule-bondscale) * 0.1]
    479             SendCmd "molecule bscale $val $dataset"
    480         }
    481     }
    482     set _updatePending 0
    483 }
    484 
    485 itcl::body Rappture::VtkViewer::EventuallyChangeSettings { args } {
    486     if { !$_updatePending } {
    487         $_dispatcher event -after 250 !update
    488         set _updatePending 1
    489     }
    490 }
    491 
    492466# ----------------------------------------------------------------------
    493467# USAGE: add <dataobj> ?<settings>?
     
    979953        }
    980954    }
    981     if { $_haveMolecules } {
    982         FixSettings molecule-radius molecule-representation
    983     }
     955    FixSettings molecule-representation
     956
    984957    SendCmd "dataset maprange visible"
    985958       
     
    13491322            set _legendPending 1
    13501323        }
    1351         "molecule-radius" {
    1352             set value [$itk_component(atomradius) value]
    1353             set value [$itk_component(atomradius) translate $value]
     1324        "molecule-representation" {
     1325            set value [$itk_component(representation) value]
     1326            set value [$itk_component(representation) translate $value]
     1327            switch -- $value {
     1328                "ballandstick" {
     1329                    set ashow 1
     1330                    set bshow 1
     1331                    set ascale 0.5
     1332                    set bscale 0.15
     1333                }
     1334                "balls" - "spheres" {
     1335                    set ashow 1
     1336                    set bshow 0
     1337                    set ascale 0.5
     1338                    set bscale 0.15
     1339                }
     1340                "sticks" {
     1341                    set ashow 0
     1342                    set bshow 1
     1343                    set ascale 0.5
     1344                    set bscale 0.15
     1345                }
     1346                "spacefilling" {
     1347                    set ashow 1
     1348                    set bshow 0
     1349                    set ascale 1.0
     1350                    set bscale 0.15
     1351                }
     1352                "rods"  {
     1353                    set ashow 0
     1354                    set bshow 1
     1355                    set ascale 0.5
     1356                    set bscale 0.25
     1357                }
     1358                "wireframe" - "lines" {
     1359                    set ashow 0
     1360                    set bshow 1
     1361                    set ascale 0.5
     1362                    set bscale 0.05
     1363                }
     1364                default {
     1365                    error "unknown representation $value"
     1366                }
     1367            }
     1368            set ascale [expr $ascale * 0.1]
     1369            set bscale [expr $bscale * 0.1]
    13541370            foreach dataset [CurrentDatasets -visible $_first] {
    13551371                foreach {dataobj comp} [split $dataset -] break
    13561372                set type [$dataobj type $comp]
    13571373                if { $type == "molecule" } {
    1358                     SendCmd "molecule rscale $value $dataset"
    1359                 }
    1360             }
    1361         }
    1362         "molecule-representation" {
    1363             set value [$itk_component(representation) value]
    1364             set value [$itk_component(representation) translate $value]
    1365             foreach dataset [CurrentDatasets -visible $_first] {
    1366                 foreach {dataobj comp} [split $dataset -] break
    1367                 set type [$dataobj type $comp]
    1368                 if { $type == "molecule" } {
    1369                     switch -- $value {
    1370                         "ballandstick" {
    1371                             SendCmd "molecule atoms 1 $dataset"
    1372                             SendCmd "molecule bonds 1 $dataset"
    1373                         }
    1374                         "spheres" {
    1375                             SendCmd "molecule atoms 1 $dataset"
    1376                             SendCmd "molecule bonds 0 $dataset"
    1377                         }
    1378                         "sticks" - "lines" {
    1379                             SendCmd "molecule atoms 0 $dataset"
    1380                             SendCmd "molecule bonds 1 $dataset"
    1381                         }
    1382                         default {
    1383                             error "unknown representation $value"
    1384                         }
    1385                     }
     1374                    SendCmd [subst {
     1375                        molecule atoms $ashow $dataset
     1376                        molecule bonds $bshow $dataset
     1377                        molecule ascale $ascale $dataset
     1378                        molecule bscale $bscale $dataset
     1379                    }]
    13861380                }
    13871381            }
     
    15141508    array set style $_style($tag)
    15151509
    1516     set name "$style(-color):$style(-levels):$style(-opacity)"
     1510    if { $style(-color) == "elementDefault" } {
     1511        set name "$style(-color)"
     1512    } else {
     1513        set name "$style(-color):$style(-levels):$style(-opacity)"
     1514    }
    15171515    if { ![info exists _colormaps($name)] } {
    15181516        BuildColormap $name [array get style]
     
    17521750#
    17531751itcl::body Rappture::VtkViewer::BuildColormap { name styles } {
     1752    puts stderr name=$name
     1753    if { $name ==  "elementDefault" } {
     1754        return
     1755    }
    17541756    array set style $styles
    17551757    set cmap [ColorsToColormap $style(-color)]
     
    22252227    }
    22262228    $inner.rep choices insert end \
    2227         "ballandstick"  "ball and stick" \
    2228         "spheres"       "spheres"         \
    2229         "sticks"        "sticks"          \
    2230         "lines"         "lines"           
     2229        "ballandstick"  "Ball and Stick" \
     2230        "spheres"       "Spheres"       \
     2231        "sticks"        "Sticks"        \
     2232        "rods"          "Rods"          \
     2233        "wireframe"     "Wireframe"     \
     2234        "spacefilling"  "Space Filling"
    22312235
    22322236    bind $inner.rep <<Value>> \
    22332237        [itcl::code $this AdjustSetting molecule-representation]
    2234     $inner.rep value "ball and stick"
     2238    $inner.rep value "Ball and Stick"
    22352239
    22362240    label $inner.palette_l -text "Palette" -font "Arial 9"
     
    22392243    }
    22402244    $inner.palette choices insert end \
     2245        "elementDefault"             "elementDefault" \
    22412246        "BCGYR"              "BCGYR"            \
    22422247        "BGYOR"              "BGYOR"            \
     
    22602265        [itcl::code $this AdjustSetting molecule-palette]
    22612266
    2262     ::scale $inner.atomscale -width 10 -font "Arial 9" \
    2263         -from 0.1 -to 2.0 -resolution 0.005 -label "Atom Scale" \
    2264         -showvalue true -orient horizontal \
    2265         -command [itcl::code $this EventuallyChangeSettings] \
    2266         -variable [itcl::scope _settings(molecule-atomscale)]
    2267     $inner.atomscale set $_settings(molecule-atomscale)
    2268     Rappture::Tooltip::for $inner.atomscale \
    2269         "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."
    2270 
    2271     ::scale $inner.bondscale -width 10 -font "Arial 9" \
    2272         -from 0.1 -to 1.0 -resolution 0.0025 -label "Bond Scale" \
    2273         -showvalue true -orient horizontal \
    2274         -command [itcl::code $this EventuallyChangeSettings] \
    2275         -variable [itcl::scope _settings(molecule-bondscale)]
    2276     Rappture::Tooltip::for $inner.bondscale \
    2277         "Adjust scale of bonds (sticks)."
    2278     $inner.bondscale set $_settings(molecule-bondscale)
    2279 
    22802267    checkbutton $inner.labels -text "Show labels on atoms" \
    22812268        -command [itcl::code $this labels update] \
     
    22952282    $inner.cell select
    22962283
    2297     label $inner.atomradius_l -text "Radius Scaling Method" \
    2298         -font "Arial 9"
    2299     itk_component add atomradius {
    2300         Rappture::Combobox $inner.atomradius -width 20 -editable no
    2301     }
    2302     $inner.atomradius choices insert end \
    2303         "van_der_waals"  "Van der Waals" \
    2304         "covalent"      "Covalent"      \
    2305         "atomic"        "Atomic"        \
    2306         "none"          "None"         
    2307     bind $inner.atomradius <<Value>> \
    2308         [itcl::code $this AdjustSetting molecule-radius]
    2309     $inner.atomradius value "Van der Waals"
    2310     label $inner.spacer
    2311 
    23122284    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    23132285    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
     
    23202292        0,0 $inner.molecule -anchor w -pady {1 0} \
    23212293        1,0 $inner.label -anchor w -pady {1 0} \
    2322         2,0 $inner.wireframe -anchor w -pady {1 0} \
    2323         4,0 $inner.edges -anchor w -pady {1 0} \
    2324         6,0 $inner.atomradius_l -anchor w -pady 2 \
    2325         7,0 $inner.atomradius -anchor w -pady {1 0} \
    2326         9,0 $inner.rep_l -anchor w -pady { 2 0 } \
    2327         10,0 $inner.rep -anchor w  \
    2328         11,0 $inner.atomscale -fill x -pady {3 0} \
    2329         12,0 $inner.bondscale -fill x -pady {1 0} \
    2330         13,0 $inner.palette_l -anchor w -pady 2 \
    2331         14,0 $inner.palette   -fill x   -pady 2  \
    2332         15,0 $inner.opacity_l -anchor w -pady 2 \
    2333         16,0 $inner.opacity   -fill x   -pady 2
     2294        2,0 $inner.edges -anchor w -pady {1 0} \
     2295        3,0 $inner.rep_l -anchor w -pady { 2 0 } \
     2296        4,0 $inner.rep -anchor w  \
     2297        5,0 $inner.palette_l -anchor w -pady 2 \
     2298        6,0 $inner.palette   -fill x   -pady 2  \
     2299        7,0 $inner.opacity_l -anchor w -pady 2 \
     2300        8,0 $inner.opacity   -fill x   -pady 2
    23342301   
    23352302    blt::table configure $inner r* -resize none
    2336     blt::table configure $inner r17 -resize expand
     2303    blt::table configure $inner r9 -resize expand
    23372304}
    23382305
     
    24902457        SendCmd "glyphs opacity $settings(-opacity) $tag"
    24912458        SendCmd "glyphs visible $settings(-visible) $tag"
     2459        set _settings(glyphs-wireframe) $settings(-wireframe)
    24922460        set _haveGlyphs 1
    24932461    } elseif { $type == "molecule" } {
     
    25072475        SendCmd "molecule opacity $settings(-opacity) $tag"
    25082476        SendCmd "molecule visible $settings(-visible) $tag"
    2509         SendCmd "molecule rscale $_settings(molecule-atomradius) $tag"
    2510         set val [expr $_settings(molecule-atomscale) * 0.1]
    2511         SendCmd "molecule ascale $val $tag"
    2512         set val [expr $_settings(molecule-bondscale) * 0.1]
    2513         SendCmd "molecule bscale $val $tag"
     2477        SendCmd "molecule rscale van_der_waals $tag"
     2478        set _settings(molecule-wireframe) $settings(-wireframe)
    25142479        set _haveMolecules 1
    25152480    } else {
Note: See TracChangeset for help on using the changeset viewer.