Debian Codegraph @

athena_parts/setup.pl

raw
1 ## -*- cperl -*-
2 ##
3 ## This file is part of Athena, copyright (c) 2001-2006, 2008 Bruce Ravel
4 ##
5 ## This section of the code contains subroutines associated with
6 ## setting up various parts of the display, such as menus and the
7 ## plot options cards
8
9
10 sub set_menus {
11
12 ## ifeffit command modes:
13 ## bit 1: send to ifeffit
14 ## bit 2: store in ifeffit buffer
15 ## bit 3: display in ifeffit interaction buffer
16 ## bit 4: store in macro buffer
17 ## bit 5: write to STDOUT
18 ## normal mode is 5, i.e. bits 1 and 3.
19
20 @group_menuitems = (-menuitems =>
21 [
22 [ command => "Copy group", -accelerator => 'Ctrl-y',
23 -command => \&copy_group],
24 [ command => "Copy series",
25 -command => \&series],
26 [ command => "About current group", -accelerator=>'Ctrl-b',
27 -command => \&about_group],
28 [ command => "About marked groups", -accelerator=>'Ctrl-B',
29 -command => sub{about_marked_groups(\%marked)}],
30 [ command => "Make detector groups", -command=>\&make_detectors,
31 -state => 'disabled'],
32 [ command => "Make background group", -command=>\&make_background,
33 -state => 'disabled'],
34 [ command => "Change group label", -accelerator => 'Ctrl-l',
35 -command => \&get_new_name],
36 [ command => "Change record type",
37 -command => \&change_record],
38 [ command => "Remove group",
39 -command => sub{delete_group($list, $dmode, 0);}],
40 "-",
41 [ command => "Move group up", -accelerator => 'Alt-k',
42 -command => \&group_up],
43 [ command => "Move group down", -accelerator => 'Alt-j',
44 -command => \&group_down],
45 "-",
46 [ command => "Remove marked groups",
47 -command => sub{delete_many($list, $dmode, 1)}],
48 [ command => "Close project", -accelerator=>'Ctrl-w',
49 -command => \&close_project],
50 # "-",
51 ]);
52
53
54 @values_menuitems = (-menuitems =>
55 [
56 ## if using Default Parameters... ----------------------------------------
57 (($use_default) ?
58 (['command'=>"Set this group's values to default",
59 -command=>sub{
60 return if ($current eq "Default Parameters");
61 Echo("Resetting parameters for \`$current\' reset to Defaults");
62 $groups{$current}->set_to_another($groups{'Default Parameters'});
63 set_properties(1, $current, 0);
64 Echo(@done);}],
65 ['command'=>"Set marked groups' values to default",
66 -command=>sub{
67 Echo("Parameters for marked groups reset to Default Parameters");
68 my $orig = $current;
69 foreach my $x (keys %marked) {
70 next if ($x eq 'Default Parameters');
71 next unless ($marked{$x});
72 $groups{$x}->set_to_another($groups{'Default Parameters'});
73 set_properties(1, $x, 0);
74 };
75 set_properties(1, $orig, 0);
76 Echo(@done);}],
77 ['command'=>"Set all groups' values to default",
78 -command=>sub{
79 Echo("Parameters for all groups reset to Default Parameters");
80 my $orig = $current;
81 foreach my $x (keys %marked) {
82 next if ($x eq 'Default Parameters');
83 $groups{$x}->set_to_another($groups{'Default Parameters'});
84 set_properties(1, $x, 0);
85 };
86 set_properties(1, $orig, 0);
87 Echo(@done);}], ) : ()),
88 ## end of this Deafult Parameters section --------------------------------
89
90 ['command'=>"Set all groups' values to the current",
91 -command=>sub{
92 Echo('No data!'), return unless ($current);
93 Echo("Parameters for all groups reset to \`$current\'");
94 my $orig = $current;
95 foreach my $x (keys %marked) {
96 next if ($x eq 'Default Parameters');
97 next if ($x eq $current);
98 $groups{$x}->set_to_another($groups{$current});
99 set_properties(1, $x, 0);
100 };
101 set_properties(1, $orig, 0);
102 Echo(@done);}],
103 ['command'=>"Set all marked groups' values to the current",
104 -command=>sub{
105 Echo('No data!'), return unless ($current);
106 Echo("Parameters for all marked groups reset to \`$current\'");
107 my $orig = $current;
108 foreach my $x (keys %marked) {
109 next if ($x eq 'Default Parameters');
110 next if ($x eq $current);
111 next unless ($marked{$x});
112 $groups{$x}->set_to_another($groups{$current});
113 set_properties(1, $x, 0);
114 };
115 set_properties(1, $orig, 0);
116 Echo(@done);}],
117 ['command'=>"Set current groups' values to their defaults",
118 -command=>sub{
119 Echo('No data!'), return unless ($current);
120 my @keys = grep {/^(bft|bkg|fft)/} (keys %widget);
121 set_params('def', @keys);
122 set_properties(1, $current, 0);
123 Echo("Reset all values for this group to their defaults");}],
124 "-",
125 ['cascade'=>'Freeze groups', -tearoff=>0,
126 -menuitems=>[[ command => 'Toggle this group', -accelerator => 'Ctrl-f',
127 -command => [\&freeze, 'this'], ],
128 [ command => 'Freeze all groups', -accelerator => 'Ctrl-F',
129 -command => [\&freeze, 'all']],
130 [ command => 'Unfreeze all groups', -accelerator => 'Ctrl-U',
131 -command => [\&freeze, 'none']],
132 [ command => "Freeze marked groups", -accelerator => 'Ctrl-M',
133 -command => [\&freeze, 'marked']],
134 [ command => "Unfreeze marked groups",
135 -command => [\&freeze, 'unmarked']],
136 [ command => "Freeze regex", -accelerator => 'Ctrl-R',
137 -command => [\&freeze, 'regex']],
138 [ command => "Unfreeze regex",
139 -command => [\&freeze, 'unregex']],
140 [ command => 'Toggle all groups',
141 -command => [\&freeze, 'toggle']],
142 ]],
143 "-",
144 ["command"=>"Make current group's values the session defaults",
145 -command => sub{
146 Echo("No data!"), return unless $current;
147 my @keys = grep {/^(bft|bkg|fft)/} (keys %widget);
148 session_defaults(@keys);
149 Echo("Made all values for this group the session defaults");
150 }],
151 ["command"=>"Unset session defaults",
152 -command => \&clear_session_defaults,
153 ],
154
155 ## if using Default Parameters... ------------------------------------------
156 (($use_default) ?
157 (['command'=>"Set Defaults to this group's values",
158 -command=>sub{
159 return if ($current eq "Default Parameters");
160 my $orig = $current;
161 Echo("Resetting Default Parameters to those of \`$current\'");
162 $groups{'Default Parameters'}->set_to_another($groups{$current});
163 set_properties(1, 'Default Parameters', 0);
164 set_properties(1, $orig, 0);
165 Echo(@done);}],) : ()),
166 ## end of this Deafult Parameters section ---------------------------------
167
168 "-",
169 ['cascade'=>'Set E0 for THIS group to ...', -tearoff=>0,
170 -menuitems=>[
171 [ command => "Ifeffit's default",
172 -command => sub{set_edge($current, 'edge'); autoreplot('e');}],
173 [ command => "zero-crossing of 2nd derivative",
174 -command => sub{set_edge($current, 'zero'); autoreplot('e');}],
175 [ command => "a set fraction of the edge step",
176 -command => sub{set_edge($current, 'fraction'); autoreplot('e');}],
177 [ command => "atomic value",
178 -command => sub{set_edge($current, 'atomic'); autoreplot('e');}],
179 [ command => "the peak of the white line",
180 -command => sub{autoreplot('e') if set_edge_peak($current);}],
181 ]],
182 ['cascade'=>'Set E0 for ALL groups to ...', -tearoff=>0,
183 -menuitems=>[
184 [ command => "Ifeffit's default",
185 -command => sub{set_edges('edge', 'all');}],
186 [ command => "zero-crossing of 2nd derivative",
187 -command => sub{set_edges('zero', 'all');}],
188 [ command => "a set fraction of the edge step",
189 -command => sub{set_edges('fraction', 'all');}],
190 [ command => "atomic value",
191 -command => sub{set_edges('atomic', 'all');}],
192 [ command => "the peaks of the white lines",
193 -command => sub{set_edges('peak', 'all');}],
194 ]],
195 ['cascade'=>'Set E0 for MARKED groups to ...', -tearoff=>0,
196 -menuitems=>[
197 [ command => "Ifeffit's default",
198 -command => sub{set_edges('edge', 'marked');}],
199 [ command => "zero-crossing of 2nd derivative",
200 -command => sub{set_edges('zero', 'marked');}],
201 [ command => "a set fraction of the edge step",
202 -command => sub{set_edges('fraction', 'marked');}],
203 [ command => "atomic value",
204 -command => sub{set_edges('atomic', 'marked');}],
205 [ command => "the peaks of the white lines",
206 -command => sub{set_edges('peak', 'marked');}],
207 ]],
208 "-",
209 [ command => "Tie reference channel",
210 -command => \&tie_reference],
211 "-",
212 [ command => "Purge LCF results from project",
213 -command => \&lcf_purge],
214 ]);
215
216 @edit_menuitems = (-menuitems =>
217 [['command'=>"Display Ifeffit buffer", -accelerator => 'Ctrl-1',
218 -command=>sub{raise_palette('ifeffit'); $cmdbox->focus; $top->update;}],
219 ['command'=>"Show group's titles", -accelerator => 'Ctrl-2',
220 -command=>sub{raise_palette('titles'); $top->update;}],
221 ['command'=>"Edit data as text", -accelerator => 'Ctrl-3',
222 -command=>\&setup_data],
223 ['command'=>"Show group's arrays",
224 -command=>sub{Echo('No data!'), return unless ($current);
225 raise_palette('ifeffit');
226 return if ($current eq "Default Parameters");
227 $setup->dispose("show \@group $current\n", $dmode)}],
228 ['command'=>"Show all strings",
229 -command=>sub{raise_palette('ifeffit');
230 $setup->dispose("show \@strings\n", $dmode)}],
231 ['command'=>"Show all macros",
232 -command=>sub{raise_palette('ifeffit');
233 $setup->dispose("show \@macros\n", $dmode)}],
234 ['command'=>"Display echo buffer", -accelerator => 'Ctrl-4',
235 -command=>sub{raise_palette('echo'); }],
236 #"-",
237 ['command'=>"Record a macro", -accelerator => 'Ctrl-5',
238 -command=>sub{raise_palette('macro');}],
239 #['command'=>"Load a macro", -command=>\&load_macro],
240 #"-",
241 ['command'=>"Write in project journal", -accelerator => 'Ctrl-6',
242 -command=>sub{raise_palette('journal'); }],
243 ['cascade'=>"Write a report", -tearoff=>0,
244 -menuitems=>[
245 ['command'=>"Excel report (all groups)",
246 -command=>[\&report_excel, 'all']],
247 ['command'=>"Excel report (marked groups)",
248 -command=>[\&report_excel, 'marked']],
249 "-",
250 ['command'=>"CSV report (all groups)",
251 -command=>[\&report_csv, 'all']],
252 ['command'=>"CSV report (marked groups)",
253 -command=>[\&report_csv, 'marked']],
254 "-",
255 ['command'=>"text report (all groups)",
256 -command=>[\&report_ascii, 'all']],
257 ['command'=>"text report (marked groups)",
258 -command=>[\&report_ascii, 'marked']],
259 "-",
260 ['command'=>"Write an Xfit file",
261 -command=>[\&write_xfit_file]],
262
263 ]],
264 ]);
265 };
266
267
268 ## This is very ugly, but very repititious. On each card, there is a
269 ## stack of frames. In each frame there are two checkbuttons. To the
270 ## left is a button without text for selecting marked plots. To the
271 ## right is a button with text for selecting groups plots.
272 sub set_plotcards {
273
274 ## colors need to be less dark on Windows than on linux. Other unixes???
275 my $red = $config{colors}{single};
276 my $vio = $config{colors}{marked};
277
278 ## energy-space options
279 ## mu
280 my $frame = $plotcard{e} -> Frame() -> pack(-fill=>'x');
281 $frame -> Checkbutton(-text=>'mu(E)', -selectcolor=>$red, -command=>\&replot_group_e,
282 -onvalue=>'m', -offvalue=>"", -variable=>\$plot_features{e_mu})
283 -> grid(-row=>0, -column=>0, -pady=>0, -sticky=>'w');
284 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_e,
285 -value=>'e', -variable=>\$plot_features{e_marked})
286 -> grid(-row=>0, -column=>1, -pady=>0, -sticky=>'w');
287 ## mu0
288 $frame -> Checkbutton(-text=>'background', -selectcolor=>$red, -command=>\&replot_group_e,
289 -onvalue=>'z', -offvalue=>"", -variable=>\$plot_features{e_mu0})
290 -> grid(-row=>1, -column=>0, -pady=>0, -sticky=>'w');
291 ## pre
292 $frame -> Checkbutton(-text=>'pre-edge line', -selectcolor=>$red, -command=>\&replot_group_e,
293 -command=>
294 sub{($plot_features{e_pre} eq 'p') and
295 (($plot_features{e_norm},$plot_features{e_der})=('',''));
296 &replot_group_e;},
297 -onvalue=>'p', -offvalue=>"", -variable=>\$plot_features{e_pre})
298 -> grid(-row=>2, -column=>0, -pady=>0, -sticky=>'w');
299 ## post
300 $frame -> Checkbutton(-text=>'post-edge line', -selectcolor=>$red,
301 -command=>
302 sub{($plot_features{e_post} eq 't') and
303 (($plot_features{e_norm},$plot_features{e_der})=('',''));
304 &replot_group_e;},
305 -onvalue=>'t', -offvalue=>"", -variable=>\$plot_features{e_post})
306 -> grid(-row=>3, -column=>0, -pady=>0, -sticky=>'w');
307 ## norm
308 $frame -> Checkbutton(-text=>'Normalized', -selectcolor=>$red,
309 -command=>
310 sub{($plot_features{e_norm} eq 'n') and
311 (($plot_features{e_pre},$plot_features{e_post})=('',''));
312 &replot_group_e;},
313 -onvalue=>'n', -offvalue=>"", -variable=>\$plot_features{e_norm})
314 -> grid(-row=>4, -column=>0, -pady=>0, -sticky=>'w');
315 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_e,
316 -value=>'n', -variable=>\$plot_features{e_marked})
317 -> grid(-row=>4, -column=>1, -pady=>0, -sticky=>'w');
318 ## deriv
319 $frame -> Checkbutton(-text=>'Derivative', -selectcolor=>$red,
320 -command=>
321 sub{($plot_features{e_der} eq 'd') and
322 (($plot_features{e_pre},$plot_features{e_post})=('',''));
323 &replot_group_e;},
324 -onvalue=>'d', -offvalue=>"", -variable=>\$plot_features{e_der})
325 -> grid(-row=>5, -column=>0, -pady=>0, -sticky=>'w');
326 $frame -> Checkbutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_e,
327 -onvalue=>'d', -offvalue=>"", -variable=>\$plot_features{e_mderiv})
328 -> grid(-row=>5, -column=>1, -pady=>0, -sticky=>'w');
329 ## emin/emax
330 my $frm = $frame -> Frame() # -> pack(-expand=>1, -fill=>'x');
331 -> grid(-row=>6, -column=>0, -columnspan=>5, -padx=>1, -pady=>2, -sticky=>'we');
332 $frm -> Label(-text=>'Emin:') -> pack(-side=>'left');
333 $frm -> RetEntry(-width=>5,
334 -textvariable=>\$plot_features{emin},
335 -state=>'normal',
336 -command=>[\&autoreplot,'e'],
337 -validate=>'key',
338 -validatecommand=>[\&set_variable,"po_emin"])
339 -> pack(-side=>'left');
340 $frm -> RetEntry(-width=>5,
341 -textvariable=>\$plot_features{emax},
342 -state=>'normal',
343 -command=>[\&autoreplot,'e'],
344 -validate=>'key',
345 -validatecommand=>[\&set_variable,"po_emax"])
346 -> pack(-side=>'right');
347 $frm -> Label(-text=>'Emax:') -> pack(-side=>'right');
348
349 ## k choices --------------------------------------------------------------
350 $frame = $plotcard{k} -> Frame() -> pack(-fill=>'x', -expand=>1, -side=>'bottom');
351 # $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_k,
352 # -value=>'w', -variable=>\$plot_features{k_w})
353 # -> grid(-row=>0, -column=>1, -pady=>0, -sticky=>'w');
354 # $frame -> Radiobutton(-text=>'chi*k^kw', -selectcolor=>$red, -command=>\&replot_group_k,
355 # -value=>'w', -variable=>\$plot_features{k_w})
356 # -> grid(-row=>0, -column=>0, -pady=>0, -sticky=>'w');
357 #
358 # $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_k,
359 # -value=>'0', -variable=>\$plot_features{k_w})
360 # -> grid(-row=>1, -column=>1, -pady=>0, -sticky=>'w');
361 # $frame -> Radiobutton(-text=>'chi', -selectcolor=>$red, -command=>\&replot_group_k,
362 # -value=>'0', -variable=>\$plot_features{k_w})
363 # -> grid(-row=>1, -column=>0, -pady=>0, -sticky=>'w');
364 #
365 # $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_k,
366 # -value=>'1', -variable=>\$plot_features{k_w})
367 # -> grid(-row=>2, -column=>1, -pady=>0, -sticky=>'w');
368 # $frame -> Radiobutton(-text=>'chi*k' , -selectcolor=>$red, -command=>\&replot_group_k,
369 # -value=>'1', -variable=>\$plot_features{k_w})
370 # -> grid(-row=>2, -column=>0, -pady=>0, -sticky=>'w');
371 #
372 # $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_k,
373 # -value=>'2', -variable=>\$plot_features{k_w})
374 # -> grid(-row=>3, -column=>1, -pady=>0, -sticky=>'w');
375 # $frame -> Radiobutton(-text=>'chi*k^2', -selectcolor=>$red, -command=>\&replot_group_k,
376 # -value=>'2', -variable=>\$plot_features{k_w})
377 # -> grid(-row=>3, -column=>0, -pady=>0, -sticky=>'w');
378 #
379 # $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_k,
380 # -value=>'3', -variable=>\$plot_features{k_w})
381 # -> grid(-row=>4, -column=>1, -pady=>0, -sticky=>'w');
382 # $frame -> Radiobutton(-text=>'chi*k^3', -selectcolor=>$red, -command=>\&replot_group_k,
383 # -value=>'3', -variable=>\$plot_features{k_w})
384 # -> grid(-row=>4, -column=>0, -pady=>0, -sticky=>'w');
385
386 $frame -> Checkbutton(-text=>q{}, -selectcolor=>$vio, -command=>\&replot_marked_k,
387 -onvalue=>'e', -offvalue=>q{}, -variable=>\$plot_features{chie})
388 -> grid(-row=>4, -column=>1, -pady=>0, -sticky=>'w');
389 $frame -> Checkbutton(-text=>'Plot chi(E)', -selectcolor=>$red, -command=>\&replot_group_k,
390 -onvalue=>'e', -offvalue=>q{}, -variable=>\$plot_features{chie})
391 -> grid(-row=>4, -column=>0, -pady=>0, -sticky=>'w');
392 $frame -> Checkbutton(-text=>'Window', -onvalue=>'w', -offvalue=>q{}, -selectcolor=>$red,
393 -variable=>\$plot_features{k_win}, -command=>\&replot_group_k,)
394 -> grid(-row=>5, -column=>0, -pady=>0, -sticky=>'w');
395
396 $frm = $frame -> Frame()
397 -> grid(-row=>6, -column=>0, -columnspan=>5, -pady=>2, -sticky=>'we');
398 $frm -> Label(-text=>'kmin:') -> pack(-side=>'left');
399 $frm -> RetEntry(-width=>5,
400 -textvariable=>\$plot_features{kmin},
401 -state=>'normal',
402 -command=>[\&autoreplot,'k'],
403 -validate=>'key',
404 -validatecommand=>[\&set_variable,"po_kmin"])
405 -> pack(-side=>'left');
406 $frm -> RetEntry(-width=>5,
407 -textvariable=>\$plot_features{kmax},
408 -state=>'normal',
409 -command=>[\&autoreplot,'k'],
410 -validate=>'key',
411 -validatecommand=>[\&set_variable,"po_kmax"])
412 -> pack(-side=>'right');
413 $frm -> Label(-text=>'kmax:') -> pack(-side=>'right');
414
415
416 ## R choices --------------------------------------------------------------
417 $frame = $plotcard{r} -> Frame() -> pack(-fill=>'x');
418 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_r,
419 -value=>'rm', -variable=>\$plot_features{r_marked})
420 -> grid(-row=>0, -column=>1, -pady=>0, -sticky=>'w');
421 $frame -> Checkbutton(-text=>'Magnitude', -onvalue=>'m', -offvalue=>"", -selectcolor=>$red,
422 -variable=>\$plot_features{r_mag},
423 -command=> sub{$plot_features{r_env}=''; &replot_group_r; }, )
424 -> grid(-row=>0, -column=>0, -pady=>0, -sticky=>'w');
425
426 $frame -> Checkbutton(-text=>'Envelope', -onvalue=>'e', -offvalue=>"", -selectcolor=>$red,
427 -variable=>\$plot_features{r_env},
428 -command=> sub{$plot_features{r_mag}=''; &replot_group_r; }, )
429 -> grid(-row=>1, -column=>0, -pady=>0, -sticky=>'w');
430
431 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_r,
432 -value=>'rr', -variable=>\$plot_features{r_marked})
433 -> grid(-row=>2, -column=>1, -pady=>0, -sticky=>'w');
434 $frame -> Checkbutton(-text=>'Real part', -onvalue=>'r', -offvalue=>"", -selectcolor=>$red,
435 -variable=>\$plot_features{r_re}, -command=>\&replot_group_r)
436 -> grid(-row=>2, -column=>0, -pady=>0, -sticky=>'w');
437
438 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_r,
439 -value=>'ri', -variable=>\$plot_features{r_marked})
440 -> grid(-row=>3, -column=>1, -pady=>0, -sticky=>'w');
441 $frame -> Checkbutton(-text=>'Imaginary part', -onvalue=>'i', -offvalue=>"", -selectcolor=>$red,
442 -variable=>\$plot_features{r_im}, -command=>\&replot_group_r)
443 -> grid(-row=>3, -column=>0, -pady=>0, -sticky=>'w');
444
445 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_r,
446 -value=>'rp', -variable=>\$plot_features{r_marked})
447 -> grid(-row=>4, -column=>1, -pady=>0, -sticky=>'w');
448 $frame -> Checkbutton(-text=>'Phase', -onvalue=>'p', -offvalue=>"", -selectcolor=>$red,
449 -variable=>\$plot_features{r_pha}, -command=>\&replot_group_r)
450 -> grid(-row=>4, -column=>0, -pady=>0, -sticky=>'w');
451
452 $frame -> Checkbutton(-text=>'Window', -onvalue=>'w', -offvalue=>"", -selectcolor=>$red,
453 -variable=>\$plot_features{r_win}, -command=>\&replot_group_r)
454 -> grid(-row=>5, -column=>0, -pady=>0, -sticky=>'w');
455
456 $frm = $frame -> Frame() ->
457 grid(-row=>6, -column=>0, -columnspan=>5, -pady=>2, -sticky=>'we');
458 $frm -> Label(-text=>'Rmin:') -> pack(-side=>'left');
459 $frm -> RetEntry(-width=>5,
460 -textvariable=>\$plot_features{rmin},
461 -state=>'normal',
462 -command=>[\&autoreplot,'r'],
463 -validate=>'key',
464 -validatecommand=>[\&set_variable,"po_rmin"])
465 -> pack(-side=>'left');
466 $frm -> RetEntry(-width=>5,
467 -textvariable=>\$plot_features{rmax},
468 -state=>'normal',
469 -command=>[\&autoreplot,'r'],
470 -validate=>'key',
471 -validatecommand=>[\&set_variable,"po_rmax"])
472 -> pack(-side=>'right');
473 $frm -> Label(-text=>'Rmax:') -> pack(-side=>'right');
474
475
476 ## q choices --------------------------------------------------------------
477 $frame = $plotcard{q} -> Frame() -> pack(-fill=>'x');
478 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_q,
479 -value=>'qm', -variable=>\$plot_features{q_marked})
480 -> grid(-row=>0, -column=>1, -pady=>0, -sticky=>'w');
481 $frame -> Checkbutton(-text=>'Magnitude', -onvalue=>'m', -offvalue=>"", -selectcolor=>$red,
482 -command=>sub{$plot_features{q_env}=''; &replot_group_q;},
483 -variable=>\$plot_features{q_mag})
484 -> grid(-row=>0, -column=>0, -pady=>0, -sticky=>'w');
485
486 $frame -> Checkbutton(-text=>'Envelope', -onvalue=>'e', -offvalue=>"", -selectcolor=>$red,
487 -command=>sub{$plot_features{q_mag}=''; &replot_group_q;},
488 -variable=>\$plot_features{q_env})
489 -> grid(-row=>1, -column=>0, -pady=>0, -sticky=>'w');
490
491 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_q,
492 -value=>'qr', -variable=>\$plot_features{q_marked})
493 -> grid(-row=>2, -column=>1, -pady=>0, -sticky=>'w');
494 $frame -> Checkbutton(-text=>'Real part', -onvalue=>'r', -offvalue=>"", -selectcolor=>$red,
495 -variable=>\$plot_features{q_re}, -command=>\&replot_group_q)
496 -> grid(-row=>2, -column=>0, -pady=>0, -sticky=>'w');
497
498 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_q,
499 -value=>'qi', -variable=>\$plot_features{q_marked})
500 -> grid(-row=>3, -column=>1, -pady=>0, -sticky=>'w');
501 $frame -> Checkbutton(-text=>'Imaginary part', -onvalue=>'i', -offvalue=>"", -selectcolor=>$red,
502 -variable=>\$plot_features{q_im}, -command=>\&replot_group_q)
503 -> grid(-row=>3, -column=>0, -pady=>0, -sticky=>'w');
504
505 $frame -> Radiobutton(-text=>'', -selectcolor=>$vio, -command=>\&replot_marked_q,
506 -value=>'qp', -variable=>\$plot_features{q_marked})
507 -> grid(-row=>4, -column=>1, -pady=>0, -sticky=>'w');
508 $frame -> Checkbutton(-text=>'Phase', -onvalue=>'p', -offvalue=>"", -selectcolor=>$red,
509 -variable=>\$plot_features{q_pha}, -command=>\&replot_group_q)
510 -> grid(-row=>4, -column=>0, -pady=>0, -sticky=>'w');
511
512 $frame -> Checkbutton(-text=>'Window', -onvalue=>'w', -offvalue=>"", -selectcolor=>$red,
513 -variable=>\$plot_features{q_win}, -command=>\&replot_group_q)
514 -> grid(-row=>5, -column=>0, -pady=>0, -sticky=>'w');
515
516 $frm = $frame -> Frame() ->
517 grid(-row=>6, -column=>0, -columnspan=>5, -pady=>2, -sticky=>'we');
518 $frm -> Label(-text=>'qmin:') -> pack(-side=>'left');
519 $frm -> RetEntry(-width=>5,
520 -textvariable=>\$plot_features{qmin},
521 -state=>'normal',
522 -command=>[\&autoreplot,'q'],
523 -validate=>'key',
524 -validatecommand=>[\&set_variable,"po_qmin"])
525 -> pack(-side=>'left');
526 $frm -> RetEntry(-width=>5,
527 -textvariable=>\$plot_features{qmax},
528 -state=>'normal',
529 -command=>[\&autoreplot,'q'],
530 -validate=>'key',
531 -validatecommand=>[\&set_variable,"po_qmax"])
532 -> pack(-side=>'right');
533 $frm -> Label(-text=>'qmax:') -> pack(-side=>'right');
534
535 ## Stack
536 $frame = $plotcard{Stack} -> Frame() -> pack(-fill=>'x');
537 $frame -> Label(-text=>"Set y-offset values for\nall MARKED groups",
538 -font=>$config{fonts}{small},
539 -foreground=>$config{colors}{activehighlightcolor})
540 -> grid(-row=>0, -column=>0, -columnspan=>2, -ipady=>5);
541 $frame -> Label(-text=>"Initial value", -foreground=>$config{colors}{activehighlightcolor})
542 -> grid(-row=>1, -column=>0, -sticky=>'e');
543 $widget{sta_init} = $frame -> Entry(-width=>10, -validate=>'key',
544 -validatecommand=>[\&set_variable, 'sta_init'])
545 -> grid(-row=>1, -column=>1, -sticky=>'w', -ipadx=>3);
546 $frame -> Label(-text=>"Increment", -foreground=>$config{colors}{activehighlightcolor})
547 -> grid(-row=>2, -column=>0, -sticky=>'e');
548 $widget{sta_incr} = $frame -> Entry(-width=>10, -validate=>'key',
549 -validatecommand=>[\&set_variable, 'sta_incr'])
550 -> grid(-row=>2, -column=>1, -sticky=>'w', -ipadx=>3);
551 $widget{sta_init}->insert('end', 0);
552 $widget{sta_incr}->insert('end', 0);
553 $frame -> Button(-text=>'Set y-offset values', @button_list, -borderwidth=>1,
554 -command=> [\&set_stacked_plot, $widget{sta_init}, $widget{sta_incr}],
555 )
556 -> grid(-row=>3, -column=>0, -columnspan=>2, -sticky=>'ew', -pady=>3);
557 $frame -> Button(-text=>'Reset', @button_list, -borderwidth=>1,
558 -command=> [\&reset_stacked_plot, $widget{sta_init}, $widget{sta_incr}],
559 )
560 -> grid(-row=>4, -column=>0, -columnspan=>2, -sticky=>'ew', -pady=>3);
561
562 ## Plot indicators
563 $plotcard{Ind} -> Label(-text=>"Plot indicators",
564 -font=>$config{fonts}{bold},
565 -foreground=>$config{colors}{activehighlightcolor})
566 -> pack(-side=>'top');
567 $indicator[0] = 0;
568 $plotcard{Ind} -> Checkbutton(-text=>'Display indicators', -variable=>\$indicator[0], -selectcolor => $red,)
569 -> pack(-expand=>1, -fill=>'x', -side=>'top');
570 my $t = $plotcard{Ind} -> Scrolled('Pane',
571 -scrollbars => 'e',
572 -width => 1,
573 -height => 1,
574 -borderwidth => 0,
575 -relief => 'flat')
576 -> pack(-expand=>1, -fill=>'both', -side=>'top', -padx=>3, -pady=>3);
577 $t -> Subwidget("yscrollbar")
578 -> configure(-background=>$config{colors}{background},
579 ($is_windows) ? () : (-width=>8));
580 #BindMouseWheel($t);
581 #disable_mouse3($t->Subwidget('rotext'));
582 foreach my $r (1 .. $config{plot}{nindicators}) {
583 $indicator[$r] = ["", " ", " "];
584 $t -> Label(-text=>$r.":", -foreground=>$config{colors}{activehighlightcolor})
585 -> grid(-row=>$r, -column=>0, -ipadx=>3);
586 $t -> Label(-textvariable=>\$indicator[$r][1],
587 -width=>3)
588 -> grid(-row=>$r, -column=>1);
589 my $this = $t -> Entry(-width=>10, -textvariable=>\$indicator[$r][2],
590 -validate=>'key',
591 -validatecommand=>[\&set_variable, "ind_$r"],
592 )
593 -> grid(-row=>$r, -column=>2);
594 $indicator[$r][0] = $t -> Button(@pluck_button, @pluck, -command=>sub{&indicator_pluck($r)})
595 -> grid(-row=>$r, -column=>3);
596 };
597
598 ## Pointfinder
599 $plotcard{PF} -> Label(-text=>"Point finder",
600 -font=>$config{fonts}{bold},
601 -foreground=>$config{colors}{activehighlightcolor})
602 -> pack(-side=>'top');
603 $pointfinder{space} = $plotcard{PF} -> Label(-text=>"Last plot was in ?",
604 -font=>$config{fonts}{small})
605 -> pack(-side=>'top', -pady=>2);
606 $frame = $plotcard{PF} -> Frame()
607 -> pack(-side=>'top');
608 $frame -> Label(-text=>'X: ', -foreground=>$config{colors}{activehighlightcolor})
609 -> grid(-row=>0, -column=>0, -padx=>1, -pady=>1);
610 $pointfinder{'x'} = $frame -> Entry(-width=>8, -state=>'disabled',
611 -textvariable=>\$pointfinder{xvalue},
612 -validate=>'key', -validatecommand=>[\&set_variable,"pf_x"])
613 -> grid(-row=>0, -column=>1, -padx=>1, -pady=>1);
614 $pointfinder{xpluck} = $frame -> Button(@pluck_button, @pluck, -state=>'disabled',
615 -command=>sub{&pointfinder_pluck('x')})
616 -> grid(-row=>0, -column=>2, -padx=>1, -pady=>1);
617 $pointfinder{xfind} = $frame -> Button(-text=>'find Y', @button_list,
618 -state=>'disabled', -borderwidth=>1,
619 -command=>[\&pointfinder_find, 'x'])
620 -> grid(-row=>0, -column=>3, -padx=>1, -pady=>1);
621
622 $frame -> Label(-text=>'Y: ', -foreground=>$config{colors}{activehighlightcolor})
623 -> grid(-row=>1, -column=>0, -padx=>1, -pady=>1);
624 $pointfinder{'y'} = $frame -> Entry(-width=>8, -state=>'disabled',
625 -textvariable=>\$pointfinder{yvalue},
626 -validate=>'key', -validatecommand=>[\&set_variable,"pf_y"])
627 -> grid(-row=>1, -column=>1, -padx=>1, -pady=>1);
628 $pointfinder{ypluck} = $frame -> Button(@pluck_button, @pluck, -state=>'disabled',
629 -command=>sub{&pointfinder_pluck('y')})
630 -> grid(-row=>1, -column=>2, -padx=>1, -pady=>1);
631 $pointfinder{yfind} = $frame -> Button(-text=>'find X', @button_list,
632 -state=>'disabled', -borderwidth=>1,)
633 -> grid(-row=>1, -column=>3, -padx=>1, -pady=>1);
634
635 $pointfinder{clear} = $frame -> Button(-text=>'Clear', @button_list,
636 -state=>'disabled', -borderwidth=>1,
637 -command=>sub{$pointfinder{xvalue}="";
638 $pointfinder{yvalue}="";})
639 -> grid(-row=>2, -column=>0, -columnspan=>4, -sticky=>'ew', -padx=>1, -pady=>1);
640
641 };
642
643
644 sub set_stacked_plot {
645 Echo("No data!"), return unless $current;
646 Echo("No data!"), return if ($current eq "Default Parameters");
647 my ($ini, $inc) = @_;
648 my ($yvalue, $yinc) = ($ini->get(), $inc->get());
649 ($yvalue = 0) if ($yvalue =~ /^\s*$/);
650 ($yinc = 0) if ($yinc =~ /^\s*$/);
651 my $message = "Set y-offsets for all marked groups starting at "
652 . $yvalue . " & incrementing by " . $yinc
653 . ". Now click a purple plot button.";
654 my $n = 0;
655 foreach my $k (&sorted_group_list) {
656 next unless $marked{$k};
657 ++$n;
658 $groups{$k} -> MAKE(plot_yoffset=>sprintf("%.4f",$yvalue));
659 $yvalue += $yinc;
660 };
661 set_properties (1, $current, 0);
662 Error("No y-offset parameters were set because there were no marked groups."), return if ($n == 0);
663 Error("Only one y-offset parameter was set because there was only one marked group."),
664 return if ($n == 1);
665 Echo($message);
666 };
667
668 sub reset_stacked_plot {
669 my ($ini, $inc) = @_;
670 $ini->delete(qw(0 end));
671 $ini->insert('end', 0);
672 $inc->delete(qw(0 end));
673 $inc->insert('end', 0);
674 foreach my $k (&sorted_group_list) {
675 next unless $marked{$k};
676 $groups{$k} -> MAKE(plot_yoffset=>0);
677 };
678 set_properties (1, $current, 0);
679 Echo("Reset stacking parameters and y-offsets for all marked group to 0.");
680 };
681
682
683
684 sub indicator_pluck {
685 my $which = $_[0];
686 my $parent = $_[1] || $top;
687 Error("You have not made a plot yet."), return 0 unless ($last_plot);
688
689 Echonow("Select a point from the plot...");
690 my ($cursor_x, $cursor_y) = (0,0);
691 $indicator[$which][0] -> grab();
692 $groups{$current}->dispose("cursor(crosshair=true)\n", $dmode);
693 ($cursor_x, $cursor_y) = (Ifeffit::get_scalar("cursor_x"),
694 Ifeffit::get_scalar("cursor_y"));
695 $groups{$current}->dispose("\n", $dmode);
696 $indicator[$which][0] -> grabRelease();
697 $indicator[$which][1] = ($last_plot =~ /[kq]/) ? $last_plot : uc($last_plot);
698 $indicator[$which][2] = sprintf("%.3f", $cursor_x);
699 Echo("Made an indicator at $indicator[$which][2] in $indicator[$which][1]");
700 #$Data::Dumper::Indent = 2;
701 #print Data::Dumper->Dump([\@indicator], [qw(indicator)]);
702 #$Data::Dumper::Indent = 0;
703 };
704
705 sub pointfinder_pluck {
706 my $which = $_[0];
707 if ($which eq 'x') {
708 Echonow("Select an x value from the plot...");
709 } else {
710 Echonow("Select a y value from the plot...");
711 };
712 $pointfinder{$which . 'pluck'}->grab();
713 $groups{$current}->dispose("cursor(crosshair=true)\n", $dmode);
714 my ($cursor_x, $cursor_y) = (Ifeffit::get_scalar("cursor_x"),
715 Ifeffit::get_scalar("cursor_y"));
716 $groups{$current}->dispose("\n", $dmode);
717 $pointfinder{$which . 'pluck'} -> grabRelease();
718 if ($which eq 'x') {
719 $pointfinder{xvalue} = sprintf("%.3f", $cursor_x);
720 Echo("You selected an x-axis value of $pointfinder{xvalue}");
721 } else {
722 $pointfinder{yvalue} = sprintf("%.5f", $cursor_y);
723 Echo("You selected a y-axis value of $pointfinder{yvalue}");
724 };
725 };
726
727
728 sub pointfinder_find {
729 Error("You haven't specified an $_[0] axis point"), return unless $pointfinder{$_[0].'value'};
730 Echo("Not doing y to x yet"), return if ($_[0] eq 'y');
731 my $which = $_[0];
732 my $space = $$last_plot_params[2];
733 my $last = $$last_plot_params[3];
734 my $group = $groups{$current}->{group};
735 my $pmult = $groups{$current}->{plot_scale};
736 my $yoff = $groups{$current}->{plot_yoffset};
737 my $x = "";
738 my $array = ""; # figure out what we are interpolating
739 # off of -- kinda tricky for energy space
740 SWITCH: {
741 ($space eq 'e') and do {
742 $x = 'energy';
743 ($array = "$group.flat+$yoff"), last SWITCH if (($last =~ /m.*n/) and ($last !~ /d/) and $groups{$current}->{bkg_flatten});
744 ($array = "$group.norm+$yoff"), last SWITCH if (($last =~ /m.*n/) and ($last !~ /d/));
745 ($array = "$pmult*deriv($group.flat)/deriv($group.energy)+$yoff"), last SWITCH if (($last =~ /m.*nd/) and $groups{$current}->{bkg_flatten});
746 ($array = "$pmult*deriv($group.norm)/deriv($group.energy)+$yoff"), last SWITCH if ($last =~ /m.*nd/);
747 ($array = "$pmult*deriv($group.xmu)/deriv($group.energy)+$yoff"), last SWITCH if (($last =~ /m.*d/) and ($last !~ /m.*n/));
748 ($array = "$group.xmu+$yoff"), last SWITCH if (($last =~ /m/) and ($last !~ /[nd]/));
749 ($array = "$group.fbkg+$yoff"), last SWITCH if (($last !~ /m/) and ($last =~ /z/) and $groups{$current}->{bkg_flatten});
750 ($array = "$group.bkg+$yoff"), last SWITCH if (($last !~ /m/) and ($last =~ /z/));
751 last SWITCH;
752 };
753 ($space eq 'k') and do {
754 $x = 'k';
755 ($array = "$group.chi+$yoff"), last SWITCH if ($last =~ /k0/);
756 ($array = "$group.chi*$group.k+$yoff"), last SWITCH if ($last =~ /k1/);
757 ($array = "$group.chi*$group.k**2+$yoff"), last SWITCH if ($last =~ /k2/);
758 ($array = "$group.chi*$group.k**3+$yoff"), last SWITCH if ($last =~ /k3/);
759 last SWITCH;
760 };
761 ($space eq 'r') and do {
762 $x = 'r';
763 ($array = "$group.chir_mag+$yoff"), last SWITCH if ($last =~ /m/);
764 ($array = "$group.chir_re+$yoff"), last SWITCH if ($last =~ /r/);
765 ($array = "$group.chir_im+$yoff"), last SWITCH if ($last =~ /i/);
766 ($array = "$group.chir_pha+$yoff"), last SWITCH if ($last =~ /p/);
767 last SWITCH;
768 };
769 ($space eq 'q') and do {
770 $x = 'q';
771 ($array = "$group.chiq_mag+$yoff"), last SWITCH if ($last =~ /m/);
772 ($array = "$group.chiq_re+$yoff"), last SWITCH if ($last =~ /r/);
773 ($array = "$group.chiq_im+$yoff"), last SWITCH if ($last =~ /i/);
774 ($array = "$group.chiq_pha+$yoff"), last SWITCH if ($last =~ /p/);
775 last SWITCH;
776 };
777 };
778 Error("The pointfinder cannot grab a point from the previous plot (" . join(" ", @$last_plot_params) . ")" ), return unless $array;
779
780
781 $groups{$current} -> dispose("set $group.pf=$array", $dmode);
782 my @x = Ifeffit::get_array("$group.$x");
783 my @y = Ifeffit::get_array("$group.pf");
784
785 if ($which eq 'x') {
786 foreach my $i (0 .. $#x) {
787 next if ($x[$i] < $pointfinder{xvalue});
788 my $frac = ($pointfinder{xvalue} - $x[$i-1]) / ($x[$i] - $x[$i-1]);
789 $pointfinder{yvalue} = sprintf("%.5f", $y[$i-1] + $frac*($y[$i] - $y[$i-1]));
790 last;
791 };
792 } else {
793 ### ????
794 };
795 $groups{$current} -> dispose($Ifeffit::Group::last_plot, $dmode);
796 my $eshift = $groups{$current}->{bkg_eshift};
797
798 my $command = "pmarker \"$group.$x+$eshift\", $group.pf, $pointfinder{xvalue}, $config{plot}{pointfinder}, " .
799 "$config{plot}{pointfindercolor}, 0\n";
800 $groups{$current} -> dispose($command, $dmode);
801 $groups{$current} -> dispose("erase $group.pf", $dmode);
802 Echo("Found the point ($pointfinder{xvalue},$pointfinder{yvalue})");
803 };
804
805
806 sub replot_group_e {
807 return unless ($current);
808 my $str = 'e';
809 map {$str .= $plot_features{$_}} (qw/e_mu e_mu0 e_pre e_post e_norm e_der/);
810 ($str =~ m{d\z}) and ($str .= "s" x $plot_features{smoothderiv});
811 $groups{$current}->plotE($str,$dmode,\%plot_features, \@indicator);
812 $last_plot='e';
813 $last_plot_params = [$current, 'group', 'e', $str];
814 };
815 sub replot_marked_e {
816 return unless ($current);
817 $groups{$current}->plot_marked($plot_features{e_marked}, $dmode,
818 \%groups, \%marked, \%plot_features, $list,
819 \@indicator);
820 $last_plot='e';
821 $last_plot_params = [$current, 'marked', 'e', $plot_features{e_marked}];
822 };
823
824 sub replot_group_k {
825 return unless ($current);
826 my $str = 'k';
827 map {$str .= $plot_features{$_}} (qw/k_w k_win/);
828 $groups{$current}->plotk($str,$dmode,\%plot_features, \@indicator);
829 $last_plot='k';
830 $last_plot_params = [$current, 'group', 'k', $str];
831 };
832 sub replot_marked_k {
833 return unless ($current);
834 $groups{$current}->plot_marked($plot_features{k_w}, $dmode,
835 \%groups, \%marked, \%plot_features, $list,
836 \@indicator);
837 $last_plot='k';
838 $last_plot_params = [$current, 'marked', 'k', $plot_features{k_w}];
839 };
840
841 sub replot_group_r {
842 return unless ($current);
843 my $str = 'r';
844 map {$str .= $plot_features{$_}} (qw/r_mag r_env r_re r_im r_pha r_win/);
845 $groups{$current}->plotR($str,$dmode,\%plot_features, \@indicator);
846 $last_plot='r';
847 $last_plot_params = [$current, 'group', 'r', $str];
848 };
849 sub replot_marked_r {
850 return unless ($current);
851 $groups{$current}->plot_marked($plot_features{r_marked}, $dmode,
852 \%groups, \%marked, \%plot_features, $list,
853 \@indicator);
854 $last_plot='r';
855 $last_plot_params = [$current, 'marked', 'r', $plot_features{r_marked}];
856 };
857
858 sub replot_group_q {
859 return unless ($current);
860 my $str = 'q';
861 map {$str .= $plot_features{$_}} (qw/q_mag q_env q_re q_im q_pha q_win/);
862 $groups{$current}->plotq($str,$dmode,\%plot_features, \@indicator);
863 $last_plot='q';
864 $last_plot_params = [$current, 'group', 'q', $str];
865 };
866 sub replot_marked_q {
867 return unless ($current);
868 $groups{$current}->plot_marked($plot_features{q_marked}, $dmode,
869 \%groups, \%marked, \%plot_features, $list,
870 \@indicator);
871 $last_plot='q';
872 $last_plot_params = [$current, 'marked', 'q', $plot_features{q_marked}];
873 };
874
875
876 ## END OF SETUP SUBSECTION
877 ##########################################################################################