Changeset 3800


Ignore:
Timestamp:
Jul 15, 2013 9:29:39 AM (11 years ago)
Author:
gah
Message:

add -simulation to plotadd calls

Location:
branches/1.3/gui/scripts
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3/gui/scripts/barchartresult.tcl

    r3765 r3800  
    290290        -param ""
    291291    }
    292     foreach {opt val} $settings {
    293         if {![info exists params($opt)]} {
    294             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    295         }
    296         set params($opt) $val
    297     }
    298 
     292    array set params $settings
    299293    # if the color is "auto", then select a color from -autocolors
    300294    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
  • branches/1.3/gui/scripts/contourresult.tcl

    r3636 r3800  
    346346        -param ""
    347347    }
    348     foreach {opt val} $settings {
    349         if {![info exists params($opt)]} {
    350             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    351         }
    352         set params($opt) $val
    353     }
     348    array set params $settings
    354349    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    355350        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/datatableresult.tcl

    r3330 r3800  
    139139        -param ""
    140140    }
    141     foreach {opt val} $settings {
    142         if {![info exists params($opt)]} {
    143             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    144         }
    145         set params($opt) $val
    146     }
     141    array set params $settings
    147142    if { $params(-raise) } {
    148143        set _raised $dataobj
  • branches/1.3/gui/scripts/deviceViewer1D.tcl

    r3330 r3800  
    167167        -param ""
    168168    }
    169     foreach {opt val} $settings {
    170         if {![info exists params($opt)]} {
    171             error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]"
    172         }
    173         set params($opt) $val
    174     }
     169    array set params $settings
    175170 
    176171    set pos [lsearch -exact $dataobj $_dlist]
  • branches/1.3/gui/scripts/deviceresult.tcl

    r3330 r3800  
    7373        -param ""
    7474    }
    75     foreach {opt val} $settings {
    76         if {![info exists params($opt)]} {
    77             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    78         }
    79         set params($opt) $val
    80     }
     75    array set params $settings
    8176
    8277    eval $itk_component(viewer) add $dataobj [list $settings]
  • branches/1.3/gui/scripts/energyLevels.tcl

    r3330 r3800  
    274274        -param ""
    275275    }
    276     foreach {opt val} $settings {
    277         if {![info exists params($opt)]} {
    278             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    279         }
    280         set params($opt) $val
    281     }
     276    array set params $settings
    282277
    283278    # convert -linestyle to BLT -dashes
  • branches/1.3/gui/scripts/flowvisviewer.tcl

    r3633 r3800  
    588588        -param ""
    589589    }
    590     foreach {opt val} $settings {
    591         if {![info exists params($opt)]} {
    592             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    593         }
    594         set params($opt) $val
    595     }
     590    array set params $settings
    596591    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    597592        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/histogramresult.tcl

    r3765 r3800  
    286286        -param ""
    287287    }
    288     foreach {opt val} $settings {
    289         if {![info exists params($opt)]} {
    290             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    291         }
    292         set params($opt) $val
    293     }
     288    array set params $settings
    294289
    295290    # if the color is "auto", then select a color from -autocolors
  • branches/1.3/gui/scripts/imageresult.tcl

    r3330 r3800  
    189189        -param ""
    190190    }
    191     foreach {opt val} $settings {
    192         if {![info exists params($opt)]} {
    193             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    194         }
    195         set params($opt) $val
    196     }
     191    array set params $settings
    197192
    198193    if {$params(-raise)} {
  • branches/1.3/gui/scripts/meshresult.tcl

    r3330 r3800  
    136136        -param ""
    137137    }
    138     foreach {opt val} $settings {
    139         if {![info exists params($opt)]} {
    140             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    141         }
    142         set params($opt) $val
    143     }
     138    array set params $settings
    144139    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    145140        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/moleculeViewer.tcl

    r3330 r3800  
    235235        -param ""
    236236    }
    237     foreach {opt val} $settings {
    238         if {![info exists params($opt)]} {
    239             error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]"
    240         }
    241         set params($opt) $val
    242     }
     237    array set params $settings
    243238 
    244239    set pos [lsearch -exact $dataobj $_dlist]
  • branches/1.3/gui/scripts/molvisviewer.tcl

    r3637 r3800  
    450450        -param          ""
    451451    }
    452 
    453     foreach {opt val} $options {
    454         if {![info exists params($opt)]} {
    455             error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]"
    456         }
    457         set params($opt) $val
    458     }
     452    array set params $settings
    459453
    460454    set pos [lsearch -exact $dataobj $_dlist]
  • branches/1.3/gui/scripts/nanovisviewer.tcl

    r3633 r3800  
    410410        -param ""
    411411    }
    412     foreach {opt val} $settings {
    413         if {![info exists params($opt)]} {
    414             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    415         }
    416         set params($opt) $val
    417     }
     412    array set params $settings
     413
    418414    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    419415        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/numberresult.tcl

    r3765 r3800  
    276276        -param ""
    277277    }
    278     foreach {opt val} $settings {
    279         if {![info exists params($opt)]} {
    280             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    281         }
    282         set params($opt) $val
    283     }
     278    array set params $settings
    284279
    285280    # if type is set to "scatter", then override the width
  • branches/1.3/gui/scripts/resultviewer.tcl

    r3573 r3800  
    195195
    196196                set index [_cleanIndex $index]
     197                lappend opts "-simulation" [expr $index + 1]
    197198                set reset "-color autoreset"
    198199                set slot [lindex $_dataslots $index]
  • branches/1.3/gui/scripts/sequenceresult.tcl

    r3666 r3800  
    212212        -param ""
    213213    }
    214     foreach {opt val} $settings {
    215         if {![info exists params($opt)]} {
    216             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    217         }
    218         set params($opt) $val
    219     }
     214    array set params $settings
    220215
    221216    if {$params(-raise) && "" == $_topmost} {
  • branches/1.3/gui/scripts/textresult.tcl

    r3330 r3800  
    186186        -param ""
    187187    }
    188     foreach {opt val} $settings {
    189         if {![info exists params($opt)]} {
    190             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    191         }
    192         set params($opt) $val
    193     }
     188    array set params $settings
    194189
    195190    set replace 0
  • branches/1.3/gui/scripts/valueresult.tcl

    r3330 r3800  
    8484        -param ""
    8585    }
    86     foreach {opt val} $settings {
    87         if {![info exists params($opt)]} {
    88             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    89         }
    90         set params($opt) $val
    91     }
     86    array set params $settings
     87
    9288    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    9389        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/vtkglyphviewer.tcl

    r3790 r3800  
    526526    set params(-description) ""
    527527    set params(-param) ""
    528     foreach {opt val} $settings {
    529         if {![info exists params($opt)]} {
    530             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    531         }
    532         set params($opt) $val
    533     }
     528    array set params $settings
     529
    534530    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    535531        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/vtkheightmapviewer.tcl

    r3739 r3800  
    8888    private method BuildDownloadPopup { widget command }
    8989    private method Combo { option }
    90     private method ConvertToVtkData { dataobj comp }
    9190    private method DrawLegend {}
    9291    private method EnterLegend { x y }
     
    389388
    390389    set _image(download) [image create photo]
    391     puts stderr "args=$args"
    392390    eval itk_initialize $args
    393391    Connect
     
    484482    set params(-description) ""
    485483    set params(-param) ""
    486     foreach {opt val} $settings {
    487         if {![info exists params($opt)]} {
    488             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    489         }
    490         set params($opt) $val
    491     }
     484    array set params $settings
     485
    492486    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    493487        # can't handle -autocolors yet
     
    21722166        foreach comp [$dataobj components] {
    21732167            set tag $dataobj-$comp
    2174             #set contents [ConvertToVtkData $dataobj $comp]
    21752168            set contents [$dataobj vtkdata $comp]
    2176             append bytes "$contents\n\n"
     2169            append bytes "$contents\n"
    21772170        }
    21782171    }
  • branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl

    r3780 r3800  
    533533    set params(-description) ""
    534534    set params(-param) ""
    535     foreach {opt val} $settings {
    536         if {![info exists params($opt)]} {
    537             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    538         }
    539         set params($opt) $val
    540     }
     535    array set params $settings
     536
    541537    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    542538        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl

    r3765 r3800  
    561561    set params(-description) ""
    562562    set params(-param) ""
    563     foreach {opt val} $settings {
    564         if {![info exists params($opt)]} {
    565             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    566         }
    567         set params($opt) $val
    568     }
     563    array set params $settings
     564
    569565    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    570566        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/vtkviewer.tcl

    r3785 r3800  
    9494    private method EventuallySetBondScale { args }
    9595    private method EventuallySetMoleculeOpacity { args }
     96    private method EventuallySetMoleculeQuality { args }
    9697    private method EventuallySetPolydataOpacity { args }
    9798    private method EventuallyResize { w h }
     
    109110    private method SetLegendTip { x y }
    110111    private method SetMoleculeOpacity {}
     112    private method SetMoleculeQuality {}
    111113    private method SetObjectStyle { dataobj comp }
    112114    private method SetOpacity { dataset }
     
    152154    private variable _bondScalePending 0
    153155    private variable _moleculeOpacityPending 0
     156    private variable _moleculeQualityPending 0
    154157    private variable _polydataOpacityPending 0
    155158    private variable _glyphsOpacityPending 0
     
    203206    $_dispatcher dispatch $this !moleculeOpacity \
    204207        "[itcl::code $this SetMoleculeOpacity]; list"
     208
     209    # Molecule quality event
     210    $_dispatcher register !moleculeQuality
     211    $_dispatcher dispatch $this !moleculeQuality \
     212        "[itcl::code $this SetMoleculeQuality]; list"
    205213
    206214    # Polydata opacity event
     
    259267    array set _settings [subst {
    260268        legend                  1
     269        glyphs-opacity          100
     270        glyphs-wireframe        0
    261271        polydata-edges          0
    262272        polydata-lighting       1
    263         polydata-opacity        40
     273        polydata-opacity        100
    264274        polydata-palette        rainbow
    265275        polydata-visible        1
    266276        polydata-wireframe      0
    267         molecule-atomscale      1.0
    268         molecule-bondscale      1.0
     277        molecule-atomscale      0.3
     278        molecule-bondscale      0.075
    269279        molecule-atoms-visible  1
    270280        molecule-bonds-visible  1
     
    274284        molecule-opacity        100
    275285        molecule-palette        elementDefault
     286        molecule-quality        1.0
    276287        molecule-representation "Ball and Stick"
     288        molecule-rscale         "covalent"
    277289        molecule-visible        1
    278290        molecule-wireframe      0
     
    497509}
    498510
     511itcl::body Rappture::VtkViewer::SetMoleculeQuality {} {
     512    SendCmd [subst {molecule aquality $_settings(molecule-quality)
     513molecule bquality $_settings(molecule-quality)}]
     514    set _moleculeQualityPending 0
     515}
     516
    499517itcl::body Rappture::VtkViewer::SetPolydataOpacity {} {
    500518    set _polydataOpacityPending 0
     
    525543        set _moleculeOpacityPending 1
    526544        $_dispatcher event -after $_scaleDelay !moleculeOpacity
     545    }
     546}
     547
     548itcl::body Rappture::VtkViewer::EventuallySetMoleculeQuality { args } {
     549    if { !$_moleculeQualityPending } {
     550        set _moleculeQualityPending 1
     551        $_dispatcher event -after $_scaleDelay !moleculeQuality
    527552    }
    528553}
     
    556581    set params(-description) ""
    557582    set params(-param) ""
    558     foreach {opt val} $settings {
    559         if {![info exists params($opt)]} {
    560             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    561         }
    562         set params($opt) $val
    563     }
     583    array set params $settings
     584
    564585    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    565586        # can't handle -autocolors yet
     
    13681389                if { $type == "polydata" } {
    13691390                    ChangeColormap $dataobj $comp $palette
     1391                    #SendCmd "polydata colormode scalar {} $dataset"
    13701392                }
    13711393            }
     
    14451467            switch -- $value {
    14461468                "ballandstick" {
    1447                     set rscale covalent
     1469                    set _settings(molecule-rscale) covalent
    14481470                    set _settings(molecule-atoms-visible) 1
    14491471                    set _settings(molecule-bonds-visible) 1
     
    14531475                }
    14541476                "balls" - "spheres" {
    1455                     set rscale covalent
     1477                    set _settings(molecule-rscale) covalent
    14561478                    set _settings(molecule-atoms-visible) 1
    14571479                    set _settings(molecule-bonds-visible) 0
     
    14611483                }
    14621484                "sticks" {
    1463                     set rscale none
     1485                    set _settings(molecule-rscale) none
    14641486                    set _settings(molecule-atoms-visible) 1
    14651487                    set _settings(molecule-bonds-visible) 1
     
    14691491                }
    14701492                "spacefilling" {
    1471                     set rscale van_der_waals
     1493                    set _settings(molecule-rscale) van_der_waals
    14721494                    set _settings(molecule-atoms-visible) 1
    14731495                    set _settings(molecule-bonds-visible) 0
     
    14771499                }
    14781500                "rods"  {
    1479                     set rscale none
     1501                    set _settings(molecule-rscale) none
    14801502                    set _settings(molecule-atoms-visible) 1
    14811503                    set _settings(molecule-bonds-visible) 1
     
    14851507                }
    14861508                "wireframe" - "lines" {
    1487                     set rscale none
     1509                    set _settings(molecule-rscale) none
    14881510                    set _settings(molecule-atoms-visible) 0
    14891511                    set _settings(molecule-bonds-visible) 1
     
    14961518                }
    14971519            }
     1520            $itk_component(rscale) value [$itk_component(rscale) label $_settings(molecule-rscale)]
     1521            switch -- $value {
     1522                "ballandstick" - "balls" - "spheres" {
     1523                    $itk_component(rscale) configure -state normal
     1524                }
     1525                default {
     1526                    $itk_component(rscale) configure -state disabled
     1527                }
     1528            }
    14981529            foreach dataset [CurrentDatasets -visible $_first] {
    14991530                foreach {dataobj comp} [split $dataset -] break
    15001531                set type [$dataobj type $comp]
    15011532                if { $type == "molecule" } {
    1502                     SendCmd [subst {molecule rscale $rscale $dataset
     1533                    SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset
    15031534molecule ascale $_settings(molecule-atomscale) $dataset
    15041535molecule bscale $_settings(molecule-bondscale) $dataset
     
    15061537molecule atoms $_settings(molecule-atoms-visible) $dataset
    15071538molecule bonds $_settings(molecule-bonds-visible) $dataset}]
     1539                }
     1540            }
     1541        }
     1542        "molecule-rscale" {
     1543            set value [$itk_component(rscale) value]
     1544            set value [$itk_component(rscale) translate $value]
     1545            set _settings(molecule-rscale) $value
     1546            foreach dataset [CurrentDatasets -visible $_first] {
     1547                foreach {dataobj comp} [split $dataset -] break
     1548                set type [$dataobj type $comp]
     1549                if { $type == "molecule" } {
     1550                    SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset}]
    15081551                }
    15091552            }
     
    18641907        -showvalue off \
    18651908        -command [itcl::code $this AdjustSetting polydata-opacity]
     1909    $inner.opacity set $_settings(polydata-opacity)
    18661910
    18671911    blt::table $inner \
     
    21882232        [itcl::code $this AdjustSetting molecule-representation]
    21892233    $inner.rep value "Ball and Stick"
     2234
     2235    label $inner.rscale_l -text "Atom Radii" \
     2236        -font "Arial 9"
     2237
     2238    itk_component add rscale {
     2239        Rappture::Combobox $inner.rscale -width 20 -editable no
     2240    }
     2241    $inner.rscale choices insert end \
     2242        "atomic"        "Atomic"   \
     2243        "covalent"      "Covalent" \
     2244        "van_der_waals" "VDW"      \
     2245        "none"          "Constant"
     2246
     2247    bind $inner.rscale <<Value>> \
     2248        [itcl::code $this AdjustSetting molecule-rscale]
     2249    $inner.rscale value "Covalent"
    21902250
    21912251    label $inner.palette_l -text "Palette" -font "Arial 9"
     
    22352295    label $inner.atomscale_l -text "Atom Scale" -font "Arial 9"
    22362296    ::scale $inner.atomscale -width 15 -font "Arial 7" \
    2237         -from 0.0 -to 2.0 -resolution 0.05 -label "" \
     2297        -from 0.025 -to 2.0 -resolution 0.025 -label "" \
    22382298        -showvalue true -orient horizontal \
    2239         -command [itcl::code $this EventuallyAtomScale] \
     2299        -command [itcl::code $this EventuallySetAtomScale] \
    22402300        -variable [itcl::scope _settings(molecule-atomscale)]
    22412301    $inner.atomscale set $_settings(molecule-atomscale)
    22422302    Rappture::Tooltip::for $inner.atomscale \
    2243         "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."
     2303        "Adjust relative scale of atoms (spheres or balls)."
    22442304
    22452305    label $inner.bondscale_l -text "Bond Scale" -font "Arial 9"
    22462306    ::scale $inner.bondscale -width 15 -font "Arial 7" \
    2247         -from 0.0 -to 1.0 -resolution 0.025 -label "" \
     2307        -from 0.005 -to 0.3 -resolution 0.005 -label "" \
    22482308        -showvalue true -orient horizontal \
    2249         -command [itcl::code $this EventuallyBondScale] \
     2309        -command [itcl::code $this EventuallySetBondScale] \
    22502310        -variable [itcl::scope _settings(molecule-bondscale)]
    22512311    Rappture::Tooltip::for $inner.bondscale \
     
    22582318        -width 15 -font "Arial 7" \
    22592319        -showvalue on \
    2260         -command [itcl::code $this EventuallyMoleculeOpacity]
     2320        -command [itcl::code $this EventuallySetMoleculeOpacity]
     2321
     2322    label $inner.quality_l -text "Quality" -font "Arial 9"
     2323    ::scale $inner.quality -width 15 -font "Arial 7" \
     2324        -from 0.0 -to 10.0 -resolution 0.1 -label "" \
     2325        -showvalue true -orient horizontal \
     2326        -command [itcl::code $this EventuallySetMoleculeQuality] \
     2327        -variable [itcl::scope _settings(molecule-quality)]
     2328    Rappture::Tooltip::for $inner.quality \
     2329        "Adjust tesselation quality"
     2330    $inner.quality set $_settings(molecule-quality)
    22612331
    22622332    blt::table $inner \
    2263         0,0 $inner.molecule    -anchor w -pady {1 0} \
    2264         1,0 $inner.label       -anchor w -pady {1 0} \
    2265         2,0 $inner.edges       -anchor w -pady {1 0} \
    2266         3,0 $inner.rep_l       -anchor w -pady { 2 0 } \
    2267         4,0 $inner.rep         -fill x    -pady 2 \
    2268         5,0 $inner.palette_l   -anchor w  -pady 0 \
    2269         6,0 $inner.palette     -fill x    -padx 2 \
    2270         7,0 $inner.atomscale_l -anchor w -pady {3 0} \
    2271         8,0 $inner.atomscale   -fill x    -padx 2 \
    2272         9,0 $inner.bondscale_l -anchor w -pady {3 0} \
    2273         10,0 $inner.bondscale  -fill x   -padx 2 \
    2274         11,0 $inner.opacity_l  -anchor w -pady {3 0} \
    2275         12,0 $inner.opacity    -fill x    -padx 2
     2333        0,0 $inner.molecule     -anchor w -pady {1 0} \
     2334        1,0 $inner.label        -anchor w -pady {1 0} \
     2335        2,0 $inner.edges        -anchor w -pady {1 0} \
     2336        3,0 $inner.rep_l        -anchor w -pady { 2 0 } \
     2337        4,0 $inner.rep          -fill x    -pady 2 \
     2338        5,0 $inner.rscale_l     -anchor w -pady { 2 0 } \
     2339        6,0 $inner.rscale       -fill x    -pady 2 \
     2340        7,0 $inner.palette_l    -anchor w  -pady 0 \
     2341        8,0 $inner.palette      -fill x    -padx 2 \
     2342        9,0 $inner.atomscale_l  -anchor w -pady {3 0} \
     2343        10,0 $inner.atomscale   -fill x    -padx 2 \
     2344        11,0 $inner.bondscale_l -anchor w -pady {3 0} \
     2345        12,0 $inner.bondscale   -fill x   -padx 2 \
     2346        13,0 $inner.opacity_l   -anchor w -pady {3 0} \
     2347        14,0 $inner.opacity     -fill x    -padx 2 \
     2348        15,0 $inner.quality_l   -anchor w -pady {3 0} \
     2349        16,0 $inner.quality     -fill x    -padx 2
    22762350   
    22772351    blt::table configure $inner r* -resize none
    2278     blt::table configure $inner r13 -resize expand
     2352    blt::table configure $inner r17 -resize expand
    22792353}
    22802354
     
    24182492        "molecule" {
    24192493            SendCmd "molecule add $tag"
    2420             SendCmd "molecule rscale van_der_waals $tag"
    24212494            set _haveMolecules 1
    24222495        }
    24232496        "polydata" {
    24242497            array set settings {
    2425                 -color \#6666FF
     2498                -color \#FFFFFF
    24262499                -edges 1
    24272500                -edgecolor black
     
    24442517            SendCmd "polydata linewidth $settings(-linewidth) $tag"
    24452518            SendCmd "polydata opacity $settings(-opacity) $tag"
    2446             set _settings(polydata-opacity) $settings(-opacity)
     2519            set _settings(polydata-opacity) [expr 100.0 * $settings(-opacity)]
    24472520            SendCmd "polydata wireframe $settings(-wireframe) $tag"
    24482521            set _settings(polydata-wireframe) $settings(-wireframe)
  • branches/1.3/gui/scripts/vtkvolumeviewer.tcl

    r3765 r3800  
    531531    set params(-description) ""
    532532    set params(-param) ""
    533     foreach {opt val} $settings {
    534         if {![info exists params($opt)]} {
    535             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    536         }
    537         set params($opt) $val
    538     }
     533    array set params $settings
     534
    539535    if {$params(-color) == "auto" || $params(-color) == "autoreset"} {
    540536        # can't handle -autocolors yet
  • branches/1.3/gui/scripts/xylegend.tcl

    r3785 r3800  
    8686    private method Raise { args }
    8787    private method PopupMenu { x y }
    88     private method Recolor {}
    8988    private method Rename {}
    9089    private method SelectAll {}
     
    159158        delete ""
    160159        rename ""
    161         recolor ""
    162160    }
    163161    foreach { but icon} $commands {
     
    177175    grid $controls.rename     -column 1 -row 2 -sticky w
    178176    grid $controls.delete     -column 1 -row 3 -sticky w
    179     grid $controls.recolor    -column 1 -row 4 -sticky w
    180177
    181178    grid columnconfigure $controls 0  -weight 1
     
    396393    set nodes [$itk_component(legend) curselection]
    397394    foreach n { hide show toggle raise lower
    398         rename average difference delete recolor } {
     395        rename average difference delete } {
    399396        $itk_component(controls).$n configure -state disabled
    400397    }
     
    414411        }
    415412        1 {
    416             foreach n { hide show toggle rename recolor } {
     413            foreach n { hide show toggle rename } {
    417414                $itk_component(controls).$n configure -state normal
    418415            }
    419416        }
    420417        2 {
    421             foreach n { hide show toggle difference average recolor } {
     418            foreach n { hide show toggle difference average } {
    422419                $itk_component(controls).$n configure -state normal
    423420            }
    424421        }
    425422        default {
    426             foreach n { hide show toggle average recolor } {
     423            foreach n { hide show toggle average } {
    427424                $itk_component(controls).$n configure -state normal
    428425            }
     
    551548
    552549
    553 itcl::body Rappture::XyLegend::Recolor {} {
    554     set nodes [$itk_component(legend) curselection]
    555     if { $nodes == "" } {
    556         return
    557     }
    558     foreach node $nodes {
    559         set elem [$_tree label $node]
    560         if { $_lastColorIndex == 0 } {
    561             set _lastColorIndex [llength $_autocolors]
    562         }
    563         incr _lastColorIndex -1
    564         set color [lindex $_autocolors $_lastColorIndex]
    565         if { [$_graph element type $elem] == "bar" } {
    566             $_graph element configure $elem -background $color \
    567                 -foreground $color
    568         } else {
    569             $_graph element configure $elem -color $color
    570         }
    571         set im [$itk_component(legend) entry cget $node -icon]
    572         $_graph legend icon $elem $im
    573     }
    574 }
    575 
    576550itcl::body Rappture::XyLegend::UnmapHidden {} {
    577551    $_graph configure -unmaphiddenelements $_unmapHidden
  • branches/1.3/gui/scripts/xyresult.tcl

    r3785 r3800  
    7171    itk_option define -autocolors autoColors AutoColors ""
    7272
    73     private variable _viewable "";          # Display list for widget.
     73    private variable _viewable "";      # Display list for widget.
     74    private variable _dispatcher "";    # Dispatcher for !events
     75    private variable _dlist "";         # List of dataobj objects
     76    private variable _dataobj2raise;    # Maps dataobj => raise flag 0/1
     77    private variable _dataobj2desc;     # Maps dataobj => description of data
     78    private variable _dataobj2sim;      # Maps dataobj => type of graph element
     79    private variable _elem2comp;        # Maps graph element => dataobj
     80    private variable _comp2elem;        # Maps graph element => dataobj
     81    private variable _label2axis;       # Maps axis label => axis ID
     82    private variable _limits;           # Axis limits:  x-min, x-max, etc.
     83    private variable _nextColorIndex 0; # Index for next "-color auto"
     84    private variable _hilite;           # Info for element currently highlighted
     85    private variable _axis;             # Info for axis manipulations
     86    private variable _axisPopup;        # Info for axis being edited in popup
     87    common _downloadPopup;              # Download options from popup
     88    private variable _markers
     89    private variable _nextElement 0
     90
    7491    constructor {args} {
    7592        # defined below
     
    99116    protected method LeaveMarker { g name }
    100117
    101     private variable _dispatcher "" ;# dispatcher for !events
    102     private variable _dlist ""     ;# list of dataobj objects
    103     private variable _dataobj2color  ;# maps dataobj => plotting color
    104     private variable _dataobj2width  ;# maps dataobj => line width
    105     private variable _dataobj2dashes ;# maps dataobj => BLT -dashes list
    106     private variable _dataobj2raise  ;# maps dataobj => raise flag 0/1
    107     private variable _dataobj2desc   ;# maps dataobj => description of data
    108     private variable _dataobj2type   ;# maps dataobj => type of graph element
    109     private variable _dataobj2barwidth ;# maps dataobj => type of graph element
    110     private variable _elem2comp   ;# maps graph element => dataobj
    111     private variable _comp2elem   ;# maps graph element => dataobj
    112     private variable _label2axis   ;# maps axis label => axis ID
    113     private variable _limits       ;# axis limits:  x-min, x-max, etc.
    114     private variable _autoColorI 0 ;# index for next "-color auto"
    115     private variable _hilite       ;# info for element currently highlighted
    116     private variable _axis         ;# info for axis manipulations
    117     private variable _axisPopup    ;# info for axis being edited in popup
    118     common _downloadPopup          ;# download options from popup
    119     private variable _markers
    120     private variable _nextElement 0
    121 
    122     private method BuildElements { dlist }
     118
     119    private method BuildGraph { dlist }
    123120    private method BuildMarkers { dataobj elem }
    124121    private method FormatAxis { axis w value }
     
    127124    private method ShowAxisPopup { axis }
    128125    private method SetAxis { setting }
     126    private method SetElements { dataobj {settings ""} }
    129127    private method SetAxisRangeState { axis }
    130128}
     
    232230# ----------------------------------------------------------------------
    233231itcl::body Rappture::XyResult::add {dataobj {settings ""}} {
    234     #puts stderr "XyResult::add dataobj=$dataobj settings=$settings"
    235     array set params {
    236         -color auto
    237         -brightness 0
    238         -width 1
    239         -barwidth 1
    240         -raise 0
    241         -type "line"
    242         -linestyle solid
    243         -description ""
    244         -param ""
    245     }
    246     # Override the defaults with first the <style> specified and then the
    247     # settings list passed into this routoue.
    248     array set params [$dataobj hints style]
    249     set type [$dataobj hints type]
    250     if { $type == "" } {
    251         set type "line"
    252     }
    253     foreach {opt val} $settings {
    254         if {![info exists params($opt)]} {
    255             error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]"
    256         }
    257         set params($opt) $val
    258     }
    259 
    260     # if type is set to "scatter", then override the width
    261     if { $type == "scatter" } {
    262         set params(-width) 0
    263     }
    264     # if the color is "auto", then select a color from -autocolors
    265     if { $params(-color) == "auto" || $params(-color) == "autoreset" } {
    266         if {$params(-color) == "autoreset"} {
    267             set _autoColorI 0
    268         }
    269         set color [lindex $itk_option(-autocolors) $_autoColorI]
     232    #puts stderr "add: dataobj=$dataobj settings=$settings"
     233    set g $itk_component(plot)
     234    SetElements $dataobj $settings
     235
     236    array set attrs $settings
     237
     238    # Colors have to be set/reset here because of "-brightness" and "auto".
     239    # Colors can't be overriden by the user.
     240
     241    # If the color is "auto", then select a color from -autocolors
     242    if { ![info exists attrs(-color)] } {
     243        set color "auto"
     244    } else {
     245        set color $attrs(-color)
     246    }
     247    if { $color == "auto" || $color == "autoreset" } {
     248        if { $color == "autoreset" } {
     249            set _nextColorIndex 0
     250        }
     251        set color [lindex $itk_option(-autocolors) $_nextColorIndex]
    270252        if { "" == $color} {
    271253            set color black
    272254        }
    273         set params(-color) $color
    274         # set up for next auto color
    275         if {[incr _autoColorI] >= [llength $itk_option(-autocolors)]} {
    276             set _autoColorI 0
    277         }
    278     }
    279 
    280     # convert -linestyle to BLT -dashes
    281     switch -- $params(-linestyle) {
    282         dashed { set params(-linestyle) {4 4} }
    283         dotted { set params(-linestyle) {2 4} }
    284         default { set params(-linestyle) {} }
    285     }
    286 
    287     # if -brightness is set, then update the color
    288     if {$params(-brightness) != 0} {
    289         set params(-color) [Rappture::color::brightness \
    290             $params(-color) $params(-brightness)]
     255        # Set up for next auto color
     256        incr _nextColorIndex
     257        if { $_nextColorIndex >= [llength $itk_option(-autocolors)] } {
     258            set _nextColorIndex 0
     259        }
     260    }
     261    # If -brightness is set, then update the color.
     262    if { [info exists attrs(-brightness)] } {
     263        set brightness $attrs(-brightness)
     264        set color [Rappture::color::brightness $color $brightness]
    291265        set bg [$itk_component(plot) cget -plotbackground]
    292266        foreach {h s v} [Rappture::color::RGBtoHSV $bg] break
    293267        if {$v > 0.5} {
    294             set params(-color) [Rappture::color::brightness_max \
    295                 $params(-color) 0.8]
     268            set color [Rappture::color::brightness_max $color 0.8]
    296269        } else {
    297             set params(-color) [Rappture::color::brightness_min \
    298                 $params(-color) 0.2]
    299         }
    300     }
    301 
    302     set _dataobj2raise($dataobj) $params(-raise)
    303 
    304     set g $itk_component(plot)
    305     set color $params(-color)
    306     set lwidth $params(-width)
    307     set dashes $params(-linestyle)
    308     set raise $params(-raise)
    309     set desc $params(-description)
    310     set barwidth $params(-barwidth)
    311     foreach {mapx mapy} [GetAxes $dataobj] break
    312     foreach comp [$dataobj components] {
    313         set tag $dataobj-$comp
    314         if { [info exists _comp2elem($tag)] } {
    315             set elem $_comp2elem($tag)
    316             # Ignore -type, it's already been set
    317             switch -- [$g element type $elem] {
    318                 "line" - "scatter" {
    319                     $g line configure $elem \
    320                         -linewidth $lwidth \
    321                         -dashes $dashes -hide no
    322                 } "bar" {
    323                     $g bar configure $elem \
    324                         -barwidth $barwidth \
    325                         -hide no
    326                 }
    327             }
     270            set color [Rappture::color::brightness_min $color 0.2]
     271        }
     272    }
     273    set type [$dataobj hints type]
     274    foreach cname [$dataobj components] {
     275        set tag $dataobj-$cname
     276        set elem $_comp2elem($tag)
     277        if { $type == "bar" } {
     278            $g bar configure $elem -foreground $color -background $color \
     279                -hide no
    328280        } else {
    329             set elem "$type[incr _nextElement]"
    330             set label [$dataobj hints label]
    331             set _elem2comp($elem) $tag
    332             set _comp2elem($tag) $elem
    333             lappend label2elem($label) $elem
    334             set xv [$dataobj mesh $comp]
    335             set yv [$dataobj values $comp]
    336             switch -- $type {
    337                 "line" {
    338                     if {([$xv length] <= 1) || ($lwidth == 0)} {
    339                         set sym square
    340                         set pixels 2
    341                     } else {
    342                         set sym ""
    343                         set pixels 6
    344                     }
    345                     $g element create $elem -x $xv -y $yv \
    346                         -symbol $sym -pixels $pixels -linewidth $lwidth \
    347                         -label $label \
    348                         -color $color -dashes $dashes \
    349                         -mapx $mapx -mapy $mapy -hide no
    350                 }
    351                 "scatter" {
    352                     $g element create $elem -x $xv -y $yv \
    353                         -symbol square -pixels 2 -linewidth $lwidth \
    354                         -label $label \
    355                         -color $color -dashes $dashes \
    356                         -mapx $mapx -mapy $mapy -hide no
    357                 }
    358                 "bar" {
    359                     $g bar create $elem -x $xv -y $yv \
    360                         -barwidth $barwidth \
    361                         -label $label \
    362                         -color $color \
    363                         -mapx $mapx -mapy $mapy
    364                 }
    365             }
     281            $g line configure $elem -color $color -hide no
    366282        }
    367283        if { [lsearch $_viewable $elem] < 0 } {
     
    442358    #puts stderr "XyResult::scale args=$args"
    443359    set _dlist $args
    444     BuildElements $args
     360    BuildGraph $args
    445361}
    446362
     
    653569    # Fix duplicate labels by appending the simulation number
    654570    # Collect the labels from all the viewable elements.
     571    set above {}
     572    set below {}
    655573    foreach elem $_viewable {
    656574        foreach {dataobj cname} [split $_elem2comp($elem) -] break
     
    669587            }
    670588            foreach {dataobj cname} [split $_elem2comp($elem) -] break
    671             regexp {^::curve(?:Value)?([0-9]+)$} $dataobj match suffix
    672             incr suffix
    673             set elabel [format "%s \#%d" $label $suffix]
     589            set sim $_dataobj2sim($dataobj)
     590            set elabel [format "%s \#%d" $label $sim]
    674591            $g element configure $elem -label $elabel
    675592        }
     
    11631080        }
    11641081    }
    1165     if {$_autoColorI >= [llength $itk_option(-autocolors)]} {
    1166         set _autoColorI 0
     1082    if {$_nextColorIndex >= [llength $itk_option(-autocolors)]} {
     1083        set _nextColorIndex 0
    11671084    }
    11681085}
     
    15191436
    15201437#
    1521 # BuildElements --
     1438# BuildGraph --
    15221439#
    15231440#       This procedure loads each data objects specified into the
     
    15271444#       for all datasets, even those not currently being displayed.
    15281445#       
    1529 itcl::body Rappture::XyResult::BuildElements { dlist } {
     1446itcl::body Rappture::XyResult::BuildGraph { dlist } {
    15301447    set g $itk_component(plot)
    15311448   
     
    16221539    }
    16231540   
    1624     # Create data elements and markers, but mark them as hidden.
    1625     # The "add" method will un-hide them.
    1626     set count 0
    16271541    foreach dataobj $dlist {
    1628         set label [$dataobj hints label]
    1629         array set params [$dataobj hints style]
    1630         set type [$dataobj hints type]
    1631         # Default
    1632         if {[info exists params(-color)]} {
    1633             set color params(-color)
     1542        SetElements $dataobj
     1543    }
     1544    ResetLegend
     1545}
     1546
     1547#
     1548# SetElements --
     1549#
     1550#       This procedure loads each data objects specified into the
     1551#       graph.  The data object may already be loaded (from the "add"
     1552#       method which gets called first).   The graph elements that
     1553#       are created, are hidden.  This allows the graph to account
     1554#       for all datasets, even those not currently being displayed.
     1555#       
     1556itcl::body Rappture::XyResult::SetElements { dataobj {settings ""} } {
     1557    set g $itk_component(plot)
     1558
     1559    array set attrs [$dataobj hints style]
     1560    array set attrs $settings
     1561    set type [$dataobj hints type]
     1562    if { $type == "" } {
     1563        set type "line"
     1564    }
     1565
     1566    # Now fix attributes to a more usable form for the graph.
     1567
     1568    # Convert -linestyle to BLT -dashes
     1569    if { ![info exists attrs(-linestyle)] } {
     1570        set dashes {}
     1571    } else {
     1572        switch -- $attrs(-linestyle) {
     1573            dashed  { set dashes {4 4} }
     1574            dotted  { set dashes {2 4} }
     1575            default { set dashes {}    }
     1576        }
     1577    }
     1578    if { ![info exists attrs(-barwidth)] } {
     1579        set barwidth 1.0
     1580    } else {
     1581        set barwidth $attrs(-barwidth)
     1582    }
     1583    if { ![info exists attrs(-width)] } {
     1584        set linewidth 1
     1585    } else {
     1586        set linewidth $attrs(-width)
     1587    }
     1588    if { ![info exists attrs(-raise)] } {
     1589        set raise 0
     1590    } else {
     1591        set raise $attrs(-raise)
     1592    }
     1593    if { ![info exists attrs(-simulation)] } {
     1594        set sim 0
     1595    } else {
     1596        set sim $attrs(-simulation)
     1597    }
     1598
     1599    foreach {mapx mapy} [GetAxes $dataobj] break
     1600    set label [$dataobj hints label]
     1601
     1602    foreach cname [$dataobj components] {
     1603        set tag $dataobj-$cname
     1604        set xv [$dataobj mesh $cname]
     1605        set yv [$dataobj values $cname]
     1606
     1607        if {([$xv length] <= 1) || ($linewidth == 0)} {
     1608            set sym square
     1609            set pixels 2
    16341610        } else {
    1635             set color black
    1636         }
    1637         if { $type == "" } {
    1638             set type "line"
    1639         }
    1640         if {[info exists parmas(-barwidth)]} {
    1641             set barwidth $params(-barwidth)
    1642         } else {
    1643             set barwidth 1.0
    1644         }
    1645         if {[info exists params(-width)]} {
    1646             set lwidth $params(-width)
    1647         } else {
    1648             set lwidth 2
    1649         }
    1650         if {[info exists params(-linestyle)]} {
    1651             set dashes $parmas(-linestyle)
    1652         } else {
    1653             set dashes ""
    1654         }
    1655         foreach {mapx mapy} [GetAxes $dataobj] break
    1656         foreach comp [$dataobj components] {
    1657             set tag $dataobj-$comp
    1658             if { [info exists _comp2elem($tag)] } {
    1659                 set found($_comp2elem($tag)) 1
    1660                 lappend label2elem($label) $_comp2elem($tag)
    1661                 # Element already created for data object/component.
    1662                 continue
    1663             }
    1664             set xv [$dataobj mesh $comp]
    1665             set yv [$dataobj values $comp]
    1666            
    1667             if {([$xv length] <= 1) || ($lwidth == 0)} {
    1668                 set sym square
    1669                 set pixels 2
    1670             } else {
    1671                 set sym ""
    1672                 set pixels 6
    1673             }
     1611            set sym ""
     1612            set pixels 6
     1613        }
     1614        if { ![info exists _comp2elem($tag)] } {
    16741615            set elem "$type[incr _nextElement]"
    16751616            set _elem2comp($elem) $tag
     
    16781619            lappend label2elem($label) $elem
    16791620            switch -- $type {
    1680                 "line" - "scatter" {
     1621                "line" {
    16811622                    $g line create $elem \
    16821623                        -x $xv -y $yv \
    16831624                        -symbol $sym \
    16841625                        -pixels $pixels \
    1685                         -linewidth $lwidth \
     1626                        -linewidth $linewidth \
    16861627                        -label $label \
    1687                         -color $color \
    16881628                        -dashes $dashes \
    16891629                        -mapx $mapx \
    16901630                        -mapy $mapy \
    16911631                        -hide yes
    1692                 } "bar" {
     1632                }
     1633                "scatter" {               
     1634                    $g line create $elem \
     1635                        -x $xv -y $yv \
     1636                        -symbol square \
     1637                        -pixels 2 \
     1638                        -linewidth 0 \
     1639                        -label $label \
     1640                        -dashes $dashes \
     1641                        -mapx $mapx \
     1642                        -mapy $mapy \
     1643                        -hide yes
     1644                }
     1645                "bar" {
    16931646                    $g bar create $elem \
    16941647                        -x $xv -y $yv \
    16951648                        -barwidth $barwidth \
    16961649                        -label $label \
    1697                         -foreground $color \
    1698                         -background $color \
    16991650                        -mapx $mapx \
    17001651                        -mapy $mapy \
     
    17021653                }
    17031654            }
    1704             if { [$dataobj info class] == "Rappture::Curve" } {
    1705                 BuildMarkers $dataobj $elem
    1706             }
    1707         }
    1708     }
    1709     foreach elem [$g element names] {
    1710         if { ![info exists found($elem)] } {
    1711             $g element delete $elem
    1712         }
    1713     }
    1714     ResetLegend
    1715 }
     1655        } else {
     1656            set elem $_comp2elem($tag)
     1657            switch -- $type {
     1658                "line" {
     1659                    $g line configure $elem \
     1660                        -symbol $sym \
     1661                        -pixels $pixels \
     1662                        -linewidth $linewidth \
     1663                        -dashes $dashes
     1664                }
     1665                "bar" {
     1666                    $g bar configure $elem \
     1667                        -barwidth $barwidth \
     1668                        -label $label
     1669                }
     1670            }
     1671        }
     1672        set _dataobj2raise($dataobj) $raise
     1673        set _dataobj2sim($dataobj) $sim
     1674    }
     1675}
Note: See TracChangeset for help on using the changeset viewer.