source: trunk/atomcons.tcl @ 318

Last change on this file since 318 was 318, checked in by toby, 14 years ago

# on 2000/10/12 21:30:14, toby did:
Add www help support

  • Property rcs:author set to toby
  • Property rcs:date set to 2000/10/12 21:30:14
  • Property rcs:lines set to +14 -10
  • Property rcs:rev set to 1.7
  • Property rcs:state set to Exp
  • Property svn:keywords set to Author Date Revision Id
File size: 20.8 KB
Line 
1# $Revision: 318 $ $Date: 2009-12-04 23:04:03 +0000 (Fri, 04 Dec 2009) $
2# initial constraint sort mode
3set expcons(sortmode) num
4# size of constraint box
5set expcons(height) 300
6
7# this is used to create the contents of the constraint page
8proc MakeConstraintsPane {} {
9    global expgui expcons
10    # create the notebook
11    grid [NoteBook $expgui(consFrame).n -bd 2 -side bottom] -sticky news
12    # create pages for each of the constraint "subpages"
13    set expcons(atommaster) [\
14            $expgui(consFrame).n insert end atomic -text Atomic \
15            -createcmd "MakeAtomsConstraintsPane" \
16            -raisecmd "DisplayAtomConstraints"]   
17    # profile constraints page
18    catch {
19        source [file join $expgui(scriptdir) profcons.tcl]
20        set expcons(profilemaster) [\
21                $expgui(consFrame).n  insert end profile -text Profile \
22                -createcmd "MakeProfileConstraintsPane" \
23                -raisecmd "DisplayProfileConstraints"]   
24    }
25}
26
27# this is used to update the contents of the constraint page when displayed
28proc DisplayConstraintsPane {} {
29    global expgui
30    set page [$expgui(consFrame).n raise]
31    # open the atom constraints page if no page is open
32    if {$page == ""} {
33        set page atomic
34        $expgui(consFrame).n raise atomic
35    } else {
36        set pageupdate [$expgui(consFrame).n itemcget $page -raisecmd]
37        catch $pageupdate
38    }
39}
40
41# fill the atom constraints pane
42proc MakeAtomsConstraintsPane {} {
43    global expgui expcons
44
45    grid [button $expcons(atommaster).new -text "New Constraint" \
46            -command "EditAtomConstraint new"] \
47            -column 0 -sticky sw -row 1
48    grid [button $expcons(atommaster).del -text "Delete" \
49            -command "DeleteAtomConstraints"] \
50            -column 1 -sticky se -row 1
51    grid [canvas $expcons(atommaster).canvas \
52            -scrollregion {0 0 5000 500} -width 0 -height 250 \
53            -yscrollcommand "$expcons(atommaster).scroll set"] \
54            -column 0 -row 0 -columnspan 2 -sticky nsew
55    grid columnconfigure $expcons(atommaster) 0 -weight 1
56    grid rowconfigure $expcons(atommaster) 0 -weight 1
57    grid rowconfigure $expcons(atommaster) 1 -pad 5
58    scrollbar $expcons(atommaster).scroll \
59            -command "$expcons(atommaster).canvas yview"
60}
61
62
63# this is called to display the constraints on atomic parameters
64proc DisplayAtomConstraints {} {
65    global expgui expcons expmap
66    catch {destroy $expcons(atommaster).canvas.fr}
67    set top [frame $expcons(atommaster).canvas.fr]
68    $expcons(atommaster).canvas create window 0 0 -anchor nw -window $top
69
70    # get a list of constraints
71    set expcons(lastconstr) 0
72    set expcons(clist) {}
73    set i 0
74    catch {unset varlist}
75    while {[set clist [constrinfo atom get [incr i]]] != -1} {
76        set clist [lsort -index 1 $clist]
77        if {$expcons(sortmode) == "num"} {
78            set sortvar $i
79        } elseif {$expcons(sortmode) == "var"} {
80            set sortvar [lindex [lindex $clist 0] 2]
81        } elseif {$expcons(sortmode) == "atom"} {
82            set sortvar [lindex [lindex $clist 0] 1]
83            if {$sortvar == "ALL"} {set sortvar 0}
84        } elseif {$expcons(sortmode) == "phase"} {
85            set sortvar [lindex [lindex $clist 0] 0]
86        }
87        # tabulate a list where each phase-atom-var is referenced
88        foreach item $clist {
89            set phase [lindex $item 0]
90            set atom [lindex $item 1]
91            if {$atom == "ALL"} {set atom $expmap(atomlist_$phase)}
92            foreach a $atom {
93                set key [lindex $item 2]_${phase}_${a}
94                lappend varlist($key) $i
95            }
96        }
97        lappend expcons(clist) [list $sortvar $i $clist]
98    }
99    # were any variables referenced more than once?
100   
101    set problems {}
102    foreach key [array names varlist] {
103        if {[llength $varlist($key)] > 1} {
104            append problems " $varlist($key)"
105        }
106    }
107    # column headings
108    set row 0
109    set col -1
110    foreach lbl {# "" Phase \
111            "" Atom(s) Variable Multiplier \
112            "" Atom(s) Variable Multiplier \
113            "" Delete} {
114        incr col
115        if {$lbl != ""} {
116            grid [label $top.t$col -text $lbl] -column $col -row $row
117        }
118    }
119    # make some column headings into buttons
120    foreach col {0 2 4 5} val {num phase atom var} {
121        $top.t$col config -relief raised -bd 2
122        bind $top.t$col <1> "set  expcons(sortmode) $val; DisplayAtomConstraints"
123    }
124    # extra column spacing
125    foreach col {1 2 4 5 6 8 9 10} { 
126        grid columnconfig $top $col -pad 6
127    }
128    set i 0
129    if {$expcons(sortmode) == "var"} {
130        set sortlist [lsort -index 0 -ascii $expcons(clist)]
131    } else {
132        set sortlist [lsort -index 0 -integer $expcons(clist)]
133    }
134    foreach item $sortlist {
135        set clist [lindex $item 2]
136        set num [lindex $item 1]
137        incr i
138        # row separator
139        grid [frame $top.sp$row -bd 8 -bg white] \
140                -columnspan 20 -column 0 -row [incr row] -sticky nsew
141        grid rowconfig $top $row -minsize 2 -pad 2
142        set startrow [incr row]
143        catch {unset atomlist}
144        # make a list of unique phase #, variables & multipliers
145        foreach item $clist {
146            set key [lindex $item 0]_[lindex $item 2]_[lindex $item 3]
147            lappend atomlist($key) [lindex $item 1]
148        }
149        set phprev 0
150        incr row -1
151        foreach key [lsort [array names atomlist]] {
152            regexp {(.*)_(.*)_(.*)} $key dummy phase var mult
153            if {$phase != $phprev} {
154                set col 1
155                if {$phprev!= 0} {
156                    grid [frame $top.sp$row -bg white] \
157                            -columnspan 14 -column 2 \
158                            -row [incr row] -sticky nsew
159                    grid rowconfig $top $row -minsize 1
160                }
161                grid [label $top.c${col}$row -text $phase] \
162                        -column [incr col] -row [incr row]
163                set phprev $phase
164            }
165            incr col
166            if {$col > 8} {
167                incr row
168                set col 3
169            }
170            grid [label $top.c${col}$row \
171                    -text [CompressList $atomlist($key)]] \
172                    -column [incr col] -row $row -sticky w
173            grid [label $top.c${col}$row -text $var] \
174                    -column [incr col] -row $row
175            if {$mult > 0} {
176                grid [label $top.c${col}$row -text "x $mult"] \
177                        -column [incr col] -row $row
178            } else {
179                grid [label $top.c${col}$row -text "x $mult" -fg red] \
180                        -column [incr col] -row $row
181            }
182        }
183        grid [button $top.but$row -text "edit" \
184                -command "EditAtomConstraint $num"] \
185                -column 1 -row $startrow \
186                -rowspan [expr 1 + $row - $startrow]
187        set expcons(delete$num) 0
188        grid [checkbutton $top.del$row  \
189                -variable expcons(delete$num)] \
190                -column 12 -row $startrow \
191                -rowspan [expr 1 + $row - $startrow]
192        if {[lsearch $problems $num] == -1} {
193            grid [label $top.l$i -text $num] \
194                    -column 0 -row $startrow \
195                    -rowspan [expr 1 + $row - $startrow]
196        } else {
197            grid [label $top.l$i -text $num -fg red] \
198                    -column 0 -row $startrow \
199                    -rowspan [expr 1 + $row - $startrow]
200        }
201        set expcons(lastconstr) \
202                [expr $expcons(lastconstr) > $num ? \
203                $expcons(lastconstr) : $num ]
204    }
205    # row separator
206    grid [frame $top.sp$row -bd 8 -bg white] \
207            -columnspan 16 -column 0 -row [incr row] -sticky nsew
208    grid rowconfig $top $row -minsize 2 -pad 2
209    # column separators
210    foreach col {3 7 11} {
211        grid [frame $top.vs${col}$row -bd 8 -bg white] \
212                -column $col -row 0 -rowspan $row -sticky nsew
213        grid columnconfig $top $col -minsize 2 -pad 2
214    }
215    # resize the canvas & scrollbar
216    update idletasks
217    set sizes [grid bbox $top]
218    $expcons(atommaster).canvas config -scrollregion $sizes
219    set hgt [lindex $sizes 3]
220    # set the maximum height for the canvas from the frame
221    set maxheight [expr \
222            [winfo height [winfo parent $expgui(consFrame)]] - 130]
223
224    # use the scroll for BIG constraint lists
225    if {$hgt > $maxheight} {
226        grid $expcons(atommaster).scroll -sticky ns -column 2 -row 0
227    }
228    $expcons(atommaster).canvas config \
229            -height $maxheight \
230            -width [lindex $sizes 2]
231    $expgui(consFrame).n compute_size
232    # report constraint errors
233    set msg {}
234    foreach key [lsort [array names varlist]] {
235        if {[llength $varlist($key)] > 1} {
236            regexp {(.*)_(.*)_(.*)} $key dummy var phase atom
237            append msg "   $var for atom $atom (phase $phase) is in"
238            append msg " constraints [CompressList $varlist($key)]\n"
239        }
240    }
241    $expgui(consFrame).n compute_size
242    update idletasks
243    if {$msg != ""} {
244        set msg "Error: an atomic parameter can appear in only one constraint. Here is a list of parameters that are referenced in more than one constraint:\n\n$msg"
245        MyMessageBox -icon error -message $msg \
246                -helplink "expgui6.html AtomConstraintsError" \
247                -parent [winfo toplevel $expgui(consFrame)] 
248    }
249}
250
251# this is called to delete an atomic constraint
252proc DeleteAtomConstraints {} {
253    global expcons expgui
254    # get the constraints to delete
255    set dellist {}
256    for {set i 1} {$i <= $expcons(lastconstr)} {incr i} {
257        if $expcons(delete$i) {lappend dellist $i}
258    }
259    # nothing to delete?
260    if {$dellist == ""} return
261    if {[MyMessageBox -message \
262            "Do you want to delete constraint(s) [CompressList $dellist]?" \
263            -parent [winfo toplevel $expcons(atommaster)] \
264            -type {No Delete} -default no] == "no"} return
265    foreach num [lsort -decreasing -integer $dellist] {
266        constrinfo atom delete $num
267        incr expgui(changed)
268    }
269    DisplayAtomConstraints
270}
271
272# called to edit a single constraint set
273proc EditAtomConstraint {num args} {
274    global expcons expmap expgui
275
276    set top {.editcons}
277    catch {toplevel $top}
278    bind $top <Key-F1> "MakeWWWHelp expgui6.html EditAtomConstraints"
279    eval destroy [grid slaves $top]
280    if {$num == "new"} {
281        wm title $top "New Constraint"
282        set clist {}
283        grid [label $top.top -text "Editing new constraint"] \
284            -column 0 -row 0 -columnspan 4
285
286    } else {
287        wm title $top "Constraint #$num"
288        set clist [constrinfo atom get $num]
289        grid [label $top.top -text "Editing constraint #$num"] \
290            -column 0 -row 0 -columnspan 4
291    }
292    # column headings
293    grid [canvas $top.canvas \
294            -scrollregion {0 0 5000 500} -width 100 -height 50 \
295            -xscrollcommand "$top.scroll set"] \
296            -column 0 -row 1 -columnspan 4 -sticky nsew
297    grid columnconfigure $top 3 -weight 1
298    grid rowconfigure $top 1 -weight 1
299    catch {destroy $top.scroll}
300    scrollbar $top.scroll -orient horizontal \
301            -command "$top.canvas xview"
302    #    grid $top.scroll -sticky ew -column 0 -row 2 -columnspan 4
303    # create a scrollable frame inside the canvas
304    set cfr [frame $top.canvas.fr]
305    $top.canvas create window 0 0 -anchor nw  -window $cfr
306
307    grid [button $top.add -text "New Column" \
308            -command "NewAtomConstraintColumn $top $cfr $num"] \
309            -column 0 -row 3  -columnspan 2 -sticky ew
310    grid [button $top.done -text "Save" \
311            -command "SaveAtomConstraint $num $top"] \
312            -column 0 -row 4 -sticky ns
313    grid [button $top.quit -text "Cancel\nChanges" \
314            -command "CancelEditConstraint $top"]  -column 1 -row 4
315    grid [button $top.help -text Help -bg yellow \
316            -command "MakeWWWHelp expgui6.html EditAtomConstraints"] \
317            -column 2 -row 3 -columnspan 99 -rowspan 2 -sticky e
318
319    set col 0
320    set row 1
321    foreach lbl {Phase Atom(s) Variable Multiplier} {
322        # row separator
323        grid [frame $cfr.spc$row -bd 8 -bg white] \
324                -columnspan 60 -column 0 -row [incr row] -sticky nsew
325        grid rowconfig $cfr $row -minsize 2 -pad 2
326        if {$lbl == ""} {
327            incr row
328        } else {
329            grid [label $cfr.t$row -text $lbl] -column $col -row [incr row]
330        }
331    }
332    # row separator
333    grid [frame $cfr.spc$row -bd 8 -bg white] \
334            -columnspan 60 -column 0 -row [incr row] -sticky nsew
335    grid rowconfig $cfr $row -minsize 2 -pad 2
336    # make a list of unique phase #, variables & multipliers
337    catch {unset atomlist}
338    foreach item $clist {
339        if {$item == -1} break
340        set key [lindex $item 0]_[lindex $item 2]_[lindex $item 3]
341        lappend atomlist($key) [lindex $item 1]
342    }
343    set ic 0
344    foreach key [lsort [array names atomlist]] {
345        incr ic
346        regexp {(.*)_(.*)_(.*)} $key dummy phase var mult
347    }
348    # delete traces on expcons(var1)
349    foreach v [ trace vinfo expcons(var1)] {
350        eval trace vdelete expcons(var1) $v
351    }
352    # fill the listbox & set the vars
353    set ic 0
354    foreach key [lsort [array names atomlist]] {
355        incr ic
356        regexp {(.*)_(.*)_(.*)} $key dummy phase var mult
357        # delete traces on expcons(phase$ic)
358        foreach v [ trace vinfo expcons(phase$ic)] {
359            eval trace vdelete expcons(phase$ic) $v
360        }
361        MakeAtomConstraintColumn $cfr $ic $col $num
362        incr col 3
363        # set the various variables
364        set expcons(phase$ic) $phase
365        set expcons(mult$ic) $mult
366        set expcons(var$ic) $var
367        FillAtomsConstraintList $ic $atomlist($key)
368        trace variable expcons(phase$ic) w "FillAtomsConstraintList $ic {}"
369    }
370    if {$num == "new"} {NewAtomConstraintColumn $top $cfr $num}
371    trace variable expcons(var1) w SetVarConstraintMenu
372    SetVarConstraintMenu
373    # resize the canvas & scrollbar
374    update idletasks
375    set sizes [grid bbox $cfr]
376    $top.canvas config -scrollregion $sizes
377    set width [lindex $sizes 2]
378    # use the scroll for BIG constraints
379    if {$width > 600} {
380        set width 600
381        grid $top.scroll -sticky ew -column 0 -row 2 -columnspan 4
382    }
383    $top.canvas config -height [lindex $sizes 3] -width $width
384    # force the window to stay on top
385    putontop $top
386    tkwait window $top
387    afterputontop
388}
389
390# called when the "Cancel Changes" button is pressed
391proc CancelEditConstraint {top} {
392    set ans [MyMessageBox -type "{Abandon Changes} {Continue Edit}" \
393            -parent [winfo toplevel $top] -default "abandon changes" \
394            -helplink "expguierr.html AbandonEditConstraints" \
395            -icon warning -message  \
396            {Do you want to lose any changes made to this constraint?}]
397    if {$ans == "abandon changes"} {destroy $top}
398}
399
400# called to make each column in the atom parameter dialog
401proc MakeAtomConstraintColumn {cfr ic col num} {
402    global expmap expcons expgui
403    set row 1
404    # make column separator
405    incr col 2
406    grid [frame $cfr.sp$col -bd 8 -bg white] \
407            -rowspan 9 -column $col -row $row -sticky nsew
408    grid columnconfig $cfr $col -minsize 2 -pad 2
409
410    eval tk_optionMenu $cfr.phase$ic expcons(phase$ic) $expmap(phaselist)
411    grid $cfr.phase$ic -column [incr col] -row [incr row 2] -columnspan 2
412    # make the listbox
413    set expcons(atomlistbox$ic) $cfr.lb$ic
414    grid [listbox $cfr.lb$ic -height 10 -width 12 \
415            -font $expgui(coordfont) \
416            -exportselection 0 -selectmode extended \
417            -yscrollcommand " $cfr.sb$ic set"] \
418            -column $col -row [incr row 2] -sticky nse
419    bind $expcons(atomlistbox$ic) <Button-3> \
420            "$expcons(atomlistbox$ic) selection set 0 end"
421    grid [scrollbar $cfr.sb$ic -command "$cfr.lb$ic yview"] \
422            -column [expr 1+$col] -row $row -sticky wns
423    if {$num == "new"} {
424        set expcons(varmenu$ic) [tk_optionMenu $cfr.var$ic expcons(var$ic) \
425                FRAC X Y Z UISO U11 U22 U33 U12 U23 U13 MX MY MZ XYZU Uxx]
426        $expcons(varmenu$ic) insert 14 separator
427    } else {
428        set expcons(varmenu$ic) [tk_optionMenu $cfr.var$ic expcons(var$ic) \
429                FRAC X Y Z UISO U11 U22 U33 U12 U23 U13 MX MY MZ]
430    }
431    grid $cfr.var$ic -column $col -row [incr row 2] -columnspan 2
432    grid [entry $cfr.c${col}$ic -width 10 \
433            -textvariable expcons(mult$ic)] \
434            -column $col -row [incr row 2] -columnspan 2
435}
436
437# called when the "New column" button is pressed to add a new constraint
438proc NewAtomConstraintColumn {top cfr num} {
439    global expcons expmap expgui
440    set col -3
441    set row 1
442    for {set ic 1} {$ic < 500} {incr ic} {
443        incr col 3
444        if [winfo exists $cfr.phase$ic] continue
445        # delete traces on expcons(phase$ic)
446        foreach v [ trace vinfo expcons(phase$ic)] {
447            eval trace vdelete expcons(phase$ic) $v
448        }
449        MakeAtomConstraintColumn $cfr $ic $col $num
450        # set the various variables to initial values
451        set expcons(atmlst$ic) {}
452        set expcons(phase$ic) {}
453        set expcons(var$ic) {}
454        set expcons(mult$ic) 1.0
455        trace variable expcons(phase$ic) w "FillAtomsConstraintList $ic {}"
456        break
457    }
458    # set the allowed constraints
459    SetVarConstraintMenu
460    # resize the canvas & scrollbar
461    update idletasks
462    set sizes [grid bbox $cfr]
463    $top.canvas config -scrollregion $sizes
464    set width [lindex $sizes 2]
465    # use the scroll for BIG constraints
466    if {$width > 600} {
467        set width 600
468        grid $top.scroll -sticky ew -column 0 -row 2 -columnspan 4
469    }
470    $top.canvas config -height [lindex $sizes 3] -width $width
471}
472
473# called when the leftmost constraint variable is changed, so that
474# only allowed constraints are offered to the user.
475proc SetVarConstraintMenu {args} {
476    global expcons
477    set maxvar [$expcons(varmenu1) index end]
478    set allowed {}
479    switch $expcons(var1) {
480        FRAC {set allowed FRAC}
481        X -
482        Y -
483        Z {set allowed "X Y Z"}
484        XYZU {set allowed XYZU}
485        UISO {set allowed UISO}
486        U11 -
487        U22 -
488        U33 -
489        U12 -
490        U23 -
491        U13 {set allowed "U11 U22 U33 U12 U23 U13"}
492        Uxx {set allowed Uxx}
493        MX -
494        MY -
495        MZ {set allowed "MX MY MZ"}
496    }
497    for {set ic 2} {$ic < 500} {incr ic} {
498        if [catch {set expcons(varmenu$ic)}] break
499        if [winfo exists $expcons(varmenu$ic)] {
500            # if only one variable choice is allowed select it,
501            # if not and the current value is not allowed, blank it out
502            if {[llength $allowed] == 1} {
503                set expcons(var$ic) $allowed
504            } elseif {[lsearch $allowed $expcons(var$ic)] == -1} {
505                set expcons(var$ic) {}
506            }
507            set num 0
508            for {set num 0} {$num <= $maxvar} {incr num} {
509                # ignore error on separators
510                catch {
511                    set var [$expcons(varmenu$ic) entrycget $num -label]
512                    if {[lsearch $allowed $var] == -1} {
513                        $expcons(varmenu$ic) entryconfigure $num \
514                                -state disabled
515                    } else {
516                        $expcons(varmenu$ic) entryconfigure $num \
517                                -state normal
518                    }
519                }
520            }
521        } else {
522            break
523        }
524    }
525}
526
527# called to load the parameter values into the atom parameter dialog
528proc FillAtomsConstraintList {ic atomselectlist args} {
529    global expcons expgui expmap
530    # fill the atoms box
531    set phase $expcons(phase$ic)
532    $expcons(atomlistbox$ic) delete 0 end
533    set atmlst {}
534    if  {$expgui(asorttype) == "type"} {
535        # sort on atom type
536        foreach atom $expmap(atomlist_$phase) {
537            lappend atmlst "$atom [atominfo $phase $atom type]"
538        }
539        set atmlst [lsort -ascii -index 1 $atmlst]
540    } elseif {$expgui(asorttype) == "number"} {
541        # sort on atom number
542        foreach atom $expmap(atomlist_$phase) {
543            lappend atmlst "$atom $atom $phase"
544        }
545        set atmlst [lsort -integer -index 1 $atmlst]
546    } elseif {$expgui(asorttype) == "x"} {
547        # sort on x
548        foreach atom $expmap(atomlist_$phase) {
549            lappend atmlst "$atom [atominfo $phase $atom x]"
550        }
551        set atmlst [lsort -real -index 1 $atmlst]
552    } elseif {$expgui(asorttype) == "y"} {
553        # sort on y
554        foreach atom $expmap(atomlist_$phase) {
555            lappend atmlst "$atom [atominfo $phase $atom y]"
556        }
557        set atmlst [lsort -real -index 1 $atmlst]
558    } elseif {$expgui(asorttype) == "z"} {
559        # sort on z
560        foreach atom $expmap(atomlist_$phase) {
561            lappend atmlst "$atom [atominfo $phase $atom z]"
562        }
563        set atmlst [lsort -real -index 1 $atmlst]
564    } else {
565        error "Bad expgui(asorttype = $expgui(asorttype)"
566    }
567    # make a list of atoms in the box
568    set expcons(atmlst$ic) {}
569    foreach tuple $atmlst {
570        set atom [lindex $tuple 0]
571        lappend expcons(atmlst$ic) $atom
572        $expcons(atomlistbox$ic) insert end [format "%-6s%3d %-6s" \
573                [atominfo $phase $atom label] \
574                $atom \
575                [atominfo $phase $atom type]]
576        # select the atom if appropriate
577        if {[lsearch $atomselectlist $atom] != -1} {
578            $expcons(atomlistbox$ic) selection set end
579        }
580    }
581    if {$atomselectlist == "ALL"} {
582        $expcons(atomlistbox$ic) selection set 0 end
583    }
584}
585
586# this is called to change an atomic consraint
587proc SaveAtomConstraint {num top} {
588    global expcons expgui
589    # special variables XYZU & Uxx should only occur with num == "new"
590    # then add new constraints
591    set varlist {{}}
592    if {$expcons(var1) == "XYZU"} {set varlist "X Y Z UISO"}
593    if {$expcons(var1) == "Uxx"} {set varlist "U11 U22 U33 U12 U23 U13"}
594    foreach var $varlist {
595        set clist {}
596        for {set ic 1} {$ic < 500} {incr ic} {
597            if [catch {set expcons(varmenu$ic)}] break
598            if [winfo exists $expcons(varmenu$ic)] {
599                set phase $expcons(phase$ic)
600                if {$var == ""} {
601                    set v $expcons(var$ic)
602                } else {
603                    set v $var
604                }
605                set mult $expcons(mult$ic)
606                set atomlist {}
607                foreach indx [$expcons(atomlistbox$ic) curselection] {
608                    lappend atomlist [lindex $expcons(atmlst$ic) $indx]
609                }
610                if {[llength $atomlist] == [llength $expcons(atmlst$ic)] \
611                        && $v == "UISO"} {
612                    set atomlist ALL
613                } else {
614                    set atomlist [lsort -integer $atomlist]
615                }
616                # ignore this column if phase is invalid or there are no atoms
617                if {![catch {expr $phase}] && \
618                        [llength $atomlist] > 0 && \
619                        $v != ""} {
620                    # error if mult is invalid
621                    if [catch {expr $mult}] {
622                        MyMessageBox -message \
623                                "Multiplier value \"$mult\" in column $ic is invalid" \
624                                -parent [winfo toplevel $expcons(atommaster)] \
625                                -type {Fix} -default fix -icon error
626                        return
627                    }
628                    foreach atom $atomlist {
629                        lappend clist [list $phase $atom $v $mult]
630                    }
631                }
632            }
633        }
634        # maximum number of parameters in a constraint is 100
635        if {[llength $clist] > 100} {
636            MyMessageBox -message \
637                    "There are [llength $clist] parameters in this constraint, but only 100 are allowed in an atom constraint." \
638                    -parent [winfo toplevel $expcons(atommaster)] \
639                    -helplink "expgui6.html AtomConstraintsMax" \
640                    -type {Fix} -default fix -icon error
641            return
642        }
643        if {$num == "new"} {
644            constrinfo atom add {} $clist
645        } elseif {$clist != ""} {
646            constrinfo atom set $num $clist
647        } else {
648            constrinfo atom delete $num
649        }
650        incr expgui(changed)
651    }
652    destroy $top
653    DisplayAtomConstraints
654}
Note: See TracBrowser for help on using the repository browser.