| 1 |
|
| 2 |
|
| 3 |
## -*- cperl -*- |
| 4 |
## |
| 5 |
## This file is part of Athena, copyright (c) 2001-2006, 2009 Bruce Ravel |
| 6 |
## |
| 7 |
## This section of the code contains subroutines for drawing the |
| 8 |
## frame which contains all the parameters of the selected group |
| 9 |
|
| 10 |
|
| 11 |
## This is just a lot of boring layout of widgets. It's some really |
| 12 |
## dense, repititious, and uninteresting code. |
| 13 |
|
| 14 |
sub draw_properties { |
| 15 |
#my $c = $_[0]; |
| 16 |
my $frame = $_[0]; |
| 17 |
my ($f_label, $f_text, $f_bold, $f_tiny) = ($config{fonts}{bold}, |
| 18 |
$config{fonts}{small}, |
| 19 |
$config{fonts}{small}, |
| 20 |
$config{fonts}{tiny}); |
| 21 |
my $bigtextcolor = $config{colors}{activehighlightcolor}; |
| 22 |
my ($t, $y) = ("", '0.4c'); |
| 23 |
my @rectangle = ("-fill", $config{colors}{background}, |
| 24 |
"-outline", $config{colors}{background}, |
| 25 |
"-width", 3); |
| 26 |
|
| 27 |
my $gap = 10; |
| 28 |
my $jump = 0; |
| 29 |
$y = 7; |
| 30 |
|
| 31 |
|
| 32 |
## ============================================================================ |
| 33 |
## ============================================================================ |
| 34 |
## projectbar |
| 35 |
my $c = $frame -> Frame(qw/-relief ridge -borderwidth 2 -width 12.5c/, |
| 36 |
-highlightcolor=>$config{colors}{background}) |
| 37 |
-> pack(qw/-expand 1 -fill both/); |
| 38 |
# disable_mouse_wheel($c); |
| 39 |
$widget{main_canvas} = $c; |
| 40 |
my @bbox_list = (); |
| 41 |
$props{project} = $c; |
| 42 |
my $box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>3); |
| 43 |
$header{project} = $box -> Label(-text=>" Project", |
| 44 |
-foreground=>$bigtextcolor, |
| 45 |
-font=>$f_label) |
| 46 |
-> pack(-side=>'left'); |
| 47 |
&group_click($header{project}, 'project'); |
| 48 |
my $project_label = $box -> Label(-textvariable => \$project_name, |
| 49 |
-width => 1, |
| 50 |
#-justify => 'right', |
| 51 |
-anchor => 'e') |
| 52 |
-> pack(-side=>'left', -padx=>12, -expand=>1, -fill=>'x'); |
| 53 |
|
| 54 |
|
| 55 |
## Current group section |
| 56 |
$c = $frame -> Frame(qw(-relief ridge -borderwidth 2 -width 12.5c), |
| 57 |
-highlightcolor=>$config{colors}{background}) |
| 58 |
-> pack(qw/-expand 1 -fill x/); #disable_mouse_wheel($c); |
| 59 |
$props{current} = $c; |
| 60 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>3); |
| 61 |
$header{current} = $box -> Label(-text => " Current group", |
| 62 |
-foreground => $bigtextcolor, |
| 63 |
-font => $f_label) |
| 64 |
-> pack(-side=>'left'); |
| 65 |
&group_click($header{current}, 'current'); |
| 66 |
$widget{current} = $box -> Entry(-width=>30, -relief=>'flat', -font=>$f_bold, |
| 67 |
-foreground=>$config{colors}{button}, |
| 68 |
(($Tk::VERSION >= 804) ? (-disabledforeground=>$config{colors}{button}) : ()), |
| 69 |
-state=>'disabled') |
| 70 |
-> pack(-side=>'left', -expand=>1, -fill=>'x', -padx=>12); |
| 71 |
## not displaying the ifeffit data group |
| 72 |
$widget{group} = $box -> Entry(-width=>10, -relief=>'flat', -font=>$f_bold, |
| 73 |
-foreground=>$config{colors}{button}, |
| 74 |
-state=>'disabled'); |
| 75 |
## -> pack(-side=>'left', -expand=>1, -fill=>'x'); |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>3); |
| 80 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 81 |
$t = $box -> Label(-text=>"File:", |
| 82 |
-foreground=>'black', -font=>$f_text) |
| 83 |
-> pack(-side=>'left'); |
| 84 |
&click_help($t,0); |
| 85 |
$widget{file} = $box -> Entry(-width=>45, -state=>'disabled', -relief=>'groove', |
| 86 |
-foreground=>$config{colors}{foreground}, |
| 87 |
(($Tk::VERSION >= 804) ? (-disabledforeground=>$config{colors}{foreground}) : ()), |
| 88 |
) |
| 89 |
-> pack(-side=>'left', -expand=>1, -fill=>'x', -padx=>6); |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>3); |
| 94 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 95 |
$t = $box -> Label(-text=>"Z: ", |
| 96 |
-foreground=>'black', -font=>$f_text) |
| 97 |
-> pack(-side=>'left'); |
| 98 |
&click_help($t,'bkg_z'); |
| 99 |
$widget{z} = $box -> Optionmenu(-font=>$config{fonts}{small}, |
| 100 |
-textvariable => \$menus{bkg_z}, |
| 101 |
-borderwidth=>1, -state=>'disabled', |
| 102 |
) |
| 103 |
-> pack(-side=>'left', -padx=>6); |
| 104 |
my $last = 90; |
| 105 |
while ($last < 104) { |
| 106 |
last unless (Xray::Absorption->in_resource($last)); |
| 107 |
++$last; |
| 108 |
}; |
| 109 |
--$last; |
| 110 |
foreach my $l ([1..20], [21..40], [41..60], [61..80], [81..$last]) { |
| 111 |
my $cas = $widget{z} -> |
| 112 |
cascade(-label => get_symbol($$l[0]) . " (" . $$l[0] . ") to " . get_symbol($$l[-1]) . " (" . $$l[-1] . ") ", |
| 113 |
-tearoff=>0 ); |
| 114 |
foreach my $i (@$l) { |
| 115 |
$cas -> command(-label => $i . ": " . get_symbol($i), |
| 116 |
-command=> |
| 117 |
sub{$menus{bkg_z}=get_symbol($i); |
| 118 |
if ($groups{$current}->{frozen}) { |
| 119 |
$menus{bkg_z}=$groups{$current}->{bkg_z}; |
| 120 |
return; |
| 121 |
}; |
| 122 |
$groups{$current}->make(bkg_z=>$menus{bkg_z}, |
| 123 |
update_bkg=>1); |
| 124 |
# |
| 125 |
if ($groups{$current}->{reference} and $groups{$current}->{refsame}) { |
| 126 |
$groups{$groups{$current}->{reference}}->make(bkg_z=>$menus{bkg_z}, |
| 127 |
update_bkg=>1); |
| 128 |
}; |
| 129 |
#$groups{$current} -> |
| 130 |
# plotE('emzn',$dmode,\%plot_features, \@indicator); |
| 131 |
project_state(0); |
| 132 |
}); |
| 133 |
}; |
| 134 |
}; |
| 135 |
$t = $box -> Label(-text=>"Edge:", |
| 136 |
-foreground=>'black', -font=>$f_text) |
| 137 |
-> pack(-side=>'left'); |
| 138 |
&click_help($t,'fft_edge'); |
| 139 |
$menus{fft_edge} = 'K'; |
| 140 |
$widget{edge} = $box -> Optionmenu(-font=>$config{fonts}{small}, |
| 141 |
-borderwidth=>1, -state=>'disabled', |
| 142 |
-textvariable => \$menus{fft_edge},) |
| 143 |
-> pack(-side=>'left', -padx=>6); |
| 144 |
foreach my $i (qw(K L1 L2 L3 M1 M2 M3 M4 M5)) { |
| 145 |
$widget{edge} -> command(-label => $i, |
| 146 |
-command=> |
| 147 |
sub{$menus{fft_edge}=$i; |
| 148 |
if ($groups{$current}->{frozen}) { |
| 149 |
$menus{fft_edge}=$groups{$current}->{fft_edge}; |
| 150 |
return; |
| 151 |
}; |
| 152 |
$groups{$current}->make(fft_edge=>$menus{fft_edge}, |
| 153 |
update_fft=>1); |
| 154 |
if ($groups{$current}->{reference} and $groups{$current}->{refsame}) { |
| 155 |
$groups{$groups{$current}->{reference}}->make(fft_edge=>$menus{fft_edge}, |
| 156 |
update_bkg=>1); |
| 157 |
}; |
| 158 |
project_state(0); |
| 159 |
}); |
| 160 |
}; |
| 161 |
|
| 162 |
$t = $box -> Label(-text=>"E shift:", |
| 163 |
-foreground=>'black', -font=>$f_text) |
| 164 |
-> pack(-side=>'left'); |
| 165 |
&click_help($t,'bkg_eshift'); |
| 166 |
$widget{bkg_eshift} = $box -> Entry(-width=>5, -font=>$config{fonts}{entry}, |
| 167 |
-validate=>'key', -validatecommand=>[\&set_variable, 'bkg_eshift']) |
| 168 |
-> pack(-side=>'left', -padx=>6); |
| 169 |
|
| 170 |
|
| 171 |
$t = $box -> Label(-text=>"Importance:", |
| 172 |
-foreground=>'black', -font=>$f_text) |
| 173 |
-> pack(-side=>'left'); |
| 174 |
&click_help($t,'importance'); |
| 175 |
$widget{importance} = $box -> Entry(-width=>4, |
| 176 |
-font=>$config{fonts}{entry}, |
| 177 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 178 |
-validate=>'key', |
| 179 |
-validatecommand=>[\&set_variable, 'importance']) |
| 180 |
-> pack(-side=>'left', -padx=>6); |
| 181 |
|
| 182 |
#$box = $c -> Frame() -> pack(-side=>'top', -fill=>'y', -expand=>1); |
| 183 |
|
| 184 |
|
| 185 |
## Background Removal section |
| 186 |
$c = $frame -> Frame(qw/-relief ridge -borderwidth 2 -width 12.5c/, # -height 7.0c/, |
| 187 |
-highlightcolor=>$config{colors}{background}) |
| 188 |
-> pack(qw/-expand 1 -fill both/); |
| 189 |
# disable_mouse_wheel($c); |
| 190 |
$props{bkg} = $c; |
| 191 |
|
| 192 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>3); |
| 193 |
$header{bkg} = $box -> Label(-text=>" Background removal", |
| 194 |
-foreground=>$bigtextcolor, |
| 195 |
-font=>$f_label) |
| 196 |
-> pack(-side=>'left'); |
| 197 |
|
| 198 |
&group_click($header{bkg}, 'bkg'); |
| 199 |
$widget{bkg_switch} = $box -> Button(-text=>"Show additional parameters", |
| 200 |
-font=>$config{fonts}{small}, |
| 201 |
-borderwidth=>1, |
| 202 |
-command => sub { |
| 203 |
$props{bkg}->packForget; |
| 204 |
$props{bkg_secondary} -> pack(qw/-expand 1 -fill both -after/, $props{current}); |
| 205 |
}) |
| 206 |
-> pack(-side=>'right', -padx=>12); |
| 207 |
|
| 208 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 209 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 210 |
$t = $box -> Label(-text=>"E0:", |
| 211 |
-foreground=>'black', -font=>$f_text) |
| 212 |
-> pack(-side=>'left'); |
| 213 |
&click_help($t,'bkg_e0'); |
| 214 |
$widget{bkg_e0} = $box -> Entry(-width=>8, -validate=>'all', -font=>$config{fonts}{entry}, |
| 215 |
-validatecommand=>[\&set_variable, 'bkg_e0']) |
| 216 |
-> pack(-side=>'left', -padx=>6); |
| 217 |
$grab{bkg_e0} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_e0']) |
| 218 |
-> pack(-side=>'left'); |
| 219 |
|
| 220 |
$t = $box -> Label(-text=>"", |
| 221 |
-foreground=>'black', -font=>$f_text) |
| 222 |
-> pack(-side=>'left', -padx=>10); |
| 223 |
$t = $box -> Label(-text=>"Rbkg:", |
| 224 |
-foreground=>'black', -font=>$f_text) |
| 225 |
-> pack(-side=>'left'); |
| 226 |
&click_help($t,'bkg_rbkg'); |
| 227 |
$widget{bkg_rbkg} = $box -> RetEntry(-width=>4, |
| 228 |
-font=>$config{fonts}{entry}, |
| 229 |
-command=>\&autoreplot, |
| 230 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 231 |
-validate=>'key', |
| 232 |
-validatecommand=>[\&set_variable, 'bkg_rbkg']) |
| 233 |
-> pack(-side=>'left', -padx=>6); |
| 234 |
$grab{bkg_rbkg} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_rbkg']) |
| 235 |
-> pack(-side=>'left'); |
| 236 |
|
| 237 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 238 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 239 |
$t = $box -> Label(-text=>"k-weight:", |
| 240 |
-foreground=>'black', -font=>$f_text) |
| 241 |
-> pack(-side=>'left'); |
| 242 |
&click_help($t,'bkg_kw'); |
| 243 |
$widget{bkg_kw} = $box -> RetEntry(-width=>3, |
| 244 |
-font=>$config{fonts}{entry}, |
| 245 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 246 |
-command=>\&autoreplot, |
| 247 |
-validate=>'key', |
| 248 |
-validatecommand=>[\&set_variable, 'bkg_kw']) |
| 249 |
-> pack(-side=>'left', -padx=>6); |
| 250 |
|
| 251 |
$t = $box -> Label(-text=>"Edge step:", |
| 252 |
-foreground=>'black', -font=>$f_text) |
| 253 |
-> pack(-side=>'left'); |
| 254 |
&click_help($t,0); |
| 255 |
$widget{bkg_step} = $box -> NumEntry(-width => 7, |
| 256 |
-font => $config{fonts}{entry}, |
| 257 |
-orient => 'horizontal', |
| 258 |
-foreground => $config{colors}{foreground}, |
| 259 |
-increment => $config{bkg}{step_increment}, |
| 260 |
-browsecmd => sub{$menus{bkg_fixstep}=1; |
| 261 |
$groups{$current}->make(bkg_step=>$widget{bkg_step}->cget('-value'), |
| 262 |
bkg_fixstep=>$menus{bkg_fixstep}, |
| 263 |
update_bkg=>1); |
| 264 |
project_state(0); |
| 265 |
}, |
| 266 |
-command => sub{$menus{bkg_fixstep}=1; |
| 267 |
$groups{$current}->make(bkg_step=>$widget{bkg_step}->cget('-value'), |
| 268 |
bkg_fixstep=>$menus{bkg_fixstep}, |
| 269 |
update_bkg=>1); |
| 270 |
project_state(0); |
| 271 |
autoreplot(); |
| 272 |
}, |
| 273 |
#-textvariable=>\$$rhash{$s}{$v}{new}, |
| 274 |
#-validate=>'key', |
| 275 |
#-validatecommand=>[\&set_variable, 'bkg_step'] |
| 276 |
) |
| 277 |
-> pack(-side=>'left', -padx=>6); |
| 278 |
$widget{bkg_fixstep} = $box -> Checkbutton(-text => 'fix step', |
| 279 |
-onvalue => 1, |
| 280 |
-offvalue => 0, |
| 281 |
-font => $f_text, |
| 282 |
-selectcolor => $config{colors}{single}, |
| 283 |
-variable => \$menus{bkg_fixstep}, |
| 284 |
-command => |
| 285 |
sub{$groups{$current}-> |
| 286 |
make(bkg_step => $widget{bkg_step}->cget('-value'), |
| 287 |
bkg_fixstep => $menus{bkg_fixstep}, |
| 288 |
update_bkg => 1); |
| 289 |
project_state(0); |
| 290 |
##$widget{bkg_step} -> configure(-state=>($menus{bkg_fixstep}) ? 'disabled' : 'normal'); |
| 291 |
}) |
| 292 |
-> pack(-side=>'left', -padx=>6); |
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
## $t = $c -> createText('5.0c', $y, -anchor=>'w', -text=>"dk: ", |
| 297 |
## -fill=>'black', -font=>$f_text); |
| 298 |
## &click_help($t,'bkg_dk'); |
| 299 |
## $widget{bkg_dk} = $c -> RetEntry(-width=>5, -validate=>'key', |
| 300 |
## -font=>$config{fonts}{entry}, |
| 301 |
## -validatecommand=>[\&set_variable, 'bkg_dk']); |
| 302 |
## $c -> createWindow('6.0c', $y, -anchor=>'w', -window => $widget{bkg_dk}); |
| 303 |
## $t = $c -> createText('8.0c', $y, -anchor=>'w', -text=>"window type:", |
| 304 |
## -fill=>'black', -font=>$f_text); |
| 305 |
## &click_help($t,'bkg_win'); |
| 306 |
## $widget{bkg_win} = $c -> Optionmenu(-font=>$config{fonts}{small}, |
| 307 |
## -textvariable => \$menus{bkg_win},); |
| 308 |
## foreach my $i ($setup->Windows) { |
| 309 |
## $widget{bkg_win} -> command(-label => $i, |
| 310 |
## -command=>sub{$menus{bkg_win}=$i; |
| 311 |
## project_state(0); |
| 312 |
## $groups{$current}->make(bkg_win=>$i, |
| 313 |
## update_bkg=>1)}); |
| 314 |
## }; |
| 315 |
## $c -> createWindow('10.9c', $y, -anchor=>'w', -window => $widget{bkg_win}); |
| 316 |
|
| 317 |
# pre edge |
| 318 |
$box = $c -> Frame() -> pack(-side=>'top', -pady=>2, -anchor=>'w'); |
| 319 |
$box -> Label(-text=>" ") |
| 320 |
-> grid(-row=>0, -column=>0, -sticky=>'w', -ipady=>1); |
| 321 |
$t = $box -> Label(-text=>"Pre-edge range:", -anchor=>'w', |
| 322 |
-foreground=>'black', -font=>$f_text) |
| 323 |
-> grid(-row=>0, -column=>1, -columnspan=>2, -sticky=>'w'); |
| 324 |
&click_help($t,'bkg_pre1','bkg_pre2'); |
| 325 |
$widget{bkg_pre1} = $box -> RetEntry(-width=>8, |
| 326 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 327 |
-font=>$config{fonts}{entry}, |
| 328 |
-command=>\&autoreplot, |
| 329 |
-validate=>'key', |
| 330 |
-validatecommand=>[\&set_variable, 'bkg_pre1']) |
| 331 |
-> grid(-row=>0, -column=>3, -sticky=>'w'); |
| 332 |
$grab{bkg_pre1} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_pre1']) |
| 333 |
-> grid(-row=>0, -column=>4, -sticky=>'w', -padx=>2); |
| 334 |
$box -> Label(-text=>"to", |
| 335 |
-foreground=>'black', -font=>$f_text) |
| 336 |
-> grid(-row=>0, -column=>5, -sticky=>'ew', -ipadx=>5); |
| 337 |
$widget{bkg_pre2} = $box -> RetEntry(-width=>8, |
| 338 |
-font=>$config{fonts}{entry}, |
| 339 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 340 |
-command=>\&autoreplot, |
| 341 |
-validate=>'key', |
| 342 |
-validatecommand=>[\&set_variable, 'bkg_pre2']) |
| 343 |
-> grid(-row=>0, -column=>6, -sticky=>'ew'); |
| 344 |
$grab{bkg_pre2} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_pre2']) |
| 345 |
-> grid(-row=>0, -column=>7, -sticky=>'w', -padx=>2); |
| 346 |
|
| 347 |
# normalization |
| 348 |
$box -> Label(-text=>" ") |
| 349 |
-> grid(-row=>1, -column=>0, -sticky=>'ew', -ipady=>1); |
| 350 |
$t = $box -> Label(-text=>"Normalization range:", -anchor=>'w', |
| 351 |
-foreground=>'black', -font=>$f_text) |
| 352 |
-> grid(-row=>1, -column=>1, -columnspan=>2, -sticky=>'w'); |
| 353 |
&click_help($t,'bkg_nor1','bkg_nor2'); |
| 354 |
$widget{bkg_nor1} = $box -> RetEntry(-width=>8, |
| 355 |
-font=>$config{fonts}{entry}, |
| 356 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 357 |
-command=>\&autoreplot, |
| 358 |
-validate=>'key', |
| 359 |
-validatecommand=>[\&set_variable, 'bkg_nor1']) |
| 360 |
-> grid(-row=>1, -column=>3, -sticky=>'ew'); |
| 361 |
$grab{bkg_nor1} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_nor1']) |
| 362 |
-> grid(-row=>1, -column=>4, -sticky=>'w', -padx=>2); |
| 363 |
$box -> Label(-text=>"to", |
| 364 |
-foreground=>'black', -font=>$f_text) |
| 365 |
-> grid(-row=>1, -column=>5, -sticky=>'ew', -ipadx=>5); |
| 366 |
$widget{bkg_nor2} = $box -> RetEntry(-width=>8, |
| 367 |
-font=>$config{fonts}{entry}, |
| 368 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 369 |
-command=>\&autoreplot, |
| 370 |
-validate=>'key', |
| 371 |
-validatecommand=>[\&set_variable, 'bkg_nor2']) |
| 372 |
-> grid(-row=>1, -column=>6, -sticky=>'ew'); |
| 373 |
$grab{bkg_nor2} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_nor2']) |
| 374 |
-> grid(-row=>1, -column=>7, -sticky=>'w', -padx=>2); |
| 375 |
|
| 376 |
# spline k |
| 377 |
$box -> Label(-text=>" ") |
| 378 |
-> grid(-row=>2, -column=>0, -sticky=>'ew', -ipady=>1); |
| 379 |
$t = $box -> Label(-text=>"Spline range:", -anchor=>'w', |
| 380 |
-foreground=>'black', -font=>$f_text) |
| 381 |
-> grid(-row=>2, -column=>1, -sticky=>'w'); |
| 382 |
&click_help($t,'bkg_spl1','bkg_spl2'); |
| 383 |
$t = $box -> Label(-text=>"k: ", -anchor=>'e', |
| 384 |
-foreground=>'black', -font=>$f_text) |
| 385 |
-> grid(-row=>2, -column=>2, -sticky=>'e'); |
| 386 |
&click_help($t,'bkg_spl1','bkg_spl2'); |
| 387 |
$widget{bkg_spl1} = $box -> RetEntry(-width=>8, |
| 388 |
-font=>$config{fonts}{entry}, |
| 389 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 390 |
-command=>\&autoreplot, |
| 391 |
-validate=>'key', |
| 392 |
-validatecommand=>[\&set_variable, 'bkg_spl1']) |
| 393 |
-> grid(-row=>2, -column=>3, -sticky=>'ew'); |
| 394 |
$grab{bkg_spl1} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_spl1']) |
| 395 |
-> grid(-row=>2, -column=>4, -sticky=>'w', -padx=>2); |
| 396 |
$box -> Label(-text=>"to", |
| 397 |
-foreground=>'black', -font=>$f_text) |
| 398 |
-> grid(-row=>2, -column=>5, -sticky=>'ew', -ipadx=>5); |
| 399 |
$widget{bkg_spl2} = $box -> RetEntry(-width=>8, |
| 400 |
-font=>$config{fonts}{entry}, |
| 401 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 402 |
-command=>\&autoreplot, |
| 403 |
-validate=>'key', |
| 404 |
-validatecommand=>[\&set_variable, 'bkg_spl2']) |
| 405 |
-> grid(-row=>2, -column=>6, -sticky=>'ew'); |
| 406 |
$grab{bkg_spl2} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_spl2']) |
| 407 |
-> grid(-row=>2, -column=>7, -sticky=>'w', -padx=>2); |
| 408 |
|
| 409 |
# spline E |
| 410 |
$box -> Label(-text=>" ") |
| 411 |
-> grid(-row=>3, -column=>0, -sticky=>'ew', -ipady=>1); |
| 412 |
$t = $box -> Label(-text=>"E: ", -anchor=>'e', |
| 413 |
-foreground=>'black', -font=>$f_text) |
| 414 |
-> grid(-row=>3, -column=>2, -sticky=>'e'); |
| 415 |
&click_help($t,'bkg_spl1e','bkg_spl2e'); |
| 416 |
$widget{bkg_spl1e} = $box -> RetEntry(-width=>8, |
| 417 |
-font=>$config{fonts}{entry}, |
| 418 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 419 |
-command=>\&autoreplot, |
| 420 |
-validate=>'key', |
| 421 |
-validatecommand=>[\&set_variable, 'bkg_spl1e']) |
| 422 |
-> grid(-row=>3, -column=>3, -sticky=>'w'); |
| 423 |
$grab{bkg_spl1e} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_spl1e']) |
| 424 |
-> grid(-row=>3, -column=>4, -sticky=>'w', -padx=>2); |
| 425 |
$box -> Label(-text=>"to", |
| 426 |
-foreground=>'black', -font=>$f_text) |
| 427 |
-> grid(-row=>3, -column=>5, -sticky=>'ew'); |
| 428 |
$widget{bkg_spl2e} = $box -> RetEntry(-width=>8, |
| 429 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 430 |
-validate=>'key', |
| 431 |
-command=>\&autoreplot, |
| 432 |
-font=>$config{fonts}{entry}, |
| 433 |
-validatecommand=>[\&set_variable, 'bkg_spl2e']) |
| 434 |
-> grid(-row=>3, -column=>6, -sticky=>'w'); |
| 435 |
$grab{bkg_spl2e} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bkg_spl2e']) |
| 436 |
-> grid(-row=>3, -column=>7, -sticky=>'w', -padx=>2); |
| 437 |
|
| 438 |
|
| 439 |
## secondary background parameters |
| 440 |
$c = $frame -> Frame(qw/-relief ridge -borderwidth 2 -width 12.5c/, # -height 7.0c/, |
| 441 |
-highlightcolor=>$config{colors}{background}); |
| 442 |
# -> pack(qw/-expand 1 -fill both/); |
| 443 |
# disable_mouse_wheel($c); |
| 444 |
$props{bkg_secondary} = $c; |
| 445 |
|
| 446 |
|
| 447 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 448 |
$header{bkg_secondary} = $box -> Label(-text=>" Background removal", |
| 449 |
-foreground=>$bigtextcolor, |
| 450 |
-font=>$f_label) |
| 451 |
-> pack(-side=>'left'); |
| 452 |
&group_click($header{bkg_secondary}, 'bkg'); |
| 453 |
$widget{bkg_switch2} = $box -> Button(-text=>"Show main parameters", |
| 454 |
-font=>$config{fonts}{small}, |
| 455 |
-borderwidth=>1, |
| 456 |
-command => sub{ |
| 457 |
$props{bkg_secondary}->packForget; |
| 458 |
$props{bkg} -> pack(qw/-expand 1 -fill both -after/, $props{current}); |
| 459 |
}) |
| 460 |
-> pack(-side=>'right', -padx=>12); |
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 465 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 466 |
$widget{bkg_flatten} = $box -> Checkbutton(-text => 'Flatten normalized data', |
| 467 |
-onvalue => 1, |
| 468 |
-offvalue => 0, |
| 469 |
-font => $f_text, |
| 470 |
-selectcolor => $config{colors}{single}, |
| 471 |
-variable => \$menus{bkg_flatten}, |
| 472 |
-command => |
| 473 |
sub{$groups{$current}-> |
| 474 |
make(bkg_flatten=>$menus{bkg_flatten}); |
| 475 |
autoreplot('e'); |
| 476 |
project_state(0)}) |
| 477 |
|
| 478 |
-> pack(-side=>'left'); |
| 479 |
$widget{bkg_flatten} -> bind('<ButtonPress-3>' => |
| 480 |
sub{return 0 unless ($current); |
| 481 |
return 0 unless (scalar keys %groups > 1); |
| 482 |
my $is_active = ($widget{bkg_flatten}->cget('-state') ne 'disabled'); |
| 483 |
return 0 unless $is_active; |
| 484 |
my $menu=$top->Menu(-tearoff=>0, |
| 485 |
-menuitems=>[["command"=>"Set all groups to this value of flatten", |
| 486 |
-command => sub{&set_params('all', 'bkg_flatten')}, |
| 487 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 488 |
], |
| 489 |
["command"=>"Set marked groups to this value of flatten", |
| 490 |
-command => sub{&set_params('marked', 'bkg_flatten')}, |
| 491 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 492 |
], |
| 493 |
"-", |
| 494 |
["command"=>"Set this value of flatten to the standard", |
| 495 |
-command => sub{&set_params('this', 'bkg_flatten')}, |
| 496 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 497 |
], |
| 498 |
]); |
| 499 |
$menu -> Popup(-popover=>'cursor', -popanchor=>'w'); |
| 500 |
}); |
| 501 |
##&click_help($t,'bkg_flatten'); |
| 502 |
$t = $box -> Label(-text=>" ", |
| 503 |
-foreground=>'black', |
| 504 |
-font=>$f_text) |
| 505 |
-> pack(-side=>'left'); |
| 506 |
|
| 507 |
$menus{bkg_alg} = 'Autobk'; ####!!!!! |
| 508 |
$t = $box -> Label(-text=>"Background:", |
| 509 |
-foreground=>'black', -font=>$f_text) |
| 510 |
-> pack(-side=>'left'); |
| 511 |
&click_help($t,'bkg_alg'); |
| 512 |
$widget{bkg_alg} = $box -> Optionmenu(-font=>$config{fonts}{small}, |
| 513 |
-borderwidth=>1, |
| 514 |
-textvariable => \$menus{bkg_alg},) |
| 515 |
-> pack(-side=>'left', -padx=>6); |
| 516 |
foreach my $i ('Autobk', 'CLnorm') { |
| 517 |
$widget{bkg_alg} -> command(-label => $i, |
| 518 |
-command=> |
| 519 |
sub{$menus{bkg_alg}=$i; |
| 520 |
if ($groups{$current}->{frozen}) { |
| 521 |
$menus{bkg_alg}='Autobk'; |
| 522 |
$menus{bkg_alg}='CLnorm' if $groups{$current}->{bkg_cl}; |
| 523 |
return; |
| 524 |
}; |
| 525 |
## flatten should be off when CL |
| 526 |
## is on |
| 527 |
if ($menus{bkg_alg} ne 'Autobk') { |
| 528 |
$groups{$current}->{bkg_flatten_was} = $groups{$current}->{bkg_flatten}; |
| 529 |
}; |
| 530 |
$menus{bkg_flatten} = ($menus{bkg_alg} eq 'Autobk') ? $groups{$current}->{bkg_flatten_was} : 0; |
| 531 |
$groups{$current} -> |
| 532 |
make(bkg_cl => ($menus{bkg_alg} eq 'Autobk') ? 0 : 1, |
| 533 |
bkg_flatten => ($menus{bkg_alg} eq 'Autobk') ? $groups{$current}->{bkg_flatten_was} : 0, |
| 534 |
bkg_z => $menus{bkg_z}, |
| 535 |
update_bkg => 1); |
| 536 |
## disable widgets not needed by |
| 537 |
## the selected background algorithm |
| 538 |
#$widget{bkg_z} -> |
| 539 |
# configure(-state=>($menus{bkg_alg} eq 'Autobk') |
| 540 |
# ? 'disabled' : 'normal'); |
| 541 |
## dk win |
| 542 |
foreach (qw(stan rbkg kw spl1 spl2 spl1e spl2e flatten)) { |
| 543 |
$widget{'bkg_'.$_} -> |
| 544 |
configure(-state=>($menus{bkg_alg} eq 'CLnorm') |
| 545 |
? 'disabled' : 'normal'); |
| 546 |
}; |
| 547 |
foreach (qw(rbkg spl1 spl2 spl1e spl2e)) { |
| 548 |
$grab{'bkg_'.$_} -> |
| 549 |
configure(-state=>($menus{bkg_alg} eq 'CLnorm') |
| 550 |
? 'disabled' : 'normal'); |
| 551 |
}; |
| 552 |
## make a plot |
| 553 |
project_state(0); |
| 554 |
#if ($menus{bkg_alg} eq 'CLnorm') { |
| 555 |
# if (lc($menus{bkg_z}) eq 'h') { |
| 556 |
# &z_popup($current, 'cl'); |
| 557 |
# } else { |
| 558 |
# &z_popup($current, 'cl,update'); |
| 559 |
# }; |
| 560 |
#}; |
| 561 |
#($menus{bkg_alg} eq 'Autobk') and |
| 562 |
$groups{$current}->plotE('emz',$dmode,\%plot_features, \@indicator);; |
| 563 |
} |
| 564 |
); |
| 565 |
}; |
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 570 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 571 |
$t = $box -> Label(-text=>"Normalization order:", |
| 572 |
-foreground=>'black', -font=>$f_text) |
| 573 |
-> pack(-side=>'left'); |
| 574 |
&click_help($t,'bkg_nnorm1'); |
| 575 |
foreach my $i (1,2,3) { |
| 576 |
my $this = "bkg_nnorm".$i; |
| 577 |
$widget{$this} = $box -> Radiobutton(-text => "$i", |
| 578 |
-value => $i, |
| 579 |
-selectcolor => $config{colors}{single}, |
| 580 |
-font => $f_text, |
| 581 |
-variable => \$menus{bkg_nnorm}, |
| 582 |
-command => sub{$groups{$current}-> |
| 583 |
make(bkg_nnorm=>$menus{bkg_nnorm}, |
| 584 |
update_bkg=>1); |
| 585 |
autoreplot('e'); |
| 586 |
project_state(0)}) |
| 587 |
-> pack(-side=>'left', -padx=>3); |
| 588 |
}; |
| 589 |
|
| 590 |
|
| 591 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 592 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 593 |
$widget{bkg_fnorm} = $box -> Checkbutton(-text => 'Use functional normalization', |
| 594 |
-onvalue => 1, |
| 595 |
-offvalue => 0, |
| 596 |
-selectcolor => $config{colors}{single}, |
| 597 |
-font => $f_text, |
| 598 |
-variable => \$menus{bkg_fnorm}, |
| 599 |
-command => |
| 600 |
sub{$groups{$current}-> |
| 601 |
make(bkg_fnorm=>$menus{bkg_fnorm}); |
| 602 |
autoreplot('e'); |
| 603 |
project_state(0)}) |
| 604 |
-> pack(-side=>'left'); |
| 605 |
$widget{bkg_fnorm} -> bind('<ButtonPress-3>' => |
| 606 |
sub{return 0 unless ($current); |
| 607 |
return 0 unless (scalar keys %groups > 1); |
| 608 |
my $is_active = ($widget{bkg_fnorm}->cget('-state') ne 'disabled'); |
| 609 |
return 0 unless $is_active; |
| 610 |
my $menu=$top->Menu(-tearoff=>0, |
| 611 |
-menuitems=>[["command"=>"Set all groups to use functional normalization", |
| 612 |
-command => sub{&set_params('all', 'bkg_fnorm')}, |
| 613 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 614 |
], |
| 615 |
["command"=>"Set marked groups to use functional normalization", |
| 616 |
-command => sub{&set_params('marked', 'bkg_fnorm')}, |
| 617 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 618 |
], |
| 619 |
"-", |
| 620 |
["command"=>"Set use of functional normalization to the standard", |
| 621 |
-command => sub{&set_params('this', 'bkg_fnorm')}, |
| 622 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 623 |
], |
| 624 |
]); |
| 625 |
$menu -> Popup(-popover=>'cursor', -popanchor=>'w'); |
| 626 |
}); |
| 627 |
|
| 628 |
|
| 629 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 630 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 631 |
$t = $box -> Label(-text=>"Standard:", |
| 632 |
-foreground=>'black', -font=>$f_text) |
| 633 |
-> pack(-side=>'left'); |
| 634 |
&click_help($t,'bkg_stan'); |
| 635 |
$widget{bkg_stan} = $box -> BrowseEntry(-variable=>\$menus{bkg_stan_lab}, |
| 636 |
-width=>30, |
| 637 |
@browseentry_list, |
| 638 |
-browsecmd => sub { |
| 639 |
my $text = $_[1]; |
| 640 |
my $this = $1 if ($text =~ /^(\d+):/); |
| 641 |
Echo("Failed to match in browsecmd. Yikes! Complain to Bruce."), return unless defined($this); |
| 642 |
#$this -= 1; |
| 643 |
project_state(0); |
| 644 |
my $x = $menus{keys}->[$this]; |
| 645 |
$groups{$x}->dispatch_bkg($dmode) if |
| 646 |
$groups{$x}->{update_bkg}; |
| 647 |
$groups{$current}->make(bkg_stan=>$menus{keys}->[$this], |
| 648 |
bkg_stan_lab=>$groups{$x}->{label}, |
| 649 |
update_bkg=>1); |
| 650 |
autoreplot('e') |
| 651 |
}) |
| 652 |
-> pack(-side=>'left', -padx=>6); |
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
# clamps |
| 658 |
$menus{bkg_clamp1} = 'None'; |
| 659 |
$menus{bkg_clamp2} = 'Strong'; |
| 660 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 661 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 662 |
$t = $box -> Label(-text=>"Spline clamps: ", |
| 663 |
-foreground=>'black', -font=>$f_text) |
| 664 |
-> pack(-side=>'left'); |
| 665 |
&click_help($t); |
| 666 |
$t = $box -> Label(-text=>"low:", |
| 667 |
-foreground=>'black', -font=>$f_text) |
| 668 |
-> pack(-side=>'left'); |
| 669 |
&click_help($t,'bkg_clamp1'); |
| 670 |
$widget{bkg_clamp1} = $box -> Optionmenu(-font=>$config{fonts}{small}, |
| 671 |
-borderwidth=>1, |
| 672 |
-textvariable => \$menus{bkg_clamp1},) |
| 673 |
-> pack(-side=>'left', -padx=>6); |
| 674 |
foreach my $i (qw(None Slight Weak Medium Strong Rigid)) { |
| 675 |
$widget{bkg_clamp1} -> command(-label => $i, |
| 676 |
-command=>sub{$menus{bkg_clamp1}=$i; |
| 677 |
if ($groups{$current}->{frozen}) { |
| 678 |
$menus{bkg_clamp1}=$groups{$current}->{bkg_clamp1}; |
| 679 |
return; |
| 680 |
}; |
| 681 |
project_state(0); |
| 682 |
$groups{$current}->make(bkg_clamp1=>$i, |
| 683 |
update_bkg=>1); |
| 684 |
autoreplot('e') }); |
| 685 |
}; |
| 686 |
|
| 687 |
$t = $box -> Label(-text=>"high:", |
| 688 |
-foreground=>'black', -font=>$f_text) |
| 689 |
-> pack(-side=>'left'); |
| 690 |
&click_help($t,'bkg_clamp2'); |
| 691 |
$widget{bkg_clamp2} = $box -> Optionmenu(-font=>$config{fonts}{small}, |
| 692 |
-borderwidth=>1, |
| 693 |
-textvariable => \$menus{bkg_clamp2},) |
| 694 |
-> pack(-side=>'left', -padx=>6); |
| 695 |
foreach my $i (qw(None Slight Weak Medium Strong Rigid)) { |
| 696 |
$widget{bkg_clamp2} -> command(-label => $i, |
| 697 |
-command=>sub{$menus{bkg_clamp2}=$i; |
| 698 |
if ($groups{$current}->{frozen}) { |
| 699 |
$menus{bkg_clamp2}=$groups{$current}->{bkg_clamp2}; |
| 700 |
return; |
| 701 |
}; |
| 702 |
project_state(0); |
| 703 |
$groups{$current}->make(bkg_clamp2=>$i, |
| 704 |
update_bkg=>1); |
| 705 |
autoreplot('e')}); |
| 706 |
}; |
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
## Forward transform section |
| 712 |
$c = $frame -> Frame(qw/-relief ridge -borderwidth 2 -width 12.5c/, # -height 3.3c/, |
| 713 |
-highlightcolor=>$config{colors}{background}) |
| 714 |
-> pack(qw/-expand 1 -fill both/); |
| 715 |
# disable_mouse_wheel($c); |
| 716 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 717 |
$header{fft} = $box -> Label(-text=>" Forward Fourier transform", |
| 718 |
-foreground=>$bigtextcolor, |
| 719 |
-font=>$f_label) |
| 720 |
-> pack(-side=>'left'); |
| 721 |
$props{fft} = $c; |
| 722 |
&group_click($header{fft}, 'fft'); |
| 723 |
|
| 724 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 725 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 726 |
$t = $box -> Label(-text=>"k-range:", -width=>9, -anchor=>'w', |
| 727 |
-foreground=>'black', -font=>$f_text) |
| 728 |
-> pack(-side=>'left'); |
| 729 |
&click_help($t,'fft_kmin','fft_kmax'); |
| 730 |
$widget{fft_kmin} = $box -> RetEntry(-width=>8, |
| 731 |
-font=>$config{fonts}{entry}, |
| 732 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 733 |
-command=>[\&autoreplot,'r'], |
| 734 |
-validate=>'key', |
| 735 |
-validatecommand=>[\&set_variable, 'fft_kmin']) |
| 736 |
-> pack(-side=>'left', -padx=>6); |
| 737 |
$grab{fft_kmin} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'fft_kmin']) |
| 738 |
-> pack(-side=>'left'); |
| 739 |
$box -> Label(-text=>" to ", |
| 740 |
-foreground=>'black', -font=>$f_text) |
| 741 |
-> pack(-side=>'left'); |
| 742 |
$widget{fft_kmax} = $box -> RetEntry(-width=>8, |
| 743 |
-font=>$config{fonts}{entry}, |
| 744 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 745 |
-command=>[\&autoreplot,'r'], |
| 746 |
-validate=>'key', |
| 747 |
-validatecommand=>[\&set_variable, 'fft_kmax']) |
| 748 |
-> pack(-side=>'left', -padx=>6); |
| 749 |
$grab{fft_kmax} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'fft_kmax']) |
| 750 |
-> pack(-side=>'left'); |
| 751 |
|
| 752 |
|
| 753 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 754 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 755 |
$t = $box -> Label(-text=>"dk: ", -width=>4, -anchor=>'w', |
| 756 |
-foreground=>'black', -font=>$f_text) |
| 757 |
-> pack(-side=>'left'); |
| 758 |
&click_help($t,'fft_dk'); |
| 759 |
$widget{fft_dk} = $box -> RetEntry(-width=>5, |
| 760 |
-font=>$config{fonts}{entry}, |
| 761 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 762 |
-command=>[\&autoreplot,'r'], |
| 763 |
-validate=>'key', |
| 764 |
-validatecommand=>[\&set_variable, 'fft_dk']) |
| 765 |
-> pack(-side=>'left', -padx=>6); |
| 766 |
$t = $box -> Label(-text=>"window type:", |
| 767 |
-foreground=>'black', -font=>$f_text) |
| 768 |
-> pack(-side=>'left'); |
| 769 |
&click_help($t,'fft_win'); |
| 770 |
$widget{fft_win} = $box -> Optionmenu(-font=>$config{fonts}{small}, |
| 771 |
-borderwidth=>1, |
| 772 |
-textvariable => \$menus{fft_win},) |
| 773 |
-> pack(-side=>'left', -padx=>6); |
| 774 |
foreach my $i ($setup->Windows) { |
| 775 |
$widget{fft_win} -> command(-label => $i, |
| 776 |
-command=>sub{$menus{fft_win}=$i; |
| 777 |
if ($groups{$current}->{frozen}) { |
| 778 |
$menus{fft_win}=$groups{$current}->{fft_win}; |
| 779 |
return; |
| 780 |
}; |
| 781 |
project_state(0); |
| 782 |
$groups{$current}->make(fft_win=>$i, |
| 783 |
update_fft=>1); |
| 784 |
autoreplot('r')}); |
| 785 |
}; |
| 786 |
|
| 787 |
|
| 788 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 789 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 790 |
$t = $box -> Label(-text=>"Phase correction:", |
| 791 |
-foreground=>'black', -font=>$f_text) |
| 792 |
-> pack(-side=>'left'); |
| 793 |
&click_help($t,'fft_pc'); |
| 794 |
$menus{fft_pc} = 'off'; |
| 795 |
$widget{fft_pc} = |
| 796 |
$box -> Checkbutton(-selectcolor => $config{colors}{single}, |
| 797 |
-activebackground => $config{colors}{background}, |
| 798 |
-font => $f_text, |
| 799 |
-variable => \$menus{fft_pc}, |
| 800 |
-textvariable => \$menus{fft_pc}, |
| 801 |
-onvalue => 'on', |
| 802 |
-offvalue => 'off', |
| 803 |
-command => |
| 804 |
sub{$groups{$current}->make(fft_pc=>$menus{fft_pc}, update_fft=>1); |
| 805 |
if ($menus{fft_pc} eq 'on') { |
| 806 |
&z_popup($current, 'pc') if (lc($menus{bkg_z}) eq 'h'); |
| 807 |
Echo("Doing central-atom phase-corrected Fourier transforms."); |
| 808 |
} else { |
| 809 |
Echo("Doing uncorrected Fourier transforms."); |
| 810 |
}; |
| 811 |
project_state(0); |
| 812 |
} |
| 813 |
) |
| 814 |
-> pack(-side=>'left', -padx=>6); |
| 815 |
$t = $box -> Label(-text=>"arbitrary k-weight:", |
| 816 |
-foreground=>'black', -font=>$f_text) |
| 817 |
-> pack(-side=>'left'); |
| 818 |
&click_help($t,'fft_arbkw'); |
| 819 |
$widget{fft_arbkw} = $box -> RetEntry(-width=>6, |
| 820 |
-font=>$config{fonts}{entry}, |
| 821 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 822 |
-command=>[\&autoreplot, 'r'], |
| 823 |
-validate=>'key', |
| 824 |
-validatecommand=>[\&set_variable, 'fft_arbkw']) |
| 825 |
-> pack(-side=>'left', -padx=>6); |
| 826 |
|
| 827 |
|
| 828 |
## Backward transform section |
| 829 |
$c = $frame -> Frame(qw/-relief ridge -borderwidth 2 -width 12.5c/, # -height 2.4c/, |
| 830 |
-highlightcolor=>$config{colors}{background}) |
| 831 |
-> pack(qw/-expand 1 -fill both/); |
| 832 |
# disable_mouse_wheel($c); |
| 833 |
$props{bft} = $c; |
| 834 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 835 |
$header{bft} = $box -> Label(-text=>" Backward Fourier transform", |
| 836 |
-foreground=>$bigtextcolor, |
| 837 |
-font=>$f_label) |
| 838 |
-> pack(-side=>'left'); |
| 839 |
&group_click($header{bft}, 'bft'); |
| 840 |
|
| 841 |
|
| 842 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 843 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 844 |
$t = $box -> Label(-text=>"R-range:", -width=>9, -anchor=>'w', |
| 845 |
-foreground=>'black', -font=>$f_text) |
| 846 |
-> pack(-side=>'left'); |
| 847 |
&click_help($t,'bft_rmin','bft_rmax'); |
| 848 |
$widget{bft_rmin} = $box -> RetEntry(-width=>8, |
| 849 |
-font=>$config{fonts}{entry}, |
| 850 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 851 |
-command=>[\&autoreplot, 'q'], |
| 852 |
-validate=>'key', |
| 853 |
-validatecommand=>[\&set_variable, 'bft_rmin']) |
| 854 |
-> pack(-side=>'left', -padx=>6); |
| 855 |
$grab{bft_rmin} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bft_rmin']) |
| 856 |
-> pack(-side=>'left'); |
| 857 |
$box -> Label(-text=>" to ", |
| 858 |
-foreground=>'black', -font=>$f_text) |
| 859 |
-> pack(-side=>'left'); |
| 860 |
$widget{bft_rmax} = $box -> RetEntry(-width=>8, |
| 861 |
-font=>$config{fonts}{entry}, |
| 862 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 863 |
-command=>[\&autoreplot, 'q'], |
| 864 |
-validate=>'key', |
| 865 |
-validatecommand=>[\&set_variable, 'bft_rmax']) |
| 866 |
-> pack(-side=>'left', -padx=>6); |
| 867 |
$grab{bft_rmax} = $box -> Button(@pluck_button, @pluck, -command=>[\&pluck, 'bft_rmax']) |
| 868 |
-> pack(-side=>'left'); |
| 869 |
|
| 870 |
|
| 871 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 872 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 873 |
$t = $box -> Label(-text=>"dr: ", -width=>4, -anchor=>'w', |
| 874 |
-foreground=>'black', -font=>$f_text) |
| 875 |
-> pack(-side=>'left'); |
| 876 |
&click_help($t,'bft_dr'); |
| 877 |
$widget{bft_dr} = $box -> RetEntry(-width=>5, |
| 878 |
-font=>$config{fonts}{entry}, |
| 879 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 880 |
-command=>[\&autoreplot, 'q'], |
| 881 |
-validate=>'key', |
| 882 |
-validatecommand=>[\&set_variable, 'bft_dr']) |
| 883 |
-> pack(-side=>'left', -padx=>6); |
| 884 |
$t = $box -> Label(-text=>"window type:", |
| 885 |
-foreground=>'black', -font=>$f_text) |
| 886 |
-> pack(-side=>'left'); |
| 887 |
&click_help($t,'bft_win'); |
| 888 |
$widget{bft_win} = $box -> Optionmenu(-font=>$config{fonts}{small}, |
| 889 |
-borderwidth=>1, |
| 890 |
-textvariable => \$menus{bft_win},) |
| 891 |
-> pack(-side=>'left', -padx=>6); |
| 892 |
foreach my $i ($setup->Windows) { |
| 893 |
$widget{bft_win} -> command(-label => $i, |
| 894 |
-command=>sub{$menus{bft_win}=$i; |
| 895 |
if ($groups{$current}->{frozen}) { |
| 896 |
$menus{bft_win}=$groups{$current}->{bft_win}; |
| 897 |
return; |
| 898 |
}; |
| 899 |
project_state(0); |
| 900 |
$groups{$current}->make(bft_win=>$i, |
| 901 |
update_bft=>1); |
| 902 |
autoreplot('q')}); |
| 903 |
}; |
| 904 |
|
| 905 |
|
| 906 |
## Plot parameters |
| 907 |
$c = $frame -> Frame(qw/-relief ridge -borderwidth 2 -width 12.5c -height 1.4c/, |
| 908 |
-highlightcolor=>$config{colors}{background}) |
| 909 |
-> pack(qw/-expand 1 -fill both/); |
| 910 |
# disable_mouse_wheel($c); |
| 911 |
$props{plot} = $c; |
| 912 |
|
| 913 |
|
| 914 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 915 |
$header{plot} = $box -> Label(-text=>" Plotting parameters", |
| 916 |
-foreground=>$bigtextcolor, |
| 917 |
-font=>$f_label) |
| 918 |
-> pack(-side=>'left'); |
| 919 |
&group_click($header{plot}, 'plot'); |
| 920 |
|
| 921 |
$box = $c -> Frame() -> pack(-side=>'top', -fill=>'x', -expand=>1, -pady=>2); |
| 922 |
$box -> Label(-text=>" ") -> pack(-side=>'left'); |
| 923 |
$t = $box -> Label(-text=>"plot multiplier:", |
| 924 |
-foreground=>'black', -font=>$f_text) |
| 925 |
-> pack(-side=>'left'); |
| 926 |
&click_help($t,'plot_scale'); |
| 927 |
$widget{plot_scale} = $box -> RetEntry(-width=>8, |
| 928 |
-font=>$config{fonts}{entry}, |
| 929 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 930 |
-command=>\&autoreplot, |
| 931 |
-validate=>'key', |
| 932 |
-validatecommand=>[\&set_variable, 'plot_scale']) |
| 933 |
-> pack(-side=>'left', -padx=>6); |
| 934 |
|
| 935 |
$t = $box -> Label(-text=>"y-axis offset:", |
| 936 |
-foreground=>'black', -font=>$f_text) |
| 937 |
-> pack(-side=>'left'); |
| 938 |
&click_help($t,'plot_yoffset'); |
| 939 |
$widget{plot_yoffset} = $box -> RetEntry(-width=>8, |
| 940 |
-font=>$config{fonts}{entry}, |
| 941 |
#-disabledforeground=>$config{colors}{disabledforeground}, |
| 942 |
-command=>\&autoreplot, |
| 943 |
-validate=>'key', |
| 944 |
-validatecommand=>[\&set_variable, 'plot_yoffset']) |
| 945 |
-> pack(-side=>'left', -padx=>6); |
| 946 |
|
| 947 |
}; |
| 948 |
|
| 949 |
|
| 950 |
## Handle mouse-over functionality for labels in the main window |
| 951 |
sub click_help { |
| 952 |
my $t = shift; |
| 953 |
my @keys = @_; |
| 954 |
|
| 955 |
|
| 956 |
## ------ MOUSE OVER |
| 957 |
my @bold = (-foreground => $config{colors}{foreground}, |
| 958 |
-background => $config{colors}{activebackground}, |
| 959 |
-font => $config{fonts}{small}, |
| 960 |
-cursor => $mouse_over_cursor); |
| 961 |
my @normal = (-foreground => $config{colors}{foreground}, |
| 962 |
-background => $config{colors}{background}, |
| 963 |
-font => $config{fonts}{small}); |
| 964 |
|
| 965 |
my @in = (-fill => $config{colors}{activebackground}, |
| 966 |
-outline => $config{colors}{activebackground},); |
| 967 |
my @out = (-fill => $config{colors}{background}, |
| 968 |
-outline => $config{colors}{background}); |
| 969 |
$t -> bind('<Any-Enter>'=>sub{$t -> configure(@bold ) }); |
| 970 |
$t -> bind('<Any-Leave>'=>sub{$t -> configure(@normal) }); |
| 971 |
|
| 972 |
|
| 973 |
## ------ LEFT CLICK |
| 974 |
my $text = $t -> cget('-text'); |
| 975 |
$text =~ s/\s+$//; |
| 976 |
my $str = $click_help{$text} || "$text ???"; |
| 977 |
$t -> bind('<1>' => sub{Echo("$str")}); |
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
## a few parameters need additional items in their context menus |
| 982 |
my %extra = ( |
| 983 |
E0 => [[ command => "Set E0 to Ifeffit's default", |
| 984 |
#-state => $groups{$current}->{frozen} ? 'disabled' : 'normal', |
| 985 |
-command => sub{set_edge($current, 'edge'); autoreplot('e');}], |
| 986 |
[ command => "Set E0 to zero-crossing of 2nd derivative", |
| 987 |
#-state => $groups{$current}->{frozen} ? 'disabled' : 'normal', |
| 988 |
-command => sub{set_edge($current, 'zero'); autoreplot('e');}], |
| 989 |
[ command => "Set E0 to a set fraction of the edge step", |
| 990 |
#-state => $groups{$current}->{frozen} ? 'disabled' : 'normal', |
| 991 |
-command => sub{set_edge($current, 'fraction'); autoreplot('e');}], |
| 992 |
[ command => "Set E0 to atomic value", |
| 993 |
#-state => $groups{$current}->{frozen} ? 'disabled' : 'normal', |
| 994 |
-command => sub{set_edge($current, 'atomic'); autoreplot('e');}], |
| 995 |
[ command => "Set E0 to the peak of the white line", |
| 996 |
#-state => &wlbool($current), |
| 997 |
-command => sub{autoreplot('e') if set_edge_peak($current);}], |
| 998 |
"-", |
| 999 |
[checkbutton => 'Tie energy and k values to E0 (Ctrl-T)', |
| 1000 |
-onvalue => 1, |
| 1001 |
-offvalue => 0, |
| 1002 |
-selectcolor => $config{colors}{single}, |
| 1003 |
-variable => \$menus{bkg_tie_e0}, |
| 1004 |
-command => \&tie_untie_e0, |
| 1005 |
], |
| 1006 |
], |
| 1007 |
|
| 1008 |
'k-range' =>[[ command => "Set kmax to Ifeffit's suggestion", |
| 1009 |
#-state => $groups{$current}->{frozen} ? 'disabled' : 'normal', |
| 1010 |
-command => sub{Echonow("Not changing kmax. This group is frozen."), return if ($groups{$current}->{frozen}); |
| 1011 |
$groups{$current}->dispatch_bkg if $groups{$current}->{update_bkg}; |
| 1012 |
my @array = Ifeffit::get_array("$current.k"); |
| 1013 |
$groups{$current}->MAKE(fft_kmax=>$array[-1]); |
| 1014 |
my $kx = sprintf("%.3f", $groups{$current}->kmax_suggest(\%plot_features)); |
| 1015 |
project_state(0); |
| 1016 |
set_properties(1, $current, 0); |
| 1017 |
Echo("Set kmax to Ifeffit's suggested value of $kx"); |
| 1018 |
}, |
| 1019 |
], |
| 1020 |
], |
| 1021 |
|
| 1022 |
|
| 1023 |
Importance => [['command'=>"Set importance of all groups to 1", |
| 1024 |
-command=>sub{ |
| 1025 |
foreach my $g (keys %marked) { |
| 1026 |
$groups{$g}->make(importance=>1); |
| 1027 |
} |
| 1028 |
set_properties(0,$current,0); |
| 1029 |
project_state(0); |
| 1030 |
}], |
| 1031 |
['command'=>"Set importance of marked groups to 1", |
| 1032 |
-command=>sub{ |
| 1033 |
foreach my $g (keys %marked) { |
| 1034 |
next unless $marked{$g}; |
| 1035 |
$groups{$g}->make(importance=>1); |
| 1036 |
} |
| 1037 |
set_properties(0,$current,0); |
| 1038 |
project_state(0); |
| 1039 |
}] |
| 1040 |
], |
| 1041 |
|
| 1042 |
'E shift' => [[ command => "Identify reference channel", |
| 1043 |
-command => \&identify_reference,], |
| 1044 |
[ command => "Understanding the E shift", |
| 1045 |
-command => \&explain_eshift,], |
| 1046 |
], |
| 1047 |
); |
| 1048 |
|
| 1049 |
|
| 1050 |
## ------ RIGHT CLICK |
| 1051 |
if ($keys[0]) { |
| 1052 |
## need to treat z and edge specially |
| 1053 |
($keys[0] = 'z') if ($keys[0] eq 'bkg_z'); |
| 1054 |
($keys[0] = 'edge') if ($keys[0] eq 'fft_edge'); |
| 1055 |
$text =~ s/:$//; # same text as left click |
| 1056 |
($text eq 'k') and ($text = 'spline k-range'); |
| 1057 |
($text eq 'E') and ($text = 'spline E-range'); |
| 1058 |
($text eq 'low') and ($text = 'low-end spline clamp'); |
| 1059 |
($text eq 'high') and ($text = 'high-end spline clamp'); |
| 1060 |
my $def_ok = not (($keys[0] =~ /^plot/) or |
| 1061 |
($keys[0] =~ /^(edge|z)$/) or |
| 1062 |
($keys[0] =~ /^bkg_(alg|eshift|e0|stan|step)/) or |
| 1063 |
($text eq 'E-range')); |
| 1064 |
my $is_mee = ($keys[0] =~ m{^mee}); |
| 1065 |
$t -> bind('<3>' => |
| 1066 |
sub{return 0 unless ($current); |
| 1067 |
return 0 unless (scalar keys %groups > 1); |
| 1068 |
my $is_active = ($widget{$keys[0]}->cget('-state') eq 'normal'); |
| 1069 |
return 0 unless $is_active; |
| 1070 |
my $menu=$t->Menu(-tearoff=>0, |
| 1071 |
-menuitems=>[["command"=>"Set all groups to this value of $text", |
| 1072 |
-command => sub{&set_params('all', @keys)}, |
| 1073 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 1074 |
], |
| 1075 |
["command"=>"Set marked groups to this value of $text", |
| 1076 |
-command => sub{&set_params('marked', @keys)}, |
| 1077 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 1078 |
], |
| 1079 |
(($is_mee) ? |
| 1080 |
() : |
| 1081 |
( |
| 1082 |
"-", |
| 1083 |
["command"=>"Set this value of $text to the standard", |
| 1084 |
-command => sub{&set_params('this', @keys)}, |
| 1085 |
-state=>((scalar keys %groups > 2) and (not $groups{$current}->{frozen})) ? 'normal' : 'disabled', |
| 1086 |
], |
| 1087 |
(($def_ok) ? |
| 1088 |
("-", |
| 1089 |
["command"=>"Make this value of $text the session default", |
| 1090 |
-command => sub{session_defaults(@keys)}], |
| 1091 |
"-", |
| 1092 |
["command"=>"Set $text to its default for this group", |
| 1093 |
-state => $groups{$current}->{frozen} ? 'disabled' : 'normal', |
| 1094 |
-command => sub{&set_params('def', @keys)}, |
| 1095 |
], |
| 1096 |
) : ()), |
| 1097 |
## additional items in the context menu |
| 1098 |
((exists $extra{$text}) ? |
| 1099 |
("-", |
| 1100 |
[ command => "---- $text options ----", |
| 1101 |
-foreground =>'grey20', |
| 1102 |
-activeforeground =>'grey20', |
| 1103 |
-background =>$config{colors}{background}, |
| 1104 |
-activebackground =>$config{colors}{background}, |
| 1105 |
-font =>$config{fonts}{smbold},], |
| 1106 |
@{ $extra{$text} }) |
| 1107 |
: ()), |
| 1108 |
)), |
| 1109 |
]); |
| 1110 |
$menu ->Popup(-popover=>'cursor', -popanchor=>'w'); |
| 1111 |
}); |
| 1112 |
}; |
| 1113 |
}; |
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
## this is bound to a keyboard shortcut, so I cannot rely on the |
| 1118 |
## checkbutton just above to maintain the state correctly |
| 1119 |
sub tie_untie_e0 { |
| 1120 |
my $state = $groups{$current}->{bkg_tie_e0}; |
| 1121 |
$state = ($state+1) % 2; |
| 1122 |
$groups{$current}->make(bkg_tie_e0 => $state, |
| 1123 |
bkg_former_e0 => ($state) ? $groups{$current}->{bkg_e0} : 0); |
| 1124 |
$menus{bkg_tie_e0} = $state; |
| 1125 |
my $message = ($menus{bkg_tie_e0}) ? |
| 1126 |
"Energy and k values tied to e0." : |
| 1127 |
"Energy and k values untied from e0."; |
| 1128 |
Echo($message); |
| 1129 |
}; |
| 1130 |
|
| 1131 |
sub group_click { |
| 1132 |
my ($t, $which) = @_; |
| 1133 |
|
| 1134 |
|
| 1135 |
my @in = (-background => $config{colors}{activebackground}, |
| 1136 |
-cursor => $mouse_over_cursor, ); |
| 1137 |
my @out = (-background => $config{colors}{background}); |
| 1138 |
$t -> bind('<Any-Enter>'=>sub{$t -> configure(@in ); }); |
| 1139 |
$t -> bind('<Any-Leave>'=>sub{$t -> configure(@out); }); |
| 1140 |
|
| 1141 |
my ($str, $desc) = ("", ""); |
| 1142 |
SWITCH: { |
| 1143 |
($which eq 'project') and do { |
| 1144 |
$str = 'The name of the current project file. Click the "modified" button to save this project.'; |
| 1145 |
$desc = 'PROJECT'; |
| 1146 |
last SWITCH; |
| 1147 |
}; |
| 1148 |
($which eq 'current') and do { |
| 1149 |
$str = "These parameters set aspects of the central atom."; |
| 1150 |
$desc = 'BACKGROUND'; |
| 1151 |
last SWITCH; |
| 1152 |
}; |
| 1153 |
($which eq 'bkg') and do { |
| 1154 |
$str = "These parameters determine how the normalization and background spline are found."; |
| 1155 |
$desc = 'BACKGROUND'; |
| 1156 |
last SWITCH; |
| 1157 |
}; |
| 1158 |
($which eq 'fft') and do { |
| 1159 |
$str = "These parameters determine how the forward Fourier transform is performed."; |
| 1160 |
$desc = "FORWARD TRANSFORM"; |
| 1161 |
last SWITCH; |
| 1162 |
}; |
| 1163 |
($which eq 'bft') and do { |
| 1164 |
$str = "These parameters determine how the backward Fourier transform is performed."; |
| 1165 |
$desc = "BACKWARD TRANSFORM"; |
| 1166 |
last SWITCH; |
| 1167 |
}; |
| 1168 |
($which eq 'plot') and do { |
| 1169 |
$str = "These parameters set certain plotting features specific to this group."; |
| 1170 |
$desc = "PLOTTING"; |
| 1171 |
last SWITCH; |
| 1172 |
}; |
| 1173 |
}; |
| 1174 |
$t -> bind('<1>' => sub{Echo($str)}); |
| 1175 |
$t -> bind('<3>' => |
| 1176 |
sub{my $t = shift; |
| 1177 |
return 0 if ($which eq 'current'); |
| 1178 |
return 0 unless ($current); |
| 1179 |
return 0 unless (scalar keys %groups > 1); |
| 1180 |
my $is_frozen = $groups{$current}->{frozen}; |
| 1181 |
##my $blue = ($is_frozen) ? $config{colors}{frozen} : $config{colors}{activehighlightcolor}; |
| 1182 |
##my $cyan = ($is_frozen) ? $config{colors}{frozenrequiresupdate} : $config{colors}{requiresupdate}; |
| 1183 |
my $blue = $config{colors}{activehighlightcolor}; |
| 1184 |
my $cyan = $config{colors}{requiresupdate}; |
| 1185 |
my $is_active = (($t->cget('-foreground') eq $blue) or |
| 1186 |
($t->cget('-foreground') eq $cyan)); |
| 1187 |
return 0 unless $is_active; |
| 1188 |
my @keys = grep {/^$which/ and not /eshift/} (keys %widget); |
| 1189 |
##print join(" ", @keys), $/; |
| 1190 |
my $menu; |
| 1191 |
if ($which eq 'project') { |
| 1192 |
$menu=$t->Menu(-tearoff=>0, |
| 1193 |
-menuitems=>[['command'=>"Set all groups' values to the current", |
| 1194 |
-command=>sub{ |
| 1195 |
Echo('No data!'), return unless ($current); |
| 1196 |
Echo("Parameters for all groups reset to \`$current\'"); |
| 1197 |
my $orig = $current; |
| 1198 |
foreach my $x (keys %marked) { |
| 1199 |
next if ($x eq 'Default Parameters'); |
| 1200 |
next if ($x eq $current); |
| 1201 |
next if ($groups{$x}->{frozen}); |
| 1202 |
$groups{$x}->set_to_another($groups{$current}); |
| 1203 |
set_properties(1, $x, 0); |
| 1204 |
}; |
| 1205 |
set_properties(1, $orig, 0); |
| 1206 |
Echo(@done);}], |
| 1207 |
['command'=>"Set all marked groups' values to the current", |
| 1208 |
-command=>sub{ |
| 1209 |
Echo('No data!'), return unless ($current); |
| 1210 |
Echo("Parameters for all marked groups reset to \`$current\'"); |
| 1211 |
my $orig = $current; |
| 1212 |
foreach my $x (keys %marked) { |
| 1213 |
next if ($x eq 'Default Parameters'); |
| 1214 |
next if ($x eq $current); |
| 1215 |
next if ($groups{$x}->{frozen}); |
| 1216 |
next unless ($marked{$x}); |
| 1217 |
$groups{$x}->set_to_another($groups{$current}); |
| 1218 |
set_properties(1, $x, 0); |
| 1219 |
}; |
| 1220 |
set_properties(1, $orig, 0); |
| 1221 |
Echo(@done);}], |
| 1222 |
['command'=>"Set current groups' values to their defaults", |
| 1223 |
-state => $is_frozen ? 'disabled' : 'normal', |
| 1224 |
-command=>sub{ |
| 1225 |
Echo('No data!'), return unless ($current); |
| 1226 |
my @keys = grep {/^(bft|bkg|fft)/} (keys %widget); |
| 1227 |
set_params('def', @keys); |
| 1228 |
set_properties(1, $current, 0); |
| 1229 |
Echo("Reset all values for this group to their defaults");}], |
| 1230 |
]); |
| 1231 |
} else { |
| 1232 |
$menu=$t->Menu(-tearoff=>0, |
| 1233 |
-menuitems=>[["command"=>"Set all groups to these $desc parameters", |
| 1234 |
-command => sub{&set_params('all', @keys)}, |
| 1235 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 1236 |
], |
| 1237 |
["command"=>"Set marked groups to these $desc parameters", |
| 1238 |
-command => sub{&set_params('marked', @keys)}, |
| 1239 |
-state=>(scalar keys %groups > 2) ? 'normal' : 'disabled', |
| 1240 |
], |
| 1241 |
"-", |
| 1242 |
["command"=>"Set these $desc parameters to the standard", |
| 1243 |
-command => sub{&set_params('this', @keys)}, |
| 1244 |
-state=>((scalar keys %groups > 2) and (not $is_frozen)) ? 'normal' : 'disabled', |
| 1245 |
], |
| 1246 |
"-", |
| 1247 |
["command"=>"Set these $desc parameters to their defaults", |
| 1248 |
-state => $is_frozen ? 'disabled' : 'normal', |
| 1249 |
-command => sub{&set_params('def', @keys)}], |
| 1250 |
["command"=>"Make these $desc parameters the session defaults", |
| 1251 |
-command => sub{session_defaults(@keys)}], |
| 1252 |
(($which eq 'bkg') ? |
| 1253 |
("-", |
| 1254 |
["command"=>"Document section: background removal", |
| 1255 |
-command =>sub{pod_display("bkg::index.pod")}]) |
| 1256 |
: ()), |
| 1257 |
]); |
| 1258 |
}; |
| 1259 |
$menu ->Popup(-popover=>'cursor', -popanchor=>'w'); |
| 1260 |
}); |
| 1261 |
}; |
| 1262 |
|
| 1263 |
|
| 1264 |
## This is the function invoked by the right mouse click of a |
| 1265 |
## parameter label. It is used to set individual parameters in or |
| 1266 |
## from other groups. |
| 1267 |
## all: set this parameter in all groups to the current |
| 1268 |
## group's value |
| 1269 |
## marked: set this parameter in all marked groups |
| 1270 |
## this: set this parameter in this group to the value in the |
| 1271 |
## marked group (requires that one and only one group be marked) |
| 1272 |
sub set_params { |
| 1273 |
my $how = shift; |
| 1274 |
my @keys = @_; |
| 1275 |
($keys[0] = 'bkg_z') if ($keys[0] eq 'z'); |
| 1276 |
($keys[0] = 'fft_edge') if ($keys[0] eq 'edge'); |
| 1277 |
my ($e0response, $eshiftresponse) = ("",""); |
| 1278 |
my $save = $groups{$current}->{bkg_tie_e0}; # temporarily turn off tie_e0 |
| 1279 |
$groups{$current}->make(bkg_tie_e0=>0); |
| 1280 |
|
| 1281 |
SP: { |
| 1282 |
($how eq 'this') and do { |
| 1283 |
my ($n, $which) = (0, ''); |
| 1284 |
foreach my $g (keys %marked) { |
| 1285 |
($marked{$g}) and ($which = $g) and ++$n; |
| 1286 |
}; |
| 1287 |
if ($n != 1) { |
| 1288 |
$groups{$current}->make(bkg_tie_e0=>$save); |
| 1289 |
Error('A standard is defined by marking one and only one group.'); |
| 1290 |
return; |
| 1291 |
}; |
| 1292 |
foreach my $k (@keys) { |
| 1293 |
my $val = $groups{$which}->{$k}; |
| 1294 |
## take care not to make a group it's own bkg standard |
| 1295 |
($k eq 'bkg_stan') and ($val eq $current) and next; |
| 1296 |
($k eq 'bkg_alg') or $groups{$current} -> make($k => $val); |
| 1297 |
($k = 'bkg_nnorm') if ($k =~ m{bkg_nnorm}); |
| 1298 |
if ($k eq 'bkg_alg') { |
| 1299 |
$val = $groups{$which}->{bkg_cl}; |
| 1300 |
$groups{$current} -> make(bkg_cl=>$val); |
| 1301 |
$val and $groups{$current} -> make(bkg_z=>$groups{$which}->{bkg_z}); |
| 1302 |
$menus{bkg_alg} = ($val) ? 'CLnorm' : 'Autobk'; |
| 1303 |
if ($val) { |
| 1304 |
$menus{bkg_z} = $groups{$which}->{bkg_z}; |
| 1305 |
#$widget{bkg_z} -> configure(-state=>'normal'); |
| 1306 |
$widget{bkg_rbkg} -> configure(-state=>'disabled'); |
| 1307 |
foreach my $s (qw(bkg_spl1 bkg_spl2 bkg_spl1e bkg_spl2e)) { |
| 1308 |
$widget{$s} -> configure(-state=>'disabled'); |
| 1309 |
$grab{$s} -> configure(-state=>'disabled'); |
| 1310 |
}; |
| 1311 |
} else { |
| 1312 |
#$widget{bkg_z} -> configure(-state=>'disabled'); |
| 1313 |
$widget{bkg_rbkg} -> configure(-state=>'normal'); |
| 1314 |
foreach my $s (qw(bkg_spl1 bkg_spl2 bkg_spl1e bkg_spl2e)) { |
| 1315 |
$widget{$s} -> configure(-state=>'normal'); |
| 1316 |
$grab{$s} -> configure(-state=>'normal'); |
| 1317 |
}; |
| 1318 |
}; |
| 1319 |
} elsif ($widget{$k} =~ /Entry/) { |
| 1320 |
$widget{$k} -> configure(-validate=>'none'); |
| 1321 |
$widget{$k} -> delete(qw/0 end/); |
| 1322 |
$widget{$k} -> insert(0, $groups{$current}->{$k}); |
| 1323 |
$widget{$k} -> configure(-validate=>'key'); |
| 1324 |
set_variable($k, $val, 1); |
| 1325 |
} elsif ($widget{$k} =~ /Optionmenu/) { |
| 1326 |
$menus{$k} = $groups{$current}->{$k}; |
| 1327 |
($k eq 'bkg_alg') and ($val eq 'CLnorm') and |
| 1328 |
$menus{bkg_z} = $groups{$current}->{bkg_z}; |
| 1329 |
} elsif ($k eq 'bkg_flatten') { |
| 1330 |
$groups{$current} -> make(bkg_flatten=>$groups{$which}->{bkg_flatten}); |
| 1331 |
if ($groups{$current} -> {bkg_flatten}) { |
| 1332 |
$widget{bkg_flatten}->select; |
| 1333 |
} else { |
| 1334 |
$widget{bkg_flatten}->deselect; |
| 1335 |
}; |
| 1336 |
}; # flag for updates |
| 1337 |
($k =~ /bkg/) and $groups{$current}->make(update_bkg=>1); |
| 1338 |
($k =~ /fft/) and $groups{$current}->make(update_fft=>1); |
| 1339 |
($k =~ /bft/) and $groups{$current}->make(update_bft=>1); |
| 1340 |
}; |
| 1341 |
Echo("Set variable(s) to the standard."); |
| 1342 |
}; ## end of "this" block |
| 1343 |
|
| 1344 |
($how eq 'def') and do { |
| 1345 |
foreach my $k (@keys) { |
| 1346 |
($k = 'bkg_nnorm') if ($k =~ m{bkg_nnorm}); |
| 1347 |
if ($k eq 'importance') { |
| 1348 |
$groups{$current}->make(importance=>1); |
| 1349 |
set_properties(0,$current,0); |
| 1350 |
$groups{$current}->make(bkg_tie_e0=>$save); |
| 1351 |
return; |
| 1352 |
}; |
| 1353 |
next if (($k =~ /^plot/) or ($k =~ /^(edge|z)$/) or |
| 1354 |
($k =~ /^bkg_(alg|e0|eshift|fixstep|stan|step)/)); |
| 1355 |
my ($s,$key) = split(/_/, $k); |
| 1356 |
my $val = $config{$s}{$key}; |
| 1357 |
#print join("|", $k, $s, $key, $val), $/; |
| 1358 |
$groups{$current}->make($k=>$val); |
| 1359 |
($k =~ /bkg/) and $groups{$current}->make(update_bkg=>1); |
| 1360 |
($k =~ /fft/) and $groups{$current}->make(update_fft=>1); |
| 1361 |
($k =~ /bft/) and $groups{$current}->make(update_bft=>1); |
| 1362 |
## range parameters require special attention |
| 1363 |
if ($k =~ /(bkg_(nor[12]|pre[12]|spl([12]|1e|2e))|fft_km(ax|in))/) { |
| 1364 |
my ($pre1, $pre2, $nor1, $nor2, $spl1, $spl2, $kmin, $kmax) = |
| 1365 |
set_range_params($current); |
| 1366 |
($kmax = 12) if ($kmax <= 0); |
| 1367 |
SWITCH: { |
| 1368 |
$groups{$current}->make(bkg_pre1 =>$pre1), last SWITCH if ($k eq 'bkg_pre1'); |
| 1369 |
$groups{$current}->make(bkg_pre2 =>$pre2), last SWITCH if ($k eq 'bkg_pre2'); |
| 1370 |
$groups{$current}->make(bkg_nor1 =>$nor1), last SWITCH if ($k eq 'bkg_nor1'); |
| 1371 |
$groups{$current}->make(bkg_nor2 =>$nor2), last SWITCH if ($k eq 'bkg_nor2'); |
| 1372 |
$groups{$current}->make(bkg_spl1 =>$spl1, |
| 1373 |
bkg_spl1e=>$groups{$current}->k2e($spl1)), last SWITCH if ($k eq 'bkg_spl1'); |
| 1374 |
$groups{$current}->make(bkg_spl2 =>$spl2, |
| 1375 |
bkg_spl2e=>$groups{$current}->k2e($spl2)), last SWITCH if ($k eq 'bkg_spl2'); |
| 1376 |
$groups{$current}->make(fft_kmin =>$kmin), last SWITCH if ($k eq 'fft_kmin'); |
| 1377 |
$groups{$current}->make(fft_kmax =>$kmax), last SWITCH if ($k eq 'fft_kmax'); |
| 1378 |
$groups{$current}->make(bkg_spl1 =>$spl1, |
| 1379 |
bkg_spl1e=>$groups{$current}->k2e($spl1)), last SWITCH if ($k eq 'bkg_spl1e'); |
| 1380 |
$groups{$current}->make(bkg_spl2 =>$spl2, |
| 1381 |
bkg_spl2e=>$groups{$current}->k2e($spl2)), last SWITCH if ($k eq 'bkg_spl2e'); |
| 1382 |
$groups{$current}->make(bkg_flatten =>$config{bkg}{flatten}), last SWITCH if ($k eq 'bkg_flatten'); |
| 1383 |
}; |
| 1384 |
$groups{$current} -> kmax_suggest(\%plot_features) if ($groups{$current}->{fft_kmax} == 999); |
| 1385 |
}; |
| 1386 |
}; |
| 1387 |
set_properties(0,$current,0); |
| 1388 |
Echo("Set default variable value(s)."); |
| 1389 |
}; ## end of "def" block |
| 1390 |
|
| 1391 |
(($how eq 'all') or ($how eq 'marked')) and do { |
| 1392 |
my ($inc_e0, $inc_eshift) = ("", ""); |
| 1393 |
if ($config{general}{query_constrain}) { |
| 1394 |
my $dialog = |
| 1395 |
$top -> Dialog(-bitmap => 'questhead', |
| 1396 |
-text => "You are about to constrain parameters across $how groups. Are you sure you want to do this?", |
| 1397 |
-title => 'Athena: Constrain parameters...?', |
| 1398 |
-buttons => [qw/Yes No/], |
| 1399 |
-default_button => 'Yes'); |
| 1400 |
my $response = $dialog->Show(); |
| 1401 |
return if ($response eq 'No'); |
| 1402 |
$e0response = $eshiftresponse = 'Yes'; |
| 1403 |
} else { |
| 1404 |
$inc_e0 = grep(/bkg_e0/, @keys); |
| 1405 |
$inc_eshift = grep(/bkg_eshift/, @keys); |
| 1406 |
if ($inc_e0 and $inc_eshift) { |
| 1407 |
my $dialog = |
| 1408 |
$top -> Dialog(-bitmap => 'questhead', |
| 1409 |
-text => "You are about to constrain both E0 and the E0 shift for $how groups. Constraining E0 shifts can be a bad idea if there are groups of different edges and E0 shifts are typically set in the alignment dialog. Should Athena constrain the E0 values?", |
| 1410 |
-title => 'Athena: Constrain e0 and the e0 shift...?', |
| 1411 |
-buttons => [qw/Yes No/], |
| 1412 |
-default_button => 'Yes'); |
| 1413 |
$e0response = $dialog->Show(); |
| 1414 |
$eshiftresponse = $e0response; |
| 1415 |
}; |
| 1416 |
}; |
| 1417 |
foreach my $g (keys %marked) { |
| 1418 |
next if ($g eq $current); |
| 1419 |
next if (($how eq 'marked') and not $marked{$g}); |
| 1420 |
my $was = $groups{$g}->{bkg_tie_e0}; # temporarily turn off tie_e0 |
| 1421 |
$groups{$g}->make(bkg_tie_e0=>0); |
| 1422 |
K: foreach my $k (@keys) { |
| 1423 |
($k = 'bkg_nnorm') if ($k =~ m{bkg_nnorm}); |
| 1424 |
if (($k eq 'bkg_e0') and not $inc_eshift) { |
| 1425 |
next K if ($e0response eq 'No'); |
| 1426 |
unless ($e0response eq 'Yes') { |
| 1427 |
my $dialog = |
| 1428 |
$top -> Dialog(-bitmap => 'questhead', |
| 1429 |
-text => "You are about to constrain E0 for $how groups. This is handy if these groups are all of the same edge, but is a poor idea for groups of different edges. Should Athena constrain the E0 values?", |
| 1430 |
-title => 'Athena: Constrain e0...?', |
| 1431 |
-buttons => [qw/Yes No/], |
| 1432 |
-default_button => 'Yes'); |
| 1433 |
$e0response = $dialog->Show(); |
| 1434 |
next K if ($e0response eq 'No'); |
| 1435 |
}; |
| 1436 |
} elsif (($k eq 'bkg_eshift') and not $inc_e0) { |
| 1437 |
next K if ($eshiftresponse eq 'No'); |
| 1438 |
unless ($eshiftresponse eq 'Yes') { |
| 1439 |
my $dialog = |
| 1440 |
$top -> Dialog(-bitmap => 'questhead', |
| 1441 |
-text => "You are about to constrain the E0 shift for $how groups. Setting E0 shifts is normally done via the alignment dialog. Should Athena constrain the E0 shift values?", |
| 1442 |
-title => 'Athena: Constrain the e0 shift...?', |
| 1443 |
-buttons => [qw/Yes No/], |
| 1444 |
-default_button => 'Yes'); |
| 1445 |
$eshiftresponse = $dialog->Show(); |
| 1446 |
next K if ($eshiftresponse eq 'No'); |
| 1447 |
}; |
| 1448 |
}; |
| 1449 |
my $val = $groups{$current}->{$k}; |
| 1450 |
## take care not to make a group it's own bkg standard |
| 1451 |
($k eq 'bkg_stan') and ($val eq $g) and next; |
| 1452 |
if ($k eq 'bkg_alg') { |
| 1453 |
$val = $groups{$current}->{bkg_cl}; |
| 1454 |
$groups{$g} -> make(bkg_cl=>$val); |
| 1455 |
$val and $groups{$g} -> make(bkg_z=>$groups{$current}->{bkg_z}); |
| 1456 |
} elsif ($k eq 'bkg_stan') { |
| 1457 |
$groups{$g} -> make(bkg_stan => $val, |
| 1458 |
#bkg_stan_lab => $groups, |
| 1459 |
); |
| 1460 |
} else { |
| 1461 |
$groups{$g} -> make($k => $val); |
| 1462 |
SWITCH: { |
| 1463 |
$groups{$g} -> make(bkg_spl1e => $groups{$g}->k2e($val)), |
| 1464 |
last SWITCH if ($k eq 'bkg_spl1'); |
| 1465 |
$groups{$g} -> make(bkg_spl2e => $groups{$g}->k2e($val)), |
| 1466 |
last SWITCH if ($k eq 'bkg_spl2'); |
| 1467 |
$groups{$g} -> make(bkg_spl1 => $groups{$g}->e2k($val)), |
| 1468 |
last SWITCH if ($k eq 'bkg_spl1e'); |
| 1469 |
$groups{$g} -> make(bkg_spl2 => $groups{$g}->e2k($val)), |
| 1470 |
last SWITCH if ($k eq 'bkg_spl2e'); |
| 1471 |
}; |
| 1472 |
}; # flag for updates |
| 1473 |
($k =~ /bkg/) and $groups{$g}->make(update_bkg=>1); |
| 1474 |
($k =~ /fft/) and $groups{$g}->make(update_fft=>1); |
| 1475 |
($k =~ /bft/) and $groups{$g}->make(update_bft=>1); |
| 1476 |
}; |
| 1477 |
$groups{$g}->make(bkg_tie_e0=>$was); |
| 1478 |
}; |
| 1479 |
Echo("Set variable(s) for all groups") if ($how eq 'all'); |
| 1480 |
Echo("Set variable(s) for all marked groups") if ($how eq 'marked'); |
| 1481 |
}; # end of "all" and "marked" |
| 1482 |
|
| 1483 |
(($how eq 'def_all') or ($how eq 'def_marked')) and do { |
| 1484 |
Echo("Set this parameter to its default for all or marked groups...."); |
| 1485 |
}; |
| 1486 |
|
| 1487 |
$groups{$current}->make(bkg_tie_e0=>$save); |
| 1488 |
}; |
| 1489 |
project_state(0); |
| 1490 |
}; |
| 1491 |
|
| 1492 |
|
| 1493 |
sub session_defaults { |
| 1494 |
Echo("No data!"), return unless $current; |
| 1495 |
foreach my $key (@_) { |
| 1496 |
$groups{$current} -> SetDefault($key => $groups{$current}->{$key}); |
| 1497 |
}; |
| 1498 |
}; |
| 1499 |
sub clear_session_defaults { |
| 1500 |
## set default analysis parameter values |
| 1501 |
$setup -> SetDefault(bkg_e0 => $config{bkg}{e0}, |
| 1502 |
bkg_kw => $config{bkg}{kw}, |
| 1503 |
bkg_rbkg => $config{bkg}{rbkg}, |
| 1504 |
bkg_pre1 => $config{bkg}{pre1}, |
| 1505 |
bkg_pre2 => $config{bkg}{pre2}, |
| 1506 |
bkg_nor1 => $config{bkg}{nor1}, |
| 1507 |
bkg_nor2 => $config{bkg}{nor2}, |
| 1508 |
bkg_nnorm => $config{bkg}{nnorm}, |
| 1509 |
bkg_spl1 => $config{bkg}{spl1}, |
| 1510 |
bkg_spl2 => $config{bkg}{spl2}, |
| 1511 |
bkg_nclamp => $config{bkg}{nclamp}, |
| 1512 |
bkg_clamp1 => $config{bkg}{clamp1}, |
| 1513 |
bkg_clamp2 => $config{bkg}{clamp2}, |
| 1514 |
bkg_flatten => $config{bkg}{flatten}, |
| 1515 |
#fft_kw => $config{fft}{kw}, |
| 1516 |
fft_dk => $config{fft}{dk}, |
| 1517 |
fft_win => $config{fft}{win}, |
| 1518 |
fft_kmin => $config{fft}{kmin}, |
| 1519 |
fft_kmax => $config{fft}{kmax}, |
| 1520 |
fft_pc => $config{fft}{pc}, |
| 1521 |
bft_dr => $config{bft}{dr}, |
| 1522 |
bft_win => $config{bft}{win}, |
| 1523 |
bft_rmin => $config{bft}{rmin}, |
| 1524 |
bft_rmax => $config{bft}{rmax}, |
| 1525 |
); |
| 1526 |
}; |
| 1527 |
|
| 1528 |
|
| 1529 |
## This is the callback used to validate entry boxes. Mostly it makes |
| 1530 |
## sure that the entry is a number. For the spline ranges, it |
| 1531 |
## recomputes the values in E or k as appropriate. It also worries |
| 1532 |
## about relative and absolute energy values. |
| 1533 |
sub set_variable { |
| 1534 |
##print join(" | ", @_, $/); |
| 1535 |
my ($k, $entry, $prop) = (shift, shift, shift); |
| 1536 |
## attempt to change background color on focus. validate does not |
| 1537 |
## seem to work as advertised. |
| 1538 |
#(defined($prop)) or $widget{$k} -> configure(-background=>'pink'); |
| 1539 |
return 0 if (($groups{$current}->{frozen}) and ($k !~ /^(ind|pf|po|sta|plot_yoffset)/)); |
| 1540 |
($entry =~ m{\A\s*\z}) and ($entry = 0); # error checking ... |
| 1541 |
($entry =~ m{\A\s*-\z}) and return 1; # error checking ... |
| 1542 |
($entry =~ m{\A\s*-?(\d+\.?\d*|\.\d+)\s*\z}) or return 0; |
| 1543 |
(($k =~ m{([bf]ft|spl[12]|rbkg)}) and ($entry < 0)) and return 0; |
| 1544 |
(($k =~ m{\Atft_(?:d[kr]|[kr]m(?:ax|in)|npts|r[123])}) and ($entry < 0)) and return 0; |
| 1545 |
(($k =~ m{lcf_noise}) and ($entry < 0)) and return 0; |
| 1546 |
|
| 1547 |
## editing bkg_e0 and parameters are tied to the background |
| 1548 |
## need to keep track of previous reasonable value -- consider |
| 1549 |
## an edge energy of 11111. Changing that to 11110 involves the |
| 1550 |
## sequence 11111 -> 1111 -> 11110. For the middle step, all the |
| 1551 |
## other values will change by 10000 volts! To avoid that, the |
| 1552 |
## former_e0 parameter is maintained and used to compute the shift |
| 1553 |
## of all the other parameters |
| 1554 |
if (($k eq "bkg_e0") and ($groups{$current}->{bkg_tie_e0})) { |
| 1555 |
my $save = $groups{$current}->{bkg_e0}; |
| 1556 |
my $delta = $entry - $groups{$current}->{bkg_former_e0}; |
| 1557 |
my $shift = sprintf("%.4f", (abs($delta) > 100) ? 0 : $delta); |
| 1558 |
##print join("\t", $entry, $groups{$current}->{bkg_e0}, $groups{$current}->{bkg_former_e0}, $delta, $shift), $/; |
| 1559 |
$groups{$current}->make(bkg_former_e0 => (abs($delta) > 100) |
| 1560 |
? $groups{$current}->{bkg_former_e0} |
| 1561 |
: $entry); |
| 1562 |
foreach my $which (qw(pre1 pre2 nor1 nor2 spl1e spl2e)) { |
| 1563 |
my $value = $groups{$current}->{"bkg_$which"}-$shift; |
| 1564 |
($value = 0) if (($value < 0) and ($which =~ m{spl})); |
| 1565 |
$groups{$current} -> make("bkg_$which" => $value); |
| 1566 |
$widget{"bkg_$which"} -> configure(-validate=>'none'); |
| 1567 |
$widget{"bkg_$which"} -> delete(qw/0 end/); |
| 1568 |
$widget{"bkg_$which"} -> insert(0, $groups{$current}->{"bkg_$which"}); |
| 1569 |
$widget{"bkg_$which"} -> configure(-validate=>'key'); |
| 1570 |
}; |
| 1571 |
## now fix up all the k-valued parameters |
| 1572 |
$groups{$current}->make(bkg_spl1=>$groups{$current}->e2k($groups{$current}->{bkg_spl1e}), |
| 1573 |
bkg_spl2=>$groups{$current}->e2k($groups{$current}->{bkg_spl2e}), |
| 1574 |
); |
| 1575 |
foreach my $which (qw(fft_kmin fft_kmax)) { |
| 1576 |
my $e = $groups{$current}->k2e($groups{$current}->{$which})-$shift; |
| 1577 |
my $k = $groups{$current}->e2k($e); |
| 1578 |
$groups{$current}->make($which=>$k); |
| 1579 |
}; |
| 1580 |
foreach my $which (qw(bkg_spl1 bkg_spl2 fft_kmin fft_kmax)) { |
| 1581 |
$widget{$which} -> configure(-validate=>'none'); |
| 1582 |
$widget{$which} -> delete(qw/0 end/); |
| 1583 |
$widget{$which} -> insert(0, $groups{$current}->{$which}); |
| 1584 |
$widget{$which} -> configure(-validate=>'key'); |
| 1585 |
}; |
| 1586 |
}; |
| 1587 |
|
| 1588 |
## spline boundaries |
| 1589 |
if ($k =~ /bkg_spl/) { |
| 1590 |
my $x; |
| 1591 |
if ($k eq 'bkg_spl1') { |
| 1592 |
my $e = $groups{$current}->k2e($entry); |
| 1593 |
$groups{$current}->make(bkg_spl1e=>$e); |
| 1594 |
$x = 'bkg_spl1e'; |
| 1595 |
} elsif ($k eq 'bkg_spl2') { |
| 1596 |
my $e = $groups{$current}->k2e($entry); |
| 1597 |
$groups{$current}->make(bkg_spl2e=>$e); |
| 1598 |
$x = 'bkg_spl2e'; |
| 1599 |
} elsif ($k eq 'bkg_spl1e') { |
| 1600 |
my $k = $groups{$current}->e2k($entry); |
| 1601 |
$groups{$current}->make(bkg_spl1=>$k); |
| 1602 |
$x = 'bkg_spl1'; |
| 1603 |
} elsif ($k eq 'bkg_spl2e') { |
| 1604 |
my $k = $groups{$current}->e2k($entry); |
| 1605 |
$groups{$current}->make(bkg_spl2=>$k); |
| 1606 |
$x = 'bkg_spl2'; |
| 1607 |
}; |
| 1608 |
$widget{$x} -> configure(-validate=>'none'); |
| 1609 |
$widget{$x} -> delete(qw/0 end/); |
| 1610 |
$widget{$x} -> insert(0, $groups{$current}->{$x}); |
| 1611 |
$widget{$x} -> configure(-validate=>'key'); |
| 1612 |
}; |
| 1613 |
|
| 1614 |
# handle limits of deglitching margins |
| 1615 |
if ($k =~ /^deg/) { |
| 1616 |
my ($abs_pre1, $abs_pre2, $abs_nor1, $abs_nor2) = |
| 1617 |
($groups{$current}->{bkg_e0} + $groups{$current}->{bkg_pre1}, |
| 1618 |
$groups{$current}->{bkg_e0} + $groups{$current}->{bkg_pre2}, |
| 1619 |
$groups{$current}->{bkg_e0} + $groups{$current}->{bkg_nor1}, |
| 1620 |
$groups{$current}->{bkg_e0} + $groups{$current}->{bkg_nor2}); |
| 1621 |
my $x; |
| 1622 |
if ($k eq 'deg_emin') { |
| 1623 |
if (($entry > $groups{$current}->{deg_emax}) and |
| 1624 |
($entry < $groups{$current}->{bkg_e0}) and |
| 1625 |
($groups{$current}->{deg_emax} < $groups{$current}->{bkg_e0})) { |
| 1626 |
return 0 |
| 1627 |
} elsif (($entry < $groups{$current}->{bkg_e0}) and |
| 1628 |
($groups{$current}->{deg_emax} > $abs_pre2)) { |
| 1629 |
$groups{$current}->make(deg_emax=>$abs_pre2); |
| 1630 |
$x = 'deg_emax'; |
| 1631 |
} elsif (($entry > $groups{$current}->{bkg_e0}) and |
| 1632 |
($groups{$current}->{deg_emax} < $entry)) { |
| 1633 |
$groups{$current}->make(deg_emax=>$abs_nor2); |
| 1634 |
$x = 'deg_emax'; |
| 1635 |
}; |
| 1636 |
} elsif ($k eq 'deg_emax'){ |
| 1637 |
if (($entry < $groups{$current}->{deg_emin}) and |
| 1638 |
($entry > $groups{$current}->{bkg_e0}) and |
| 1639 |
($groups{$current}->{deg_emin} > $groups{$current}->{bkg_e0})) { |
| 1640 |
return 0 |
| 1641 |
} elsif (($entry < $groups{$current}->{bkg_e0}) and |
| 1642 |
($groups{$current}->{deg_emin} > $entry)) { |
| 1643 |
$groups{$current}->make(deg_emin=>$abs_pre1); |
| 1644 |
$x = 'deg_emin'; |
| 1645 |
} elsif (($entry > $groups{$current}->{bkg_e0}) and |
| 1646 |
($groups{$current}->{deg_emin} < $abs_nor1)) { |
| 1647 |
$groups{$current}->make(deg_emin=>$abs_nor1); |
| 1648 |
$x = 'deg_emin'; |
| 1649 |
}; |
| 1650 |
}; |
| 1651 |
if ($x) { |
| 1652 |
my $v = $groups{$current}->{$x}; |
| 1653 |
$widget{$x} -> configure(-validate=>'none'); |
| 1654 |
$widget{$x} -> delete(qw/0 end/); |
| 1655 |
$widget{$x} -> insert(0, $v); |
| 1656 |
$widget{$x} -> configure(-validate=>'key'); |
| 1657 |
}; |
| 1658 |
}; |
| 1659 |
|
| 1660 |
## linear combination fit parameters |
| 1661 |
if ($k =~ /^lcf_fitm(ax|in)/) { |
| 1662 |
$groups{$current}->make($k=>$entry); |
| 1663 |
$widget{$k} -> configure(-validate=>'none'); |
| 1664 |
$widget{$k} -> delete(qw/0 end/); |
| 1665 |
$widget{$k} -> insert(0, $groups{$current}->{$k}); |
| 1666 |
$widget{$k} -> configure(-validate=>'key'); |
| 1667 |
return 1; |
| 1668 |
}; |
| 1669 |
|
| 1670 |
$groups{$current}->make($k=>$entry), return 1 if ($k =~ m{^mee}); |
| 1671 |
|
| 1672 |
## return if this is not a front-page variable |
| 1673 |
return 1 if ($k =~ /\A(?:al|lcf|tft)/); |
| 1674 |
project_state(0), return 1 if ($k =~ /\A(?:conv|ind|pf|po|sa|sta)/); |
| 1675 |
return 1 if ($k =~ /\A(?:enc|rebin)/); |
| 1676 |
|
| 1677 |
## set this variable |
| 1678 |
$groups{$current}->make($k=>$entry); |
| 1679 |
if ($k eq 'bkg_e0') { |
| 1680 |
my $k = $groups{$current}->{bkg_spl1}; |
| 1681 |
$groups{$current} -> make(bkg_spl1e=>$groups{$current}->k2e($k)); |
| 1682 |
$k = $groups{$current}->{bkg_spl2}; |
| 1683 |
$groups{$current} -> make(bkg_spl2e=>$groups{$current}->k2e($k)); |
| 1684 |
foreach my $x (qw/bkg_spl1e bkg_spl2e/) { |
| 1685 |
$widget{$x} -> configure(-validate=>'none'); |
| 1686 |
$widget{$x} -> delete(qw/0 end/); |
| 1687 |
$widget{$x} -> insert(0, $groups{$current}->{$x}); |
| 1688 |
$widget{$x} -> configure(-validate=>'key'); |
| 1689 |
}; |
| 1690 |
}; |
| 1691 |
|
| 1692 |
## tie together data and reference |
| 1693 |
if ($k eq 'bkg_eshift') { |
| 1694 |
if ($groups{$current}->{reference} and exists($groups{$groups{$current}->{reference}})) { |
| 1695 |
$groups{$groups{$current}->{reference}} -> make(bkg_eshift=>$entry); |
| 1696 |
}; |
| 1697 |
}; |
| 1698 |
|
| 1699 |
SWITCH: { # flag what chores need updating |
| 1700 |
$groups{$current}->make(update_bkg=>1), last SWITCH if ($k =~ /bkg/); |
| 1701 |
$groups{$current}->make(update_fft=>1), last SWITCH if ($k =~ /fft/); |
| 1702 |
$groups{$current}->make(update_bft=>1), last SWITCH if ($k =~ /bft/); |
| 1703 |
}; |
| 1704 |
|
| 1705 |
project_state(0); |
| 1706 |
return 1; |
| 1707 |
}; |
| 1708 |
|
| 1709 |
sub check_z { |
| 1710 |
my $this = shift; |
| 1711 |
return 1 if ($this =~ /$Ifeffit::Files::elem_regex$/i); |
| 1712 |
my $dialog = |
| 1713 |
$top -> Dialog(-bitmap => 'error', |
| 1714 |
-text => "$menus{bkg_z} is not an element symbol", |
| 1715 |
-title => 'Athena: Invalid element symbol', |
| 1716 |
-buttons => ['OK'], |
| 1717 |
-default_button => 'OK', |
| 1718 |
-popover => 'cursor'); |
| 1719 |
$dialog->raise; |
| 1720 |
my $response = $dialog->Show(); |
| 1721 |
$widget{z} -> focus; |
| 1722 |
return 0; |
| 1723 |
}; |
| 1724 |
|
| 1725 |
sub identify_reference { |
| 1726 |
my $message = "This group does not have a reference channel."; |
| 1727 |
if (exists($groups{$groups{$current}->{reference}})) { |
| 1728 |
my $this = $groups{$current}->{label}; |
| 1729 |
my $ref = $groups{$groups{$current}->{reference}}->{label}; |
| 1730 |
$message = "The reference for \"$this\" is \"$ref\"."; |
| 1731 |
}; |
| 1732 |
Echo($message); |
| 1733 |
}; |
| 1734 |
|
| 1735 |
sub explain_eshift { |
| 1736 |
my $text = <<EOH |
| 1737 |
The energy shift is applied to the energy axis of the input data before any other data processing |
| 1738 |
happens. Thus the value for E0 is chosen on the data's energy axis AFTER the energy shift is applied. |
| 1739 |
|
| 1740 |
Other energy values, such as the pre- and post-edge line parameters and the plotting range |
| 1741 |
take relative energy values. Their values are relative to E0, thus computed AFTER the energy |
| 1742 |
shift is applied. |
| 1743 |
|
| 1744 |
Data processing operations such as merging and calculation of difference spectra are also |
| 1745 |
performed AFTER the energy shift is applied. The energy shift can be changed by hand, but is |
| 1746 |
normally set using the data alignment dialog. |
| 1747 |
EOH |
| 1748 |
; |
| 1749 |
$text =~ s{\n}{ }g; |
| 1750 |
$text =~ s/ /\n\n/g; |
| 1751 |
my $dialog = |
| 1752 |
$top -> Dialog(-bitmap => 'questhead', |
| 1753 |
-text => $text, |
| 1754 |
-title => 'Athena: Understanding the energy shift', |
| 1755 |
-buttons => ['OK'], |
| 1756 |
-default_button => 'OK', |
| 1757 |
#-popover => 'cursor', |
| 1758 |
); |
| 1759 |
$dialog->raise; |
| 1760 |
my $response = $dialog->Show(); |
| 1761 |
return 0; |
| 1762 |
}; |
| 1763 |
|
| 1764 |
## END OF DRAW PROPERTIES SUBSECTION |
| 1765 |
########################################################################################## |