1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
|
package Demeter::UI::Athena::Plot::PlotE;
use strict;
use warnings;
use Wx qw( :everything );
use base 'Wx::Panel';
use Wx::Event qw(EVT_CHECKBOX EVT_RADIOBUTTON EVT_TEXT_ENTER);
use Wx::Perl::TextValidator;
use Demeter::UI::Wx::SpecialCharacters qw(:all);
use Demeter::UI::Athena::Replot;
use Scalar::Util qw(looks_like_number);
sub new {
my ($class, $parent, $app) = @_;
my $this = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxMAXIMIZE_BOX );
my $box = Wx::BoxSizer->new( wxVERTICAL );
my $hbox = Wx::BoxSizer->new( wxVERTICAL );
$box -> Add($hbox, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 4);
my $slots = Wx::GridSizer->new( 7, 2, 0, 1 );
$hbox -> Add($slots, 0, wxGROW|wxALL, 0);
$this->{mu} = Wx::CheckBox->new($this, -1, $MU.'(E)', wxDefaultPosition, wxDefaultSize);
$this->{mu} -> SetValue(Demeter->co->default("plot", "e_mu"));
$slots -> Add($this->{mu}, 1, wxGROW|wxALL, 0);
$this->{mmu} = Wx::RadioButton->new($this, -1, $MU.'(E)', wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
$this->{mmu} -> SetValue(Demeter->co->default("plot", "e_mu"));
$slots -> Add($this->{mmu}, 1, wxGROW|wxALL, 0);
EVT_CHECKBOX($this, $this->{mu}, sub{$_[0]->replot(qw(E single))});
EVT_RADIOBUTTON($this, $this->{mmu}, sub{$_[0]->replot(qw(E marked))});
$app->mouseover($this->{mu}, "Plot $MU(E) when ploting the current group in energy.");
$app->mouseover($this->{mmu}, "Plot $MU(E) when ploting the marked groups in energy.");
$this->{bkg} = Wx::CheckBox->new($this, -1, 'Background', wxDefaultPosition, wxDefaultSize);
$this->{bkg} -> SetValue(Demeter->co->default("plot", "e_bkg"));
$slots -> Add($this->{bkg}, 1, wxGROW|wxALL, 0);
EVT_CHECKBOX($this, $this->{bkg},
sub{my ($this, $event) = @_;
if ($this->{bkg}->GetValue) {
$this->{der}->SetValue(0);
$this->{sec}->SetValue(0);
};
$this->replot(qw(E single));
});
EVT_CHECKBOX($this, $this->{mbkg}, sub{$_[0]->replot(qw(E marked))});
$app->mouseover($this->{bkg}, "Plot the background when ploting the current group in energy.");
$slots -> Add(Wx::StaticText->new($this, -1, q{}), 0, wxGROW|wxALL, 0);
$this->{pre} = Wx::CheckBox->new($this, -1, 'pre-edge line', wxDefaultPosition, wxDefaultSize);
$this->{pre} -> SetValue(Demeter->co->default("plot", "e_pre"));
$slots -> Add($this->{pre}, 1, wxGROW|wxALL, 0);
EVT_CHECKBOX($this, $this->{pre},
sub{my ($this, $event) = @_;
if ($this->{pre}->GetValue) {
$this->{norm}->SetValue(0);
$this->{der}->SetValue(0);
$this->{sec}->SetValue(0);
};
$this->replot(qw(E single));
});
$app->mouseover($this->{pre}, "Plot the pre-edge line when ploting the current group in energy.");
$slots -> Add(Wx::StaticText->new($this, -1, q{}), 0, wxGROW|wxALL, 0);
$this->{post} = Wx::CheckBox->new($this, -1, 'post-edge line', wxDefaultPosition, wxDefaultSize);
$this->{post} -> SetValue(Demeter->co->default("plot", "e_post"));
$slots -> Add($this->{post}, 1, wxGROW|wxALL, 0);
EVT_CHECKBOX($this, $this->{post},
sub{my ($this, $event) = @_;
if ($this->{post}->GetValue) {
$this->{norm}->SetValue(0);
$this->{der}->SetValue(0);
$this->{sec}->SetValue(0);
};
$this->replot(qw(E single));
});
$app->mouseover($this->{post}, "Plot the post-edge line when ploting the current group in energy.");
$slots -> Add(Wx::StaticText->new($this, -1, q{}), 0, wxGROW|wxALL, 0);
$this->{norm} = Wx::CheckBox->new($this, -1, 'Normalized', wxDefaultPosition, wxDefaultSize);
$this->{norm} -> SetValue(Demeter->co->default("plot", "e_norm"));
$slots -> Add($this->{norm}, 1, wxGROW|wxALL, 0);
$this->{mnorm} = Wx::RadioButton->new($this, -1, 'Normalized', wxDefaultPosition, wxDefaultSize);
$this->{mnorm} -> SetValue(Demeter->co->default("plot", "e_norm"));
$slots -> Add($this->{mnorm}, 1, wxGROW|wxALL, 0);
EVT_CHECKBOX($this, $this->{norm},
sub{my ($this, $event) = @_;
if ($this->{norm}->GetValue) {
$this->{pre}->SetValue(0);
$this->{post}->SetValue(0);
};
$this->replot(qw(E single));
});
EVT_RADIOBUTTON($this, $this->{mnorm}, sub{$_[0]->replot(qw(E marked))});
$app->mouseover($this->{norm}, "Plot normalized data when ploting the current group in energy.");
$app->mouseover($this->{mnorm}, "Plot normalized data when ploting the marked groups in energy.");
$this->{der} = Wx::CheckBox->new($this, -1, 'Derivative', wxDefaultPosition, wxDefaultSize);
$this->{der} -> SetValue(Demeter->co->default("plot", "e_der"));
$slots -> Add($this->{der}, 1, wxGROW|wxALL, 0);
$this->{mder} = Wx::CheckBox->new($this, -1, 'Derivative', wxDefaultPosition, wxDefaultSize);
$this->{mder} -> SetValue(Demeter->co->default("plot", "e_der"));
$slots -> Add($this->{mder}, 1, wxGROW|wxALL, 0);
EVT_CHECKBOX($this, $this->{der},
sub{my ($this, $event) = @_;
if ($this->{der}->GetValue) {
$this->{bkg}->SetValue(0);
$this->{pre}->SetValue(0);
$this->{post}->SetValue(0);
$this->{sec}->SetValue(0);
};
$this->replot(qw(E single));
});
EVT_CHECKBOX($this, $this->{mder},
sub{my ($this, $event) = @_;
if ($this->{mder}->GetValue) {
$this->{msec}->SetValue(0);
};
$this->replot(qw(E marked))
});
$app->mouseover($this->{der}, "Plot first derivative data when ploting the current group in energy.");
$app->mouseover($this->{mder}, "Plot first derivative data when ploting the marked groups in energy.");
$this->{sec} = Wx::CheckBox->new($this, -1, '2nd derivative', wxDefaultPosition, wxDefaultSize);
$this->{sec} -> SetValue(Demeter->co->default("plot", "e_sec"));
$slots -> Add($this->{sec}, 1, wxGROW|wxALL, 0);
$this->{msec} = Wx::CheckBox->new($this, -1, '2nd derivative', wxDefaultPosition, wxDefaultSize);
$this->{msec} -> SetValue(Demeter->co->default("plot", "e_sec"));
$slots -> Add($this->{msec}, 1, wxGROW|wxALL, 0);
EVT_CHECKBOX($this, $this->{sec},
sub{my ($this, $event) = @_;
if ($this->{sec}->GetValue) {
$this->{bkg}->SetValue(0);
$this->{pre}->SetValue(0);
$this->{post}->SetValue(0);
$this->{der}->SetValue(0);
};
$this->replot(qw(E single));
});
EVT_CHECKBOX($this, $this->{msec},
sub{my ($this, $event) = @_;
if ($this->{msec}->GetValue) {
$this->{mder}->SetValue(0);
};
$this->replot(qw(E marked))
});
$app->mouseover($this->{sec}, "Plot second derivative data when ploting the current group in energy.");
$app->mouseover($this->{msec}, "Plot second derivative data when ploting the marked groups in energy.");
$this->{mnorm}->SetValue(1);
$this->{$_}->SetBackgroundColour( Wx::Colour->new(Demeter->co->default("athena", "single")) )
foreach (qw(mu bkg pre post norm der sec));
$this->{$_}->SetBackgroundColour( Wx::Colour->new(Demeter->co->default("athena", "marked")) )
foreach (qw(mmu mnorm mder msec));
# my $right = Wx::BoxSizer->new( wxVERTICAL );
# $hbox -> Add($right, 0, wxALL, 4);
$box -> Add(1, 1, 1);
my $range = Wx::BoxSizer->new( wxHORIZONTAL );
$box -> Add($range, 0, wxALL|wxGROW, 0);
my $label = Wx::StaticText->new($this, -1, "Emin", wxDefaultPosition, wxDefaultSize);
$this->{emin} = Wx::TextCtrl ->new($this, -1, Demeter->co->default("plot", "emin"),
wxDefaultPosition, [40,-1], wxTE_PROCESS_ENTER);
$range -> Add($label, 0, wxALL, 5);
$range -> Add($this->{emin}, 1, wxRIGHT, 10);
$label = Wx::StaticText->new($this, -1, "Emax", wxDefaultPosition, wxDefaultSize);
$this->{emax} = Wx::TextCtrl ->new($this, -1, Demeter->co->default("plot", "emax"),
wxDefaultPosition, [40,-1], wxTE_PROCESS_ENTER);
$range -> Add($label, 0, wxALL, 5);
$range -> Add($this->{emax}, 1, wxRIGHT, 5);
foreach my $x (qw(emin emax)) {
$this->{$x} -> SetValidator( Wx::Perl::TextValidator->new( qr([-0-9.]) ) );
EVT_TEXT_ENTER($this, $this->{$x}, sub{OnTextEnter(@_, $::app, $x)});
};
$this->SetSizerAndFit($box);
return $this;
};
sub OnTextEnter {
my ($main, $event, $app, $which) = @_;
my @list = $app->marked_groups;
my $how = (@list) ? 'marked' : 'single';
$app->plot(q{}, q{}, 'E', $how);
};
sub label {
return 'Plot in energy';
};
sub pull_single_values {
my ($this) = @_;
my $po = Demeter->po;
$po->e_mu ($this->{mu} -> GetValue);
$po->e_bkg ($this->{bkg} -> GetValue);
$po->e_pre ($this->{pre} -> GetValue);
$po->e_post($this->{post}-> GetValue);
$po->e_norm($this->{norm}-> GetValue);
$po->e_der ($this->{der} -> GetValue);
$po->e_sec ($this->{sec} -> GetValue);
my $emin = $this->{emin}-> GetValue;
my $emax = $this->{emax}-> GetValue;
($emin,$emax) = sort {$a <=> $b} ($emin,$emax);
$::app->{main}->status(q{}, 'nobuffer');
if (not looks_like_number($emin)) {
$emin = Demeter->co->default('plot','emin');
$::app->{main}->status("Emin is not a number", 'error|nobuffer');
};
if (not looks_like_number($emax)) {
$emax = Demeter->co->default('plot','emax');
$::app->{main}->status("Emax is not a number", 'error|nobuffer');
};
$po->emin($emin);
$po->emax($emax);
$po->e_markers(1);
};
sub pull_marked_values {
my ($this) = @_;
my $po = Demeter->po;
$po->e_mu ($this->{mmu} -> GetValue);
$po->e_bkg (0);
$po->e_pre (0);
$po->e_post(0);
$po->e_norm($this->{mnorm}-> GetValue);
$po->e_der ($this->{mder} -> GetValue);
$po->e_sec ($this->{msec} -> GetValue);
my $emin = $this->{emin}-> GetValue;
my $emax = $this->{emax}-> GetValue;
($emin,$emax) = sort {$a <=> $b} ($emin,$emax);
$::app->{main}->status(q{}, 'nobuffer');
if (not looks_like_number($emin)) {
$emin = Demeter->co->default('plot','emin');
$::app->{main}->status("Emin is not a number", 'error|nobuffer');
};
if (not looks_like_number($emax)) {
$emax = Demeter->co->default('plot','emax');
$::app->{main}->status("Emax is not a number", 'error|nobuffer');
};
$po->emin($emin);
$po->emax($emax);
$po->e_mu(1) if $po->e_norm;
$po->e_markers(0);
};
1;
=head1 NAME
Demeter::UI::Athena::Plot::PlotE - energy space plotting controls
=head1 VERSION
This documentation refers to Demeter version 0.9.26.
=head1 SYNOPSIS
This module provides controls for plotting in energy in Athena
=head1 DEPENDENCIES
Demeter's dependencies are in the F<Build.PL> file.
=head1 BUGS AND LIMITATIONS
Please report problems to the Ifeffit Mailing List
(L<http://cars9.uchicago.edu/mailman/listinfo/ifeffit/>)
Patches are welcome.
=head1 AUTHOR
Bruce Ravel, L<http://bruceravel.github.io/home>
L<http://bruceravel.github.io/demeter/>
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2006-2019 Bruce Ravel (L<http://bruceravel.github.io/home>). All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlgpl>.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
=cut
|