3
3
## Hephaestus: a souped-up periodic table for the absorption
6
## Hephaestus is copyright (c) 2004-2006 Bruce Ravel
6
## Hephaestus is copyright (c) 2004-2007 Bruce Ravel
8
8
## http://cars9.uchicago.edu/~ravel/
10
## Ifeffit is copyright (c) 1992-2006 Matt Newville
10
## Ifeffit is copyright (c) 1992-2007 Matt Newville
11
11
## newville@cars.uchicago.edu
12
12
## http://cars9.uchicago.edu/~newville/ifeffit/
50
## make sure the pgplot environment is sane...
51
## these defaults assume that the pgplot rpm was installed
52
$ENV{PGPLOT_DIR} ||= '/usr/local/share/pgplot';
53
$ENV{PGPLOT_DEV} ||= '/XSERVE';
50
## ## make sure the pgplot environment is sane...
51
## ## these defaults assume that the pgplot rpm was installed
52
## $ENV{PGPLOT_DIR} ||= '/usr/local/share/pgplot';
53
## $ENV{PGPLOT_DEV} ||= '/XSERVE';
117
117
tie %config, 'Config::IniFiles', (-file=>$personal_rcfile, -import=>$system_config_ref);
118
my $config_ref = tied %config;
118
#my $config_ref = tied %config;
120
120
## sanity check the config file and transfer the values into the %data hash
122
verify_config(tied %config);
124
124
if ($config{general}{ifeffit}) {
130
## print Data::Dumper->Dump([$config_ref], [qw(*config)]);
133
130
my $current = "";
134
131
## absorption data
157
tie %userformulas, 'Config::IniFiles', (-file=>File::Spec->catfile($horae_lib, 'hephaestus.data'))
154
tie %userformulas, 'Config::IniFiles', (-file=>Ifeffit::FindFile->find("hephaestus", "data"))
158
155
if (-e File::Spec->catfile($horae_lib, 'hephaestus.data'));
159
156
foreach my $k (keys %{$userformulas{data}}) {
160
157
next if ($k eq '^^^^');
173
170
my $top = MainWindow->new(-class=>'horae');
174
171
$top -> withdraw;
172
$top -> optionAdd('*font', $config{fonts}{small});
176
175
my $splash = $top->Splashscreen();
177
176
$splash -> Label(-image => $top -> Photo(-file => File::Spec->catfile($hephaestus_lib, "vulcan.gif")),
179
178
-> pack(qw/-fill both -expand 1 -side left/);
180
179
$splash -> Label(-text => " Hephaestus $VERSION\nis starting ...",
181
180
-background => 'white',
182
-font => 'Helvetica 14 bold')
181
-font => $config{fonts}{largebold},)
183
182
-> pack(qw/-fill both -expand 1 -side right/);
184
183
$splash -> Splash;
187
186
$top -> setPalette(foreground => 'black',
188
187
background => $bgcolor,
189
188
highlightColor => 'DarkSlateBlue',
190
#font => 'Helvetica 10 bold'
189
-font => $config{fonts}{smbold},
192
191
my $iconbitmap = File::Spec->catfile($hephaestus_lib, "hephaestus_icon.xbm");
193
192
$top -> iconbitmap('@'.$iconbitmap);
195
194
$top -> bind('<Control-Key-0>' => \&help);
198
$top -> configure(-menu=> my $menubar = $top->Menu(-relief=>'ridge'));
197
$top -> configure(-menu=> my $menubar = $top->Menu(-relief=>'ridge', -font=>$config{fonts}{smbold}));
201
200
## common widget arguments
202
my @label_args = qw(-foreground blue4);
203
my @button_args = qw(-foreground seashell
204
-background darkslateblue
205
-activeforeground seashell
206
-activebackground slateblue),
201
my $l_text = $config{fonts}{smbold};
202
my $b_text = $config{fonts}{smbold};
203
my @label_args = (-foreground => 'blue4',
205
my @button_args = (-foreground => 'seashell',
206
-background => 'darkslateblue',
207
-activeforeground => 'seashell',
208
-activebackground => 'slateblue',
209
212
my @answer_args = (-foreground=>'black',
234
237
use vars qw($title);
235
238
$title = $main -> Label(-foreground=>'#49007a',
236
239
#-background=>'white',
237
-font=>'Helvetica 12 bold',
240
-font=>$config{fonts}{medbold},
238
241
-relief=>'ridge')
239
242
-> pack(-fill=>'x', -pady=>8, -padx=>4);
339
342
## event, and input focus)
341
344
my $file_menu = $menubar->cascade(-label => '~File',
345
-font => $config{fonts}{smbold},
342
346
-menuitems =>[@menuitems,
344
348
[ command =>'~Quit',
408
412
You are using Perl $] and Perl/Tk $Tk::VERSION
410
copyright � 2004-2006 Bruce Ravel
414
copyright � 2004-2007 Bruce Ravel
411
415
http://cars9.uchicago.edu/~ravel/software/
412
416
bravel\@anl.gov";
413
417
my $help_menu = $menubar->cascade(-label => '~Help',
428
432
## set up the various frames needed by the utilities
429
433
use vars qw($periodic_table %bottom);
430
434
$periodic_table = periodic_table($main);
435
$top -> packPropagate(1);
431
436
foreach my $k (keys %frames) {
432
437
eval "\$bottom{$k} = setup_$k(\$main)";
439
444
## display the absorption utility at startup, but make sure the window
440
445
## is big enough for both the transition chart and the periodic table
441
$top -> packPropagate(1);
444
448
my @geom = ($top->width, $top->height);
447
($geom[0] = $top->width) if ($geom[0] < $top->width);
448
($geom[1] = $top->height) if ($geom[1] < $top->height);
451
($geom[0] = $top->width) if ($geom[0] < $top->width);
452
($geom[1] = $top->height) if ($geom[1] < $top->height);
451
if (not $is_windows) {
452
($geom[0] = $top->width) if ($geom[0] < $top->width);
453
($geom[1] = $top->height) if ($geom[1] < $top->height);
456
($geom[0] = $top->width) if ($geom[0] < $top->width);
457
($geom[1] = $top->height) if ($geom[1] < $top->height);
460
($geom[0] = $top->width) if ($geom[0] < $top->width);
461
($geom[1] = $top->height) if ($geom[1] < $top->height);
453
463
$top -> geometry(join("x", @geom)) unless $is_windows;
454
465
$top -> packPropagate(0);
463
474
&line, last STARTUP if (lc($config{general}{startup}) eq 'line');
464
475
&f1f2, last STARTUP if ((lc($config{general}{startup}) eq 'f1f2') and ($config{general}{ifeffit}));
469
## if ($is_windows) {
470
## open PARID, ">".Ifeffit::FindFile->find("hephaestus", "par") :
471
## print PARID $ENV{PAR_TEMP}, $/;
476
479
$top -> title('Hephaestus');
501
504
sub periodic_table {
502
505
my $table = $_[0] -> Frame(-borderwidth=>2, -relief=>'ridge');
503
506
my $frame = $table -> Frame()
504
-> pack(-side=>'top', -fill=>'x');
507
-> pack(-side=>'top', -fill=>'x', -padx=>2, -pady=>2);
505
508
my $trans = $table -> Frame()
506
-> pack(-side=>'bottom');
509
-> pack(-side=>'bottom', -padx=>2, -pady=>2);
509
512
# columns: 0 -- 17 rows: 0 -- 8
623
626
-background => 'darkslategrey',
624
627
-activeforeground => 'black',
625
628
-activebackground => 'slategrey',
626
-font => 'Helvetica 10 bold');
629
-font => $config{fonts}{smbold});
627
630
my @semimetal_args = (-foreground => 'seashell',
628
631
-background => 'khaki4',
629
632
-activeforeground => 'black',
630
633
-activebackground => 'khaki3',
631
-font => 'Helvetica 10 bold');
634
-font => $config{fonts}{smbold});
632
635
my @nonmetal_args = (-foreground => 'seashell',
633
636
-background => 'cadetblue4',
634
637
-activeforeground => 'black',
635
638
-activebackground => 'cadetblue3',
636
-font => 'Helvetica 10 bold');
639
-font => $config{fonts}{smbold});
637
640
my @gas_args = (-foreground => 'seashell',
638
641
-background => 'goldenrod4',
639
642
-activeforeground => 'black',
640
643
-activebackground => 'goldenrod3',
641
-font => 'Helvetica 10 bold');
644
-font => $config{fonts}{smbold});
643
646
## -------------------------------------------------------------------
644
647
## set up periodic table
660
663
-command => [\&multiplexer, $s])
661
664
-> grid(-column=>$c, -row=>$r, -sticky=>'ew');
665
$button -> bind('<ButtonPress-3>' =>
667
return if ($current ne "absorption");
668
$data{abs_filter} = $s;
662
670
} else { # lanthandes and actinides
663
671
my $button = $trans -> Button(-text => $s,
664
672
-width => ($is_windows) ? 3 : 1,
666
674
-command => [\&multiplexer, $s])
667
675
-> grid(-column=>$c, -row=>$r-7, -sticky=>'ew');
676
$button -> bind('<ButtonPress-3>' =>
678
return if ($current ne "absorption");
679
$data{abs_filter} = $s;
748
762
$data{sample_energy} = e2l(9000);
750
764
Xray::Absorption -> load($data{resource});
766
## fallbacks for font settings
767
$config{fonts}{small} ||= 'Helvetica 10';
768
$config{fonts}{smfixed} ||= 'Courier 10';
769
$config{fonts}{fixed} ||= 'Courier 11';
770
$config{fonts}{largebold} ||= 'Helvetica 14 bold';
771
$config{fonts}{medbold} ||= 'Helvetica 12 bold';
772
$config{fonts}{smbold} ||= 'Helvetica 10 bold';
775
## print Data::Dumper->Dump([$config_ref], [qw(*config)]);
751
777
$config_ref -> WriteConfig(Ifeffit::FindFile->find("hephaestus", "rc_personal"));
759
785
$bottom{$current} -> packForget if $current;
760
786
$frames{$current} -> configure(-relief=>'flat') if ($current and ($current ne 'help'));
761
787
$current = "help";
762
$bottom{help} -> pack(-side=>'top', -pady=>4, -expand=>1, -fill=>'both');
788
$bottom{help} -> pack(-side=>'top', -pady=>4, -fill=>'both', -expand=>1);
763
789
$title->configure(-text=>'Hephaestus Document');