App-GUI-Harmonograph
view release on metacpan or search on metacpan
lib/App/GUI/Harmonograph/Frame/Panel/Pendulum.pm view on Meta::CPAN
# settings for all pendula
package App::GUI::Harmonograph::Frame::Panel::Pendulum;
use base qw/Wx::Panel/;
use v5.12;
use utf8;
use warnings;
use Wx;
use App::GUI::Wx::Widget::Custom::SliderCombo;
my @const_names = (1, 2, 3, 'â2', 'â3', 'â5', 'Ï', 'Ï', 'Ï', 'Φ', 'Ï', 'e', 'γ', 'Î', 'G', 'A');
my %const = (1 => 1, 2 => 2, 3 => 3, 'â2' => 1.4142135623731, 'â3' => 1.73205080756888, 'â5' => 2.236067977499789,
'Ï' => 3.1415926535, 'Ï' => 6.2831853071795,
'Ï' => 0.61803398874989, 'Φ' => 1.61803398874989, 'Ï' => 1.46557123187676802665,
e => 2.718281828, 'γ' => 0.57721566490153286, 'Î' => 1.7724538509055160,
G => 0.9159655941772190150, A => 1.28242712910062,
);
sub new {
my ( $class, $parent, $label, $help, $on, $max ) = @_;
return unless defined $max;
my $self = $class->SUPER::new( $parent, -1);
$self->{'name'} = $label;
$self->{'maxf'} = $max;
$self->{'initially_on'} = $on;
$self->{'callback'} = sub {};
$self->{'on'} = Wx::CheckBox->new( $self, -1, '', [-1,-1], [-1,-1], $on );
$self->{'on'}->SetToolTip("set partial $help on or off");
my $main_label = Wx::StaticText->new($self, -1, uc($label) );
$main_label->SetToolTip($help);
$self->{'frequency'} = App::GUI::Wx::Widget::Custom::SliderCombo->new
( $self, 100, 'Frequency', 'frequency of '.$help, 1, $max, 1 );
$self->{'freq_dez'} = App::GUI::Wx::Widget::Custom::SliderCombo->new
( $self, 100, 'Precise ', 'decimals of frequency at '.$help, 0, 1000, 0);
$self->{'freq_factor'} = Wx::ComboBox->new( $self, -1, 1, [-1,-1],[70, 20], [@const_names]);
$self->{'freq_factor'}->SetToolTip('base factor the frequency will be multiplied with: one (no), or a math constants as shown');
$self->{'freq_damp'} = App::GUI::Wx::Widget::Custom::SliderCombo->new( $self, 100, 'Damp ', 'damping factor (diminishes frequency over time)', 0, 200, 0);
$self->{'freq_damp_type'} = Wx::ComboBox->new( $self, -1, '*', [-1,-1],[70, 20], [ '*', '-']);
$self->{'freq_damp_acc'} = App::GUI::Wx::Widget::Custom::SliderCombo->new( $self, 100, 'Acceleration ', 'accelaration of damping factor', 0, 100, 0);
$self->{'freq_damp_acc_type'} = Wx::ComboBox->new( $self, -1, '*', [-1,-1],[70, 20], [ '*', '/', '+', '-']);
$self->{'invert_freq'} = Wx::CheckBox->new( $self, -1, ' Inv.');
$self->{'invert_freq'}->SetToolTip('invert (1/x) pendulum frequency');
$self->{'neg_freq'} = Wx::CheckBox->new( $self, -1, ' Neg.');
$self->{'neg_freq'}->SetToolTip('allow frequency to become negative');
$self->{'invert_dir'} = Wx::CheckBox->new( $self, -1, ' Dir.');
$self->{'invert_dir'}->SetToolTip('invert pendulum direction (to counter clockwise)');
$self->{'half_off'} = Wx::CheckBox->new( $self, -1, ' 180');
$self->{'half_off'}->SetToolTip("$help starts with offset of half rotation");
$self->{'quarter_off'} = Wx::CheckBox->new( $self, -1, ' 90');
$self->{'quarter_off'}->SetToolTip("$help starts with offset of quater rotation");
$self->{'offset'} = App::GUI::Wx::Widget::Custom::SliderCombo->new
($self, 110, 'Offset', "additional offset $help starts with (0 - quater rotation)", 0, 100, 0);
$self->{'radius'} = App::GUI::Wx::Widget::Custom::SliderCombo->new( $self, 100, 'Radius %', "radius / amplitude of $help swing", 0, 200, 100);
$self->{'radius_factor'} = Wx::ComboBox->new( $self, -1, 1, [-1,-1],[70, 20], [@const_names]);
$self->{'radius_factor'}->SetToolTip('base factor the radius will be multiplied with: one (no), or a math constants as shown');
$self->{'neg_radius'} = Wx::CheckBox->new( $self, -1, ' Neg.');
$self->{'neg_radius'}->SetToolTip('allow radius to become negative');
$self->{'radius_damp'} = App::GUI::Wx::Widget::Custom::SliderCombo->new( $self, 100, 'Damp ', 'damping factor (diminishes amplitude over time)', 0, 200, 0);
$self->{'radius_damp_type'} = Wx::ComboBox->new( $self, -1, '*', [-1,-1],[70, 20], [ '*', '-']);
$self->{'radius_damp_acc'} = App::GUI::Wx::Widget::Custom::SliderCombo->new( $self, 100, 'Acceleration ', 'accelaration of damping factor', 0, 100, 0);
$self->{'radius_damp_acc_type'} = Wx::ComboBox->new( $self, -1, '*', [-1,-1],[70, 20], [ '*', '/', '+', '-']);
$self->{'reset_radius'} = Wx::Button->new( $self, -1, '1', [-1,-1], [35, 17] );
$self->{'reset_radius'}->SetToolTip('reset radius to 100 %');
Wx::Event::EVT_BUTTON( $self, $self->{'reset_radius'}, sub { $self->{'radius'}->SetValue(100) });
Wx::Event::EVT_CHECKBOX( $self, $self->{'on'}, sub { $self->update_enable(); $self->{'callback'}->() });
Wx::Event::EVT_CHECKBOX( $self, $self->{ $_ }, sub { $self->{'callback'}->() })
for qw/invert_freq invert_dir neg_freq half_off quarter_off neg_radius/;
Wx::Event::EVT_COMBOBOX( $self, $self->{ $_ }, sub { $self->{'callback'}->() })
for qw/freq_factor freq_damp_type freq_damp_acc_type radius_damp_type radius_damp_acc_type/;
my $base_attr = &Wx::wxALIGN_LEFT | &Wx::wxALIGN_CENTER_VERTICAL | &Wx::wxGROW;
my $box_attr = $base_attr | &Wx::wxTOP | &Wx::wxBOTTOM;
my $fd = 6;
$fd += 3 if lc $label eq 'f';
$fd-- if lc $label eq 'w';
my $f_sizer = Wx::BoxSizer->new(&Wx::wxHORIZONTAL);
( run in 0.806 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )