Changeset 1005 for branches/sandbox


Ignore:
Timestamp:
Sep 15, 2010 5:54:04 PM (10 years ago)
Author:
chlake
Message:

Made SR_Sort generic and added sort routine to restraint list box.

Bug: when restraint editor box closes, it SR_Bond_List needs to be reset

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/distrest.tcl

    r1004 r1005  
    4242        -sticky sw -columnspan 2
    4343
    44         set h_list .hard_list
     44
    4545        foreach {top main side lbl} [MakeScrollTable $rightfr] {}
    4646
    47         button $top.alabel1 -text "Atom 1 "
    48         button $top.alabel2 -text "Atom 2 "
    49         label  $top.rlabel1 -text "Restraint"
    50         label  $top.rlabel2 -text "esd"
    51 
    52         grid $top.alabel1 -column 1 -row 2
    53         grid $top.alabel2 -column 2 -row 2
     47        set atom1_state  1
     48        set atom2_state  1
     49
     50        button $top.alabel1 -text "Atom 1"    -width 6 -anchor center \
     51               -command "SR_Sort atom1 $main $top.alabel1 $top.alabel2 {}"
     52
     53        button $top.alabel2 -text "Atom 2"   -width 6  -anchor center \
     54               -command "SR_Sort atom2 $main $top.alabel1 $top.alabel2 {}"
     55
     56        label  $top.rlabel1 -text "Restraint" -width 9 -anchor center
     57        label  $top.rlabel2 -text "esd"       -width 9 -anchor center
     58
     59        grid $top.alabel1 -column 1 -row 2 -padx 3
     60        grid $top.alabel2 -column 2 -row 2 -padx 3
    5461        grid $top.rlabel1 -column 4 -row 2
    5562        grid $top.rlabel2 -column 5 -row 2
     
    6673#source c:/gsas/expgui/readexp.tcl
    6774#source c:/gsas/expgui/gsascmds.tcl
     75
     76
     77
     78
    6879
    6980#*********************************************************************************************
     
    176187# Procedure to sort soft restraints ---------------------------------------------
    177188#**************************************************************************************
    178 proc SR_Sort {whichbutton main} {
     189proc SR_Sort {whichbutton main alabel1 alabel2 dlabel1} {
    179190# reset all button labels
    180        $::sr_top.alabel1 config -text "Atom 1"
    181        $::sr_top.alabel2 config -text "Atom 2"
    182        $::sr_top.dlabel1 config -text "Distance"
     191       $alabel1 config -text "Atom 1"
     192       $alabel2 config -text "Atom 2"
     193       if {$dlabel1 != ""} {$dlabel1 config -text "Distance"}
    183194
    184195       if {$whichbutton == "atom1"} {
     
    186197             set sr_prsort [lsort -integer -decreasing -index 1 $::sr_bond_list]
    187198
    188              $::sr_top.alabel1 config -text "Atom 1 \u2193"
     199             $alabel1 config -text "Atom 1 \u2193"
    189200             } else {
    190201               set sr_prsort [lsort -integer -increasing -index 1 $::sr_bond_list]
    191                $::sr_top.alabel1 config -text "Atom 1 \u2191"
     202               $alabel1 config -text "Atom 1 \u2191"
    192203          }
    193204          set x [expr $::sr_atom1_button * -1]
     
    197208          if {$::sr_atom2_button == 1} {
    198209             set sr_prsort [lsort -integer -decreasing -index 2 $::sr_bond_list]
    199              $::sr_top.alabel2 config -text "Atom 2 \u2193"
     210             $alabel2 config -text "Atom 2 \u2193"
    200211             } else {
    201212               set sr_prsort [lsort -integer -increasing -index 2 $::sr_bond_list]
    202                $::sr_top.alabel2 config -text "Atom 2 \u2191"
     213               $alabel2 config -text "Atom 2 \u2191"
    203214          }
    204215          set x [expr $::sr_atom2_button * -1]
     
    208219             puts "distance"
    209220             set sr_prsort [lsort -increasing -index 8 $::sr_bond_list]
    210              $::sr_top.dlabel1 config -text "Distance \u2193"
     221             $dlabel1 config -text "Distance \u2193"
    211222             } else {
    212223               set sr_prsort [lsort -decreasing -index 8 $::sr_bond_list]
    213                $::sr_top.dlabel1 config -text "Distance \u2191"
     224               $dlabel1 config -text "Distance \u2191"
    214225         }
    215226         set x [expr $::sr_distance_button * -1]
     
    233244set     ::contraintmainbox $main
    234245
    235 button $::sr_top.alabel1 -text "Atom 1 "   -command "SR_Sort atom1 $main"
    236 button $::sr_top.alabel2 -text "Atom 2 "   -command "SR_Sort atom2 $main"
    237 button $::sr_top.dlabel1 -text "Distance " -command "SR_Sort distance $main"
     246button $::sr_top.alabel1 -text "Atom 1 "   \
     247       -command "SR_Sort atom1 $main $::sr_top.alabel1 $::sr_top.alabel2 $::sr_top.dlabel1"
     248button $::sr_top.alabel2 -text "Atom 2 " \
     249       -command "SR_Sort atom2 $main $::sr_top.alabel1 $::sr_top.alabel2 $::sr_top.dlabel1"
     250button $::sr_top.dlabel1 -text "Distance " \
     251       -command "SR_Sort distance $main $::sr_top.alabel1 $::sr_top.alabel2 $::sr_top.dlabel1"
    238252
    239253grid $::sr_top.alabel1 -column 1 -row 2
Note: See TracChangeset for help on using the changeset viewer.