Debian Codegraph @

artemis_parts/main_window.pl

raw
1 # -*- cperl -*-
2 ## This file is part of Artemis, copyright (c) 2002-2010 Bruce Ravel
3 ##
4 ## THE MAIN WINDOW
5
6
7 ###===================================================================
8 ### set up widgets in main windows
9 ###===================================================================
10
11 sub make_opparams {
12 my $parent = $_[0];
13
14 my @pluck_button = (-foreground => $config{colors}{highlightcolor},
15 -activeforeground => $config{colors}{activehighlightcolor},
16 -background => $config{colors}{background},
17 -activebackground => $config{colors}{activebackground});
18 my @start = ("-foreground", $config{colors}{activehighlightcolor}, "-font", $config{fonts}{med});
19 my $pluck_bitmap = '#define pluck_width 9
20 #define pluck_height 9
21 static unsigned char pluck_bits[] = {
22 0x81, 0x01, 0xc3, 0x00, 0x66, 0x00, 0x3c, 0x00, 0x38, 0x00, 0x78, 0x00,
23 0xcc, 0x00, 0x86, 0x01, 0x03, 0x01};
24 ';
25 my $pluck_X = $top -> Bitmap('pluck', -data=>$pluck_bitmap,
26 -foreground=>$config{colors}{activehighlightcolor});
27 my @pluck=(-image=>$pluck_X);
28
29 my $c = $parent -> Frame(-relief=>'flat',
30 #@window_size,
31 -borderwidth=>0,
32 -highlightcolor=>$config{colors}{background})
33 -> pack(-fill=>'both', -expand=>1);
34
35 ## titles
36 my $lfr = $c -> LabFrame(-label => 'Titles',
37 -font => $config{fonts}{med},
38 -foreground => $config{colors}{activehighlightcolor},
39 -labelside => 'acrosstop',
40 -width => 14)
41 -> pack(-side=>'top', -padx=>4, -fill=>'x');
42 &labframe_help($lfr);
43 push @op_text, $lfr;
44 $widgets{op_titles} = $lfr -> Scrolled('Text',
45 -height=>5,
46 -font=>$config{fonts}{fixed},
47 -scrollbars=>'se',
48 -width=>50,
49 -wrap=>'none')
50 -> pack(-fill=>'x', -padx=>4, -pady=>4);
51 &disable_mouse3($widgets{op_titles}->Subwidget("text"));
52 BindMouseWheel($widgets{op_titles});
53 $widgets{op_titles}->Subwidget("xscrollbar")
54 ->configure(-background=>$config{colors}{background},
55 ($is_windows) ? () : (-width=>8));
56 $widgets{op_titles}->Subwidget("yscrollbar")
57 ->configure(-background=>$config{colors}{background},
58 ($is_windows) ? () : (-width=>8));
59
60
61 ## data and background files
62 my $fr = $c -> Frame()
63 -> pack(-side=>'top', -fill=>'x', -padx=>12, -pady=>0);
64 my $t = $fr -> Label(-text=>"Data file", @start,
65 -font=>$config{fonts}{bold},)
66 -> pack(-side=>'left');
67 &click_help($t);
68 push @op_text, $t;
69 $widgets{op_file} = $fr -> Entry(-relief=>'groove',
70 -width=>43,
71 -borderwidth=>2,
72 -foreground=>$config{colors}{foreground},
73 -background => $config{colors}{background2},
74 ($Tk::VERSION > 804) ? (-disabledforeground=>$config{colors}{foreground}) : (),
75 )
76 -> pack(-side=>'right', -fill=>'x', -expand=>1, -padx=>4, -pady=>2);
77 $widgets{op_file} -> configure(-state=>'disabled');
78
79 $temp{data_showing} = "chi";
80 $fr = $c -> Frame();
81 #$fr -> pack(-side=>'top', -padx=>6, -pady=>0,);
82 $widgets{show_chi} = $fr -> Radiobutton(-text => 'Show chi(k)',
83 -value => 'chi',
84 -variable => \$temp{data_showing},
85 -state => 'disabled',
86 -command => sub{
87 $widgets{mu_frame} -> packForget;
88 $widgets{chi_frame} -> pack(-side=>'top', -padx=>6, -pady=>0,);
89 })
90 -> pack(-side=>'left', -padx=>6);
91 $widgets{show_mu} = $fr -> Radiobutton(-text => 'Show mu(E)',
92 -value => 'mu',
93 -variable => \$temp{data_showing},
94 -state => 'disabled',
95 -command => sub{
96 $widgets{chi_frame} -> packForget;
97 $widgets{mu_frame} -> pack(-side=>'top', -padx=>6, -pady=>0,);
98 })
99 -> pack(-side=>'left', -padx=>6);
100
101 $widgets{mu_frame} = $c -> Frame();
102 $widgets{chi_frame} = $c -> Frame()
103 -> pack(-side=>'top', -padx=>6, -pady=>0,);
104 $fr = $widgets{chi_frame} -> Frame()
105 -> pack(-side=>'top');
106 my $left = $fr -> LabFrame(-label => 'Data controls',
107 -font => $config{fonts}{med},
108 -foreground => $config{colors}{activehighlightcolor},
109 -labelside => 'acrosstop',
110 -width => 14)
111 -> pack(-side=>'left', -padx=>4, -fill=>'x', -anchor=>'n');
112 &labframe_help($left);
113 push @op_text, $left;
114 $widgets{controls_frame} = $left;
115 $widgets{op_include} = $left -> Checkbutton(-text=>'Include in the fit',
116 -foreground=>$config{colors}{foreground},
117 -activeforeground=>$config{colors}{foreground},
118 -selectcolor=>$config{colors}{check},
119 -font=>$config{fonts}{med},
120 -variable=>\$temp{op_include},
121 -onvalue=>1, -offvalue=>0,
122 -command=>
123 sub{my $this = $paths{$current}->data;
124 $paths{$this}->make(include=>$temp{op_include});
125 &toggle_data($this);
126 project_state(0);
127 },
128 )
129 -> pack(-side=>'top', -anchor=>'w');
130 $widgets{op_plot} =
131 $left -> Checkbutton(-text=>'Plot after the fit',
132 -foreground=>$config{colors}{foreground},
133 -activeforeground=>$config{colors}{foreground},
134 -selectcolor=>$config{colors}{check},
135 -font=>$config{fonts}{med},
136 -variable=>\$temp{op_plot},
137 -onvalue=>1, -offvalue=>0,
138 -command=>
139 sub{my $this = $paths{$current}->data;
140 $paths{$this}->make(plot=>$temp{op_plot});
141 project_state(0);
142 #my @all = &all_data;
143 #if ($#all == 1) {
144 # foreach my $d (@all) {
145 # next if ($d eq $this);
146 # $paths{$d}->make(plot=>abs($temp{op_plot}-1));
147 # };
148 #} else {
149 # foreach my $d (@all) {
150 # next if ($d eq $this);
151 # $paths{$d}->make(plot=>0);
152 # };
153 #};
154 },
155 )
156 -> pack(-side=>'top', -anchor=>'w');
157
158 $widgets{op_do_bkg} = $left -> Checkbutton(-text=>'Fit background',
159 -foreground=>$config{colors}{foreground},
160 -activeforeground=>$config{colors}{foreground},
161 -selectcolor=>$config{colors}{check},
162 -font=>$config{fonts}{med},
163 -variable=>\$temp{op_do_bkg},
164 -onvalue=>"yes", -offvalue=>'no',
165 -command=>
166 sub{my $this = $paths{$current}->data;
167 $paths{$this}->make(do_bkg=>$temp{op_do_bkg});
168 project_state(0);
169 },
170 )
171 -> pack(-side=>'top', -anchor=>'w');
172
173
174
175
176
177
178
179 ## k parameters
180 $fr = $fr -> LabFrame(-label => 'Fourier and fit parameters',
181 -font => $config{fonts}{med},
182 -foreground => $config{colors}{activehighlightcolor},
183 -labelside => 'acrosstop',
184 -width => 14)
185 -> pack(-side=>'right', -padx=>4, -fill=>'x', -anchor=>'n');
186 &labframe_help($fr);
187 push @op_text, $fr;
188
189 $t = $fr -> Label(@start, -text=>'k-range')
190 -> grid(-column=>0, -row=>0, -sticky=>'w', -padx=>2);
191 &click_help($t);
192 push @op_text, $t;
193 $widgets{op_kmin} = $fr -> Entry(-width=>6,
194 -validate=>'key',
195 -validatecommand=>[\&set_opparam, 'kmin'])
196 -> grid(-column=>1, -row=>0, -sticky=>'w');
197 $grab{op_kmin} = $fr -> Button(@pluck_button, @pluck,
198 -command=>[\&pluck, 'op_kmin'])
199 -> grid(-column=>2, -row=>0, -sticky=>'w');
200 $t = $fr -> Label(@start, -text=>' to ')
201 -> grid(-column=>3, -row=>0, -sticky=>'w', -padx=>2);
202 push @op_text, $t;
203 $widgets{op_kmax} = $fr -> Entry(-width=>6,
204 -validate=>'key',
205 -validatecommand=>[\&set_opparam, 'kmax'])
206 -> grid(-column=>4, -row=>0, -sticky=>'w');
207 $grab{op_kmax} = $fr -> Button(@pluck_button, @pluck,
208 -command=>[\&pluck, 'op_kmax'])
209 -> grid(-column=>5, -row=>0, -sticky=>'w');
210
211 ## R parameters
212 $t = $fr -> Label(@start, -text=>'R-range')
213 -> grid(-column=>0, -row=>1, -sticky=>'w', -padx=>2);
214 &click_help($t);
215 push @op_text, $t;
216 $widgets{op_rmin} = $fr -> Entry(-width=>6,
217 -validate=>'key',
218 -validatecommand=>[\&set_opparam, 'rmin'])
219 -> grid(-column=>1, -row=>1, -sticky=>'w');
220 $grab{op_rmin} = $fr -> Button(@pluck_button, @pluck,
221 -command=>[\&pluck, 'op_rmin'])
222 -> grid(-column=>2, -row=>1, -sticky=>'w');
223 $t = $fr -> Label(@start, -text=>' to ')
224 -> grid(-column=>3, -row=>1, -sticky=>'w', -padx=>2);
225 push @op_text, $t;
226 $widgets{op_rmax} = $fr -> Entry(-width=>6,
227 -validate=>'key',
228 -validatecommand=>[\&set_opparam, 'rmax'])
229 -> grid(-column=>4, -row=>1, -sticky=>'w');
230 $grab{op_rmax} = $fr -> Button(@pluck_button, @pluck,
231 -command=>[\&pluck, 'op_rmax'])
232 -> grid(-column=>5, -row=>1, -sticky=>'w');
233
234 $t = $fr -> Label(@start, -text=>'dk')
235 -> grid(-column=>0, -row=>2, -padx=>2);
236 &click_help($t);
237 push @op_text, $t;
238 $widgets{op_dk} = $fr -> Entry(-width=>6,
239 -validate=>'key',
240 -validatecommand=>[\&set_opparam, 'dk'])
241 -> grid(-column=>1, -row=>2, -sticky=>'w');
242 $t = $fr -> Label(@start, -text=>'dr')
243 -> grid(-column=>3, -row=>2, -padx=>2);
244 &click_help($t);
245 push @op_text, $t;
246 $widgets{op_dr} = $fr -> Entry(-width=>6,
247 -validate=>'key',
248 -validatecommand=>[\&set_opparam, 'dr'])
249 -> grid(-column=>4, -row=>2, -sticky=>'w');
250
251 $t = $fr -> Label(@start, -text=>'k window')
252 -> grid(-column=>0, -row=>3, -sticky=>'e', -columnspan=>2, -padx=>2);
253 &click_help($t);
254 push @op_text, $t;
255 $widgets{op_kwindow} = $fr -> Optionmenu(-textvariable => \$temp{op_kwindow},
256 -borderwidth=>1)
257 -> grid(-column=>2, -row=>3, -sticky=>'w', -columnspan=>4, -pady=>2);
258 foreach my $i ($paths{data0}->Windows) {
259 my $l = ucfirst($i);
260 ($i eq "kaiser-bessel") and ($l = "Kaiser-Bessel");
261 $widgets{op_kwindow} -> command(-label => $l,
262 -command=>
263 sub {
264 my $this = $paths{$current}->data;
265 $paths{$this}->make(kwindow=>$i);
266 &toggle_do('r');
267 $temp{op_kwindow} = ucfirst($l);
268 ($temp{op_kwindow} eq "kaiser-bessel") and
269 ($temp{op_kwindow} = "Kaiser-Bessel");
270 project_state(0);
271 });
272 };
273 $t = $fr -> Label(@start, -text=>'R window')
274 -> grid(-column=>0, -row=>4, -sticky=>'e', -columnspan=>2, -padx=>2);
275 &click_help($t);
276 push @op_text, $t;
277 $widgets{op_rwindow} = $fr -> Optionmenu(-textvariable => \$temp{op_rwindow},
278 -borderwidth=>1,)
279 -> grid(-column=>2, -row=>4, -sticky=>'w', -columnspan=>4);
280 foreach my $i ($paths{data0}->Windows) { #($setup->Windows) {
281 my $l = ucfirst($i);
282 ($i eq "kaiser-bessel") and ($l = "Kaiser-Bessel");
283 $widgets{op_rwindow} -> command(-label => $l,
284 -command=>
285 sub{
286 my $this = $paths{$current}->data;
287 $paths{$this}->make(rwindow=>$i);
288 &toggle_do('q');
289 $temp{op_rwindow} = ucfirst($l);
290 ($temp{op_rwindow} eq "kaiser-bessel") and
291 ($temp{op_rwindow} = "Kaiser-Bessel");
292 project_state(0);
293 })
294 };
295
296
297
298 ## k-weighting
299 $fr = $widgets{chi_frame} -> Frame()
300 -> pack(-side=>'bottom', -padx=>12, -pady=>4);
301
302 ## fitting space and other fit params
303 $left = $fr -> LabFrame(-label => 'Other parameters',
304 -font => $config{fonts}{med},
305 -foreground => $config{colors}{activehighlightcolor},
306 -labelside => 'acrosstop',
307 -width => 14)
308 -> pack(-side=>'left', -padx=>4, -fill=>'x', -anchor=>'n');
309 &labframe_help($left);
310 push @op_text, $left;
311 my $inner = $left -> Frame()
312 -> pack(-side=>'top', -fill=>'x', -padx=>2, -pady=>2);
313 $t = $inner -> Label(@start, -text=>'Fitting space ',)
314 -> pack(-side=>'left', -padx=>2);
315 &click_help($t);
316 push @op_text, $t;
317 $widgets{op_fitspace} = $inner -> Optionmenu(-textvariable => \$temp{op_fitspace},
318 -borderwidth=>1,)
319 -> pack(-side=>'left');
320 foreach my $i (qw(k R q)) {
321 $widgets{op_fitspace} -> command(-label => $i,
322 -command=>sub{my $curr;
323 ($current =~ /(\d+)$/) and ($curr = $1);
324 foreach my $d (&every_data) {
325 $paths{$d}->make(fit_space=>$i);
326 };
327 project_state(0);
328 $temp{op_fitspace} = $i; })
329 };
330 $t = $inner -> Label(-text=>' ',)
331 -> pack(-side=>'left');
332 $t = $inner -> Label(-text=>'Epsilon ', @start,)
333 -> pack(-side=>'left', -padx=>0);
334 &click_help($t);
335 push @op_text, $t;
336 $widgets{op_epsilon_k} = $inner -> Entry(-width=>6,
337 -validate=>'key',
338 -validatecommand=>[\&set_opparam, 'epsilon_k'])
339 -> pack(-side=>'left');
340
341 $inner = $left -> Frame()
342 -> pack(-side=>'top', -fill=>'x', -padx=>2, -pady=>2);
343 $t = $inner -> Label(@start, -text=>'Minimum reported correlation ')
344 -> pack(-side=>'left', -padx=>2);
345 &click_help($t);
346 push @op_text, $t;
347 $widgets{op_cormin} = $inner -> Entry(-width=>6,
348 -validate=>'key',
349 -validatecommand=>[\&set_opparam, 'cormin'])
350 -> pack(-side=>'left');
351
352
353 ## phase corrections and epsilon_k
354 $t = $left -> Label(@start, -text=>'Path to use for phase corrections ',)
355 -> pack(-side=>'top', -anchor=>'w', -padx=>2);
356 &click_help($t);
357 push @op_text, $t;
358 $widgets{op_pcpath} = $left -> Optionmenu(-textvariable => \$temp{op_pcpath_label},
359 -borderwidth=>1,)
360 -> pack(-side=>'top', -anchor=>'e', -padx=>5);
361
362 $widgets{help_op} = $left -> Button(-text => "Document: Fitting parameters", @button2_list,
363 -command=>sub{pod_display("artemis_opparams.pod")},
364 )
365 -> pack(-side=>'bottom', -padx=>2, -fill=>'x', -pady=>2);
366
367
368
369
370 my $right = $fr -> LabFrame(-label => 'Fit k-weights',
371 -font => $config{fonts}{med},
372 -foreground => $config{colors}{activehighlightcolor},
373 -labelside => 'acrosstop',
374 -width => 14)
375 -> pack(-side=>'right', -padx=>4, -fill=>'x', -anchor=>'n');
376 &labframe_help($right);
377 push @op_text, $right;
378 $widgets{op_k1} = $right ->
379 Checkbutton(-text=>'kw=1',
380 -foreground=>$config{colors}{foreground},
381 -activeforeground=>$config{colors}{foreground},
382 -selectcolor=>$config{colors}{check},
383 -font=>$config{fonts}{med},
384 -variable=>\$temp{op_k1},
385 -onvalue=>1, -offvalue=>0,
386 -command=>
387 sub{
388 $paths{$current}->make(k1=>$temp{op_k1});
389 project_state(0);
390 }
391 )
392 -> pack(-side=>'top', -anchor=>'w');
393 $widgets{op_k2} = $right ->
394 Checkbutton(-text=>'kw=2',
395 -foreground=>$config{colors}{foreground},
396 -activeforeground=>$config{colors}{foreground},
397 -selectcolor=>$config{colors}{check},
398 -font=>$config{fonts}{med},
399 -variable=>\$temp{op_k2},
400 -onvalue=>1, -offvalue=>0,
401 -command=>
402 sub{
403 $paths{$current}->make(k2=>$temp{op_k2});
404 project_state(0);
405 }
406 )
407 -> pack(-side=>'top', -anchor=>'w');
408 $widgets{op_k3} = $right ->
409 Checkbutton(-text=>'kw=3',
410 -foreground=>$config{colors}{foreground},
411 -activeforeground=>$config{colors}{foreground},
412 -selectcolor=>$config{colors}{check},
413 -font=>$config{fonts}{med},
414 -variable=>\$temp{op_k3},
415 -onvalue=>1, -offvalue=>0,
416 -command=>
417 sub{
418 $paths{$current}->make(k3=>$temp{op_k3});
419 project_state(0);
420 }
421 )
422 -> pack(-side=>'top', -anchor=>'w');
423 $widgets{op_karb_use} = $right ->
424 Checkbutton(-text=>'other k weight',
425 -foreground=>$config{colors}{foreground},
426 -activeforeground=>$config{colors}{foreground},
427 -selectcolor=>$config{colors}{check},
428 -font=>$config{fonts}{med},
429 -variable=>\$temp{op_karb_use},
430 -onvalue=>1, -offvalue=>0,
431 -command=>
432 sub{
433 $widgets{op_karb} ->
434 configure(-state=>$temp{op_karb_use} ? 'normal' : 'disabled');
435 $paths{$current}->make(karb_use=>$temp{op_karb_use});
436 project_state(0);
437 }
438 )
439 -> pack(-side=>'top', -anchor=>'w');
440 $widgets{op_karb} = $right -> Entry(-width=>6,
441 -validate=>'key',
442 -validatecommand=>[\&set_opparam, 'karb'])
443 -> pack(-side=>'right', -anchor=>'se');
444
445
446 ## fill in the mu(E) tab
447 $fr = $widgets{mu_frame} -> LabFrame(-label => 'Background Removal Parameters',
448 -font => $config{fonts}{med},
449 -foreground => $config{colors}{activehighlightcolor},
450 -labelside => 'acrosstop',)
451 -> pack(-fill=>'x', -anchor=>'n', -pady=>2);
452 $fr -> Label(@start, -text=>'E0')
453 -> grid(-row=>0, -column=>0, -sticky=>'e');
454 $widgets{bkg_e0} = $fr -> Entry(-width=>9,
455 -validate=>'key',
456 -validatecommand=>[\&set_opparam, 'bkg_e0'])
457 -> grid(-row=>0, -column=>1, -sticky=>'w');
458
459 $fr -> Label(@start, -text=>'E shift')
460 -> grid(-row=>0, -column=>3, -sticky=>'e');
461 $widgets{bkg_eshift} = $fr -> Entry(-width=>9,
462 -validate=>'key',
463 -validatecommand=>[\&set_opparam, 'bkg_eshift'])
464 -> grid(-row=>0, -column=>4, -sticky=>'w');
465
466 $fr -> Label(@start, -text=>'Rbkg')
467 -> grid(-row=>1, -column=>0, -sticky=>'e');
468 $widgets{bkg_rbkg} = $fr -> Entry(-width=>9,
469 -validate=>'key',
470 -validatecommand=>[\&set_opparam, 'bkg_rbkg'])
471 -> grid(-row=>1, -column=>1, -sticky=>'w');
472
473 $fr -> Label(@start, -text=>'kw')
474 -> grid(-row=>2, -column=>0, -sticky=>'e');
475 $widgets{bkg_kw} = $fr -> Entry(-width=>9,
476 -validate=>'key',
477 -validatecommand=>[\&set_opparam, 'bkg_kw'])
478 -> grid(-row=>2, -column=>1, -sticky=>'w');
479
480 $fr -> Label(@start, -text=>'step')
481 -> grid(-row=>2, -column=>3, -sticky=>'e');
482 $widgets{bkg_step} = $fr -> NumEntry(-width=>6,
483 -orient=>'horizontal',
484 -increment=>0.1)
485 -> grid(-row=>2, -column=>4, -sticky=>'w');
486 $widgets{bkg_fixstep} = $fr -> Checkbutton(-text=>'fix step',
487 -foreground=>$config{colors}{foreground},
488 -activeforeground=>$config{colors}{foreground},
489 -selectcolor=>$config{colors}{check},
490 -font=>$config{fonts}{med},
491 -variable=>\$temp{bkg_fixstep},
492 -onvalue=>1, -offvalue=>0,
493 -command=> sub{ $paths{$current}->make(bkg_fixstep=>$temp{bkg_fixstep});
494 project_state(0);
495 },
496 )
497 -> grid(-row=>2, -column=>5, -sticky=>'w');
498 $widgets{bkg_flatten} = $fr -> Checkbutton(-text=>'flatten',
499 -foreground=>$config{colors}{foreground},
500 -activeforeground=>$config{colors}{foreground},
501 -selectcolor=>$config{colors}{check},
502 -font=>$config{fonts}{med},
503 -variable=>\$temp{bkg_flatten},
504 -onvalue=>1, -offvalue=>0,
505 -command=> sub{ $paths{$current}->make(bkg_flatten=>$temp{bkg_flatten});
506 project_state(0);
507 },
508 )
509 -> grid(-row=>1, -column=>5, -sticky=>'w');
510
511
512 $fr -> Label(@start, -text=>'Pre-edge')
513 -> grid(-row=>3, -column=>0, -sticky=>'e');
514 $widgets{bkg_pre1} = $fr -> Entry(-width=>9,
515 -validate=>'key',
516 -validatecommand=>[\&set_opparam, 'bkg_pre1'])
517 -> grid(-row=>3, -column=>1, -sticky=>'w');
518 $grab{bkg_pre1} = $fr -> Button(@pluck_button, @pluck,
519 #-command=>[\&pluck, 'op_rmax']
520 )
521 -> grid(-row=>3, -column=>2, -sticky=>'w');
522 $fr -> Label(@start, -text=>' to ')
523 -> grid(-row=>3, -column=>3, -sticky=>'e');
524 $widgets{bkg_pre2} = $fr -> Entry(-width=>9,
525 -validate=>'key',
526 -validatecommand=>[\&set_opparam, 'bkg_pre2'])
527 -> grid(-row=>3, -column=>4, -sticky=>'w');
528 $grab{bkg_pre2} = $fr -> Button(@pluck_button, @pluck,
529 #-command=>[\&pluck, 'op_rmax']
530 )
531 -> grid(-row=>3, -column=>5, -sticky=>'w');
532
533 $fr -> Label(@start, -text=>'Normalization')
534 -> grid(-row=>4, -column=>0, -sticky=>'e');
535 $widgets{bkg_nor1} = $fr -> Entry(-width=>9,
536 -validate=>'key',
537 -validatecommand=>[\&set_opparam, 'bkg_nor1'])
538 -> grid(-row=>4, -column=>1, -sticky=>'w');
539 $grab{bkg_nor1} = $fr -> Button(@pluck_button, @pluck,
540 #-command=>[\&pluck, 'op_rmax']
541 )
542 -> grid(-row=>4, -column=>2, -sticky=>'w');
543 $fr -> Label(@start, -text=>' to ')
544 -> grid(-row=>4, -column=>3, -sticky=>'e');
545 $widgets{bkg_nor2} = $fr -> Entry(-width=>9,
546 -validate=>'key',
547 -validatecommand=>[\&set_opparam, 'bkg_nor2'])
548 -> grid(-row=>4, -column=>4, -sticky=>'w');
549 $grab{bkg_nor2} = $fr -> Button(@pluck_button, @pluck,
550 #-command=>[\&pluck, 'op_rmax']
551 )
552 -> grid(-row=>4, -column=>5, -sticky=>'w');
553
554 $fr -> Label(@start, -text=>'Spline')
555 -> grid(-row=>5, -column=>0, -sticky=>'e');
556 $widgets{bkg_spl1} = $fr -> Entry(-width=>9,
557 -validate=>'key',
558 -validatecommand=>[\&set_opparam, 'bkg_spl1'])
559 -> grid(-row=>5, -column=>1, -sticky=>'w');
560 $grab{bkg_spl1} = $fr -> Button(@pluck_button, @pluck,
561 #-command=>[\&pluck, 'op_rmax']
562 )
563 -> grid(-row=>5, -column=>2, -sticky=>'w');
564 $fr -> Label(@start, -text=>' to ')
565 -> grid(-row=>5, -column=>3, -sticky=>'e');
566 $widgets{bkg_spl2} = $fr -> Entry(-width=>9,
567 -validate=>'key',
568 -validatecommand=>[\&set_opparam, 'bkg_spl2'])
569 -> grid(-row=>5, -column=>4, -sticky=>'w');
570 $grab{bkg_spl2} = $fr -> Button(@pluck_button, @pluck,
571 #-command=>[\&pluck, 'op_rmax']
572 )
573 -> grid(-row=>5, -column=>5, -sticky=>'w');
574
575 $fr -> Label(@start, -text=>'High end clamp')
576 -> grid(-row=>6, -column=>0, -sticky=>'e');
577 $widgets{bkg_clamp2} = $fr -> Optionmenu(-options => ['None', 'Slight', 'Weak', 'Medium', 'Strong', 'Rigid'],
578 -command => sub{ $paths{$current}->make(bkg_clamp2=>$temp{bkg_clamp2}, do_xmu=>1);
579 project_state(0);
580 },
581 -textvariable => \$temp{bkg_clamp2},
582 )
583 -> grid(-row=>6, -column=>1, -columnspan=>2, -sticky=>'w');
584
585
586
587 # $fr = $widgets{mu_frame} -> LabFrame(-label=>'mu(E) plot controls',
588 # -font=>$config{fonts}{med},
589 # -foreground=>$config{colors}{activehighlightcolor},
590 # -labelside=>'acrosstop',)
591 $fr = $widgets{mu_frame} -> Frame(-borderwidth => 2,
592 -relief => 'groove')
593 -> pack(-anchor=>'n', -pady=>0);
594
595 $fr -> Checkbutton(-text=>'mu(E) data')
596 -> grid(-column=>0, -row=>0, -sticky=>'w');
597 $fr -> Checkbutton(-text=>'background')
598 -> grid(-column=>1, -row=>0, -sticky=>'w');
599 $fr -> Checkbutton(-text=>'pre edge line')
600 -> grid(-column=>0, -row=>1, -sticky=>'w');
601 $fr -> Checkbutton(-text=>'post edge line')
602 -> grid(-column=>1, -row=>1, -sticky=>'w');
603 $fr -> Checkbutton(-text=>'normalized')
604 -> grid(-column=>0, -row=>2, -sticky=>'w');
605 $fr -> Checkbutton(-text=>'derivative')
606 -> grid(-column=>1, -row=>2, -sticky=>'w');
607 $fr -> Button(-text=>'Plot in energy', -width=>20, @button_list)
608 -> grid(-column=>2, -row=>0, -sticky=>'ew');
609 $fr -> Button(-text=>'Save chi(k)', -width=>20, @button_list)
610 -> grid(-column=>2, -row=>2, -sticky=>'ew');
611
612 return $c;
613 };
614
615 sub pluck {
616 my $widg = $_[0];
617 my $parent = $_[1] || $top;
618 Echo("You have not made a plot yet."), return 0
619 unless ($last_plot);
620
621 if (($last_plot eq 'r') and ($widg =~ /^op_k/)) {
622 Echo("You cannot pluck an k value from the last plot, which was an R plot.");
623 return 0;
624 } elsif (($last_plot eq 'k') and ($widg =~ /^op_r/)) {
625 Echo("You cannot pluck an R value from the last plot, which was an k plot.");
626 return 0;
627 } elsif (($last_plot eq 'q') and ($widg =~ /^op_r/)) {
628 Echo("You cannot pluck an R value from the last plot, which was an q plot.");
629 return 0;
630 };
631 Echo("Select a value for $widg from the plot...");
632 my ($cursor_x, $cursor_y) = (0,0);
633 $grab{$widg} -> grab();
634 $top -> Busy();
635 my $data = &first_data;
636 $paths{$data}->dispose("cursor(crosshair=true)\n", 1);
637 ($cursor_x, $cursor_y) = (Ifeffit::get_scalar("cursor_x"),
638 Ifeffit::get_scalar("cursor_y"));
639 $top -> Unbusy;
640 $grab{$widg} -> grabRelease();
641 my $value = sprintf("%.3f", $cursor_x);
642 my $which = substr($widg, 3);
643 set_opparam($which, $value, 1);
644 #Echo("Plucked the value of $value for " . (split(/_/, $widg))[1] );
645 $widgets{$widg} -> configure(-validate=>'none');
646 $widgets{$widg} -> delete(qw/0 end/);
647 $widgets{$widg} -> insert(0, $value);
648 $widgets{$widg} -> configure(-validate=>'key');
649 return 1;
650 };
651
652
653 ## lab frame labels...
654 sub click_help {
655 my $t = shift;
656 my $text = $t->cget('-text');
657 $text =~ s/\s+$//;
658
659 ## don't post mouse-3 menu for some parameters
660 my $skip = ($text =~ /^(Data|Epsilon|Path)/);
661
662 my @bold = (-foreground => $config{colors}{mbutton},
663 -background => $config{colors}{activebackground},
664 -cursor => $mouse_over_cursor,
665 -font => ($text =~ /Data file/) ? $config{fonts}{bold} : $config{fonts}{med});
666 my @normal = (-foreground => $config{colors}{activehighlightcolor},
667 -background => $config{colors}{background},
668 -font => ($text =~ /Data file/) ? $config{fonts}{bold} : $config{fonts}{med});
669 my @nodata = (-foreground => $config{colors}{activehighlightcolor},
670 -background => $config{colors}{background},
671 -font => ($text =~ /Data file/) ? $config{fonts}{bold} : $config{fonts}{med});
672
673 $t -> bind("<Any-Enter>", sub {shift->configure(@bold)});
674 $t -> bind("<Any-Leave>", sub {my $tt=shift;
675 if ($n_data) {
676 $tt->configure(@normal);
677 } else {
678 $tt->configure(@nodata);
679 }
680 });
681
682 my $str = $click_help{$text} || "$text ???";
683 $t -> bind('<ButtonPress-1>' => sub{Echo("$str")});
684 $t -> bind("<ButtonPress-3>",
685 sub{ return unless $n_data;
686 my @every = &every_data;
687 my $menu=$top->Menu(-tearoff=>0,
688 -menuitems=>[(($text =~ /^(Minimum)/) ? () :
689 (["command"=>"Set all data sets to this value of \`$text\'",
690 -command => [\&constrain_param, $text, 'all'],
691 -state=>($#every)?'normal':'disabled'],
692 "-",
693 ["command"=>"Grab \`$text\' from previous data set",
694 -command => [\&constrain_param, $text, 'prev'],
695 -state=>($#every)?'normal':'disabled' ],
696 ["command"=>"Grab \`$text\' from next data set",
697 -command => [\&constrain_param, $text, 'next'],
698 -state=>($#every)?'normal':'disabled' ],
699 "-",)),
700 [ command => "Restore default value for \`$text\'",
701 -command => [\&restore_default, $text]],
702 ]);
703 $menu ->Popup(-popover=>'cursor', -popanchor=>'w');
704 })
705 unless $skip;
706 };
707
708 sub labframe_help {
709 my $lf = $_[0];
710 my $t = $lf->Subwidget("label");
711 my $text = $t->cget('-text');
712 $text =~ s/\s+$//;
713
714 my $skip = ($text !~ /^(Fit|Fourier|Space)/);
715
716 my @bold = (-foreground => $config{colors}{mbutton},
717 -cursor => $mouse_over_cursor,
718 );
719 my @normal = (-foreground => $config{colors}{activehighlightcolor},);
720 my @nodata = (-foreground => $config{colors}{activehighlightcolor},);
721
722 $t -> bind("<Any-Enter>", sub {shift->configure(@bold)});
723 $t -> bind("<Any-Leave>", sub {my $tt=shift;
724 if (($n_data) or ($text =~ /^Space/)) {
725 $tt->configure(@normal);
726 } else {
727 $tt->configure(@nodata);
728 }});
729 my $str = $click_help{$text} || "$text ???";
730 $t -> bind('<ButtonPress-1>' => sub{Echo("$str")});
731 $t -> bind("<ButtonPress-3>",
732 sub{ return unless $n_data;
733 my @every = &every_data;
734 my $menu=$top->Menu(-tearoff=>0,
735 -menuitems=>[["command"=>"Set all data sets to this value of \`$text\'",
736 -command => [\&constrain_param, $text, 'all'],
737 -state=>($#every)?'normal':'disabled'],
738 "-",
739 ["command"=>"Grab \`$text\' from previous data set",
740 -command => [\&constrain_param, $text, 'prev'],
741 -state=>($#every)?'normal':'disabled' ],
742 ["command"=>"Grab \`$text\' from next data set",
743 -command => [\&constrain_param, $text, 'next'],
744 -state=>($#every)?'normal':'disabled' ],
745 "-",
746 [ command => "Restore default value for \`$text\'",
747 -command => [\&restore_default, $text]],
748 ]);
749 $menu ->Popup(-popover=>'cursor', -popanchor=>'w');
750 })
751 unless $skip;
752
753 };
754
755
756 sub constrain_param {
757 my ($which, $how) = @_;
758 $which = lc($which);
759 my $this = $paths{$current}->data;
760 my @vars = ();
761 WHICH: {
762 @vars = (qw(kmin kmax)), last WHICH if ($which eq 'k-range');
763 @vars = (qw(rmin rmax)), last WHICH if ($which eq 'r-range');
764 @vars = (qw(dk)), last WHICH if ($which eq 'dk');
765 @vars = (qw(dr)), last WHICH if ($which eq 'dr');
766 @vars = (qw(kwindow)), last WHICH if ($which eq 'k window');
767 @vars = (qw(rwindow)), last WHICH if ($which eq 'r window');
768 @vars = (qw(pcpath)), last WHICH if ($which =~ /^Path/);
769 @vars = (qw(epsilon_k)), last WHICH if ($which eq 'epsilon');
770 @vars = (qw(k1 k2 k3 karb karb_use)),
771 last WHICH if ($which =~ /^fit/);
772 @vars = (qw(kmin kmax dk rmin rmax dr kwindow rwindow)),
773 last WHICH if ($which =~ /^fourier/);
774 };
775 HOW: {
776 ($how eq 'all') and do {
777 foreach my $d (&every_data) {
778 foreach my $v (@vars) {
779 next if ($d eq $this);
780 $paths{$d} -> make($v=>$paths{$this}->get($v));
781 };
782 };
783 &display_properties;
784 project_state(0);
785 Echo("Set \`$which\' for all data sets");
786 last HOW;
787 };
788 ($how eq 'next') and do {
789 my $found = 0;
790 my $next = "";
791 foreach my $d (sort(&all_data)) {
792 ($next = $d), last if $found;
793 ($found = 1) if ($d eq $this);
794 };
795 Error("This is the last data set"), last HOW unless $next;
796 foreach my $v (@vars) {
797 $paths{$this} -> make($v=>$paths{$next}->get($v));
798 };
799 &display_properties;
800 project_state(0);
801 Echo("Grabbed \`$which\' from the next data set");
802 last HOW;
803 };
804 ($how eq 'prev') and do {
805 my $found = 0;
806 my $prev = "";
807 foreach my $d (sort(&all_data)) {
808 last if ($d eq $this);
809 $prev = $d;
810 };
811 Error("This is the first data set"), last HOW unless $prev;
812 foreach my $v (@vars) {
813 $paths{$this} -> make($v=>$paths{$prev}->get($v));
814 };
815 &display_properties;
816 project_state(0);
817 Echo("Grabbed \`$which\' from the previous data set");
818 last HOW;
819 };
820 };
821
822 };
823
824
825 sub restore_default {
826 my $which = $_[0];
827 $which = lc($which);
828 my $this = $paths{$current}->data;
829 my @vars = ();
830 WHICH: {
831 @vars = (qw(kmin kmax)), last WHICH if ($which eq 'k-range');
832 @vars = (qw(rmin rmax)), last WHICH if ($which eq 'r-range');
833 @vars = (qw(dk)), last WHICH if ($which eq 'dk');
834 @vars = (qw(dr)), last WHICH if ($which eq 'dr');
835 @vars = (qw(kwindow)), last WHICH if ($which eq 'k window');
836 @vars = (qw(rwindow)), last WHICH if ($which eq 'r window');
837 @vars = (qw(fit_space)), last WHICH if ($which eq 'fitting space');
838 @vars = (qw(cormin)), last WHICH if ($which =~ /^minimum/);
839 #@vars = (qw(pcpath)), last WHICH if ($which =~ /^Path/);
840 @vars = (qw(k1 k2 k3 karb karb_use)),
841 last WHICH if ($which =~ /^fit/);
842 @vars = (qw(kmin kmax dk rmin rmax dr kwindow rwindow)),
843 last WHICH if ($which =~ /^fourier/);
844 @vars = (qw(kmin kmax rmin rmax dk dr kwindow rwindow k1 k2 k3 karb karb_use)),
845 last WHICH if ($which eq 'all');
846 };
847 foreach my $v (@vars) {
848 if ($v =~ /^k(1|2|3|arb(|_use))/) {
849 $temp{'op_'.$v} = ($v eq "k".$config{data}{kweight}) ? 1 : 0;
850 $paths{$this} -> make($v=>($v eq 'k1') ? 1 : 0);
851 $widgets{op_karb} -> delete(0,'end') if $v eq 'karb_use';
852 } else {
853 $paths{$this} -> make($v=>$config{data}{$v});
854 }
855 };
856 $paths{$this} -> fix_values;
857 &display_properties;
858 project_state(0);
859 ($which eq 'all') ? Echo("Restored all parameters to their defaults")
860 : Echo("Restored \`$which\' to it's default");
861 };
862
863
864 sub set_spline {
865 my $how = $_[0];
866 HOW: {
867 ($how eq 'allon') and do {
868 foreach my $d (&all_data) {
869 $paths{$d} -> make(do_bkg => 'yes');
870 };
871 &display_properties;
872 last HOW;
873 };
874 ($how eq 'alloff') and do {
875 foreach my $d (&all_data) {
876 $paths{$d} -> make(do_bkg => 'no');
877 };
878 &display_properties;
879 last HOW;
880 };
881 };
882 };
883
884 sub toggle_do {
885 my $sp = "do_" . $_[0];
886 my $this = $paths{$current}->data;
887 foreach my $k (keys %paths) {
888 next unless (ref($paths{$k}) =~ /Ifeffit/);
889 next unless ($k =~ /$this/);
890 $paths{$k} -> make($sp=>1);
891 };
892 };
893
894
895
896 sub set_plotoptions {
897
898 my $container = $_[0];
899 my %parts = (m=>'Magnitude', r=>'Real part', i=>'Imaginary part', p=>'Phase');
900
901 my $frm = $container -> Frame(-borderwidth=>2, -relief=>'groove')
902 -> pack(-fill=>'x', -anchor=>'w', -pady=>4);
903
904 $plot_features{r_pl} ||= 'm';
905 $plot_features{r_pl_label} = $parts{$plot_features{r_pl}};
906 $frm -> Label(-text => 'Plot in R: ',
907 -font => $config{fonts}{med},
908 -foreground => $config{colors}{activehighlightcolor})
909 -> grid(-row=>0, -column=>0, -sticky=>'e');
910 ## $widgets{plot_r} = $frm -> Optionmenu(-textvariable => \$plot_features{r_pl_label},
911 ## -width=>12,
912 ## -borderwidth=>1,)
913 ## -> grid(-row=>0, -column=>1, -sticky=>'w');
914 my $r = 0;
915 my @list = ($config{plot}{plot_phase}) ? (qw(m r i p)) : (qw(m r i));
916 foreach my $p (@list) {
917 $frm -> Radiobutton(-value => $p,
918 -font => $config{fonts}{med},
919 -text => $parts{$p},
920 -selectcolor=>$config{colors}{check},
921 -variable => \$plot_features{r_pl},
922 -command => sub{$plot_features{r_pl} = $p;
923 &plot('r', 0) }
924 )
925 -> grid(-row=>$r++, -column=>1, -sticky=>'w');
926 ## $widgets{plot_r} -> command(-label => $parts{$p},
927 ## -command=>sub{$plot_features{r_pl} = $p;
928 ## $plot_features{r_pl_label} = $parts{$p};
929 ## &plot('r', 0) }
930 ## );
931 };
932
933
934 $plot_features{q_pl} ||= 'r';
935 $plot_features{q_pl_label} = $parts{$plot_features{q_pl}};
936 $frm -> Label(-text => 'Plot in q: ',
937 -font => $config{fonts}{med},
938 -foreground => $config{colors}{activehighlightcolor})
939 -> grid(-row=>$r, -column=>0, -sticky=>'e');
940 foreach my $p (@list) {
941 $frm -> Radiobutton(-value => $p,
942 -font => $config{fonts}{med},
943 -text => $parts{$p},
944 -selectcolor=>$config{colors}{check},
945 -variable => \$plot_features{q_pl},
946 -command => sub{$plot_features{q_pl} = $p;
947 &plot('q', 0) }
948 )
949 -> grid(-row=>$r++, -column=>1, -sticky=>'w');
950 };
951
952 $plot_features{win} ||= 0;
953 $widgets{plot_win} = $container ->
954 Checkbutton(-text => 'Window',
955 -font => $config{fonts}{med},
956 -onvalue => 'w',
957 -offvalue => "",
958 -selectcolor => $config{colors}{check},
959 -foreground => $config{colors}{activehighlightcolor},
960 -activeforeground => $config{colors}{activehighlightcolor},
961 -variable => \$plot_features{win},
962 -command => sub{&plot($last_plot, 0)}
963 )
964 -> pack();
965 $widgets{plot_bkg} = $container ->
966 Checkbutton(-text => 'Background',
967 -font => $config{fonts}{med},
968 -onvalue => 'b',
969 -offvalue => "",
970 -selectcolor => $config{colors}{check},
971 -activeforeground => $config{colors}{activehighlightcolor},
972 -foreground => $config{colors}{activehighlightcolor},
973 -variable => \$plot_features{bkg},
974 -command => sub{&plot($last_plot, 0)}
975 )
976 -> pack();
977
978 $widgets{plot_res} = $container ->
979 Checkbutton(-text => 'Residual',
980 -font => $config{fonts}{med},
981 -onvalue => 'z',
982 -offvalue => "",
983 -selectcolor => $config{colors}{check},
984 -foreground => $config{colors}{activehighlightcolor},
985 -activeforeground => $config{colors}{activehighlightcolor},
986 -variable => \$plot_features{res},
987 -command => sub{&plot($last_plot, 0)}
988 )
989 -> pack();
990
991
992 $frm = $container -> Frame(-borderwidth=>2, -relief=>'flat')
993 -> pack(-side=>'top', -anchor=>'s');
994 $plot_features{kmin} ||= 0;
995 $plot_features{rmin} ||= 0;
996 $plot_features{qmin} ||= 0;
997 $plot_features{kmax} ||= 15;
998 $plot_features{rmax} ||= 6;
999 $plot_features{qmax} ||= 15;
1000 my $row = 0;
1001 foreach my $s (qw(k R q)) {
1002 $frm -> Label(-text => $s.'min:',
1003 -font => $config{fonts}{med},
1004 -foreground => $config{colors}{activehighlightcolor})
1005 -> grid(-row=>$row, -column=>0);
1006 $widgets{'plot_'.lc($s).'min'} = $frm ->
1007 Entry(-width=>5, -textvariable=>\$plot_features{lc($s).'min'}, -state=>'normal')
1008 -> grid(-row=>$row, -column=>1);
1009 $frm -> Label(-text => $s.'max:',
1010 -font => $config{fonts}{med},
1011 -foreground => $config{colors}{activehighlightcolor})
1012 -> grid(-row=>$row, -column=>2);
1013 $widgets{'plot_'.lc($s).'max'} = $frm ->
1014 Entry(-width=>5, -textvariable=>\$plot_features{lc($s).'max'}, -state=>'normal')
1015 -> grid(-row=>$row++, -column=>3);
1016 };
1017 };
1018
1019
1020 sub show_extra_plot {
1021 $widgets{plot_extra_button} -> packForget;
1022 $widgets{plot_extra_frame} -> pack(-fill => 'both', -side => 'top', -expand=>1);
1023 };
1024 sub remove_extra_plot {
1025 $widgets{plot_extra_frame} -> packForget;
1026 $widgets{plot_extra_button} -> pack(-fill => 'x', -side => 'bottom', -padx=>2, -pady=>4);
1027 };
1028
1029 sub setup_indicators {
1030 my @pluck_button = (-foreground => $config{colors}{highlightcolor},
1031 -activeforeground => $config{colors}{activehighlightcolor},
1032 -background => $config{colors}{background},
1033 -activebackground => $config{colors}{activebackground});
1034 my $pluck_bitmap = '#define pluck_width 9
1035 #define pluck_height 9
1036 static unsigned char pluck_bits[] = {
1037 0x81, 0x01, 0xc3, 0x00, 0x66, 0x00, 0x3c, 0x00, 0x38, 0x00, 0x78, 0x00,
1038 0xcc, 0x00, 0x86, 0x01, 0x03, 0x01};
1039 ';
1040 my $pluck_X = $top -> Bitmap('pluck', -data=>$pluck_bitmap,
1041 -foreground=>$config{colors}{activehighlightcolor});
1042 my @pluck=(-image=>$pluck_X);
1043 my $frame = $widgets{plot_Ind} -> Frame() -> pack(-anchor=>'n', -fill=>'both');
1044 $frame -> Label(-text=>"Plot indicators",
1045 -font=>$config{fonts}{bold},
1046 -foreground=>$config{colors}{activehighlightcolor})
1047 -> pack(-side=>'top');
1048 $extra[5] = 0;
1049 $frame -> Checkbutton(-text=>'Display indicators',
1050 -selectcolor=>$config{colors}{check},
1051 -variable=>\$extra[5])
1052 -> pack(-expand=>1, -fill=>'x', -side=>'top', -anchor=>'n');
1053 ## my $t = $frame -> Scrolled('Pane',
1054 ## -scrollbars => 'oe',
1055 ## -width => 1,
1056 ## -height => 1,
1057 ## -borderwidth => 0,
1058 ## -relief => 'flat')
1059 my $t = $frame -> Frame()
1060 -> pack(-expand=>1, -fill=>'both', -side=>'top', -padx=>3, -pady=>3, -anchor=>'n');
1061 ## $t -> Subwidget("yscrollbar")
1062 ## -> configure(-background=>$config{colors}{background},
1063 ## ($is_windows) ? () : (-width=>9));
1064 #BindMouseWheel($t);
1065 #&disable_mouse3($t->Subwidget('rotext'));
1066 foreach my $r (7 .. $config{plot}{nindicators}+6) {
1067 $extra[$r] = ["", " ", " "];
1068 my $rr = $r-6;
1069 $t -> Label(-text=>$rr.":", -foreground=>$config{colors}{activehighlightcolor})
1070 -> grid(-row=>$r, -column=>0, -ipadx=>3);
1071 $t -> Label(-textvariable=>\$extra[$r][1],
1072 -width=>3)
1073 -> grid(-row=>$r, -column=>1);
1074 my $this = $t -> Entry(-width => 10,
1075 -textvariable => \$extra[$r][2],
1076 -validate => 'key',
1077 -validatecommand => [\&set_opparam, "extra"],
1078 )
1079 -> grid(-row=>$r, -column=>2);
1080 $extra[$r][0] = $t -> Button(@pluck_button, @pluck, -command=>sub{&indicator_pluck($r)})
1081 -> grid(-row=>$r, -column=>3);
1082 };
1083 };
1084 sub indicator_pluck {
1085 my $which = $_[0];
1086 Error("You have not made a plot yet."), return 0 unless ($last_plot);
1087
1088 Echo("Select a point from the plot...");
1089 my ($cursor_x, $cursor_y) = (0,0);
1090 $extra[$which][0] -> grab();
1091 $paths{data0}->dispose("cursor(crosshair=true)\n", $dmode);
1092 ($cursor_x, $cursor_y) = (Ifeffit::get_scalar("cursor_x"),
1093 Ifeffit::get_scalar("cursor_y"));
1094 $paths{data0}->dispose("\n", $dmode);
1095 $extra[$which][0] -> grabRelease();
1096 $extra[$which][1] = ($last_plot =~ /[kq]/) ? $last_plot : uc($last_plot);
1097 $extra[$which][2] = sprintf("%.3f", $cursor_x);
1098 Echo("Made an indicator at $extra[$which][2] in $extra[$which][1]");
1099 #$Data::Dumper::Indent = 2;
1100 #print Data::Dumper->Dump([\@extra], [qw(extra)]);
1101 #$Data::Dumper::Indent = 0;
1102 };
1103
1104 sub setup_stack {
1105 my $frame = $widgets{plot_Sta} -> Frame(-borderwidth=>2, -relief=>'ridge')
1106 -> pack(-anchor=>'n', -fill=>'x', -side=>'top');
1107 $frame -> Label(-text=>"Stack plots",
1108 -font=>$config{fonts}{bold},
1109 -foreground=>$config{colors}{activehighlightcolor})
1110 -> grid(-row=>0, -column=>0, -columnspan=>2, -sticky=>'ew');
1111 $frame -> Radiobutton(-text => 'Never',
1112 -font => $config{fonts}{med},
1113 -selectcolor=>$config{colors}{check},
1114 #-width => 12,
1115 -variable => \$extra[0],
1116 -value => 0)
1117 -> grid(-row=>1, -column=>0, -columnspan=>2, -sticky=>'w');
1118 $frame -> Radiobutton(-text => 'Only chi(k)',
1119 -font => $config{fonts}{med},
1120 -selectcolor=>$config{colors}{check},
1121 #-width => 12,
1122 -variable => \$extra[0],
1123 -value => 1)
1124 -> grid(-row=>2, -column=>0, -columnspan=>2, -sticky=>'w');
1125 $frame -> Radiobutton(-text => 'Always',
1126 -font => $config{fonts}{med},
1127 -selectcolor=>$config{colors}{check},
1128 #-width => 12,
1129 -variable => \$extra[0],
1130 -value => 2)
1131 -> grid(-row=>3, -column=>0, -columnspan=>2, -sticky=>'w');
1132 $frame -> Label(-text => 'Starting value:',
1133 -font => $config{fonts}{med},)
1134 -> grid(-row=>4, -column=>0, -sticky=>'e');
1135 $frame -> Entry(-width => 8,
1136 -textvariable => \$extra[1],
1137 -validate => 'key',
1138 -validatecommand => [\&set_opparam, 'extra'])
1139 -> grid(-row=>4, -column=>1, -sticky=>'w');
1140 $frame -> Label(-text => 'Increment:',
1141 -font => $config{fonts}{med},)
1142 -> grid(-row=>5, -column=>0, -sticky=>'e');
1143 $frame -> Entry(-width => 8,
1144 -textvariable => \$extra[2],
1145 -validate => 'key',
1146 -validatecommand => [\&set_opparam, 'extra'])
1147 -> grid(-row=>5, -column=>1, -sticky=>'w');
1148
1149 ## invert
1150 $frame = $widgets{plot_Sta} -> Frame(-borderwidth=>2, -relief=>'ridge')
1151 -> pack(-anchor=>'n', -fill=>'x', -side=>'top');
1152 $frame -> Label(-text=>"Invert paths",
1153 -font=>$config{fonts}{bold},
1154 -foreground=>$config{colors}{activehighlightcolor})
1155 -> grid(-row=>0, -column=>0);
1156 $frame -> Radiobutton(-text => 'Never',
1157 -font => $config{fonts}{med},
1158 -selectcolor=>$config{colors}{check},
1159 #-width => 12,
1160 -variable => \$extra[4],
1161 -value => 0)
1162 -> grid(-row => 1, -column=>0, -sticky=>'w');
1163 $frame -> Radiobutton(-text => 'Only |chi(R)|',
1164 -font => $config{fonts}{med},
1165 -selectcolor=>$config{colors}{check},
1166 #-width => 12,
1167 -variable => \$extra[4],
1168 -value => 1)
1169 -> grid(-row => 2, -column=>0, -sticky=>'w');
1170 $frame -> Radiobutton(-text => '|chi(R)| and |chi(q)|',
1171 -font => $config{fonts}{med},
1172 -selectcolor=>$config{colors}{check},
1173 #-width => 12,
1174 -variable => \$extra[4],
1175 -value => 2)
1176 -> grid(-row=>3, -column=>0, -sticky=>'w');
1177
1178 ## MDS offset
1179 $frame = $widgets{plot_Sta} -> Frame(-borderwidth=>2, -relief=>'ridge')
1180 -> pack(-anchor=>'n', -fill=>'x', -side=>'top');
1181 $frame -> Label(-text=>"Stack data sets",
1182 -font=>$config{fonts}{bold},
1183 -foreground=>$config{colors}{activehighlightcolor})
1184 -> grid(-row=>0, -column=>0, -columnspan=>2, );
1185 $frame -> Label(-text => 'Offset:',
1186 -font => $config{fonts}{med},)
1187 -> grid(-row=>1, -column=>0, -sticky=>'e');
1188 $frame -> Entry(-width => 8,
1189 -textvariable => \$extra[3],
1190 -validate => 'key',
1191 -validatecommand => [\&set_opparam, 'extra'])
1192 -> grid(-row=>1, -column=>1, -sticky=>'w');
1193
1194 };
1195
1196
1197 sub display_page {
1198 $list->anchorSet($_[0]);
1199 $list->selectionClear;
1200 $list->selectionSet($_[0]);
1201 $list->see($_[0]);
1202 &display_properties;
1203 };
1204
1205 sub display_properties {
1206 if ($_[1] and ($_[0] !~ /^\d+$/)) { # only respond to button press events
1207 # and not button release events
1208 #print "button event: ", join(" ", @_), $/;
1209 return unless defined $_[2];
1210 }; # the check on $_[0] does the right thing for mouse-2
1211 if (ref($paths{$current}) =~ /Ifeffit/) {
1212 &read_titles($current) if ($current =~ /data\d+(\.\d+)?$/);
1213
1214 ## some chores to be done when clicking away from a feff calc
1215 if ($paths{$current}->type eq 'feff') {
1216 ## remember scrollbar positions in feff.inp and interpretation
1217 set_feff_showing($fefftabs->raised());
1218 ## save the atoms titles
1219 my $titles = $widgets{atoms_titles}->get('1.0', 'end');
1220 $titles =~ s/\n/<NL>/g;
1221 $paths{$current} -> make(atoms_titles=>$titles);
1222 ## save the feff.inp text
1223 my $feff_file = File::Spec->catfile($project_folder,
1224 $paths{$current}->get('id'),
1225 "feff.inp");
1226 $widgets{feff_inptext} -> Save($feff_file);
1227 } elsif ($paths{$current}->type eq 'data') {
1228 ##--bkg-- $paths{$current} -> make(data_showing=>$widgets{data_notebook}->raised);
1229 };
1230
1231 };
1232
1233 ## correct a hierarchy problem on windows...
1234 my $thelist = (ref($list) =~ m{Frame}) ? $list->Subwidget('tree') : $list;
1235 my $anchor = $thelist->info('anchor');
1236 $current = $anchor;
1237 return if (($current_canvas eq 'prefs') or
1238 ($current_canvas eq 'histogram') or
1239 ($current_canvas eq 'athena') or
1240 ($current_canvas eq 'firstshell')
1241 );
1242 foreach ($gsd_menu, $feff_menu, $paths_menu, $data_menu, $sum_menu, $fit_menu) { # , $settings_menu) {
1243 $_ -> configure(-state=>'normal');
1244 };
1245 $feff_menu -> menu -> entryconfigure($_, -state=>'disabled') for (5..8, 11, 12, 13, 15, 17);
1246 $paths_menu -> menu -> entryconfigure($_, -state=>'disabled') for (1..3, 5..8, 10..13);
1247 $fit_menu -> menu -> entryconfigure(1, -state=>'disabled', -label=>"Restore this fit model");
1248 $fit_menu -> menu -> entryconfigure($_, -state=>'disabled') for (3..8, 10..11, 14..15);
1249 unless ($thelist->info('hidden', $paths{$current}->data.".0")) {
1250 $file_menu -> menu -> entryconfigure($_, -state=>'normal') for ($save_index+1..$save_index+3)
1251 };
1252 ## worry about whether most recent fit had a bkg
1253
1254 my $dd = $paths{$current}->data;
1255 my $latest = (exists $paths{$dd.".0"}) ? $paths{$dd.".0"}->get('thisfit') : 0;
1256 if ($latest and
1257 (-e File::Spec->catfile($project_folder, "fits", $paths{$latest}->get('folder'), $dd.".bkg"))) {
1258 $data_menu -> menu -> entryconfigure(2, -state=>'normal');
1259 } else {
1260 $file_menu -> menu -> entryconfigure($save_index+2, -state=>'disabled');
1261 };
1262
1263
1264 ## it is dangerous to leave focus on a widget when switching
1265 ## views. in that case typing while Artemis has mouse focus will
1266 ## result in typing in a widget out of view. bad juju!
1267 $plotr_button -> focus();
1268 my $this_data = $paths{$current}->data;
1269 if ($anchor =~ /data\d+\.0(\.\d+)?$/) { # matches any fit
1270 $top -> Busy;
1271 SWITCH: {
1272 $opparams->packForget(), last SWITCH if ($current_canvas eq 'op');
1273 $gsd ->packForget(), last SWITCH if ($current_canvas eq 'gsd');
1274 $feff->packForget(), last SWITCH if ($current_canvas eq 'feff');
1275 $path->packForget(), last SWITCH if ($current_canvas eq 'path');
1276 };
1277 $logviewer->pack(-expand=>1, -fill=>'both');
1278 my $skip = 1 if ($current_canvas eq 'logview');
1279 $skip = 0 if $log_params{force};
1280 $current_canvas = 'logview';
1281 unless ($skip) {
1282 $log_params{param} ||= $gds[0]->name;
1283 &populate_logview;
1284 };
1285 map { $file_menu -> menu -> entryconfigure($_, -state=>'normal') } ($save_index..$save_index+4, $save_index+6);
1286 $fit_menu -> menu -> entryconfigure($_, -state=>'normal') for (3..8, 10..11, 14..15);
1287 if ($anchor =~ /(data\d+)\.0.\d+$/) { # not head of branch
1288 $fit_menu -> menu -> entryconfigure(1, -state=>'normal', -label=>"Restore the \"".$paths{$current}->get('lab')."\" fit model");
1289 ## disable save bkg menu entry if no bkg file exists
1290 $file_menu -> menu -> entryconfigure($save_index+2, -state=>'disabled')
1291 unless (-e File::Spec->catfile($project_folder, "fits", $paths{$current}->get('folder'), $1.".bkg"));
1292 };
1293 my $latest = $paths{$current}->parent;
1294 $latest = $paths{$latest}->get('thisfit');
1295 ## $widgets{log_latest} -> configure(-text=>($latest) ? $paths{$latest}->get('lab') : "");
1296 $widgets{log_current} -> configure(-text=>$paths{$latest}->get('lab'));
1297 $top -> Unbusy;
1298 } elsif ($anchor =~ /data\d+(\.\d+)?$/) { # matches data
1299 $top -> Busy;
1300 SWITCH: {
1301 $gsd ->packForget(), last SWITCH if ($current_canvas eq 'gsd');
1302 $feff->packForget(), last SWITCH if ($current_canvas eq 'feff');
1303 $path->packForget(), last SWITCH if ($current_canvas eq 'path');
1304 $logviewer ->packForget(), last SWITCH if ($current_canvas eq 'logview');
1305 };
1306 $opparams->pack(-expand=>1, -fill=>'both');
1307 $current_canvas = 'op';
1308 #my $this = ($current;
1309 #($anchor =~ /(data\d+)/) and ($this = $1);
1310 #$this and populate_op($this);
1311 populate_op($this_data);
1312 map { $file_menu -> menu -> entryconfigure($_, -state=>'normal') } ($save_index..$save_index+4, $save_index+6);
1313 #$file_menu -> menu -> entryconfigure($save_index+2, -state=>'disabled')
1314 # unless (-e File::Spec->catfile($project_folder, "fits", $paths{$current}->get('folder'), $1.".bkg"));
1315 $top -> Unbusy;
1316 } elsif ($anchor eq 'gsd') {
1317 SWITCH: {
1318 $opparams->packForget(), last SWITCH if ($current_canvas eq 'op');
1319 $feff ->packForget(), last SWITCH if ($current_canvas eq 'feff');
1320 $path ->packForget(), last SWITCH if ($current_canvas eq 'path');
1321 $logviewer ->packForget(), last SWITCH if ($current_canvas eq 'logview');
1322 };
1323 $gsd->pack(-expand=>1, -fill=>'both');
1324 foreach ($feff_menu, $paths_menu, $fit_menu, $data_menu, $sum_menu) {
1325 $_ -> configure(-state=>'disabled');
1326 };
1327 map { $file_menu->menu->entryconfigure($_, -state=>'disabled') }
1328 ($save_index .. $save_index+3);
1329
1330 $widgets{gds2_name} -> focus();
1331 $current_canvas = 'gsd';
1332 } elsif ($anchor =~ /feff\d+$/) {
1333 SWITCH: {
1334 $opparams->packForget(), last SWITCH if ($current_canvas eq 'op');
1335 $gsd ->packForget(), last SWITCH if ($current_canvas eq 'gsd');
1336 $path ->packForget(), last SWITCH if ($current_canvas eq 'path');
1337 $logviewer ->packForget(), last SWITCH if ($current_canvas eq 'logview');
1338 };
1339 $feff->pack(-expand=>1, -fill=>'both');
1340 $current_canvas = 'feff';
1341 populate_feff($current);
1342 map { $feff_menu -> menu -> entryconfigure($_, -state=>'normal') } (5..8, 11, 12, 13, 11, 12, 13, 15, 17);
1343 map { $paths_menu -> menu -> entryconfigure($_, -state=>'normal') } (5..8, 13);
1344 ## disabled atoms options in theory menu if the atoms data is not present
1345 my $state = $fefftabs -> pagecget("Atoms", "-state");
1346 map { $feff_menu -> menu -> entryconfigure($_, -state=>$state) } (10 .. 13);
1347 } elsif ($anchor =~ /feff\d+\.\d+$/) {
1348 SWITCH: {
1349 $opparams->packForget(), last SWITCH if ($current_canvas eq 'op');
1350 $gsd ->packForget(), last SWITCH if ($current_canvas eq 'gsd');
1351 $feff ->packForget(), last SWITCH if ($current_canvas eq 'feff');
1352 $logviewer ->packForget(), last SWITCH if ($current_canvas eq 'logview');
1353 };
1354 $path->pack(-expand=>1, -fill=>'both');
1355 $current_canvas = 'path';
1356 populate_path($current);
1357 map { $feff_menu -> menu -> entryconfigure($_, -state=>'normal') } (5..8, 11, 12, 13, 15, 17);
1358 map { $paths_menu -> menu -> entryconfigure($_, -state=>'normal') } (1..3, 5..8, 10..13);
1359 $paths_menu -> menu -> entryconfigure(3, -state=>'normal') if $n_feff;
1360 #$show_menu -> menu -> entryconfigure(3, -state=>'normal') if $n_feff;
1361 };
1362
1363 };
1364
1365
1366
1367 sub populate_op {
1368 my $this = $_[0];
1369 next unless (ref($paths{$this}) =~ /Ifeffit/);
1370 return unless ($paths{$this}->get('file'));
1371
1372 ##--bkg-- $widgets{data_notebook} -> raise($paths{$this}->get('data_showing'));
1373
1374 ## file
1375 $widgets{op_file} -> configure(-state=>'normal');
1376 $widgets{op_file} -> delete(qw(0 end));
1377 $widgets{op_file} -> insert(0, basename($paths{$this}->{file}));
1378 $widgets{op_file} -> xview('end');;
1379 $widgets{op_file} -> configure(-state=>'disabled');
1380 ## include
1381 my @every = &every_data;
1382 my @all = &all_data;
1383 my $data = $paths{$this}->data;;
1384 my $label = $paths{$this}->get('lab') || ucfirst($this);
1385 ($label = substr($label, 0, 11)."...") if (length($label) > 11);
1386 ##$widgets{controls_frame} -> configure(-label=>$label);
1387 $widgets{op_include} -> configure(-state=>($#every) ? 'normal' : 'disabled' );
1388 $paths{$this}->make(plot=>1) unless $#all; # just one group
1389 $widgets{op_plot} -> configure(-state=>($#all) ? 'normal' : 'disabled' );
1390
1391 ## titles
1392 $widgets{op_titles} -> delete(qw(1.0 end));
1393 $widgets{op_titles} -> insert('end', $paths{$this}->get('titles'));
1394
1395 ## entry widgets
1396 foreach (qw(kmin kmax dk rmin rmax dr cormin epsilon_k)) {
1397 my $key = 'op_'.$_;
1398 $widgets{$key} -> configure(-validate=>'none');
1399 $widgets{$key} -> delete(qw(0 end));
1400 $widgets{$key} -> insert(0, $paths{$this}->get($_));
1401 $widgets{$key} -> configure(-validate=>'key');
1402 };
1403 ## text
1404 ##if ($n_data) {
1405 ## map {$_->configure(-foreground => $config{colors}{activehighlightcolor})} @op_text;
1406 ##};
1407 ## optionmenus and checkbuttons
1408 $temp{op_fitspace} = $paths{$this}->get('fit_space');
1409 $temp{op_kwindow} = ucfirst $paths{$this}->get('kwindow');
1410 ($temp{op_kwindow} eq 'Kaiser-bessel') and ($temp{op_kwindow} = 'Kaiser-Bessel');
1411 $temp{op_rwindow} = ucfirst $paths{$this}->get('rwindow');
1412 ($temp{op_rwindow} eq 'Kaiser-bessel') and ($temp{op_rwindow} = 'Kaiser-Bessel');
1413 $temp{op_do_bkg} = $paths{$this}->get('do_bkg');
1414 $temp{op_include} = $paths{$this}->get('include');
1415 $temp{op_plot} = $paths{$this}->get('plot');
1416 $temp{op_k1} = $paths{$this}->get('k1');
1417 $temp{op_k2} = $paths{$this}->get('k2');
1418 $temp{op_k3} = $paths{$this}->get('k3');
1419 $temp{op_karb_use} = $paths{$this}->get('karb_use');
1420 ## arbitrary k-weight box
1421 $widgets{op_karb} -> configure(-state=>($temp{op_karb}) ? 'normal' : 'disabled');
1422 $temp{op_pcplot} = $paths{$this}->get('pcplot');
1423 $temp{op_pcpath} = (exists $paths{$paths{$this}->get('pcpath')}) ?
1424 $paths{$this}->get('pcpath') : 'None';
1425 if ($temp{op_pcpath} eq 'None') {
1426 $temp{op_pcpath_label} = 'None';
1427 } elsif (exists $paths{$temp{op_pcpath}}) {
1428 $temp{op_pcpath_label} = $paths{$temp{op_pcpath}}->descriptor();
1429 } else {
1430 $temp{op_pcpath_label} = 'None';
1431 };
1432
1433 ## restock the pcpath menu with the current path list
1434 $widgets{op_pcpath} -> configure(-options => []);
1435 $widgets{op_pcpath} -> command(-label => 'None',
1436 -command=>sub{$temp{op_pcpath}='None';
1437 $temp{op_pcpath_label}='None';
1438 project_state(0);
1439 $paths{$this}->make(pcpath=>'None', do_r=>1); });
1440 my @paths = grep {/feff\d+\.\d+/} (&pcpath_list);
1441 foreach my $p (@paths) {
1442 next unless ($paths{$p}->data eq $this);
1443 my $label = $paths{$p}->descriptor();
1444 $widgets{op_pcpath} -> command(-label => $label,
1445 -command=>sub{$temp{op_pcpath} = $p;
1446 $temp{op_pcpath_label}=$label;
1447 my $data = $paths{$current}->data;
1448 $paths{$data}->make(pcpath=>$p, do_r=>1);
1449 my $ii = $paths{$p}->index;
1450 my $pathto = $paths{$p}->get('path');
1451 my $command = $paths{$p}->write_path($ii, $pathto, $config{paths}{extpp}, $stash_dir);
1452 $paths{$p} -> dispose($command, $dmode);
1453 project_state(0);
1454 })
1455 };
1456
1457 &nidp;
1458
1459 ##--bkg--
1460 ## enable the background tweaking panel
1461 if ($paths{$this}->get('is_xmu')) {
1462 map {$widgets{$_} -> configure(-state=>'normal')} (qw(show_chi show_mu));
1463
1464 ## fill the mu(E) tab
1465 foreach my $k (qw(e0 eshift kw rbkg pre1 pre2 nor1 nor2 spl1 spl2 step)) {
1466 my $key = "bkg_".$k;
1467 $widgets{$key} -> configure(-validate=>'none');
1468 $widgets{$key} -> delete(qw(0 end));
1469 $widgets{$key} -> insert(0, $paths{$this}->get($key));
1470 $widgets{$key} -> configure(-validate=>'key');
1471 };
1472 $temp{bkg_fixstep} = $paths{$this}->get('bkg_fixstep');
1473 $temp{bkg_flatten} = $paths{$this}->get('bkg_flatten');
1474 $temp{bkg_clamp2} = $paths{$this}->get('bkg_clamp2');
1475 } else {
1476 1;
1477 };
1478 };
1479
1480
1481
1482
1483 sub clear_op {
1484 my $this = $_[0];
1485 return unless defined $paths{$this};
1486 ###!!! do i really need to be sure there is always a data0 ??
1487 if ($this =~ /data0$/) {
1488 delete $paths{$this};
1489 $paths{$this} = Ifeffit::Path -> new(id => 'data0',
1490 group => 'data0',
1491 type => 'data',
1492 sameas => 0,
1493 kwindow => $config{data}{kwindow},
1494 rwindow => $config{data}{rwindow},
1495 family => \%paths);
1496 } else {
1497 delete $paths{$this};
1498 $list->delete('entry',$this);
1499 };
1500 ## file
1501 $widgets{op_file} -> configure(-state=>'normal');
1502 $widgets{op_file} -> delete(qw(0 end));
1503 $widgets{op_file} -> configure(-state=>'disabled');
1504 $widgets{controls_frame} -> configure(-label=>'Data controls');
1505 ## titles
1506 $widgets{op_titles} -> delete(qw(1.0 end));
1507 foreach (qw(kmin kmax dk rmin rmax dr cormin)) { # epsilon_k
1508 my $key = 'op_'.$_;
1509 $widgets{$key} -> configure(-validate=>'none');
1510 $widgets{$key} -> delete(qw(0 end));
1511 $widgets{$key} -> configure(-validate=>'key');
1512 };
1513 ##map {$_->configure(-foreground=>$config{colors}{disabledforeground})} @op_text
1514 ## if $n_data;
1515 $temp{op_kwindow} = $config{data}{kwindow};
1516 $temp{op_rwindow} = $config{data}{rwindow};
1517 $temp{op_fitspace} = 'R';
1518 $temp{op_do_bkg} = 'no';
1519 $temp{op_include} = 1;
1520 $temp{op_plot} = 0;
1521 $temp{op_pcplot} = 'No';
1522 $temp{op_k1} = 0;
1523 $temp{op_k2} = 0;
1524 $temp{op_k3} = 0;
1525 $temp{op_karb_use} = 0;
1526 $temp{op_pcpath} = 'None';
1527 $temp{op_pcpath_label} = 'None';
1528 };
1529
1530
1531
1532 sub set_opparam {
1533 my ($k, $entry, $prop) = (shift, shift, shift);
1534 ($entry =~ /^\s*$/) and ($entry = 0); # error checking ...
1535 ($entry =~ /^\s*\.\s*$/) and ($entry = 0); # a sole .
1536 ($entry =~ /^\s*\-\s*$/) and ($entry = 0); # a sole -
1537 ($entry =~ /^\s*-?(\d+\.?\d*|\.\d+)\s*$/) or return 0;
1538 return 1 if ($k =~ /extra/);
1539 return 0 if (($entry < 0) and ($k !~ /^bkg/));
1540 my $which;
1541 if ($k =~ /^bkg/) { $which = 'do_xmu' };
1542 if ($k =~ /(k(max|min|weight|window)|dk)/) { $which = 'do_r' };
1543 if ($k =~ /(r(max|min|window)|dr)/) { $which = 'do_q' };
1544 my $this = $paths{$current}->data;
1545 $paths{$this} -> make($k=>$entry, $which=>1);
1546 my $i = get_index($this);
1547 unless ($k =~ /(cormin|epsilon_k)/) {
1548 foreach ("", ".0", ".2", ".1") { # flag data for updating
1549 next unless exists $paths{"data$i".$_};
1550 $paths{"data$i".$_} -> make($which=>1);
1551 };
1552 foreach (keys %paths) { # flag paths for updating
1553 next unless (ref($paths{$_}) =~ /Ifeffit/);
1554 next unless (/feff$i\.\d+/);
1555 $paths{$_} -> make($which=>1);
1556 };
1557 };
1558 if ($k =~ /cormin/) {
1559 foreach my $d (&all_data) { # force cormin to be the same for all data sets
1560 $paths{$d} -> make(cormin=>$entry);
1561 };
1562 };
1563 &nidp if (($k !~ /cormin/) and ($k =~ /((km(in|ax))|(rm(in|ax)))/));
1564 project_state(0);
1565 return 1;
1566 ## need to flag that fit needs to be redone and that project needs
1567 ## to be saved
1568 };
1569
1570 ## change the anchor in the path list AND change the display in the
1571 ## main window, but do not change the path selection. this is bound
1572 ## to mouse-2
1573 sub anchor_display {
1574 ## this first bit swiped from HList.pm
1575 my $w = shift;
1576 my $Ev = $w->XEvent;
1577 delete $w->{'shiftanchor'};
1578 my $entry = $w->GetNearest($Ev->y, 1);
1579 return unless (defined($entry) and length($entry));
1580
1581 $w->anchorSet($entry);
1582 &display_properties;
1583 };
1584
1585
1586
1587 sub read_titles {
1588 my $this = $_[0] || $paths{$current}->data;
1589 return unless $this;
1590 return unless exists $paths{$this};
1591 return if ($current =~ /data\d+\.3$/);
1592 ## next line corrects a hierarchy problem on windows
1593 my $widg = (ref($widgets{op_titles}) =~ m{Frame}) ? $widgets{op_titles}->Subwidget('text') : $widgets{op_titles};
1594 $paths{$this} -> make(titles => $widg->get(qw(1.0 end)));
1595 };
1596
1597
1598
1599 sub keyboard_up {
1600 if ($current_canvas eq 'gsd') {
1601 &gds2_update_mathexp($widgets{gds2list}, \%gds_selected);
1602 my $moveto = ($gds_selected{which}) ? # bottom if none selected
1603 $widgets{gds2list}->infoPrev($gds_selected{which}) : $#gds+1;
1604 $moveto ||= $#gds+1; # wrap around to bottom
1605 gds2_display($moveto);
1606 } else {
1607 my $moveto = $list->infoPrev($current);
1608 return unless $moveto;
1609 $list->anchorSet($moveto);
1610 &display_properties;
1611 $list->see($moveto);
1612 };
1613 };
1614
1615 sub keyboard_down {
1616 if ($current_canvas eq 'gsd') {
1617 &gds2_update_mathexp($widgets{gds2list}, \%gds_selected);
1618 my $moveto = ($gds_selected{which}) ? # top if none selected
1619 $widgets{gds2list}->infoNext($gds_selected{which}) : 1;
1620 $moveto ||= 1; # wrap around to top
1621 gds2_display($moveto);
1622 } else {
1623 my $moveto = $list->infoNext($current);
1624 return unless $moveto;
1625 $list->anchorSet($moveto);
1626 &display_properties;
1627 $list->see($moveto);
1628 };
1629 };
1630
1631 sub project_state {
1632 $project_saved = $_[0];
1633 $widgets{project_modified} -> configure(-text=>($_[0]) ?
1634 "" : "modified");
1635 $top->update;
1636 };
1637
1638
1639
1640 ## END OF THE MAIN WINDOW SUBSECTION
1641