| 1 |
## -*- cperl -*- |
| 2 |
## |
| 3 |
## This file is part of Athena, copyright (c) 2001-2006 Bruce Ravel |
| 4 |
## |
| 5 |
## This file contains the dialog for making a series of copies of a data group |
| 6 |
|
| 7 |
sub series { |
| 8 |
|
| 9 |
## generally, we do not change modes unless there is data. |
| 10 |
## exceptions include things like the prefernces and key bindings, |
| 11 |
## which are data-independent |
| 12 |
Echo("No data!"), return unless $current; |
| 13 |
Echo("No data!"), return if ($current eq "Default Parameters"); |
| 14 |
|
| 15 |
## this is a way of testing the current list of data groups for some |
| 16 |
## necessary property. for the demo, this will just be the list of |
| 17 |
## groups |
| 18 |
# my @keys = (); |
| 19 |
# foreach my $k (&sorted_group_list) { |
| 20 |
# ($groups{$k}->{is_xmu}) and push @keys, $k; |
| 21 |
# }; |
| 22 |
# Echo("You need two or more xmu groups to foobar"), return unless ($#keys >= 1); |
| 23 |
my @keys = &sorted_group_list; |
| 24 |
|
| 25 |
## you must define a hash which will contain the parameters needed |
| 26 |
## to perform the task. the hash_pointer global variable will point |
| 27 |
## to this hash for use in set_properties. you might draw these |
| 28 |
## values from configuration parameters, as in the commented out |
| 29 |
## example |
| 30 |
my %series_params; |
| 31 |
$series_params{group} = $current; |
| 32 |
$series_params{label} = $groups{$current}->{label}; |
| 33 |
|
| 34 |
## you may wish to provide a better guess for which should be the |
| 35 |
## standard and which the unknown. you may also want to adjust the |
| 36 |
## view of the groups list to show the unknown -- the following |
| 37 |
## works... |
| 38 |
my $here = ($list->bbox($groups{$current}->{text}))[1] - 5 || 0; |
| 39 |
($here < 0) and ($here = 0); |
| 40 |
my $full = ($list->bbox(@skinny_list))[3] + 5; |
| 41 |
$list -> yview('moveto', $here/$full); |
| 42 |
|
| 43 |
|
| 44 |
## these two global variables must be set before this view is |
| 45 |
## displayed. these are used at the level of set_properties to |
| 46 |
## perform chores appropriate to this dialog when changing the |
| 47 |
## current group |
| 48 |
$fat_showing = 'series'; |
| 49 |
$hash_pointer = \%series_params; |
| 50 |
|
| 51 |
## disable many menus. this makes the chore of managing the views |
| 52 |
## much easier. the idea is that the main view is "home base". if |
| 53 |
## you want to do a different analysis chore, you must first return |
| 54 |
## to the main view |
| 55 |
map {$_ -> configure(-state=>'disabled')} |
| 56 |
($data_menu, $merge_menu, $anal_menu, $settings_menu); |
| 57 |
|
| 58 |
## this removes the currently displayed view without destroying its |
| 59 |
## contents |
| 60 |
$fat -> packForget; |
| 61 |
|
| 62 |
## define the parent Frame for this analysis chore and pack it in |
| 63 |
## the correct location |
| 64 |
my $series = $container->Frame(@fatgeom, -relief=>'sunken', -borderwidth=>3) |
| 65 |
-> pack(-fill=>'both', -expand=>1); |
| 66 |
#$series -> packPropagate(0); |
| 67 |
## global variable identifying which Frame is showing |
| 68 |
$which_showing = $series; |
| 69 |
|
| 70 |
## the standard label along the top identifying this analysis chore |
| 71 |
$series -> Label(-text=>"Create a series of data group copies", |
| 72 |
-font=>$config{fonts}{large}, |
| 73 |
-foreground=>$config{colors}{activehighlightcolor}) |
| 74 |
-> pack(-side=>'top', -fill=>'x', -anchor=>'w'); |
| 75 |
|
| 76 |
## a good solution to organizing widgets is to stack frames, so |
| 77 |
## let's make a frame for the standard and the other. note that the |
| 78 |
## "labels" are actually flat buttons which display hints in the |
| 79 |
## echo area |
| 80 |
my $frame = $series -> Frame(-borderwidth=>2, -relief=>'sunken') |
| 81 |
-> pack(-side=>'top', -fill=>'x'); |
| 82 |
$frame -> Label(-text=>"Group:", |
| 83 |
-foreground=>$config{colors}{activehighlightcolor},) |
| 84 |
-> grid(-row=>0, -column=>0, -sticky=>'e', -pady=>3); |
| 85 |
$widget{safluo_group} = $frame -> Label(-anchor=>'w', -textvariable=>\$series_params{label}) |
| 86 |
-> grid(-row=>0, -column=>1, -sticky=>'ew', -pady=>3); |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
## this is a spacer frame which pushes all the widgets to the top |
| 91 |
$series -> Frame(-background=>$config{colors}{darkbackground}) |
| 92 |
-> pack(-side=>'bottom', -expand=>1, -fill=>'both'); |
| 93 |
|
| 94 |
## at the bottom of the frame, there are full width buttons for |
| 95 |
## returning to the main view and for going to the appropriate |
| 96 |
## document section |
| 97 |
$series -> Button(-text=>'Return to the main window', @button_list, |
| 98 |
-background=>$config{colors}{background2}, |
| 99 |
-activebackground=>$config{colors}{activebackground2}, |
| 100 |
-command=>sub{## clean-up chores, for instance you |
| 101 |
## may need to toggle update_bkg or |
| 102 |
## one of the others |
| 103 |
|
| 104 |
## restore the plot ranges is they |
| 105 |
## were changed |
| 106 |
## finally restore the main view |
| 107 |
&reset_window($series, "series", 0); |
| 108 |
}) |
| 109 |
-> pack(-side=>'bottom', -fill=>'x'); |
| 110 |
## help button |
| 111 |
$series -> Button(-text=>'Document section: copying groups', @button_list, |
| 112 |
-command=>sub{pod_display("ui::glist.pod") }) |
| 113 |
-> pack(-side=>'bottom', -fill=>'x', -pady=>4); |
| 114 |
|
| 115 |
tie my %params, "Tie::IxHash"; |
| 116 |
%params = ('bkg_e0' => 'Background removal E0', |
| 117 |
'bkg_rbkg' => 'Background removal R_bkg', |
| 118 |
'bkg_kw' => 'Background removal k-weight', |
| 119 |
'bkg_pre1' => 'Lower end of pre-edge range', |
| 120 |
'bkg_pre2' => 'Upper end of pre-edge range', |
| 121 |
'bkg_nor1' => 'Lower end of normalization range', |
| 122 |
'bkg_nor2' => 'Upper end of normalization range', |
| 123 |
'bkg_spl1' => 'Lower end of spline range', |
| 124 |
'bkg_spl2' => 'Upper end of spline range', |
| 125 |
'fft_kmin' => 'Fourier tranform minimum k', |
| 126 |
'fft_kmax' => 'Fourier tranform maximum k', |
| 127 |
'fft_dk' => 'Fourier tranform sill width', |
| 128 |
'bft_rmin' => 'Back tranform minimum R', |
| 129 |
'bft_rmax' => 'Back tranform maximum R', |
| 130 |
'bft_dr' => 'Back tranform sill width', |
| 131 |
); |
| 132 |
$series_params{param} = 'bkg_rbkg'; |
| 133 |
$series_params{plab} = $params{'bkg_rbkg'}; |
| 134 |
$frame -> Label(-text=>"Parameter:", |
| 135 |
-foreground=>$config{colors}{activehighlightcolor},) |
| 136 |
-> grid(-row=>1, -column=>0, -sticky=>'e', -pady=>3); |
| 137 |
$widget{series_param} = $frame -> Optionmenu(-font=>$config{fonts}{small}, |
| 138 |
-textvariable => \$series_params{plab}, |
| 139 |
-borderwidth=>1, |
| 140 |
) |
| 141 |
-> grid(-row=>1, -column=>1, -sticky=>'ew', -pady=>3); |
| 142 |
foreach my $i (keys %params) { |
| 143 |
$widget{series_param} -> command(-label => $params{$i}, |
| 144 |
-command => |
| 145 |
sub{ |
| 146 |
$series_params{param} = $i; |
| 147 |
$series_params{plab} = $params{$i}; |
| 148 |
$series_params{current} = sprintf("%.3f", $groups{$current}->{$i}); |
| 149 |
$series_params{begin} = sprintf("%.3f", $groups{$current}->{$i}); |
| 150 |
$series_params{inc} = ($i eq 'bkg_e0') ? 5 : sprintf("%.3f", abs($groups{$current}->{$i}) / 10); |
| 151 |
}); |
| 152 |
}; |
| 153 |
|
| 154 |
$series_params{current} = $groups{$current}->{'bkg_rbkg'}; |
| 155 |
$frame -> Label(-text=>"Current value:", |
| 156 |
-foreground=>$config{colors}{activehighlightcolor},) |
| 157 |
-> grid(-row=>2, -column=>0, -sticky=>'e', -pady=>3); |
| 158 |
$widget{series_current} = $frame -> Label(-anchor=>'w', |
| 159 |
-textvariable=>\$series_params{current}) |
| 160 |
-> grid(-row=>2, -column=>1, -sticky=>'ew', -pady=>3); |
| 161 |
|
| 162 |
$series_params{begin} = $groups{$current}->{'bkg_rbkg'}; |
| 163 |
$frame -> Label(-text=>"Beginning value:", |
| 164 |
-foreground=>$config{colors}{activehighlightcolor},) |
| 165 |
-> grid(-row=>3, -column=>0, -sticky=>'e', -pady=>3); |
| 166 |
$widget{series_begin} = $frame -> Entry(-textvariable=>\$series_params{begin}) |
| 167 |
-> grid(-row=>3, -column=>1, -sticky=>'ew', -pady=>3); |
| 168 |
|
| 169 |
$series_params{number} = 4; |
| 170 |
$frame -> Label(-text=>"Number of copies:", |
| 171 |
-foreground=>$config{colors}{activehighlightcolor},) |
| 172 |
-> grid(-row=>4, -column=>0, -sticky=>'e', -pady=>3); |
| 173 |
$widget{series_number} = $frame -> Entry(-textvariable=>\$series_params{number}) |
| 174 |
-> grid(-row=>4, -column=>1, -sticky=>'ew', -pady=>3); |
| 175 |
|
| 176 |
$series_params{inc} = 0.1; |
| 177 |
$frame -> Label(-text=>"Increment:", |
| 178 |
-foreground=>$config{colors}{activehighlightcolor},) |
| 179 |
-> grid(-row=>5, -column=>0, -sticky=>'e', -pady=>3); |
| 180 |
$widget{series_inc} = $frame -> Entry(-textvariable=>\$series_params{inc}) |
| 181 |
-> grid(-row=>5, -column=>1, -sticky=>'ew', -pady=>3); |
| 182 |
|
| 183 |
$frame -> Button(-text=>'Make copies', @button_list, |
| 184 |
-command=> |
| 185 |
sub{ |
| 186 |
Echo("Series of copied groups ($series_params{plab}) ..."); |
| 187 |
my $save = $series_params{begin}; |
| 188 |
$top -> Busy; |
| 189 |
series_copy(\%series_params); |
| 190 |
series_plot(\%series_params); |
| 191 |
Echo("Series of copied groups ($series_params{plab}) ... done!"); |
| 192 |
$series_params{begin} = $save; |
| 193 |
$top -> Unbusy; |
| 194 |
}, |
| 195 |
) |
| 196 |
-> grid(-row=>6, -column=>0, -columnspan=>2, -sticky=>'ew', -pady=>3); |
| 197 |
|
| 198 |
|
| 199 |
## do you need to run one of your analysis subroutines immediately? |
| 200 |
## now is a good time... |
| 201 |
|
| 202 |
## and finally.... |
| 203 |
$top -> update; |
| 204 |
|
| 205 |
}; |
| 206 |
|
| 207 |
|
| 208 |
sub series_copy { |
| 209 |
my ($rparams) = @_; |
| 210 |
##print join(" ", %$rparams), $/; |
| 211 |
my $was = $current; |
| 212 |
my ($p, $begin, $inc) = ($rparams->{param}, $rparams->{begin}, $rparams->{inc}); |
| 213 |
mark('none'); |
| 214 |
mark('this'); |
| 215 |
foreach my $i (1 .. $rparams->{number}) { |
| 216 |
my $new = ©_group; |
| 217 |
my $val = $begin+($i-1)*$inc; |
| 218 |
my $pp = (split(/_/, $p))[1]; |
| 219 |
$groups{$new} -> make($p => $val); |
| 220 |
my $label = $groups{$was}->{label} . " - $pp=$val"; |
| 221 |
rename_group($dmode, $label, $new); |
| 222 |
set_properties(0, $was); |
| 223 |
}; |
| 224 |
}; |
| 225 |
|
| 226 |
sub series_plot { |
| 227 |
my ($rparams) = @_; |
| 228 |
my $type = (split(/_/, $rparams->{param}))[0]; |
| 229 |
plot_marked_k if ($type eq 'bkg'); |
| 230 |
plot_marked_r if ($type eq 'fft'); |
| 231 |
plot_marked_q if ($type eq 'bft'); |
| 232 |
}; |
| 233 |
|
| 234 |
|
| 235 |
## END OF SERIES COPY SUBSECTION |
| 236 |
########################################################################################## |