Changeset 5179


Ignore:
Timestamp:
Apr 1, 2015 10:19:05 PM (5 years ago)
Author:
mmh
Message:

improved PDF initial values

Location:
branches/uq/gui/scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/uq/gui/scripts/gauge.tcl

    r5121 r5179  
    215215# ----------------------------------------------------------------------
    216216itcl::body Rappture::Gauge::value {args} {
    217     # puts "Gauge value: $args"
     217    #puts "Gauge value: $args"
    218218
    219219    # Query.  Just return the current value.
     
    737737
    738738        set _pde [Rappture::ProbDistEditor $inner.entry \
    739         $itk_option(-minvalue) $itk_option(-maxvalue)]
     739        $itk_option(-minvalue) $itk_option(-maxvalue) $itk_option(-units) $_value]
    740740        $_val value $_mode
    741741        $_pde value $_value
  • branches/uq/gui/scripts/probdisteditor.tcl

    r5166 r5179  
    5050# CONSTRUCTOR
    5151# ----------------------------------------------------------------------
    52 itcl::body Rappture::ProbDistEditor::constructor {min max} {
     52itcl::body Rappture::ProbDistEditor::constructor {min max units default} {
    5353    # create a dispatcher for events
    54     puts "PDE::constructor $min $max"
     54    #puts "PDE::constructor $min $max $default"
    5555
    5656    # These are the tool min and max values.  May be empty.
    5757    set _umin $min
    5858    set _umax $max
    59     set _units [Rappture::Units::Search::for $_umin]
     59    set _units $units
     60    set _uvalue(central) $default
    6061
    6162    Rappture::dispatcher _dispatcher
     
    199200# ----------------------------------------------------------------------
    200201itcl::body Rappture::ProbDistEditor::value {{newval ""}} {
    201     puts "PDE::value $newval"
     202    #puts "PDE::value $newval"
    202203
    203204    #FIXME: _value has numerical values _uvalue has value with units
     
    285286# ----------------------------------------------------------------------
    286287itcl::body Rappture::ProbDistEditor::mode {{newval ""}} {
    287     puts "PDE::mode mode=$newval min=$_umin max=$_umax units=$_units"
     288    #puts "PDE::mode mode=$newval min=$_umin max=$_umax units=$_units"
    288289
    289290    set modes {exact uniform gaussian custom}
     
    291292        return $modes
    292293    }
     294
     295    set check 0
     296    if {$newval == "check"} {
     297        set newval $_mode
     298        set check 1
     299    }
     300
    293301    if {[lsearch $modes $newval] < 0} {
    294302        error "bad value \"$newval\": should be [join $modes {, }]"
     
    342350        }
    343351        gaussian {
    344             # puts "GAUSSIAN min=$min max=$max"
     352            #puts "GAUSSIAN min=$min max=$max"
    345353            if {![info exists _value(central)]} {
    346354                if {[info exists _value(min)] && [info exists _value(max)]} {
     
    350358                }
    351359            }
    352             # puts "central=$_value(central)"
     360            #puts "central=$_value(central)"
    353361            if {![info exists _value(stddev)]} {
    354                 if {[info exists _value(min)] && [info exists _value(max)]} {
    355                     set _value(stddev) [expr {0.3*($_value(max) - $_value(min))}]
    356                 } elseif {$min != "" && $max != ""} {
    357                     set _value(stddev) [expr {0.3*($max - $min)}]
    358                 } else {
    359                     set _value(stddev)  [expr $_value(central) * 0.10]
    360                 }
     362                set _value(stddev)  [expr $_value(central) * 0.10]
    361363            }
    362364            if {$_value(stddev) <= 0} {
    363365                set _value(stddev) 1.0
    364366            }
    365             # puts "stddev=$_value(stddev)"
     367            #puts "stddev=$_value(stddev)"
    366368            # lower bound is -3 deviations or tool min
    367369            set trunc [expr {$_value(central) - 3*$_value(stddev)}]
     
    387389    }
    388390
     391    if {$check == 1} {
     392        return
     393    }
    389394    # pop up the panel of editing options for this mode
    390395    foreach w [pack slaves $itk_component(vals)] {
     
    452457# ----------------------------------------------------------------------
    453458itcl::body Rappture::ProbDistEditor::_redraw {} {
     459    #puts "PDE::_redraw"
     460
    454461    set g $itk_component(graph)
    455462    eval $g element delete [$g element names]
     
    486493        }
    487494        gaussian {
     495            #puts "min=$_value(min) max=$_value(max)"
     496            #puts "mean=$_value(central) dev=$_value(stddev)"
     497
    488498            set min $_value(min)
    489499            set max $_value(max)
     
    592602# ----------------------------------------------------------------------
    593603itcl::body Rappture::ProbDistEditor::_apply {op {widget ""}} {
    594     puts "_apply $op $widget"
     604    #puts "PDE::_apply $op $widget"
    595605    if {$op != "bindings"} {
    596606        # need this for value/finalize
     
    640650                set newval [Rappture::Units::convert [$widget get] -context $_units]
    641651            }
    642             puts "widget=$widget"
    643652            set itk $itk_component(gaussianvals).stddev
    644             puts "itk=$itk"
    645653            if {$widget != $itk && [catch {Rappture::Units::mcheck_range $newval $_umin $_umax $_units} err]} {
    646654                # oops! value is bad -- edit again
     
    658666            set $uvar $newval
    659667
     668            #if {$widget == $itk_component(gaussianvals).mean} {
     669                # need new min and max
     670                #set $_uvalue(min)
     671                #set $_uvalue(max) ...
     672            #}
     673
    660674            if {[catch {Rappture::Units::convert $newval -units off} nvar]} {
    661675                set nvar $newval
     
    663677            set $var $nvar
    664678
     679            mode check
    665680            $_dispatcher event -idle !redraw
    666681        }
Note: See TracChangeset for help on using the changeset viewer.