App-GUI-Cellgraph

 view release on metacpan or  search on metacpan

lib/App/GUI/Cellgraph/Frame/Tab/Action.pm  view on Meta::CPAN


# panel to change the values that control cell activity dependent on current subrule

package App::GUI::Cellgraph::Frame::Tab::Action;
use v5.12;
use warnings;
use Wx;
use base qw/Wx::Panel/;
use App::GUI::Cellgraph::Widget::RuleInput;
use App::GUI::Cellgraph::Widget::SliderCombo;
use Graphics::Toolkit::Color qw/color/;

sub new {
    my ( $class, $parent, $subrule_calculator ) = @_;
    my $self = $class->SUPER::new( $parent, -1);

    $self->{'subrules'} = $subrule_calculator;
    $self->{'rule_square_size'} = 20;
    $self->{'input_size'} = 0;
    $self->{'state_count'} = 0;
    $self->{'rule_mode'} = '';
    $self->{'call_back'} = sub {};
    my $merge_condition = sub {
        my ($now, $last_time) = @_;
        return 0 unless ref $last_time eq 'ARRAY';
        return 0 unless @$now == 2 and @$last_time == 2 and $now->[0] == $last_time->[0];
        return ($now->[1] - $last_time->[1]) < 2;
    };
    $self->{'result_history'} = App::GUI::Cellgraph::Compute::History->new();
    $self->{'spread_history'} = App::GUI::Cellgraph::Compute::History->new();
    $self->{'result_history'}->set_merge_condition( $merge_condition );
    $self->{'spread_history'}->set_merge_condition( $merge_condition );

    $self->{'label'}{'result'} = Wx::StaticText->new( $self, -1, 'Gain :' );
    $self->{'label'}{'result'}->SetToolTip('Functions to change all the turn based activity gain values');
    $self->{'label'}{'spread'} = Wx::StaticText->new( $self, -1, 'Spread :' );
    $self->{'label'}{'spread'}->SetToolTip('Functions to change all the turn based activity spread values');

    my $btn_data = {result => [
        ['init', '1', 15, 'put all activity gain value to default'],
        ['copy', '=',  0, 'set all activity gains to the value of the first subrule'],
        ['sub',  '-', 10, 'decrease all activity value gains by 0.05'],
        ['add',  '+',  0, 'increase all activity value gains by 0.05'],
        ['div',  '/', 10, 'decrease large and increase small values of activity gains'],
        ['mul',  '*',  0, 'increase large and decrease small values of activity gains'],
        ['wave', '%', 10, 'increase activity gain of odd numbered subrules and decrease them of even the numbered'],
        ['+rnd', '~', 10, 'change all activity gains by a small random value'],
        ['rnd',  '?',  0, 'set all activity gains to a random value'],
        ['undo','<=', 10, 'undo last gain value change'],
        ['redo','=>',  0, 'redo gain value changes'],
    ], spread => [
        ['init', '1',  0, 'put all activity spread value on default'],
        ['copy', '=',  0, 'set all activity spread to the value of the first subrule'],
        ['sub',  '-', 10, 'decrease all activity spread by 0.05'],
        ['add',  '+',  0, 'increase all activity spread by 0.05'],
        ['div',  '/', 10, 'decrease large and increase small values of activity spread'],
        ['mul',  '*',  0, 'increase large and decrease small values of activity spread'],
        ['wave', '%', 10, 'increase activity spread of odd numbered subrules and decrease them of even the numbered'],
        ['+rnd', '~', 10, 'change all activity spread by a small random value'],
        ['rnd',  '?',  0, 'set all activity spread to a random value'],
        ['undo','<=', 10, 'undo last gain value change'],
        ['redo','=>',  0, 'redo spread value changes'],
    ]};


    my $std_attr = &Wx::wxALIGN_LEFT | &Wx::wxGROW | &Wx::wxALIGN_CENTER_VERTICAL;
    my $all_attr = &Wx::wxGROW | &Wx::wxALL | &Wx::wxALIGN_CENTER_VERTICAL;
    my $sizer;
    for my $type (keys %$btn_data){
        next unless ref $btn_data->{$type} eq 'ARRAY';
        $sizer->{ $type } = Wx::BoxSizer->new( &Wx::wxHORIZONTAL );
        $sizer->{ $type }->AddSpacer( 10 );
        $sizer->{ $type }->Add( $self->{'label'}{ $type }, 0, $all_attr, 10 );

        for my $btn_data (@{$btn_data->{$type}}){



( run in 1.178 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )