92
95
# does this one have mac line-endings?
93
# my $was_mac = $groups{"Default Parameters"} ->
94
# fix_mac($_, $stash_dir, lc($config{general}{mac_eol}), $top);
95
# Echo("\"$_\" had Macintosh EOL characters and was skipped."), next DATA if ($was_mac == -1);
96
# Echo("\"$_\" had Macintosh EOL characters and was fixed.") if ($was_mac == 1);
97
my $is_record = (Ifeffit::Files->is_record($_));
96
# my $was_mac = $groups{"Default Parameters"} ->
97
# fix_mac($thisfile, $stash_dir, lc($config{general}{mac_eol}), $top);
98
# Echo("\"$thisfile\" had Macintosh EOL characters and was skipped."), next DATA if ($was_mac eq '-1');
99
# Echo("\"$thisfile\" had Macintosh EOL characters and was fixed.") if ($was_mac eq '1');
100
my $is_record = (Ifeffit::Files->is_record($thisfile));
101
my ($is_mac, $tempfile) = (0, q{});
102
if (not $is_record) {
104
open( FH, $thisfile ) or die "sudden flaming death\n";
107
if ($snarf =~ m{\r(?!\n)}) { # this matches Mac EOL but not Windows
108
Echo("Correcting Mac line termination for $thisfile");
109
$tempfile = File::Spec->catfile($stash_dir, "unmacify_".basename($thisfile));
110
$snarf =~ s{\r(?!\n)}{\n}g;
111
open TF, ">",$tempfile;
117
my $thisfile_notmac = ($is_mac) ? $tempfile : $thisfile;
98
119
my @foo = %marked;
99
120
my $empty = $#foo;
100
121
my $safe_message_issued = 0;
103
124
if ($is_record) {
125
my $fname = $thisfile_notmac;
127
my ($imported, $total) = (0,0);
128
my $frame = examine_project($fname, \%group_map, \$cancel, \$project_no_prompt);
129
($frame == 0) or $frame -> waitWindow();
130
last DATA if ($cancel);
105
131
my $nrecords = 0;
106
132
$reading_project = 1;
107
&push_mru($fname, 1, 1);
108
##open R, $fname or die "Could not open $_ as a record or project\n";
133
##open R, $fname or die "Could not open $thisfile_notmac as a record or project\n";
109
134
my $gz = gzopen($fname, "rb") or die "could not open $fname as an Athena project\n";
111
136
use vars qw($old_group @args @x @y @journal @stddev @i0 %foo);
931
993
#$widg{pre}->configure(-state=>$preproc_state);
932
994
$enlabel -> configure(-text=>'Energy:');
933
995
$fnlabel -> configure(-text=>'mu(E):');
934
$unlabel -> configure(-foreground=>$config{colors}{activehighlightcolor}); });
996
$unlabel -> configure(-foreground=>$active_color); });
935
997
$om ->command(-label=>'norm(E)',
936
998
-command=>sub{$space='n'; $space_label='norm(E)';
937
999
$widg{evkev}->configure(-state=>'normal');
938
1000
#$widg{pre}->configure(-state=>$preproc_state);
939
1001
$enlabel -> configure(-text=>'Energy:');
940
1002
$fnlabel -> configure(-text=>'norm(E):');
941
$unlabel -> configure(-foreground=>$config{colors}{activehighlightcolor}); });
1003
$unlabel -> configure(-foreground=>$active_color); });
942
1004
$om ->command(-label=>'xanes(E)',
943
1005
-command=>sub{$space='a'; $space_label='xanes(E)';
944
1006
$widg{evkev}->configure(-state=>'normal');
945
1007
#$widg{pre}->configure(-state=>$preproc_state);
946
1008
$enlabel -> configure(-text=>'Energy:');
947
1009
$fnlabel -> configure(-text=>'mu(E):');
948
$unlabel -> configure(-foreground=>$config{colors}{activehighlightcolor}); });
1010
$unlabel -> configure(-foreground=>$active_color); });
949
1011
$om ->command(-label=>'chi(k)',
950
1012
-command=>sub{$space='k'; $space_label='chi(k)';
951
1013
$widg{evkev}->configure(-state=>'disabled');
984
1046
-borderwidth=>1,
985
1047
-textvariable=>\$evkev, -width=>6)
986
1048
-> pack(-side=>'left');
987
$widg{evkev} -> command(-label=>'eV', -command=>sub{$evkev = 'ev';
988
$widg{extras} -> raise(($preproc_number>1) ? 'preprocessing' : 'reference');
989
$$prior_args{old} = $energy;
990
$$prior_args{numerator} = \%numerator;
991
$$prior_args{denominator} = \%denominator;
992
$$prior_args{do_ln} = $do_ln;
993
$$prior_args{invert} = $invert;
994
$$prior_args{space} = $space;
995
$$prior_args{evkev} = $evkev;
996
$$prior_args{is_xmudat} = $is_xmudat;
997
$$prior_args{sort} = $sort;
998
$$prior_args{multi} = $multi;
999
$$prior_args{ref} = \%reference;
1000
($xmustring, @toss) = make_xmu_string(\%numerator, \%denominator, $do_ln, $invert, $energy)
1002
$widg{evkev} -> command(-label=>'keV', -command=>sub{$evkev = 'kev';
1003
$widg{extras} -> raise(($preproc_number>1) ? 'preprocessing' : 'reference');
1004
$$prior_args{old} = $energy;
1005
$$prior_args{numerator} = \%numerator;
1006
$$prior_args{denominator} = \%denominator;
1007
$$prior_args{do_ln} = $do_ln;
1008
$$prior_args{invert} = $invert;
1009
$$prior_args{space} = $space;
1010
$$prior_args{evkev} = $evkev;
1011
$$prior_args{is_xmudat} = $is_xmudat;
1012
$$prior_args{sort} = $sort;
1013
$$prior_args{multi} = $multi;
1014
$$prior_args{ref} = \%reference;
1015
($xmustring, @toss) = make_xmu_string(\%numerator, \%denominator, $do_ln, $invert, $energy)
1017
$widg{evkev} -> command(-label=>'pixel', -command=>sub{$evkev = 'pixel';
1018
$widg{extras} -> raise(($preproc_number>1) ? 'preprocessing' : 'reference');
1019
$$prior_args{old} = $energy;
1020
$$prior_args{numerator} = \%numerator;
1021
$$prior_args{denominator} = \%denominator;
1022
$$prior_args{do_ln} = $do_ln;
1023
$$prior_args{invert} = $invert;
1024
$$prior_args{space} = $space;
1025
$$prior_args{evkev} = $evkev;
1026
$$prior_args{is_xmudat} = $is_xmudat;
1027
$$prior_args{sort} = $sort;
1028
$$prior_args{multi} = $multi;
1029
$$prior_args{ref} = \%reference;
1030
($xmustring, @toss) = make_xmu_string(\%numerator, \%denominator, $do_ln, $invert, $energy)
1049
$widg{evkev} -> command(-label =>'eV',
1050
-command=>sub{$evkev = 'ev';
1051
#$widg{extras} -> raise(($preproc_number>1) ? 'preprocessing' : 'reference');
1052
$$prior_args{old} = $energy;
1053
$$prior_args{numerator} = \%numerator;
1054
$$prior_args{denominator} = \%denominator;
1055
$$prior_args{do_ln} = $do_ln;
1056
$$prior_args{invert} = $invert;
1057
$$prior_args{space} = $space;
1058
$$prior_args{evkev} = $evkev;
1059
$$prior_args{is_xmudat} = $is_xmudat;
1060
$$prior_args{sort} = $sort;
1061
$$prior_args{multi} = $multi;
1062
$$prior_args{ref} = \%reference;
1063
($xmustring, @toss) = make_xmu_string(\%numerator, \%denominator, $do_ln, $invert, $energy)
1065
$widg{evkev} -> command(-label =>'keV',
1066
-command=>sub{$evkev = 'kev';
1067
#$widg{extras} -> raise(($preproc_number>1) ? 'preprocessing' : 'reference');
1068
$$prior_args{old} = $energy;
1069
$$prior_args{numerator} = \%numerator;
1070
$$prior_args{denominator} = \%denominator;
1071
$$prior_args{do_ln} = $do_ln;
1072
$$prior_args{invert} = $invert;
1073
$$prior_args{space} = $space;
1074
$$prior_args{evkev} = $evkev;
1075
$$prior_args{is_xmudat} = $is_xmudat;
1076
$$prior_args{sort} = $sort;
1077
$$prior_args{multi} = $multi;
1078
$$prior_args{ref} = \%reference;
1079
($xmustring, @toss) = make_xmu_string(\%numerator, \%denominator, $do_ln, $invert, $energy)
1081
$widg{evkev} -> command(-label =>'pixel',
1082
-command=>sub{$evkev = 'pixel';
1083
#$widg{extras} -> raise(($preproc_number>1) ? 'preprocessing' : 'reference');
1084
$$prior_args{old} = $energy;
1085
$$prior_args{numerator} = \%numerator;
1086
$$prior_args{denominator} = \%denominator;
1087
$$prior_args{do_ln} = $do_ln;
1088
$$prior_args{invert} = $invert;
1089
$$prior_args{space} = $space;
1090
$$prior_args{evkev} = $evkev;
1091
$$prior_args{is_xmudat} = $is_xmudat;
1092
$$prior_args{sort} = $sort;
1093
$$prior_args{multi} = $multi;
1094
$$prior_args{ref} = \%reference;
1095
($xmustring, @toss) = make_xmu_string(\%numerator, \%denominator, $do_ln, $invert, $energy)
1032
1097
-state=>($config{pixel}{do_pixel_check}) ? 'normal' : 'disabled');
1033
1098
if ($space =~ /[ck]/) {
1034
1099
$widg{evkev}->configure(-state=>'disabled');
1071
1138
## -> add("favorites", -label=>'Favorites', -anchor=>'center',);
1072
1139
## set_favorites(\%widg)
1073
1140
## -> pack(-anchor=>'n', -fill=>'x');
1141
$widg{extras} -> raise($preprocess{raised});
1075
$$prior_args{extra_shown} = 0;
1076
$widg{extra_button} = $left -> Button(-text=>'Show extra features', @button_list,
1079
my ($h,$w) = ($left->height(), $raw->width());
1080
$reference{preproc_state} = $preproc_state;
1081
$widg{extra_button} -> packForget;
1082
$top -> update; # needed so $raw resizes correctly
1083
$widg{extras} -> pack(-pady=>2, -expand=>1, -fill=>'x');
1084
$right->pack(-expand=>1, -fill=>'both',
1085
-side=>'right', -anchor=>'n');
1086
$databox->pack(-expand=>1, -fill=>'both',
1087
-padx=>4, -pady=>2);
1088
$widg{extras} -> raise(($preproc_number>1 eq 'normal') ? 'preprocessing' : 'reference');
1089
$$prior_args{extra_shown} = 1;
1091
-> pack(-expand=>1, -fill=>'x', -pady=>0);
1143
$$prior_args{extra_shown} = 1; # 0;
1144
## $widg{extra_button} = $left -> Button(-text=>'Show extra features', @button_list,
1147
## my ($h,$w) = ($left->height(), $raw->width());
1148
## $reference{preproc_state} = $preproc_state;
1149
## $widg{extra_button} -> packForget;
1150
## $top -> update; # needed so $raw resizes correctly
1151
## $widg{extras} -> pack(-pady=>2, -expand=>1, -fill=>'x');
1152
## $right->pack(-expand=>1, -fill=>'both',
1153
## -side=>'right', -anchor=>'n');
1154
## $databox->pack(-expand=>1, -fill=>'both',
1155
## -padx=>4, -pady=>2);
1156
## $widg{extras} -> raise(($preproc_number>1 eq 'normal') ? 'preprocessing' : 'reference');
1157
## $$prior_args{extra_shown} = 1;
1159
## -> pack(-expand=>1, -fill=>'x', -pady=>0);
2142
2227
$groups{$x}->{plot_yoffset});
2144
2229
-> pack(-expand=>1, -fill=>'x', -padx=>1, -pady=>2, -side=>'left');
2145
$frame -> Button(-text=>'Dismiss extras', -width=>5, @button_list,
2146
-command => sub{remove_extras($widg)} )
2147
-> pack(-expand=>1, -fill=>'x', -padx=>1, -pady=>2, -side=>'right');
2230
##$frame -> Button(-text=>'Dismiss extras', -width=>5, @button_list,
2231
## -command => sub{remove_extras($widg)} )
2232
## -> pack(-expand=>1, -fill=>'x', -padx=>1, -pady=>2, -side=>'right');
2149
2234
## initial setup
2150
foreach (keys %labels) {
2151
$labels{$_}->configure(-foreground=>($preprocess{standard} eq 'None') ?
2152
'#9c9583' : $config{colors}{activehighlightcolor});
2235
my $notnone = $config{colors}{activehighlightcolor};
2236
foreach (qw(deg_emin deg_emax deg_tol)) {
2237
my $active = (($preprocess{standard} ne 'None') and $preprocess{deg_do});
2238
$labels{$_}->configure(-foreground=> $active ? '#9c9583' : $notnone);
2240
foreach (qw(trun_e)) {
2241
my $active = (($preprocess{standard} ne 'None') and $preprocess{trun_do});
2242
$labels{$_}->configure(-foreground=> $active ? '#9c9583' : $notnone);
2154
2244
foreach (keys %widgets) {
2155
2245
next if ($_ eq 'standard'); # or ($_ =~ /(deg|trun)_check/));
2507
2597
## be saved by this subroutine
2509
2599
Echo('No data!'), return unless ($current);
2510
my $space = lc($_[0]);
2600
my ($space, $in_loop, $dir) = @_;
2601
$space = lc($space);
2511
2602
Echo("You cannot save chi for the Default Parameters"), return 0
2512
2603
if ($current eq "Default Parameters");
2514
my $this = $current;
2605
my $this = $in_loop || $current;
2515
2606
my ($suffix, $text) = ('chi', 'chi(k)');
2517
2608
(($suffix, $text) = ('chi1', 'k*chi(k)')), last SWITCH if ($space eq 'k1');
2518
2609
(($suffix, $text) = ('chi2', 'k^2*chi(k)')), last SWITCH if ($space eq 'k2');
2519
2610
(($suffix, $text) = ('chi3', 'k^3*chi(k)')), last SWITCH if ($space eq 'k3');
2611
(($suffix, $text) = ('chie', 'chi(E)')), last SWITCH if ($space eq 'ke');
2520
2612
(($suffix, $text) = ('xmu', 'mu(E)')), last SWITCH if ($space eq 'e');
2521
2613
(($suffix, $text) = ('nor', 'normalized mu(E)')), last SWITCH if ($space eq 'n');
2522
2614
(($suffix, $text) = ('der', 'derivative mu(E)')), last SWITCH if ($space eq 'd');
2699
2805
($x, $y, $mess) = ('k','chi1', "k*chi(k)"), last SWITCH if ($sp eq 'k1');
2700
2806
($x, $y, $mess) = ('k','chi2', "k^2*chi(k)"), last SWITCH if ($sp eq 'k2');
2701
2807
($x, $y, $mess) = ('k','chi3', "k^3*chi(k)"), last SWITCH if ($sp eq 'k3');
2808
($x, $y, $mess) = ('energy','chi', "chi(E)"), last SWITCH if ($sp eq 'ke');
2702
2809
($x, $y, $mess) = ('r','chir_mag', "the magnitude of chi(R)"), last SWITCH if ($sp eq 'rm');
2703
2810
($x, $y, $mess) = ('r','chir_re', "the real part of chi(R)"), last SWITCH if ($sp eq 'rr');
2704
2811
($x, $y, $mess) = ('r','chir_im', "the imaginary part of chi(R)"), last SWITCH if ($sp eq 'ri');
2824
2931
Echo("Saving $mess for each marked group ... done!");
2937
map {$m += $_} values %marked;
2938
Error("Saving files aborted. There are no marked groups."), return 1 unless ($m);
2940
my $d = $top->DialogBox(-title => "Artemis: Save each marked group to a directory",
2941
-buttons => ["Select", "Cancel"],
2942
##-popover => 'cursor'
2945
my $curr_dir = $current_data_dir;
2946
my $label = $d -> add('Label', -textvariable=>\$curr_dir)
2947
-> pack(-fill => "x", -expand => 1);
2948
my $fr = $d -> add('Frame') -> pack(-fill => "both", -expand => 1);
2949
## ----> need a create new directory button <----
2950
my $dt = $fr->Scrolled('DirTree',
2951
-scrollbars => 'osoe',
2954
-selectmode => 'browse',
2955
-exportselection => 1,
2956
-directory => $current_data_dir,
2957
-browsecmd => sub { $curr_dir = shift },
2959
# With this version of -command a double-click will
2960
# select the directory
2961
##-command => sub { $ok = 1 },
2963
# With this version of -command a double-click will
2964
# open a directory. Selection is only possible with
2966
#-command => sub { $d->opencmd($_[0]) },
2968
->pack(-fill => "both", -expand => 1);
2969
my $this = $d -> Show();
2970
Echo("Not saving each marked file"), return if ($this eq 'Cancel');
2973
my @list = (&sorted_group_list);
2974
foreach my $g (@list) {
2975
next if not $marked{$g};
2976
Echonow("Saving $groups{$g}->{label} in \"$curr_dir\" ...");
2977
$text = save_chi($sp, $g, $curr_dir);
2979
Echo("Saved $text data to \"$curr_dir\" ...");
2830
2983
sub set_defaults {