Changeset 467


Ignore:
Timestamp:
Dec 4, 2009 5:06:39 PM (11 years ago)
Author:
toby
Message:

# on 2001/10/18 23:23:58, toby did:
add new peak labeling options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/liveplot

    • Property rcs:date changed from 2001/09/25 23:34:32 to 2001/10/18 23:23:58
    • Property rcs:lines changed from +48 -18 to +47 -18
    • Property rcs:rev changed from 1.19 to 1.20
    r451 r467  
    401401    global blt_version expgui tcl_platform tcl_version
    402402    global refhkllist refphaselist peakinfo refpos
    403     # look for peaks within pixelregion pixels
    404     set xmin [$plot xaxis invtransform [expr $x - $expgui(pixelregion)]]
    405     set xmax [$plot xaxis invtransform [expr $x + $expgui(pixelregion)]]
     403    # look for peaks within pixelregion pixels or the entire plot range
     404    if {$x == "all"} {
     405        foreach {xmin xmax} [$plot xaxis limits] {}
     406    } else {
     407        set xmin [$plot xaxis invtransform [expr $x - $expgui(pixelregion)]]
     408        set xmax [$plot xaxis invtransform [expr $x + $expgui(pixelregion)]]
     409    }
    406410    set peaknums [refposvec search $xmin $xmax]
    407411    set peaklist {}
    408     set xcen 0
    409     # select by displayed phases
    410     set lbls 0
     412    # create a box, if needed
    411413    if {$expgui(hklbox)} {
    412414        catch {
     
    424426        }
    425427    }
     428    set xcen 0
     429    set lbls 0
    426430    foreach peak $peaknums {
     431        # put all hkls, all phases in the box
    427432        if {$expgui(hklbox)} {
    428433            catch {
     
    433438            }
    434439        }
     440        # label phases with tick marks
    435441        if [set peakinfo(flag[lindex $refphaselist $peak])] {
    436             set xcen [expr $xcen + [refposvec range $peak $peak]]
    437             lappend peaklist [lindex $refhkllist $peak]
    438             incr lbls
    439         }
    440     }
     442            set pos [refposvec range $peak $peak]
     443            if {$lbls <= 0} {
     444                set xcen $pos
     445                set peaklist [lindex $refhkllist $peak]
     446                set lbls 1
     447            } elseif {abs($xcen/$lbls-$pos) <= $expgui(pixelregion)} {
     448                set xcen [expr $xcen + $pos]
     449                lappend peaklist [lindex $refhkllist $peak]
     450                incr lbls
     451            } else {
     452                puthkllbl $plot $peaklist $xcen $lbls
     453                set xcen $pos
     454                set peaklist [lindex $refhkllist $peak]
     455                set lbls 1
     456            }
     457        }
     458    }
     459    puthkllbl $plot $peaklist $xcen $lbls
     460}
     461
     462proc puthkllbl {plot peaklist xcen lbls} {
     463    global blt_version tcl_platform tcl_version expgui
    441464    if {$peaklist == ""} return
    442465    set xcen [expr $xcen / $lbls]
     
    447470        set ycen Inf
    448471    }
    449     if {$tcl_platform(platform) == "windows"} {
    450         # at least right now, text can't be rotated in windows
     472    # older BLT versions can't rotate text in windows
     473    if {$tcl_platform(platform) == "windows" && \
     474            ($blt_version <= 2.3 || $blt_version == 8.0)} {
    451475        regsub -all { } $peaklist "\n" peaklist
    452476        set mark [$plot marker create text -coords "$xcen $ycen" \
    453         -text $peaklist -anchor n -bg "" -name hkl$xcen]
     477                -text $peaklist -anchor n -bg "" -name hkl$xcen]
    454478    } else {
    455479        set mark [$plot marker create text -coords "$xcen $ycen" \
    456         -rotate 90 -text $peaklist -anchor n -bg "" -name hkl$xcen]
     480                -rotate 90 -text $peaklist -anchor n -bg "" -name hkl$xcen]
    457481    }
    458482    if {$tcl_version >= 8.0} {
     
    462486        catch {
    463487            after [expr $expgui(fadetime) * 1000 ] \
    464             "catch \{ $plot marker delete $mark \}"
     488                    "catch \{ $plot marker delete $mark \}"
    465489        }
    466490    }
     
    673697    toplevel $box
    674698    focus $box
     699    wm title $box "Set PS options"
    675700    pack [frame $box.4] -side top -anchor w -fill x
    676701    pack [checkbutton $box.4.a -text "Write PostScript files" \
     
    701726    toplevel $box
    702727    focus $box
     728    wm title $box "Set hkl options"
    703729    pack [frame $box.c] -side top  -anchor w
    704730    pack [label $box.c.l -text "HKL label\nerase time:"] -side left
     
    14451471    bind . <Key-h> "lblhkl $box %x"
    14461472    bind . <Key-H> "lblhkl $box %x"
    1447 #    bind $box <Shift-Double-Button-1> "lblallhkl %W"
     1473    bind . <Key-a> "lblhkl $box all"
     1474    bind . <Key-A> "lblhkl $box all"
     1475    bind . <Key-d> "delallhkllbl $box"
     1476    bind . <Key-D> "delallhkllbl $box"
    14481477    if {[bind bltZoomGraph] != ""} {
    14491478        bind bltZoomGraph <Shift-Button-1> "lblhkl $box %x"
Note: See TracChangeset for help on using the changeset viewer.