App-GUI-Juliagraph

 view release on metacpan or  search on metacpan

lib/App/GUI/Juliagraph/Frame/Tab/Constraints.pm  view on Meta::CPAN

#

package App::GUI::Juliagraph::Frame::Tab::Constraints;
use v5.12;
use warnings;
use Wx;
use base qw/Wx::Panel/;
use App::GUI::Juliagraph::Widget::SliderStep;
use App::GUI::Juliagraph::Widget::SliderCombo;

my $default_settings = {
    type => 'Mandelbrot', coordinates_use => 'constant',
    zoom => 1, center_x => 0, center_y => 0,
    const_a => 0, const_b => 0, start_a => 0, start_b => 0,
    stop_nr => 6, stop_value => 3, stop_metric => '|var|'
};

sub new {
    my ( $class, $parent) = @_;
    my $self = $class->SUPER::new( $parent, -1);
    $self->{'callback'} = sub {};
    $self->{'tab'}{'polynome'} = '';
    $self->{'tab'}{'mapping'} = '';

    my $coor_lbl     = Wx::StaticText->new($self, -1, 'P i x e l   C o o r d i n a t e s : ' );
    my $zoom_lbl     = Wx::StaticText->new($self, -1, 'Z o o m : ' );
    my $pos_lbl      = Wx::StaticText->new($self, -1, 'P o s i t i o n : ' );
    my $x_lbl        = Wx::StaticText->new($self, -1, 'X : ' );
    my $y_lbl        = Wx::StaticText->new($self, -1, 'Y : ' );
    $self->{'lbl_const'} = Wx::StaticText->new($self, -1, 'C o n s t a n t : ' );
    $self->{'lbl_consta'} = Wx::StaticText->new($self, -1, 'A : ' );
    $self->{'lbl_constb'} = Wx::StaticText->new($self, -1, 'B : ' );
    $self->{'lbl_starta'} = Wx::StaticText->new($self, -1, 'A : ' );
    $self->{'lbl_startb'} = Wx::StaticText->new($self, -1, 'B : ' );
    $self->{'lbl_start'} = Wx::StaticText->new($self, -1, 'S t a r t    V a l u e : ' );
    my $stop_lbl     = Wx::StaticText->new($self, -1, 'I t e r a t i o n   S t o p : ' );
    my $metric_lbl   = Wx::StaticText->new($self, -1, 'M e t r i c : ' );
    $coor_lbl->SetToolTip("Which role play pixel coordinates in computation:\n - as start value of the iteration (z_0)\n - added as constant at any iteration \n - as factor of one monomial on next page (numbered from top to bottom)");
    $zoom_lbl->SetToolTip('zoom factor: the larger the more you zoom in');
    $pos_lbl->SetToolTip('center coordinates of visible sector');
    $self->{'lbl_const'}->SetToolTip('complex constant that will be used according settings in first paragraph');
    $self->{'lbl_start'}->SetToolTip('value of iteration variable Z before first iteration');
    $stop_lbl->SetToolTip('conditions that stop the iteration (computation of pixel color)');
    $metric_lbl->SetToolTip('metric for computing stop value (|var| = sqrt(z.re**2 + z.i**2), x = z.real, y = z.im');

    $self->{'type'} = Wx::RadioBox->new( $self, -1, ' T y p e ', [-1,-1], [-1, -1], ['Mandelbrot', 'Julia', 'Any'] );
    $self->{'type'}->SetToolTip( "Choose fractal type: \njulia uses position as init value of iterator var and constant as such, mandelbrot is vice versa\nany means no such restrictions." );
    $self->{'coor_as_start'} = Wx::CheckBox->new( $self, -1, ' Start Value', [-1,-1], [-1, -1]);
    $self->{'coor_as_const'} = Wx::CheckBox->new( $self, -1, ' Constant',    [-1,-1], [-1, -1]);
    $self->{'coor_as_monom'} = Wx::CheckBox->new( $self, -1, ' Monomial',    [-1,-1], [-1, -1]);
    $self->{'coor_as_start'}->SetToolTip( "Use current pixel coordinates as iteration start value, or add them to it." );
    $self->{'coor_as_const'}->SetToolTip( "Use current pixel coordinates as constant added at every iteration." );
    $self->{'coor_as_monom'}->SetToolTip( "Use current pixel coordinates as monomial factor in the next tab page." );

    $self->{'zoom'}     = Wx::TextCtrl->new( $self, -1, 1, [-1,-1], [ 80, -1] );
    $self->{'center_x'} = Wx::TextCtrl->new( $self, -1, 0, [-1,-1], [100, -1] );
    $self->{'center_y'} = Wx::TextCtrl->new( $self, -1, 0, [-1,-1], [100, -1] );
    $self->{'const_a'}  = Wx::TextCtrl->new( $self, -1, 0, [-1,-1], [100, -1] );
    $self->{'const_b'}  = Wx::TextCtrl->new( $self, -1, 0, [-1,-1], [100, -1] );
    $self->{'start_a'}  = Wx::TextCtrl->new( $self, -1, 0, [-1,-1], [100, -1] );
    $self->{'start_b'}  = Wx::TextCtrl->new( $self, -1, 0, [-1,-1], [100, -1] );
    $self->{'reset_zoom'}     = Wx::Button->new( $self, -1, 1, [-1,-1], [ 30, -1] );
    $self->{'reset_center_x'} = Wx::Button->new( $self, -1, 0, [-1,-1], [ 30, -1] );
    $self->{'reset_center_y'} = Wx::Button->new( $self, -1, 0, [-1,-1], [ 30, -1] );
    $self->{'reset_const_a'}  = Wx::Button->new( $self, -1, 0, [-1,-1], [ 30, -1] );
    $self->{'reset_const_b'}  = Wx::Button->new( $self, -1, 0, [-1,-1], [ 30, -1] );
    $self->{'reset_start_a'}  = Wx::Button->new( $self, -1, 0, [-1,-1], [ 30, -1] );
    $self->{'reset_start_b'}  = Wx::Button->new( $self, -1, 0, [-1,-1], [ 30, -1] );
    $self->{'button_zoom'} = App::GUI::Juliagraph::Widget::SliderStep->new( $self, 150, 3, 0.3, 2, 2);
    $self->{'button_x'}    = App::GUI::Juliagraph::Widget::SliderStep->new( $self, 150, 3, 1  , 7, 3);
    $self->{'button_y'}    = App::GUI::Juliagraph::Widget::SliderStep->new( $self, 150, 3, 1  , 7, 3);
    $self->{'button_ca'}   = App::GUI::Juliagraph::Widget::SliderStep->new( $self, 150, 3, 0.3, 3, 3);
    $self->{'button_cb'}   = App::GUI::Juliagraph::Widget::SliderStep->new( $self, 150, 3, 0.3, 3, 3);
    $self->{'button_sa'}   = App::GUI::Juliagraph::Widget::SliderStep->new( $self, 150, 3, 0.3, 3, 3);
    $self->{'button_sb'}   = App::GUI::Juliagraph::Widget::SliderStep->new( $self, 150, 3, 0.3, 3, 3);

    $self->{'button_zoom'}->SetToolTip('zoom factor: the larger the more you zoom in');
    $self->{'button_zoom'}->SetCallBack(sub { $self->{'zoom'}->SetValue( $self->{'zoom'}->GetValue + shift ) });
    $self->{'button_x'}->SetCallBack( sub { my $value = shift;$self->{'center_x'}->SetValue( $self->{'center_x'}->GetValue + ($value * $self->zoom_size) ) });
    $self->{'button_y'}->SetCallBack( sub { my $value = shift;$self->{'center_y'}->SetValue( $self->{'center_y'}->GetValue + ($value * $self->zoom_size) ) });



( run in 0.453 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )