Ignore:
Timestamp:
Jun 2, 2011 9:42:48 PM (10 years ago)
Author:
toby
Message:

More improvements to magnification regions based on Vince's comments; document changes on web page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/liveplot

    r1143 r1144  
    20962096menu .a.mag.menu
    20972097set maglist {}
     2098set mag0 1.0
     2099# display magnification routines -- not currently in use
    20982100proc ShowMag {} {
    20992101    global blt_version tcl_platform peakinfo expgui
     
    21102112        set lbl ""
    21112113        set xm $::xvec(min)
    2112         set ym 1.0
     2114        set ym $::mag0
    21132115        set ::maglist [lsort -real -index 0 $::maglist]
    21142116        foreach pair $::maglist {
     
    21272129}
    21282130
     2131# edit magnification regions
     2132proc EditMag {} {
     2133    set ::multrow 1
     2134    set bx .opt
     2135    catch {destroy $bx}
     2136    toplevel $bx
     2137    putontop $bx
     2138    wm iconname $bx "Mag Regs"
     2139    wm title $bx "Edit Magnification Regions"
     2140    pack [label $bx.0 -text "Vertical Magnification Regions:"] -side top
     2141    if {[llength $::maglist] == 0} {
     2142        set lbl "None"
     2143        pack [label $bx.1 -text $lbl -justify left] -side top
     2144        pack [button $bx.2 -text "Close" -command "destroy $bx"] -side top
     2145        tkwait window $bx
     2146        afterputontop
     2147        return
     2148    } else {
     2149        pack [frame $bx.1] -side top
     2150        set ::maglist [lsort -real -index 0 $::maglist]
     2151        set row 0
     2152        foreach pair $::maglist {
     2153            foreach {xh ymh} $pair {}
     2154            set row1 [expr {$row + 1}]
     2155            set ::xmag($row1) $xh
     2156            set ::mag($row1) $ymh
     2157            if {$row == 0} {
     2158                grid [label $bx.1.a$row -text "From "] -column 1 -row $row
     2159                grid [label $bx.1.b$row -text $::xvec(min)] -column 2 -row $row
     2160                grid [label $bx.1.c$row -text " to "] -column 3 -row $row
     2161                grid [entry $bx.1.d$row -textvariable xmag(1) -width 6] -column 4 -row $row
     2162                grid [label $bx.1.e$row -text " times "] -column 5 -row $row
     2163                grid [entry $bx.1.f$row -textvariable mag0 -width 4] -column 6 -row $row
     2164            } else {
     2165                grid [label $bx.1.a$row -text "From "] -column 1 -row $row
     2166                grid [entry $bx.1.b$row -textvariable xmag($row) -width 6] -column 2 -row $row
     2167                grid [label $bx.1.c$row -text " to "] -column 3 -row $row
     2168                grid [entry $bx.1.d$row -textvariable xmag($row1) -width 6] -column 4 -row $row
     2169                grid [label $bx.1.e$row -text " times "] -column 5 -row $row
     2170                grid [entry $bx.1.f$row -textvariable mag($row) -width 4] -column 6 -row $row
     2171            }
     2172            incr row
     2173        }
     2174        grid [label $bx.1.a$row -text "From "] -column 1 -row $row
     2175        grid [entry $bx.1.b$row -textvariable xmag($row) -width 6] -column 2 -row $row
     2176        grid [label $bx.1.c$row -text " to "] -column 3 -row $row
     2177        grid [label $bx.1.d$row -text $::xvec(max)] -column 4 -row $row
     2178        grid [label $bx.1.e$row -text " times "] -column 5 -row $row
     2179        grid [entry $bx.1.f$row -textvariable mag($row) -width 4] -column 6 -row $row
     2180        set ::multrow $row
     2181    }
     2182    pack [label $bx.l -text "\nSet the multiplier to zero to delete a region"] -side top
     2183    pack [frame $bx.2] -side top
     2184    pack [button $bx.2.a -text "Edit" -command "destroy $bx"] -side left
     2185    pack [button $bx.2.b -text "Cancel" -command "set multrow 0; destroy $bx"] -side left
     2186    tkwait window $bx
     2187    afterputontop
     2188    if {$::multrow == 0} return
     2189    set newmaglist {}
     2190    set xp $::xvec(min)
     2191    for {set i 1} {$i <= $::multrow} {incr i} {
     2192        if {$::mag($i) > 0} {
     2193            lappend newmaglist [list $::xmag($i) $::mag($i)]
     2194        }
     2195        set xp $::xmag($i)
     2196    }
     2197    set ::maglist $newmaglist
     2198    readdata .g
     2199}
     2200
     2201# show a menu to add a magnification region
    21292202proc AddMag {} {
    21302203    set bx .opt
     
    21592232    }
    21602233}
     2234proc AddCursorMag {p m} {
     2235    set x [.g xaxis invtransform $p]
     2236    if {$x < $::xvec(min) || $x > $::xvec(max) } {
     2237        bell
     2238        return
     2239    }
     2240    lappend ::maglist [list $x $m]
     2241    readdata .g
     2242}
     2243
     2244# scale the data with magnification regions
    21612245proc ApplyMag {} {
    21622246    foreach mrk [.g marker names mag*] {
     
    21672251    vector create ymult([xvec length])
    21682252    set xl $xvec(min)
    2169     set ym 1.0
     2253    set ym $::mag0
    21702254    set i 0
    21712255    set ::maglist [lsort -real -index 0 $::maglist]
     
    21982282if {$program == "liveplot"} {
    21992283    .a.mag.menu add command -label "Add region" -command "AddMag"
    2200     .a.mag.menu add command -label "Show" -command "ShowMag"
     2284    .a.mag.menu add command -label "Edit Regions" -command "EditMag"
    22012285    .a.mag.menu add separator
    22022286    .a.mag.menu add command -label "Clear" \
    22032287        -command "set maglist {}; readdata .g"
    22042288    .a.options.menu add command -label "Obs symbol" -command getsymopts
     2289    foreach i {1 2 3 4 5 6 7 8 9} {
     2290        bind . <Control-Key-$i> "AddCursorMag %x $i"
     2291    }
    22052292} else {
    22062293    .a.options.menu add cascade -label "Symbol Type" -menu .a.options.menu.sym
Note: See TracChangeset for help on using the changeset viewer.